MCV Undeploy
This commit is contained in:
43
OpenRa.Game/Traits/Activities/UndeployMcv.cs
Normal file
43
OpenRa.Game/Traits/Activities/UndeployMcv.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
|
||||
namespace OpenRa.Game.Traits.Activities
|
||||
{
|
||||
class UndeployMcv : IActivity
|
||||
{
|
||||
public IActivity NextActivity { get; set; }
|
||||
bool started;
|
||||
|
||||
void DoUndeploy(World w,Actor self)
|
||||
{
|
||||
self.Health = 0;
|
||||
foreach (var ns in self.traits.WithInterface<INotifySold>())
|
||||
ns.Sold(self);
|
||||
w.Remove(self);
|
||||
|
||||
var mcv = new Actor(Rules.UnitInfo["MCV"], self.Location + new int2(1, 1), self.Owner);
|
||||
mcv.traits.Get<Unit>().Facing = 96;
|
||||
w.Add(mcv);
|
||||
}
|
||||
|
||||
public IActivity Tick(Actor self)
|
||||
{
|
||||
if (!started)
|
||||
{
|
||||
var rb = self.traits.Get<RenderBuilding>();
|
||||
rb.PlayCustomAnimBackwards(self, "make",
|
||||
() => Game.world.AddFrameEndTask(w => DoUndeploy(w,self)));
|
||||
|
||||
Sound.Play("cashturn.aud");
|
||||
started = true;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public void Cancel(Actor self)
|
||||
{
|
||||
// Cancel can't happen between this being moved to the head of the list, and it being Ticked.
|
||||
throw new InvalidOperationException("UndeployMcvAction: Cancel() should never occur.");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user