Convert yaml-exposed facings to WAngle.

This commit is contained in:
Paul Chote
2020-07-09 22:08:38 +01:00
committed by reaperrr
parent 6d12301f88
commit ac975f4139
80 changed files with 477 additions and 370 deletions

View File

@@ -43,8 +43,8 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Cursor to display when unable to (un)deploy the actor.")]
public readonly string DeployBlockedCursor = "deploy-blocked";
[Desc("Facing that the actor must face before deploying. Set to -1 to deploy regardless of facing.")]
public readonly int Facing = -1;
[Desc("Facing that the actor must face before deploying. Leave undefined to deploy regardless of facing.")]
public readonly WAngle? Facing = null;
[Desc("Play a randomly selected sound from this list when deploying.")]
public readonly string[] DeploySounds = null;
@@ -94,8 +94,6 @@ namespace OpenRA.Mods.Common.Traits
{
readonly Actor self;
readonly bool checkTerrainType;
readonly bool canTurn;
readonly IMove move;
DeployState deployState;
INotifyDeployTriggered[] notify;
@@ -109,8 +107,6 @@ namespace OpenRA.Mods.Common.Traits
{
self = init.Self;
checkTerrainType = info.AllowedTerrainTypes.Count > 0;
canTurn = self.Info.HasTraitInfo<IFacingInfo>();
move = self.TraitOrDefault<IMove>();
deployState = init.GetValue<DeployStateInit, DeployState>(DeployState.Undeployed);
}
@@ -119,27 +115,25 @@ namespace OpenRA.Mods.Common.Traits
notify = self.TraitsImplementing<INotifyDeployTriggered>().ToArray();
base.Created(self);
if (Info.Facing.HasValue && deployState != DeployState.Undeployed)
{
var facing = self.TraitOrDefault<IFacing>();
if (facing != null)
facing.Facing = Info.Facing.Value;
}
switch (deployState)
{
case DeployState.Undeployed:
OnUndeployCompleted();
break;
case DeployState.Deploying:
if (canTurn)
self.Trait<IFacing>().Facing = WAngle.FromFacing(Info.Facing);
Deploy(true);
break;
case DeployState.Deployed:
if (canTurn)
self.Trait<IFacing>().Facing = WAngle.FromFacing(Info.Facing);
OnDeployCompleted();
break;
case DeployState.Undeploying:
if (canTurn)
self.Trait<IFacing>().Facing = WAngle.FromFacing(Info.Facing);
Undeploy(true);
break;
}