diff --git a/OpenRA.Mods.Cnc/Missions/CncShellmapScript.cs b/OpenRA.Mods.Cnc/Missions/CncShellmapScript.cs index d35ddfd2ac..0e549a629f 100755 --- a/OpenRA.Mods.Cnc/Missions/CncShellmapScript.cs +++ b/OpenRA.Mods.Cnc/Missions/CncShellmapScript.cs @@ -82,7 +82,7 @@ namespace OpenRA.Mods.RA { var mobile = self.Trait(); self.QueueActivity(mobile.ScriptedMove(left)); - self.QueueActivity(new Teleport(right)); + self.QueueActivity(new Teleport(null, right, false)); self.QueueActivity(new CallFunc(() => LoopTrack(self,left,right))); } } diff --git a/OpenRA.Mods.RA/Activities/Teleport.cs b/OpenRA.Mods.RA/Activities/Teleport.cs index 3155c16378..3cd1ed4939 100755 --- a/OpenRA.Mods.RA/Activities/Teleport.cs +++ b/OpenRA.Mods.RA/Activities/Teleport.cs @@ -16,15 +16,32 @@ namespace OpenRA.Mods.RA.Activities public class Teleport : Activity { CPos destination; + bool killCargo; + Actor chronosphere; - public Teleport(CPos destination) + public Teleport(Actor chronosphere, CPos destination, bool killCargo) { + this.chronosphere = chronosphere; this.destination = destination; + this.killCargo = killCargo; } public override Activity Tick(Actor self) { self.Trait().SetPosition(self, destination); + + if (killCargo && self.HasTrait()) + { + var cargo = self.Trait(); + while (!cargo.IsEmpty(self)) + { + if (chronosphere != null) + chronosphere.Owner.Kills++; + var a = cargo.Unload(self); + a.Owner.Deaths++; + } + } + return NextActivity; } } diff --git a/OpenRA.Mods.RA/ChronoshiftDeploy.cs b/OpenRA.Mods.RA/ChronoshiftDeploy.cs index af4cea046f..b61288984d 100644 --- a/OpenRA.Mods.RA/ChronoshiftDeploy.cs +++ b/OpenRA.Mods.RA/ChronoshiftDeploy.cs @@ -52,12 +52,10 @@ namespace OpenRA.Mods.RA if (order.OrderString == "ChronoshiftSelf" && movement.CanEnterCell(order.TargetLocation)) { if (self.Owner == self.World.LocalPlayer) - { self.World.CancelInputMode(); - } self.CancelActivity(); - self.QueueActivity(new Teleport(order.TargetLocation)); + self.QueueActivity(new Teleport(null, order.TargetLocation, true)); Sound.Play("chrotnk1.aud", self.CenterLocation); Sound.Play("chrotnk1.aud", order.TargetLocation.ToPPos()); chargeTick = 25 * self.Info.Traits.Get().ChargeTime; diff --git a/OpenRA.Mods.RA/Chronoshiftable.cs b/OpenRA.Mods.RA/Chronoshiftable.cs index 0d722e0f22..90de1a7e56 100755 --- a/OpenRA.Mods.RA/Chronoshiftable.cs +++ b/OpenRA.Mods.RA/Chronoshiftable.cs @@ -20,6 +20,8 @@ namespace OpenRA.Mods.RA // Return-to-sender logic [Sync] CPos chronoshiftOrigin; [Sync] int chronoshiftReturnTicks = 0; + Actor chronosphere; + bool killCargo; public void Tick(Actor self) { @@ -34,7 +36,7 @@ namespace OpenRA.Mods.RA { self.CancelActivity(); // Todo: need a new Teleport method that will move to the closest available cell - self.QueueActivity(new Teleport(chronoshiftOrigin)); + self.QueueActivity(new Teleport(chronosphere, chronoshiftOrigin, killCargo)); } } @@ -52,22 +54,12 @@ namespace OpenRA.Mods.RA /// Set up return-to-sender info chronoshiftOrigin = self.Location; chronoshiftReturnTicks = duration; - - // Kill cargo - if (killCargo && self.HasTrait()) - { - var cargo = self.Trait(); - while (!cargo.IsEmpty(self)) - { - chronosphere.Owner.Kills++; - var a = cargo.Unload(self); - a.Owner.Deaths++; - } - } + this.chronosphere = chronosphere; + this.killCargo = killCargo; // Set up the teleport self.CancelActivity(); - self.QueueActivity(new Teleport(targetLocation)); + self.QueueActivity(new Teleport(chronosphere, targetLocation, killCargo)); return true; }