diff --git a/OpenRA.Mods.Cnc/Traits/Chronoshiftable.cs b/OpenRA.Mods.Cnc/Traits/Chronoshiftable.cs index 6f9e303c47..ef68a729d6 100644 --- a/OpenRA.Mods.Cnc/Traits/Chronoshiftable.cs +++ b/OpenRA.Mods.Cnc/Traits/Chronoshiftable.cs @@ -39,7 +39,7 @@ namespace OpenRA.Mods.Cnc.Traits } public class Chronoshiftable : ConditionalTrait, ITick, ISync, ISelectionBar, - IDeathActorInitModifier, ITransformActorInitModifier, INotifyCreated + IDeathActorInitModifier, ITransformActorInitModifier { readonly Actor self; Actor chronosphere; @@ -100,9 +100,10 @@ namespace OpenRA.Mods.Cnc.Traits } } - void INotifyCreated.Created(Actor self) + protected override void Created(Actor self) { iPositionable = self.TraitOrDefault(); + base.Created(self); } // Can't be used in synced code, except with ignoreVis. diff --git a/OpenRA.Mods.Cnc/Traits/ResourcePurifier.cs b/OpenRA.Mods.Cnc/Traits/ResourcePurifier.cs index 751a446ac5..1493278143 100644 --- a/OpenRA.Mods.Cnc/Traits/ResourcePurifier.cs +++ b/OpenRA.Mods.Cnc/Traits/ResourcePurifier.cs @@ -35,7 +35,7 @@ namespace OpenRA.Mods.Cnc.Traits public override object Create(ActorInitializer init) { return new ResourcePurifier(init.Self, this); } } - public class ResourcePurifier : ConditionalTrait, INotifyCreated, INotifyResourceAccepted, ITick, INotifyOwnerChanged + public class ResourcePurifier : ConditionalTrait, INotifyResourceAccepted, ITick, INotifyOwnerChanged { readonly int[] modifier; @@ -50,15 +50,16 @@ namespace OpenRA.Mods.Cnc.Traits currentDisplayTick = Info.TickRate; } - void INotifyCreated.Created(Actor self) + protected override void Created(Actor self) { // Special case handling is required for the Player actor. // Created is called before Player.PlayerActor is assigned, // so we must query other player traits from self, knowing that // it refers to the same actor as self.Owner.PlayerActor var playerActor = self.Info.Name == "player" ? self : self.Owner.PlayerActor; - playerResources = playerActor.Trait(); + + base.Created(self); } void INotifyResourceAccepted.OnResourceAccepted(Actor self, Actor refinery, int amount) diff --git a/OpenRA.Mods.Common/Traits/AutoTarget.cs b/OpenRA.Mods.Common/Traits/AutoTarget.cs index df43919020..2412ca6692 100644 --- a/OpenRA.Mods.Common/Traits/AutoTarget.cs +++ b/OpenRA.Mods.Common/Traits/AutoTarget.cs @@ -124,7 +124,7 @@ namespace OpenRA.Mods.Common.Traits } } - public class AutoTarget : ConditionalTrait, INotifyIdle, INotifyDamage, ITick, IResolveOrder, ISync, INotifyCreated, INotifyOwnerChanged + public class AutoTarget : ConditionalTrait, INotifyIdle, INotifyDamage, ITick, IResolveOrder, ISync, INotifyOwnerChanged { public readonly IEnumerable ActiveAttackBases; [Sync] @@ -189,19 +189,21 @@ namespace OpenRA.Mods.Common.Traits PredictedStance = stance; } - void INotifyCreated.Created(Actor self) + protected override void Created(Actor self) { // AutoTargetPriority and their Priorities are fixed - so we can safely cache them with ToArray. // IsTraitEnabled can change over time, and so must appear after the ToArray so it gets re-evaluated each time. activeTargetPriorities = self.TraitsImplementing() - .OrderByDescending(ati => ati.Info.Priority).ToArray() - .Where(Exts.IsTraitEnabled).Select(atp => atp.Info); + .OrderByDescending(ati => ati.Info.Priority).ToArray() + .Where(Exts.IsTraitEnabled).Select(atp => atp.Info); conditionManager = self.TraitOrDefault(); disableAutoTarget = self.TraitsImplementing().ToArray(); notifyStanceChanged = self.TraitsImplementing().ToArray(); ApplyStanceCondition(self); + + base.Created(self); } void INotifyOwnerChanged.OnOwnerChanged(Actor self, Player oldOwner, Player newOwner) diff --git a/OpenRA.Mods.Common/Traits/Buildings/PrimaryBuilding.cs b/OpenRA.Mods.Common/Traits/Buildings/PrimaryBuilding.cs index 086cbe3635..efbcd05de9 100644 --- a/OpenRA.Mods.Common/Traits/Buildings/PrimaryBuilding.cs +++ b/OpenRA.Mods.Common/Traits/Buildings/PrimaryBuilding.cs @@ -43,7 +43,7 @@ namespace OpenRA.Mods.Common.Traits public override object Create(ActorInitializer init) { return new PrimaryBuilding(init.Self, this); } } - public class PrimaryBuilding : ConditionalTrait, INotifyCreated, IIssueOrder, IResolveOrder + public class PrimaryBuilding : ConditionalTrait, IIssueOrder, IResolveOrder { const string OrderID = "PrimaryProducer"; @@ -55,9 +55,10 @@ namespace OpenRA.Mods.Common.Traits public PrimaryBuilding(Actor self, PrimaryBuildingInfo info) : base(info) { } - void INotifyCreated.Created(Actor self) + protected override void Created(Actor self) { conditionManager = self.TraitOrDefault(); + base.Created(self); } IEnumerable IIssueOrder.Orders diff --git a/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnDeploy.cs b/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnDeploy.cs index 7779e2d38a..a3a3740169 100644 --- a/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnDeploy.cs +++ b/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnDeploy.cs @@ -66,7 +66,7 @@ namespace OpenRA.Mods.Common.Traits public enum DeployState { Undeployed, Deploying, Deployed, Undeploying } - public class GrantConditionOnDeploy : PausableConditionalTrait, IResolveOrder, IIssueOrder, INotifyCreated, + public class GrantConditionOnDeploy : PausableConditionalTrait, IResolveOrder, IIssueOrder, INotifyDeployComplete, IIssueDeployOrder, IOrderVoice, IWrapMove { readonly Actor self; @@ -93,10 +93,11 @@ namespace OpenRA.Mods.Common.Traits deployState = init.Get(); } - void INotifyCreated.Created(Actor self) + protected override void Created(Actor self) { conditionManager = self.TraitOrDefault(); notify = self.TraitsImplementing().ToArray(); + base.Created(self); switch (deployState) { diff --git a/OpenRA.Mods.Common/Traits/DetectCloaked.cs b/OpenRA.Mods.Common/Traits/DetectCloaked.cs index 725fc2e637..dff4c314dd 100644 --- a/OpenRA.Mods.Common/Traits/DetectCloaked.cs +++ b/OpenRA.Mods.Common/Traits/DetectCloaked.cs @@ -26,16 +26,17 @@ namespace OpenRA.Mods.Common.Traits public override object Create(ActorInitializer init) { return new DetectCloaked(this); } } - public class DetectCloaked : ConditionalTrait, INotifyCreated + public class DetectCloaked : ConditionalTrait { IDetectCloakedModifier[] rangeModifiers; public DetectCloaked(DetectCloakedInfo info) : base(info) { } - void INotifyCreated.Created(Actor self) + protected override void Created(Actor self) { rangeModifiers = self.TraitsImplementing().ToArray(); + base.Created(self); } public WDist Range diff --git a/OpenRA.Mods.Common/Traits/Explodes.cs b/OpenRA.Mods.Common/Traits/Explodes.cs index e112ce0619..1196681815 100644 --- a/OpenRA.Mods.Common/Traits/Explodes.cs +++ b/OpenRA.Mods.Common/Traits/Explodes.cs @@ -80,7 +80,7 @@ namespace OpenRA.Mods.Common.Traits } } - public class Explodes : ConditionalTrait, INotifyKilled, INotifyDamage, INotifyCreated + public class Explodes : ConditionalTrait, INotifyKilled, INotifyDamage { readonly IHealth health; BuildingInfo buildingInfo; @@ -91,9 +91,10 @@ namespace OpenRA.Mods.Common.Traits health = self.Trait(); } - void INotifyCreated.Created(Actor self) + protected override void Created(Actor self) { buildingInfo = self.Info.TraitInfoOrDefault(); + base.Created(self); } void INotifyKilled.Killed(Actor self, AttackInfo e) diff --git a/OpenRA.Mods.Common/Traits/KillsSelf.cs b/OpenRA.Mods.Common/Traits/KillsSelf.cs index cc9c0dadde..9c778f9c7e 100644 --- a/OpenRA.Mods.Common/Traits/KillsSelf.cs +++ b/OpenRA.Mods.Common/Traits/KillsSelf.cs @@ -32,7 +32,7 @@ namespace OpenRA.Mods.Common.Traits public override object Create(ActorInitializer init) { return new KillsSelf(init.Self, this); } } - class KillsSelf : ConditionalTrait, INotifyCreated, INotifyAddedToWorld, ITick + class KillsSelf : ConditionalTrait, INotifyAddedToWorld, ITick { int lifetime; ConditionManager conditionManager; @@ -51,9 +51,10 @@ namespace OpenRA.Mods.Common.Traits Kill(self); } - void INotifyCreated.Created(Actor self) + protected override void Created(Actor self) { conditionManager = self.TraitOrDefault(); + base.Created(self); } void INotifyAddedToWorld.AddedToWorld(Actor self) diff --git a/OpenRA.Mods.Common/Traits/ReloadAmmoPool.cs b/OpenRA.Mods.Common/Traits/ReloadAmmoPool.cs index a036cd2f6d..211f5ca3bd 100644 --- a/OpenRA.Mods.Common/Traits/ReloadAmmoPool.cs +++ b/OpenRA.Mods.Common/Traits/ReloadAmmoPool.cs @@ -43,7 +43,7 @@ namespace OpenRA.Mods.Common.Traits } } - public class ReloadAmmoPool : PausableConditionalTrait, ITick, INotifyCreated, INotifyAttack, ISync + public class ReloadAmmoPool : PausableConditionalTrait, ITick, INotifyAttack, ISync { AmmoPool ammoPool; IReloadAmmoModifier[] modifiers; @@ -54,11 +54,12 @@ namespace OpenRA.Mods.Common.Traits public ReloadAmmoPool(ReloadAmmoPoolInfo info) : base(info) { } - void INotifyCreated.Created(Actor self) + protected override void Created(Actor self) { ammoPool = self.TraitsImplementing().Single(ap => ap.Info.Name == Info.AmmoPool); modifiers = self.TraitsImplementing().ToArray(); remainingTicks = Info.Delay; + base.Created(self); } void INotifyAttack.Attacking(Actor self, Target target, Armament a, Barrel barrel) diff --git a/OpenRA.Mods.Common/Traits/World/ActorSpawnManager.cs b/OpenRA.Mods.Common/Traits/World/ActorSpawnManager.cs index b9623b70e9..1869445371 100644 --- a/OpenRA.Mods.Common/Traits/World/ActorSpawnManager.cs +++ b/OpenRA.Mods.Common/Traits/World/ActorSpawnManager.cs @@ -41,7 +41,7 @@ namespace OpenRA.Mods.Common.Traits public override object Create(ActorInitializer init) { return new ActorSpawnManager(init.Self, this); } } - public class ActorSpawnManager : ConditionalTrait, ITick, INotifyCreated + public class ActorSpawnManager : ConditionalTrait, ITick { readonly ActorSpawnManagerInfo info; @@ -55,9 +55,10 @@ namespace OpenRA.Mods.Common.Traits this.info = info; } - void INotifyCreated.Created(Actor self) + protected override void Created(Actor self) { enabled = self.Trait().Enabled; + base.Created(self); } void ITick.Tick(Actor self)