using System; namespace OpenRa.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()) ns.Sold(self); w.Remove(self); var mcv = w.CreateActor("mcv", self.Location + new int2(1, 1), self.Owner); mcv.traits.Get().Facing = 96; } public IActivity Tick(Actor self) { if (!started) { var rb = self.traits.Get(); rb.PlayCustomAnimBackwards(self, "make", () => self.World.AddFrameEndTask(w => DoUndeploy(w,self))); Sound.PlayToPlayer(self.Owner, "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."); } } }