fixed #2286 - chrono kills passengers on return too

This commit is contained in:
Chris Forbes
2012-07-01 13:31:04 +12:00
parent f5c606266d
commit 109546d20f
4 changed files with 26 additions and 19 deletions

View File

@@ -82,7 +82,7 @@ namespace OpenRA.Mods.RA
{
var mobile = self.Trait<Mobile>();
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)));
}
}

View File

@@ -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<ITeleportable>().SetPosition(self, destination);
if (killCargo && self.HasTrait<Cargo>())
{
var cargo = self.Trait<Cargo>();
while (!cargo.IsEmpty(self))
{
if (chronosphere != null)
chronosphere.Owner.Kills++;
var a = cargo.Unload(self);
a.Owner.Deaths++;
}
}
return NextActivity;
}
}

View File

@@ -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<ChronoshiftDeployInfo>().ChargeTime;

View File

@@ -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<Cargo>())
{
var cargo = self.Trait<Cargo>();
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;
}