war factory incredible hack
This commit is contained in:
@@ -197,6 +197,8 @@ namespace OpenRa.Game
|
||||
world.AddFrameEndTask(_ => world.Add(unit));
|
||||
|
||||
// todo: make the producing building play `build`
|
||||
if (producer.traits.Contains<RenderWarFactory>())
|
||||
producer.traits.Get<RenderWarFactory>().EjectUnit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,8 +44,8 @@ namespace OpenRa.Game.Graphics
|
||||
spriteRenderer.DrawSprite(image.First, loc,
|
||||
(owner != null) ? owner.Palette : 0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void Draw()
|
||||
{
|
||||
var rect = new RectangleF((region.Position + Game.viewport.Location).ToPointF(),
|
||||
@@ -54,6 +54,11 @@ namespace OpenRa.Game.Graphics
|
||||
foreach (Actor a in Game.world.Actors.OrderBy( u => u.CenterLocation.Y ))
|
||||
DrawSpriteList(a.Owner, rect, a.Render());
|
||||
|
||||
foreach (var a in Game.world.Actors
|
||||
.Where(u => u.traits.Contains<Traits.RenderWarFactory>())
|
||||
.Select(u => u.traits.Get<Traits.RenderWarFactory>()))
|
||||
DrawSpriteList(a.self.Owner, rect, a.RenderRoof(a.self)); /* RUDE HACK */
|
||||
|
||||
foreach (IEffect e in Game.world.Effects)
|
||||
DrawSpriteList(e.Owner, rect, e.Render());
|
||||
|
||||
|
||||
@@ -11,10 +11,13 @@ namespace OpenRa.Game.Traits
|
||||
{
|
||||
public Animation roof;
|
||||
bool doneBuilding;
|
||||
public readonly Actor self;
|
||||
|
||||
public RenderWarFactory(Actor self)
|
||||
: base(self)
|
||||
{
|
||||
this.self = self;
|
||||
|
||||
roof = new Animation(self.unitInfo.Image ?? self.unitInfo.Name);
|
||||
anim.PlayThen("make", () =>
|
||||
{
|
||||
@@ -24,13 +27,10 @@ namespace OpenRa.Game.Traits
|
||||
});
|
||||
}
|
||||
|
||||
public override IEnumerable<Pair<Sprite, float2>> Render(Actor self)
|
||||
public IEnumerable<Pair<Sprite, float2>> RenderRoof(Actor self)
|
||||
{
|
||||
if (doneBuilding)
|
||||
return base.Render(self).Concat(
|
||||
new[] { Pair.New(roof.Image, 24f * (float2)self.Location) });
|
||||
else
|
||||
return base.Render(self);
|
||||
yield return Pair.New(roof.Image, 24f * (float2)self.Location);
|
||||
}
|
||||
|
||||
public override void Tick(Actor self)
|
||||
@@ -38,5 +38,13 @@ namespace OpenRa.Game.Traits
|
||||
base.Tick(self);
|
||||
roof.Tick();
|
||||
}
|
||||
|
||||
public void EjectUnit()
|
||||
{
|
||||
/* todo: hold the door open */
|
||||
|
||||
roof.PlayThen("build-top",
|
||||
() => roof.PlayRepeating("idle-top"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user