Requested changes applied
* private this.info --> public Info for GCOnDeploy * Parameter change for (un)deploy activities
This commit is contained in:
@@ -18,21 +18,19 @@ namespace OpenRA.Mods.Common.Activities
|
||||
public class DeployForGrantedCondition : Activity
|
||||
{
|
||||
readonly GrantConditionOnDeploy deploy;
|
||||
readonly int facing;
|
||||
readonly bool canTurn;
|
||||
|
||||
public DeployForGrantedCondition(Actor self) : base()
|
||||
public DeployForGrantedCondition(Actor self, GrantConditionOnDeploy deploy)
|
||||
{
|
||||
this.deploy = deploy;
|
||||
canTurn = self.Info.HasTraitInfo<IFacingInfo>();
|
||||
facing = self.Info.TraitInfo<GrantConditionOnDeployInfo>().Facing;
|
||||
deploy = self.Trait<GrantConditionOnDeploy>();
|
||||
}
|
||||
|
||||
protected override void OnFirstRun(Actor self)
|
||||
{
|
||||
// Turn to the required facing.
|
||||
if (facing != -1 && canTurn)
|
||||
QueueChild(new Turn(self, facing));
|
||||
if (deploy.Info.Facing != -1 && canTurn)
|
||||
QueueChild(new Turn(self, deploy.Info.Facing));
|
||||
}
|
||||
|
||||
public override Activity Tick(Actor self)
|
||||
|
||||
@@ -19,9 +19,9 @@ namespace OpenRA.Mods.Common.Activities
|
||||
{
|
||||
readonly GrantConditionOnDeploy deploy;
|
||||
|
||||
public UndeployForGrantedCondition(Actor self) : base()
|
||||
public UndeployForGrantedCondition(Actor self, GrantConditionOnDeploy deploy)
|
||||
{
|
||||
deploy = self.Trait<GrantConditionOnDeploy>();
|
||||
this.deploy = deploy;
|
||||
}
|
||||
|
||||
public override Activity Tick(Actor self)
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public class GrantConditionOnDeploy : IResolveOrder, IIssueOrder, INotifyCreated, INotifyDeployComplete, IIssueDeployOrder
|
||||
{
|
||||
readonly Actor self;
|
||||
readonly GrantConditionOnDeployInfo info;
|
||||
public readonly GrantConditionOnDeployInfo Info;
|
||||
readonly bool checkTerrainType;
|
||||
readonly bool canTurn;
|
||||
|
||||
@@ -78,7 +78,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public GrantConditionOnDeploy(ActorInitializer init, GrantConditionOnDeployInfo info)
|
||||
{
|
||||
self = init.Self;
|
||||
this.info = info;
|
||||
Info = info;
|
||||
checkTerrainType = info.AllowedTerrainTypes.Count > 0;
|
||||
canTurn = self.Info.HasTraitInfo<IFacingInfo>();
|
||||
if (init.Contains<DeployStateInit>())
|
||||
@@ -97,19 +97,19 @@ namespace OpenRA.Mods.Common.Traits
|
||||
break;
|
||||
case DeployState.Deploying:
|
||||
if (canTurn)
|
||||
self.Trait<IFacing>().Facing = info.Facing;
|
||||
self.Trait<IFacing>().Facing = Info.Facing;
|
||||
|
||||
Deploy(true);
|
||||
break;
|
||||
case DeployState.Deployed:
|
||||
if (canTurn)
|
||||
self.Trait<IFacing>().Facing = info.Facing;
|
||||
self.Trait<IFacing>().Facing = Info.Facing;
|
||||
|
||||
OnDeployCompleted();
|
||||
break;
|
||||
case DeployState.Undeploying:
|
||||
if (canTurn)
|
||||
self.Trait<IFacing>().Facing = info.Facing;
|
||||
self.Trait<IFacing>().Facing = Info.Facing;
|
||||
|
||||
Undeploy(true);
|
||||
break;
|
||||
@@ -119,7 +119,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public IEnumerable<IOrderTargeter> Orders
|
||||
{
|
||||
get { yield return new DeployOrderTargeter("GrantConditionOnDeploy", 5,
|
||||
() => IsCursorBlocked() ? info.DeployBlockedCursor : info.DeployCursor); }
|
||||
() => IsCursorBlocked() ? Info.DeployBlockedCursor : Info.DeployCursor); }
|
||||
}
|
||||
|
||||
public Order IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
|
||||
@@ -143,15 +143,15 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (!order.Queued)
|
||||
self.CancelActivity();
|
||||
|
||||
if (deployState == DeployState.Deployed && info.CanUndeploy)
|
||||
self.QueueActivity(new UndeployForGrantedCondition(self));
|
||||
if (deployState == DeployState.Deployed && Info.CanUndeploy)
|
||||
self.QueueActivity(new UndeployForGrantedCondition(self, this));
|
||||
else if (deployState == DeployState.Undeployed)
|
||||
self.QueueActivity(new DeployForGrantedCondition(self));
|
||||
self.QueueActivity(new DeployForGrantedCondition(self, this));
|
||||
}
|
||||
|
||||
bool IsCursorBlocked()
|
||||
{
|
||||
return ((deployState == DeployState.Deployed) && !info.CanUndeploy) || (!IsValidTerrain(self.Location) && (deployState != DeployState.Deployed));
|
||||
return ((deployState == DeployState.Deployed) && !Info.CanUndeploy) || (!IsValidTerrain(self.Location) && (deployState != DeployState.Deployed));
|
||||
}
|
||||
|
||||
public bool IsValidTerrain(CPos location)
|
||||
@@ -169,12 +169,12 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
var terrainType = self.World.Map.GetTerrainInfo(location).Type;
|
||||
|
||||
return info.AllowedTerrainTypes.Contains(terrainType);
|
||||
return Info.AllowedTerrainTypes.Contains(terrainType);
|
||||
}
|
||||
|
||||
bool IsValidRampType(CPos location)
|
||||
{
|
||||
if (info.CanDeployOnRamps)
|
||||
if (Info.CanDeployOnRamps)
|
||||
return true;
|
||||
|
||||
var ramp = 0;
|
||||
@@ -210,8 +210,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (!IsValidTerrain(self.Location))
|
||||
return;
|
||||
|
||||
if (!string.IsNullOrEmpty(info.DeploySound))
|
||||
Game.Sound.Play(SoundType.World, info.DeploySound, self.CenterPosition);
|
||||
if (!string.IsNullOrEmpty(Info.DeploySound))
|
||||
Game.Sound.Play(SoundType.World, Info.DeploySound, self.CenterPosition);
|
||||
|
||||
// Revoke condition that is applied while undeployed.
|
||||
if (!init)
|
||||
@@ -234,8 +234,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (!init && deployState != DeployState.Deployed)
|
||||
return;
|
||||
|
||||
if (!string.IsNullOrEmpty(info.UndeploySound))
|
||||
Game.Sound.Play(SoundType.World, info.UndeploySound, self.CenterPosition);
|
||||
if (!string.IsNullOrEmpty(Info.UndeploySound))
|
||||
Game.Sound.Play(SoundType.World, Info.UndeploySound, self.CenterPosition);
|
||||
|
||||
if (!init)
|
||||
OnUndeployStarted();
|
||||
@@ -259,8 +259,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
void OnDeployCompleted()
|
||||
{
|
||||
if (conditionManager != null && !string.IsNullOrEmpty(info.DeployedCondition) && deployedToken == ConditionManager.InvalidConditionToken)
|
||||
deployedToken = conditionManager.GrantCondition(self, info.DeployedCondition);
|
||||
if (conditionManager != null && !string.IsNullOrEmpty(Info.DeployedCondition) && deployedToken == ConditionManager.InvalidConditionToken)
|
||||
deployedToken = conditionManager.GrantCondition(self, Info.DeployedCondition);
|
||||
|
||||
deployState = DeployState.Deployed;
|
||||
}
|
||||
@@ -275,8 +275,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
void OnUndeployCompleted()
|
||||
{
|
||||
if (conditionManager != null && !string.IsNullOrEmpty(info.UndeployedCondition) && undeployedToken == ConditionManager.InvalidConditionToken)
|
||||
undeployedToken = conditionManager.GrantCondition(self, info.UndeployedCondition);
|
||||
if (conditionManager != null && !string.IsNullOrEmpty(Info.UndeployedCondition) && undeployedToken == ConditionManager.InvalidConditionToken)
|
||||
undeployedToken = conditionManager.GrantCondition(self, Info.UndeployedCondition);
|
||||
|
||||
deployState = DeployState.Undeployed;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user