Add ISingleInstanceInit interface.
Inits that are logically singletons (e.g. actor location or owner) should implement this interface to avoid runtime inconsistencies. Duplicate instances are rejected at init-time, allowing simpler queries when they are used.
This commit is contained in:
@@ -183,7 +183,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var self = init.Self;
|
||||
ActiveAttackBases = self.TraitsImplementing<AttackBase>().ToArray().Where(Exts.IsTraitEnabled);
|
||||
|
||||
stance = init.GetValue<StanceInit, UnitStance>(info, self.Owner.IsBot || !self.Owner.Playable ? info.InitialStanceAI : info.InitialStance);
|
||||
stance = init.GetValue<StanceInit, UnitStance>(self.Owner.IsBot || !self.Owner.Playable ? info.InitialStanceAI : info.InitialStance);
|
||||
|
||||
PredictedStance = stance;
|
||||
|
||||
@@ -445,7 +445,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
}
|
||||
|
||||
public class StanceInit : ValueActorInit<UnitStance>
|
||||
public class StanceInit : ValueActorInit<UnitStance>, ISingleInstanceInit
|
||||
{
|
||||
public StanceInit(TraitInfo info, UnitStance value)
|
||||
: base(info, value) { }
|
||||
|
||||
Reference in New Issue
Block a user