Fix conditional traits that incorrectly override INotifyCreated.
This commit is contained in:
@@ -39,7 +39,7 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
}
|
}
|
||||||
|
|
||||||
public class Chronoshiftable : ConditionalTrait<ChronoshiftableInfo>, ITick, ISync, ISelectionBar,
|
public class Chronoshiftable : ConditionalTrait<ChronoshiftableInfo>, ITick, ISync, ISelectionBar,
|
||||||
IDeathActorInitModifier, ITransformActorInitModifier, INotifyCreated
|
IDeathActorInitModifier, ITransformActorInitModifier
|
||||||
{
|
{
|
||||||
readonly Actor self;
|
readonly Actor self;
|
||||||
Actor chronosphere;
|
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<IPositionable>();
|
iPositionable = self.TraitOrDefault<IPositionable>();
|
||||||
|
base.Created(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Can't be used in synced code, except with ignoreVis.
|
// Can't be used in synced code, except with ignoreVis.
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
public override object Create(ActorInitializer init) { return new ResourcePurifier(init.Self, this); }
|
public override object Create(ActorInitializer init) { return new ResourcePurifier(init.Self, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ResourcePurifier : ConditionalTrait<ResourcePurifierInfo>, INotifyCreated, INotifyResourceAccepted, ITick, INotifyOwnerChanged
|
public class ResourcePurifier : ConditionalTrait<ResourcePurifierInfo>, INotifyResourceAccepted, ITick, INotifyOwnerChanged
|
||||||
{
|
{
|
||||||
readonly int[] modifier;
|
readonly int[] modifier;
|
||||||
|
|
||||||
@@ -50,15 +50,16 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
currentDisplayTick = Info.TickRate;
|
currentDisplayTick = Info.TickRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
void INotifyCreated.Created(Actor self)
|
protected override void Created(Actor self)
|
||||||
{
|
{
|
||||||
// Special case handling is required for the Player actor.
|
// Special case handling is required for the Player actor.
|
||||||
// Created is called before Player.PlayerActor is assigned,
|
// Created is called before Player.PlayerActor is assigned,
|
||||||
// so we must query other player traits from self, knowing that
|
// so we must query other player traits from self, knowing that
|
||||||
// it refers to the same actor as self.Owner.PlayerActor
|
// it refers to the same actor as self.Owner.PlayerActor
|
||||||
var playerActor = self.Info.Name == "player" ? self : self.Owner.PlayerActor;
|
var playerActor = self.Info.Name == "player" ? self : self.Owner.PlayerActor;
|
||||||
|
|
||||||
playerResources = playerActor.Trait<PlayerResources>();
|
playerResources = playerActor.Trait<PlayerResources>();
|
||||||
|
|
||||||
|
base.Created(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
void INotifyResourceAccepted.OnResourceAccepted(Actor self, Actor refinery, int amount)
|
void INotifyResourceAccepted.OnResourceAccepted(Actor self, Actor refinery, int amount)
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class AutoTarget : ConditionalTrait<AutoTargetInfo>, INotifyIdle, INotifyDamage, ITick, IResolveOrder, ISync, INotifyCreated, INotifyOwnerChanged
|
public class AutoTarget : ConditionalTrait<AutoTargetInfo>, INotifyIdle, INotifyDamage, ITick, IResolveOrder, ISync, INotifyOwnerChanged
|
||||||
{
|
{
|
||||||
public readonly IEnumerable<AttackBase> ActiveAttackBases;
|
public readonly IEnumerable<AttackBase> ActiveAttackBases;
|
||||||
[Sync]
|
[Sync]
|
||||||
@@ -189,7 +189,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
PredictedStance = stance;
|
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.
|
// 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.
|
// IsTraitEnabled can change over time, and so must appear after the ToArray so it gets re-evaluated each time.
|
||||||
@@ -202,6 +202,8 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
disableAutoTarget = self.TraitsImplementing<IDisableAutoTarget>().ToArray();
|
disableAutoTarget = self.TraitsImplementing<IDisableAutoTarget>().ToArray();
|
||||||
notifyStanceChanged = self.TraitsImplementing<INotifyStanceChanged>().ToArray();
|
notifyStanceChanged = self.TraitsImplementing<INotifyStanceChanged>().ToArray();
|
||||||
ApplyStanceCondition(self);
|
ApplyStanceCondition(self);
|
||||||
|
|
||||||
|
base.Created(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
void INotifyOwnerChanged.OnOwnerChanged(Actor self, Player oldOwner, Player newOwner)
|
void INotifyOwnerChanged.OnOwnerChanged(Actor self, Player oldOwner, Player newOwner)
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public override object Create(ActorInitializer init) { return new PrimaryBuilding(init.Self, this); }
|
public override object Create(ActorInitializer init) { return new PrimaryBuilding(init.Self, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class PrimaryBuilding : ConditionalTrait<PrimaryBuildingInfo>, INotifyCreated, IIssueOrder, IResolveOrder
|
public class PrimaryBuilding : ConditionalTrait<PrimaryBuildingInfo>, IIssueOrder, IResolveOrder
|
||||||
{
|
{
|
||||||
const string OrderID = "PrimaryProducer";
|
const string OrderID = "PrimaryProducer";
|
||||||
|
|
||||||
@@ -55,9 +55,10 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public PrimaryBuilding(Actor self, PrimaryBuildingInfo info)
|
public PrimaryBuilding(Actor self, PrimaryBuildingInfo info)
|
||||||
: base(info) { }
|
: base(info) { }
|
||||||
|
|
||||||
void INotifyCreated.Created(Actor self)
|
protected override void Created(Actor self)
|
||||||
{
|
{
|
||||||
conditionManager = self.TraitOrDefault<ConditionManager>();
|
conditionManager = self.TraitOrDefault<ConditionManager>();
|
||||||
|
base.Created(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
IEnumerable<IOrderTargeter> IIssueOrder.Orders
|
IEnumerable<IOrderTargeter> IIssueOrder.Orders
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
public enum DeployState { Undeployed, Deploying, Deployed, Undeploying }
|
public enum DeployState { Undeployed, Deploying, Deployed, Undeploying }
|
||||||
|
|
||||||
public class GrantConditionOnDeploy : PausableConditionalTrait<GrantConditionOnDeployInfo>, IResolveOrder, IIssueOrder, INotifyCreated,
|
public class GrantConditionOnDeploy : PausableConditionalTrait<GrantConditionOnDeployInfo>, IResolveOrder, IIssueOrder,
|
||||||
INotifyDeployComplete, IIssueDeployOrder, IOrderVoice, IWrapMove
|
INotifyDeployComplete, IIssueDeployOrder, IOrderVoice, IWrapMove
|
||||||
{
|
{
|
||||||
readonly Actor self;
|
readonly Actor self;
|
||||||
@@ -93,10 +93,11 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
deployState = init.Get<DeployStateInit, DeployState>();
|
deployState = init.Get<DeployStateInit, DeployState>();
|
||||||
}
|
}
|
||||||
|
|
||||||
void INotifyCreated.Created(Actor self)
|
protected override void Created(Actor self)
|
||||||
{
|
{
|
||||||
conditionManager = self.TraitOrDefault<ConditionManager>();
|
conditionManager = self.TraitOrDefault<ConditionManager>();
|
||||||
notify = self.TraitsImplementing<INotifyDeployTriggered>().ToArray();
|
notify = self.TraitsImplementing<INotifyDeployTriggered>().ToArray();
|
||||||
|
base.Created(self);
|
||||||
|
|
||||||
switch (deployState)
|
switch (deployState)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -26,16 +26,17 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public override object Create(ActorInitializer init) { return new DetectCloaked(this); }
|
public override object Create(ActorInitializer init) { return new DetectCloaked(this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DetectCloaked : ConditionalTrait<DetectCloakedInfo>, INotifyCreated
|
public class DetectCloaked : ConditionalTrait<DetectCloakedInfo>
|
||||||
{
|
{
|
||||||
IDetectCloakedModifier[] rangeModifiers;
|
IDetectCloakedModifier[] rangeModifiers;
|
||||||
|
|
||||||
public DetectCloaked(DetectCloakedInfo info)
|
public DetectCloaked(DetectCloakedInfo info)
|
||||||
: base(info) { }
|
: base(info) { }
|
||||||
|
|
||||||
void INotifyCreated.Created(Actor self)
|
protected override void Created(Actor self)
|
||||||
{
|
{
|
||||||
rangeModifiers = self.TraitsImplementing<IDetectCloakedModifier>().ToArray();
|
rangeModifiers = self.TraitsImplementing<IDetectCloakedModifier>().ToArray();
|
||||||
|
base.Created(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
public WDist Range
|
public WDist Range
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Explodes : ConditionalTrait<ExplodesInfo>, INotifyKilled, INotifyDamage, INotifyCreated
|
public class Explodes : ConditionalTrait<ExplodesInfo>, INotifyKilled, INotifyDamage
|
||||||
{
|
{
|
||||||
readonly IHealth health;
|
readonly IHealth health;
|
||||||
BuildingInfo buildingInfo;
|
BuildingInfo buildingInfo;
|
||||||
@@ -91,9 +91,10 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
health = self.Trait<IHealth>();
|
health = self.Trait<IHealth>();
|
||||||
}
|
}
|
||||||
|
|
||||||
void INotifyCreated.Created(Actor self)
|
protected override void Created(Actor self)
|
||||||
{
|
{
|
||||||
buildingInfo = self.Info.TraitInfoOrDefault<BuildingInfo>();
|
buildingInfo = self.Info.TraitInfoOrDefault<BuildingInfo>();
|
||||||
|
base.Created(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
void INotifyKilled.Killed(Actor self, AttackInfo e)
|
void INotifyKilled.Killed(Actor self, AttackInfo e)
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public override object Create(ActorInitializer init) { return new KillsSelf(init.Self, this); }
|
public override object Create(ActorInitializer init) { return new KillsSelf(init.Self, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
class KillsSelf : ConditionalTrait<KillsSelfInfo>, INotifyCreated, INotifyAddedToWorld, ITick
|
class KillsSelf : ConditionalTrait<KillsSelfInfo>, INotifyAddedToWorld, ITick
|
||||||
{
|
{
|
||||||
int lifetime;
|
int lifetime;
|
||||||
ConditionManager conditionManager;
|
ConditionManager conditionManager;
|
||||||
@@ -51,9 +51,10 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
Kill(self);
|
Kill(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
void INotifyCreated.Created(Actor self)
|
protected override void Created(Actor self)
|
||||||
{
|
{
|
||||||
conditionManager = self.TraitOrDefault<ConditionManager>();
|
conditionManager = self.TraitOrDefault<ConditionManager>();
|
||||||
|
base.Created(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
void INotifyAddedToWorld.AddedToWorld(Actor self)
|
void INotifyAddedToWorld.AddedToWorld(Actor self)
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ReloadAmmoPool : PausableConditionalTrait<ReloadAmmoPoolInfo>, ITick, INotifyCreated, INotifyAttack, ISync
|
public class ReloadAmmoPool : PausableConditionalTrait<ReloadAmmoPoolInfo>, ITick, INotifyAttack, ISync
|
||||||
{
|
{
|
||||||
AmmoPool ammoPool;
|
AmmoPool ammoPool;
|
||||||
IReloadAmmoModifier[] modifiers;
|
IReloadAmmoModifier[] modifiers;
|
||||||
@@ -54,11 +54,12 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public ReloadAmmoPool(ReloadAmmoPoolInfo info)
|
public ReloadAmmoPool(ReloadAmmoPoolInfo info)
|
||||||
: base(info) { }
|
: base(info) { }
|
||||||
|
|
||||||
void INotifyCreated.Created(Actor self)
|
protected override void Created(Actor self)
|
||||||
{
|
{
|
||||||
ammoPool = self.TraitsImplementing<AmmoPool>().Single(ap => ap.Info.Name == Info.AmmoPool);
|
ammoPool = self.TraitsImplementing<AmmoPool>().Single(ap => ap.Info.Name == Info.AmmoPool);
|
||||||
modifiers = self.TraitsImplementing<IReloadAmmoModifier>().ToArray();
|
modifiers = self.TraitsImplementing<IReloadAmmoModifier>().ToArray();
|
||||||
remainingTicks = Info.Delay;
|
remainingTicks = Info.Delay;
|
||||||
|
base.Created(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
void INotifyAttack.Attacking(Actor self, Target target, Armament a, Barrel barrel)
|
void INotifyAttack.Attacking(Actor self, Target target, Armament a, Barrel barrel)
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public override object Create(ActorInitializer init) { return new ActorSpawnManager(init.Self, this); }
|
public override object Create(ActorInitializer init) { return new ActorSpawnManager(init.Self, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ActorSpawnManager : ConditionalTrait<ActorSpawnManagerInfo>, ITick, INotifyCreated
|
public class ActorSpawnManager : ConditionalTrait<ActorSpawnManagerInfo>, ITick
|
||||||
{
|
{
|
||||||
readonly ActorSpawnManagerInfo info;
|
readonly ActorSpawnManagerInfo info;
|
||||||
|
|
||||||
@@ -55,9 +55,10 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
this.info = info;
|
this.info = info;
|
||||||
}
|
}
|
||||||
|
|
||||||
void INotifyCreated.Created(Actor self)
|
protected override void Created(Actor self)
|
||||||
{
|
{
|
||||||
enabled = self.Trait<MapCreeps>().Enabled;
|
enabled = self.Trait<MapCreeps>().Enabled;
|
||||||
|
base.Created(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ITick.Tick(Actor self)
|
void ITick.Tick(Actor self)
|
||||||
|
|||||||
Reference in New Issue
Block a user