diff --git a/OpenRa.Game/Traits/Production.cs b/OpenRa.Game/Traits/Production.cs index 98e2dee533..4dcfe7fe63 100755 --- a/OpenRa.Game/Traits/Production.cs +++ b/OpenRa.Game/Traits/Production.cs @@ -46,8 +46,8 @@ namespace OpenRa.Game.Traits Game.world.Add( newUnit ); - if( self.traits.Contains() ) - self.traits.Get().EjectUnit(); + foreach (var t in self.traits.WithInterface()) + t.UnitProduced(self, newUnit); return true; } diff --git a/OpenRa.Game/Traits/RenderBuildingWarFactory.cs b/OpenRa.Game/Traits/RenderBuildingWarFactory.cs index 8f8dbf52f2..fe8a527911 100644 --- a/OpenRa.Game/Traits/RenderBuildingWarFactory.cs +++ b/OpenRa.Game/Traits/RenderBuildingWarFactory.cs @@ -3,7 +3,7 @@ using OpenRa.Game.Graphics; namespace OpenRa.Game.Traits { - class RenderWarFactory : IRender, INotifyBuildComplete, INotifyDamage, ITick + class RenderWarFactory : IRender, INotifyBuildComplete, INotifyDamage, ITick, INotifyProduction { public Animation roof; bool doneBuilding; @@ -42,11 +42,6 @@ namespace OpenRa.Game.Traits } } - public void EjectUnit() - { - roof.PlayThen(prefix + "build-top", () => isOpen = true); - } - public void Damaged(Actor self, AttackInfo e) { if (!e.DamageStateChanged) return; @@ -62,5 +57,10 @@ namespace OpenRa.Game.Traits break; } } + + public void UnitProduced(Actor self, Actor other) + { + roof.PlayThen(prefix + "build-top", () => isOpen = true); + } } } diff --git a/OpenRa.Game/Traits/TraitsInterfaces.cs b/OpenRa.Game/Traits/TraitsInterfaces.cs index dbe8ff8203..cb8903a396 100644 --- a/OpenRa.Game/Traits/TraitsInterfaces.cs +++ b/OpenRa.Game/Traits/TraitsInterfaces.cs @@ -38,6 +38,7 @@ namespace OpenRa.Game.Traits interface IRender { IEnumerable Render(Actor self); } interface INotifyDamage { void Damaged(Actor self, AttackInfo e); } interface INotifyBuildComplete { void BuildingComplete (Actor self); } + interface INotifyProduction { void UnitProduced(Actor self, Actor other); } interface IOrder { Order IssueOrder( Actor self, int2 xy, MouseInput mi, Actor underCursor );