fixed #2286 - chrono kills passengers on return too
This commit is contained in:
@@ -82,7 +82,7 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
var mobile = self.Trait<Mobile>();
|
var mobile = self.Trait<Mobile>();
|
||||||
self.QueueActivity(mobile.ScriptedMove(left));
|
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)));
|
self.QueueActivity(new CallFunc(() => LoopTrack(self,left,right)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,15 +16,32 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
public class Teleport : Activity
|
public class Teleport : Activity
|
||||||
{
|
{
|
||||||
CPos destination;
|
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.destination = destination;
|
||||||
|
this.killCargo = killCargo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Activity Tick(Actor self)
|
public override Activity Tick(Actor self)
|
||||||
{
|
{
|
||||||
self.Trait<ITeleportable>().SetPosition(self, destination);
|
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;
|
return NextActivity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,12 +52,10 @@ namespace OpenRA.Mods.RA
|
|||||||
if (order.OrderString == "ChronoshiftSelf" && movement.CanEnterCell(order.TargetLocation))
|
if (order.OrderString == "ChronoshiftSelf" && movement.CanEnterCell(order.TargetLocation))
|
||||||
{
|
{
|
||||||
if (self.Owner == self.World.LocalPlayer)
|
if (self.Owner == self.World.LocalPlayer)
|
||||||
{
|
|
||||||
self.World.CancelInputMode();
|
self.World.CancelInputMode();
|
||||||
}
|
|
||||||
|
|
||||||
self.CancelActivity();
|
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", self.CenterLocation);
|
||||||
Sound.Play("chrotnk1.aud", order.TargetLocation.ToPPos());
|
Sound.Play("chrotnk1.aud", order.TargetLocation.ToPPos());
|
||||||
chargeTick = 25 * self.Info.Traits.Get<ChronoshiftDeployInfo>().ChargeTime;
|
chargeTick = 25 * self.Info.Traits.Get<ChronoshiftDeployInfo>().ChargeTime;
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ namespace OpenRA.Mods.RA
|
|||||||
// Return-to-sender logic
|
// Return-to-sender logic
|
||||||
[Sync] CPos chronoshiftOrigin;
|
[Sync] CPos chronoshiftOrigin;
|
||||||
[Sync] int chronoshiftReturnTicks = 0;
|
[Sync] int chronoshiftReturnTicks = 0;
|
||||||
|
Actor chronosphere;
|
||||||
|
bool killCargo;
|
||||||
|
|
||||||
public void Tick(Actor self)
|
public void Tick(Actor self)
|
||||||
{
|
{
|
||||||
@@ -34,7 +36,7 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
self.CancelActivity();
|
self.CancelActivity();
|
||||||
// Todo: need a new Teleport method that will move to the closest available cell
|
// 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
|
/// Set up return-to-sender info
|
||||||
chronoshiftOrigin = self.Location;
|
chronoshiftOrigin = self.Location;
|
||||||
chronoshiftReturnTicks = duration;
|
chronoshiftReturnTicks = duration;
|
||||||
|
this.chronosphere = chronosphere;
|
||||||
// Kill cargo
|
this.killCargo = killCargo;
|
||||||
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++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set up the teleport
|
// Set up the teleport
|
||||||
self.CancelActivity();
|
self.CancelActivity();
|
||||||
self.QueueActivity(new Teleport(targetLocation));
|
self.QueueActivity(new Teleport(chronosphere, targetLocation, killCargo));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user