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:
Paul Chote
2020-06-02 19:37:18 +01:00
committed by teinarss
parent 4df5ac0385
commit b38018af9c
28 changed files with 365 additions and 306 deletions

View File

@@ -479,25 +479,19 @@ namespace OpenRA.Mods.Common.Traits
void ITransformActorInitModifier.ModifyTransformActorInit(Actor self, TypeDictionary init)
{
init.Add(new RuntimeCargoInit(Passengers.ToArray()));
init.Add(new RuntimeCargoInit(Info, Passengers.ToArray()));
}
}
public class RuntimeCargoInit : IActorInit<Actor[]>, ISuppressInitExport
public class RuntimeCargoInit : ValueActorInit<Actor[]>, ISuppressInitExport
{
[FieldFromYamlKey]
readonly Actor[] value = { };
public RuntimeCargoInit() { }
public RuntimeCargoInit(Actor[] init) { value = init; }
public Actor[] Value { get { return value; } }
public RuntimeCargoInit(TraitInfo info, Actor[] value)
: base(info, value) { }
}
public class CargoInit : IActorInit<string[]>
public class CargoInit : ValueActorInit<string[]>
{
[FieldFromYamlKey]
readonly string[] value = { };
public CargoInit() { }
public CargoInit(string[] init) { value = init; }
public string[] Value { get { return value; } }
public CargoInit(TraitInfo info, string[] value)
: base(info, value) { }
}
}