Replace IActorInit with an abstract class.
A shared ValueActorInit<T> is introduced to reduce duplication in the most common init cases, and an ActorInitActorReference allow actors to be referenced by map.yaml name.
This commit is contained in:
@@ -123,7 +123,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var stance = init != null ? init.Value : InitialStance;
|
||||
return stances[(int)stance];
|
||||
},
|
||||
(actor, value) => actor.ReplaceInit(new StanceInit((UnitStance)stances.IndexOf(value))));
|
||||
(actor, value) => actor.ReplaceInit(new StanceInit(this, (UnitStance)stances.IndexOf(value))));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -445,13 +445,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
}
|
||||
|
||||
public class StanceInit : IActorInit<UnitStance>
|
||||
public class StanceInit : ValueActorInit<UnitStance>
|
||||
{
|
||||
[FieldFromYamlKey]
|
||||
readonly UnitStance value = UnitStance.AttackAnything;
|
||||
|
||||
public StanceInit() { }
|
||||
public StanceInit(UnitStance init) { value = init; }
|
||||
public UnitStance Value { get { return value; } }
|
||||
public StanceInit(TraitInfo info, UnitStance value)
|
||||
: base(info, value) { }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user