Rewrite ActorInit queries.

This commit is contained in:
Paul Chote
2020-05-24 22:28:16 +01:00
committed by teinarss
parent 626b40f31b
commit 7c6ec577dc
66 changed files with 332 additions and 265 deletions

View File

@@ -74,7 +74,7 @@ namespace OpenRA.Mods.Common.Traits
{
var init = actor.Init<DeployStateInit>();
if (init != null)
return init.Value(world) == DeployState.Deployed;
return init.Value == DeployState.Deployed;
return false;
},
@@ -111,8 +111,7 @@ namespace OpenRA.Mods.Common.Traits
checkTerrainType = info.AllowedTerrainTypes.Count > 0;
canTurn = self.Info.HasTraitInfo<IFacingInfo>();
move = self.TraitOrDefault<IMove>();
if (init.Contains<DeployStateInit>())
deployState = init.Get<DeployStateInit, DeployState>();
deployState = init.GetValue<DeployStateInit, DeployState>(info, DeployState.Undeployed);
}
protected override void Created(Actor self)
@@ -344,6 +343,6 @@ namespace OpenRA.Mods.Common.Traits
readonly DeployState value = DeployState.Deployed;
public DeployStateInit() { }
public DeployStateInit(DeployState init) { value = init; }
public DeployState Value(World world) { return value; }
public DeployState Value { get { return value; } }
}
}