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