From c7350b704ed6d120d2593a624a97e7fe687694ef Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sun, 4 Aug 2013 18:22:57 +1200 Subject: [PATCH] Add trait interfaces for added/removed from world. --- OpenRA.Game/Traits/TraitsInterfaces.cs | 2 ++ OpenRA.Game/World.cs | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/OpenRA.Game/Traits/TraitsInterfaces.cs b/OpenRA.Game/Traits/TraitsInterfaces.cs index b543fbf5ca..8bbc5db90d 100755 --- a/OpenRA.Game/Traits/TraitsInterfaces.cs +++ b/OpenRA.Game/Traits/TraitsInterfaces.cs @@ -64,6 +64,8 @@ namespace OpenRA.Traits public interface IValidateOrder { bool OrderValidation(OrderManager orderManager, World world, int clientId, Order order); } public interface IOrderVoice { string VoicePhraseForOrder(Actor self, Order order); } public interface INotify { void Play(Player p, string notification); } + public interface INotifyAddedToWorld { void AddedToWorld(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 INotifyDamageStateChanged { void DamageStateChanged(Actor self, AttackInfo e); } diff --git a/OpenRA.Game/World.cs b/OpenRA.Game/World.cs index 7c2d6177a6..fe07516552 100644 --- a/OpenRA.Game/World.cs +++ b/OpenRA.Game/World.cs @@ -159,6 +159,9 @@ namespace OpenRA a.IsInWorld = true; actors.Add(a); ActorAdded(a); + + foreach (var t in a.TraitsImplementing()) + t.AddedToWorld(a); } public void Remove(Actor a) @@ -166,7 +169,9 @@ namespace OpenRA a.IsInWorld = false; actors.Remove(a); ActorRemoved(a); - + + foreach (var t in a.TraitsImplementing()) + t.RemovedFromWorld(a); } public void Add(IEffect b) { effects.Add(b); }