Let Husk implement IEffectiveOwner

This commit is contained in:
abcdefg30
2017-08-08 14:31:45 +02:00
committed by reaperrr
parent eab93ccf97
commit d4d9959159

View File

@@ -43,10 +43,12 @@ namespace OpenRA.Mods.Common.Traits
bool IOccupySpaceInfo.SharesCell { get { return false; } } bool IOccupySpaceInfo.SharesCell { get { return false; } }
} }
public class Husk : IPositionable, IFacing, ISync, INotifyCreated, INotifyAddedToWorld, INotifyRemovedFromWorld, IDeathActorInitModifier public class Husk : IPositionable, IFacing, ISync, INotifyCreated, INotifyAddedToWorld, INotifyRemovedFromWorld,
IDeathActorInitModifier, IEffectiveOwner
{ {
readonly HuskInfo info;
readonly Actor self; readonly Actor self;
readonly HuskInfo info;
readonly Player effectiveOwner;
readonly int dragSpeed; readonly int dragSpeed;
readonly WPos finalPosition; readonly WPos finalPosition;
@@ -68,6 +70,8 @@ namespace OpenRA.Mods.Common.Traits
dragSpeed = init.Contains<HuskSpeedInit>() ? init.Get<HuskSpeedInit, int>() : 0; dragSpeed = init.Contains<HuskSpeedInit>() ? init.Get<HuskSpeedInit, int>() : 0;
finalPosition = init.World.Map.CenterOfCell(TopLeft); finalPosition = init.World.Map.CenterOfCell(TopLeft);
effectiveOwner = init.Contains<EffectiveOwnerInit>() ? init.Get<EffectiveOwnerInit, Player>() : self.Owner;
} }
void INotifyCreated.Created(Actor self) void INotifyCreated.Created(Actor self)
@@ -128,10 +132,14 @@ namespace OpenRA.Mods.Common.Traits
self.World.RemoveFromMaps(self, this); self.World.RemoveFromMaps(self, this);
} }
public void ModifyDeathActorInit(Actor self, TypeDictionary init) void IDeathActorInitModifier.ModifyDeathActorInit(Actor self, TypeDictionary init)
{ {
init.Add(new FacingInit(Facing)); init.Add(new FacingInit(Facing));
} }
// We return self.Owner if there's no effective owner
bool IEffectiveOwner.Disguised { get { return true; } }
Player IEffectiveOwner.Owner { get { return effectiveOwner; } }
} }
public class HuskSpeedInit : IActorInit<int> public class HuskSpeedInit : IActorInit<int>