Added CanUndeploy property.

This commit is contained in:
dtluna
2016-04-01 23:54:49 +03:00
parent a29b9ff7be
commit cf0a4bc21f

View File

@@ -53,6 +53,9 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Sound to play when undeploying.")]
public readonly string UndeploySound = null;
[Desc("Can this actor undeploy?")]
public readonly bool CanUndeploy = true;
public object Create(ActorInitializer init) { return new DeployToUpgrade(init, this); }
}
@@ -112,7 +115,7 @@ namespace OpenRA.Mods.Common.Traits
public IEnumerable<IOrderTargeter> Orders
{
get { yield return new DeployOrderTargeter("DeployToUpgrade", 5,
() => IsOnValidTerrain() ? info.DeployCursor : info.DeployBlockedCursor); }
() => IsCursorBlocked() ? info.DeployBlockedCursor : info.DeployCursor); }
}
public Order IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
@@ -131,7 +134,7 @@ namespace OpenRA.Mods.Common.Traits
if (!order.Queued)
self.CancelActivity();
if (deployState == DeployState.Deployed)
if (deployState == DeployState.Deployed && info.CanUndeploy)
{
self.QueueActivity(new CallFunc(Undeploy));
}
@@ -145,6 +148,11 @@ namespace OpenRA.Mods.Common.Traits
}
}
bool IsCursorBlocked()
{
return ((deployState == DeployState.Deployed) && !info.CanUndeploy) || (!IsOnValidTerrain() && (deployState != DeployState.Deployed));
}
bool IsOnValidTerrain()
{
return IsOnValidTerrainType() && IsOnValidRampType();