Fix conditional traits that incorrectly override INotifyCreated.

This commit is contained in:
Paul Chote
2019-07-13 13:02:24 +01:00
committed by teinarss
parent 37325dbfc7
commit 6eaf615798
10 changed files with 34 additions and 23 deletions

View File

@@ -39,7 +39,7 @@ namespace OpenRA.Mods.Cnc.Traits
}
public class Chronoshiftable : ConditionalTrait<ChronoshiftableInfo>, 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<IPositionable>();
base.Created(self);
}
// Can't be used in synced code, except with ignoreVis.

View File

@@ -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<ResourcePurifierInfo>, INotifyCreated, INotifyResourceAccepted, ITick, INotifyOwnerChanged
public class ResourcePurifier : ConditionalTrait<ResourcePurifierInfo>, 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<PlayerResources>();
base.Created(self);
}
void INotifyResourceAccepted.OnResourceAccepted(Actor self, Actor refinery, int amount)