Move INotifySold to Common and require explicit implementation

This commit is contained in:
reaperrr
2016-10-20 18:44:29 +02:00
parent b8c04a0887
commit 22dcb1c66f
20 changed files with 53 additions and 43 deletions

View File

@@ -143,7 +143,6 @@ namespace OpenRA.Traits
public interface INotifyCreated { void Created(Actor self); } public interface INotifyCreated { void Created(Actor self); }
public interface INotifyAddedToWorld { void AddedToWorld(Actor self); } public interface INotifyAddedToWorld { void AddedToWorld(Actor self); }
public interface INotifyRemovedFromWorld { void RemovedFromWorld(Actor self); } public interface INotifyRemovedFromWorld { void RemovedFromWorld(Actor self); }
public interface INotifySold { void Selling(Actor self); void Sold(Actor self); }
public interface INotifyDamage { void Damaged(Actor self, AttackInfo e); } public interface INotifyDamage { void Damaged(Actor self, AttackInfo e); }
public interface INotifyDamageStateChanged { void DamageStateChanged(Actor self, AttackInfo e); } public interface INotifyDamageStateChanged { void DamageStateChanged(Actor self, AttackInfo e); }
public interface INotifyRepair { void Repairing(Actor self, Actor target); } public interface INotifyRepair { void Repairing(Actor self, Actor target); }

View File

@@ -143,7 +143,7 @@ namespace OpenRA.Mods.Common.Traits
readonly Actor self; readonly Actor self;
public readonly bool SkipMakeAnimation; public readonly bool SkipMakeAnimation;
/* shared activity lock: undeploy, sell, capture, etc */ // Shared activity lock: undeploy, sell, capture, etc.
[Sync] public bool Locked = true; [Sync] public bool Locked = true;
public bool Lock() public bool Lock()
@@ -181,7 +181,7 @@ namespace OpenRA.Mods.Common.Traits
return OccupiedCells().Select(c => self.World.Map.CenterOfCell(c.First)); return OccupiedCells().Select(c => self.World.Map.CenterOfCell(c.First));
} }
public void Created(Actor self) void INotifyCreated.Created(Actor self)
{ {
if (SkipMakeAnimation || !self.Info.HasTraitInfo<WithMakeAnimationInfo>()) if (SkipMakeAnimation || !self.Info.HasTraitInfo<WithMakeAnimationInfo>())
NotifyBuildingComplete(self); NotifyBuildingComplete(self);
@@ -199,7 +199,7 @@ namespace OpenRA.Mods.Common.Traits
self.World.ScreenMap.Add(self); self.World.ScreenMap.Add(self);
} }
public void RemovedFromWorld(Actor self) void INotifyRemovedFromWorld.RemovedFromWorld(Actor self)
{ {
self.World.ActorMap.RemoveInfluence(self, this); self.World.ActorMap.RemoveInfluence(self, this);
self.World.ActorMap.RemovePosition(self, this); self.World.ActorMap.RemovePosition(self, this);
@@ -220,7 +220,7 @@ namespace OpenRA.Mods.Common.Traits
notify.BuildingComplete(self); notify.BuildingComplete(self);
} }
public void Selling(Actor self) void INotifySold.Selling(Actor self)
{ {
if (Info.RemoveSmudgesOnSell) if (Info.RemoveSmudgesOnSell)
RemoveSmudges(); RemoveSmudges();
@@ -228,9 +228,9 @@ namespace OpenRA.Mods.Common.Traits
BuildComplete = false; BuildComplete = false;
} }
public void Sold(Actor self) { } void INotifySold.Sold(Actor self) { }
public void BeforeTransform(Actor self) void INotifyTransform.BeforeTransform(Actor self)
{ {
if (Info.RemoveSmudgesOnTransform) if (Info.RemoveSmudgesOnTransform)
RemoveSmudges(); RemoveSmudges();
@@ -239,8 +239,8 @@ namespace OpenRA.Mods.Common.Traits
Game.Sound.PlayToPlayer(self.Owner, s, self.CenterPosition); Game.Sound.PlayToPlayer(self.Owner, s, self.CenterPosition);
} }
public void OnTransform(Actor self) { } void INotifyTransform.OnTransform(Actor self) { }
public void AfterTransform(Actor self) { } void INotifyTransform.AfterTransform(Actor self) { }
public void RemoveSmudges() public void RemoveSmudges()
{ {

View File

@@ -168,8 +168,8 @@ namespace OpenRA.Mods.Common.Traits
} }
} }
public void Selling(Actor self) { CancelDock(self); } void INotifySold.Selling(Actor self) { CancelDock(self); }
public void Sold(Actor self) void INotifySold.Sold(Actor self)
{ {
foreach (var harv in GetLinkedHarvesters()) foreach (var harv in GetLinkedHarvesters())
harv.Trait.UnlinkProc(harv.Actor, self); harv.Trait.UnlinkProc(harv.Actor, self);

View File

@@ -76,9 +76,13 @@ namespace OpenRA.Mods.Common.Traits
reservedForAircraft.UnReserve(); reservedForAircraft.UnReserve();
} }
public void Selling(Actor self) { Sold(self); } void INotifySold.Selling(Actor self)
{
if (reservedForAircraft != null)
reservedForAircraft.UnReserve();
}
public void Sold(Actor self) void INotifySold.Sold(Actor self)
{ {
if (reservedForAircraft != null) if (reservedForAircraft != null)
reservedForAircraft.UnReserve(); reservedForAircraft.UnReserve();

View File

@@ -356,8 +356,8 @@ namespace OpenRA.Mods.Common.Traits
cargo.Clear(); cargo.Clear();
} }
public void Selling(Actor self) { } void INotifySold.Selling(Actor self) { }
public void Sold(Actor self) void INotifySold.Sold(Actor self)
{ {
if (!Info.EjectOnSell || cargo == null) if (!Info.EjectOnSell || cargo == null)
return; return;

View File

@@ -45,7 +45,7 @@ namespace OpenRA.Mods.Common.Traits
correctFaction = factionsList.Count == 0 || factionsList.Contains(self.Owner.Faction.InternalName); correctFaction = factionsList.Count == 0 || factionsList.Contains(self.Owner.Faction.InternalName);
} }
public void Selling(Actor self) { } void INotifySold.Selling(Actor self) { }
void Emit(Actor self) void Emit(Actor self)
{ {
@@ -85,6 +85,6 @@ namespace OpenRA.Mods.Common.Traits
} }
} }
public void Sold(Actor self) { Emit(self); } void INotifySold.Sold(Actor self) { Emit(self); }
} }
} }

View File

@@ -139,8 +139,8 @@ namespace OpenRA.Mods.Common.Traits
} }
public void Killed(Actor killed, AttackInfo e) { if (killed == self) { ClearQueue(); Enabled = false; } } public void Killed(Actor killed, AttackInfo e) { if (killed == self) { ClearQueue(); Enabled = false; } }
public void Selling(Actor self) { ClearQueue(); Enabled = false; } void INotifySold.Selling(Actor self) { ClearQueue(); Enabled = false; }
public void Sold(Actor self) { } void INotifySold.Sold(Actor self) { }
public void BeforeTransform(Actor self) { ClearQueue(); Enabled = false; } public void BeforeTransform(Actor self) { ClearQueue(); Enabled = false; }
public void OnTransform(Actor self) { } public void OnTransform(Actor self) { }

View File

@@ -60,8 +60,8 @@ namespace OpenRA.Mods.Common.Traits.Render
overlay.ReplaceAnim(RenderSprites.NormalizeSequence(overlay, e.DamageState, info.Sequence)); overlay.ReplaceAnim(RenderSprites.NormalizeSequence(overlay, e.DamageState, info.Sequence));
} }
public void Sold(Actor self) { } void INotifySold.Sold(Actor self) { }
public void Selling(Actor self) void INotifySold.Selling(Actor self)
{ {
charging = false; charging = false;
} }

View File

@@ -71,8 +71,8 @@ namespace OpenRA.Mods.Common.Traits.Render
buildComplete = true))); buildComplete = true)));
} }
public void Sold(Actor self) { } void INotifySold.Sold(Actor self) { }
public void Selling(Actor self) void INotifySold.Selling(Actor self)
{ {
buildComplete = false; buildComplete = false;
} }

View File

@@ -59,11 +59,11 @@ namespace OpenRA.Mods.Common.Traits.Render
buildComplete = true; buildComplete = true;
} }
public void Selling(Actor self) void INotifySold.Selling(Actor self)
{ {
buildComplete = false; buildComplete = false;
} }
public void Sold(Actor self) { } void INotifySold.Sold(Actor self) { }
} }
} }

View File

@@ -105,8 +105,8 @@ namespace OpenRA.Mods.Common.Traits.Render
buildComplete = true; buildComplete = true;
} }
public void Sold(Actor self) { } void INotifySold.Sold(Actor self) { }
public void Selling(Actor self) void INotifySold.Selling(Actor self)
{ {
buildComplete = false; buildComplete = false;
} }

View File

@@ -80,7 +80,7 @@ namespace OpenRA.Mods.Common.Traits.Render
desiredFrame = door.CurrentSequence.Length - 1; desiredFrame = door.CurrentSequence.Length - 1;
} }
public void Selling(Actor self) { buildComplete = false; } void INotifySold.Selling(Actor self) { buildComplete = false; }
public void Sold(Actor self) { } void INotifySold.Sold(Actor self) { }
} }
} }

View File

@@ -97,8 +97,8 @@ namespace OpenRA.Mods.Common.Traits.Render
self.World.AddFrameEndTask(w => SelectQueue(self)); self.World.AddFrameEndTask(w => SelectQueue(self));
} }
public void Sold(Actor self) { } void INotifySold.Sold(Actor self) { }
public void Selling(Actor self) void INotifySold.Selling(Actor self)
{ {
buildComplete = false; buildComplete = false;
} }

View File

@@ -47,11 +47,11 @@ namespace OpenRA.Mods.Common.Traits.Render
buildComplete = true; buildComplete = true;
} }
public void Selling(Actor self) void INotifySold.Selling(Actor self)
{ {
buildComplete = false; buildComplete = false;
} }
public void Sold(Actor self) { } void INotifySold.Sold(Actor self) { }
} }
} }

View File

@@ -47,11 +47,11 @@ namespace OpenRA.Mods.Common.Traits.Render
buildComplete = true; buildComplete = true;
} }
public void Selling(Actor self) void INotifySold.Selling(Actor self)
{ {
buildComplete = false; buildComplete = false;
} }
public void Sold(Actor self) { } void INotifySold.Sold(Actor self) { }
} }
} }

View File

@@ -65,8 +65,8 @@ namespace OpenRA.Mods.Common.Traits.Render
buildComplete = true))); buildComplete = true)));
} }
public void Sold(Actor self) { } void INotifySold.Sold(Actor self) { }
public void Selling(Actor self) void INotifySold.Selling(Actor self)
{ {
buildComplete = false; buildComplete = false;
} }

View File

@@ -66,7 +66,7 @@ namespace OpenRA.Mods.Common.Traits.Render
playerResources = newOwner.PlayerActor.Trait<PlayerResources>(); playerResources = newOwner.PlayerActor.Trait<PlayerResources>();
} }
public void Selling(Actor self) { rs.Remove(anim); } void INotifySold.Selling(Actor self) { rs.Remove(anim); }
public void Sold(Actor self) { } void INotifySold.Sold(Actor self) { }
} }
} }

View File

@@ -36,6 +36,13 @@ namespace OpenRA.Mods.Common.Traits
IEnumerable<IRenderable> Render(WorldRenderer wr, World w, ActorInfo ai, WPos centerPosition); IEnumerable<IRenderable> Render(WorldRenderer wr, World w, ActorInfo ai, WPos centerPosition);
} }
[RequireExplicitImplementation]
public interface INotifySold
{
void Selling(Actor self);
void Sold(Actor self);
}
[RequireExplicitImplementation] [RequireExplicitImplementation]
public interface INotifyAttack public interface INotifyAttack
{ {

View File

@@ -75,8 +75,8 @@ namespace OpenRA.Mods.D2k.Traits.Render
buildComplete = true))); buildComplete = true)));
} }
public void Sold(Actor self) { } void INotifySold.Sold(Actor self) { }
public void Selling(Actor self) void INotifySold.Selling(Actor self)
{ {
buildComplete = false; buildComplete = false;
} }

View File

@@ -86,8 +86,8 @@ namespace OpenRA.Mods.RA.Traits
public void Killed(Actor self, AttackInfo e) { RemoveGps(self); } public void Killed(Actor self, AttackInfo e) { RemoveGps(self); }
public void Selling(Actor self) { } void INotifySold.Selling(Actor self) { }
public void Sold(Actor self) { RemoveGps(self); } void INotifySold.Sold(Actor self) { RemoveGps(self); }
void RemoveGps(Actor self) void RemoveGps(Actor self)
{ {