decouple that a bit more.
This commit is contained in:
@@ -46,8 +46,8 @@ namespace OpenRa.Game.Traits
|
||||
|
||||
Game.world.Add( newUnit );
|
||||
|
||||
if( self.traits.Contains<RenderWarFactory>() )
|
||||
self.traits.Get<RenderWarFactory>().EjectUnit();
|
||||
foreach (var t in self.traits.WithInterface<INotifyProduction>())
|
||||
t.UnitProduced(self, newUnit);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ namespace OpenRa.Game.Traits
|
||||
interface IRender { IEnumerable<Renderable> 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 );
|
||||
|
||||
Reference in New Issue
Block a user