decouple that a bit more.

This commit is contained in:
Chris Forbes
2009-12-22 20:03:53 +13:00
parent b9d231d500
commit d695344a05
3 changed files with 9 additions and 8 deletions

View File

@@ -46,8 +46,8 @@ namespace OpenRa.Game.Traits
Game.world.Add( newUnit ); Game.world.Add( newUnit );
if( self.traits.Contains<RenderWarFactory>() ) foreach (var t in self.traits.WithInterface<INotifyProduction>())
self.traits.Get<RenderWarFactory>().EjectUnit(); t.UnitProduced(self, newUnit);
return true; return true;
} }

View File

@@ -3,7 +3,7 @@ using OpenRa.Game.Graphics;
namespace OpenRa.Game.Traits namespace OpenRa.Game.Traits
{ {
class RenderWarFactory : IRender, INotifyBuildComplete, INotifyDamage, ITick class RenderWarFactory : IRender, INotifyBuildComplete, INotifyDamage, ITick, INotifyProduction
{ {
public Animation roof; public Animation roof;
bool doneBuilding; 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) public void Damaged(Actor self, AttackInfo e)
{ {
if (!e.DamageStateChanged) return; if (!e.DamageStateChanged) return;
@@ -62,5 +57,10 @@ namespace OpenRa.Game.Traits
break; break;
} }
} }
public void UnitProduced(Actor self, Actor other)
{
roof.PlayThen(prefix + "build-top", () => isOpen = true);
}
} }
} }

View File

@@ -38,6 +38,7 @@ namespace OpenRa.Game.Traits
interface IRender { IEnumerable<Renderable> Render(Actor self); } interface IRender { IEnumerable<Renderable> Render(Actor self); }
interface INotifyDamage { void Damaged(Actor self, AttackInfo e); } interface INotifyDamage { void Damaged(Actor self, AttackInfo e); }
interface INotifyBuildComplete { void BuildingComplete (Actor self); } interface INotifyBuildComplete { void BuildingComplete (Actor self); }
interface INotifyProduction { void UnitProduced(Actor self, Actor other); }
interface IOrder interface IOrder
{ {
Order IssueOrder( Actor self, int2 xy, MouseInput mi, Actor underCursor ); Order IssueOrder( Actor self, int2 xy, MouseInput mi, Actor underCursor );