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

@@ -233,23 +233,17 @@ namespace OpenRA.Mods.Common.Traits
}
}
public class HealthInit : IActorInit<int>
public class HealthInit : ValueActorInit<int>
{
[FieldFromYamlKey]
readonly int value = 100;
readonly bool allowZero;
public HealthInit() { }
public HealthInit(int init)
: this(init, false) { }
public HealthInit(int init, bool allowZero)
{
this.allowZero = allowZero;
value = init;
}
public HealthInit(TraitInfo info, int value, bool allowZero = false)
: base(info, value) { this.allowZero = allowZero; }
public int Value
public HealthInit(int value, bool allowZero = false)
: base(value) { this.allowZero = allowZero; }
public override int Value
{
get
{