Merge pull request #11014 from dtluna/can_undeploy
Added CanUndeploy property
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user