Kill chronoshifted actors if the return-to-origin fails.
This commit is contained in:
@@ -15,6 +15,7 @@ using OpenRA.Activities;
|
||||
using OpenRA.Mods.Cnc.Traits;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Mods.Common.Traits.Render;
|
||||
using OpenRA.Primitives;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Cnc.Activities
|
||||
@@ -23,12 +24,16 @@ namespace OpenRA.Mods.Cnc.Activities
|
||||
{
|
||||
readonly Actor teleporter;
|
||||
readonly int? maximumDistance;
|
||||
readonly bool killOnFailure;
|
||||
readonly BitSet<DamageType> killDamageTypes;
|
||||
CPos destination;
|
||||
bool killCargo;
|
||||
bool screenFlash;
|
||||
string sound;
|
||||
|
||||
public Teleport(Actor teleporter, CPos destination, int? maximumDistance, bool killCargo, bool screenFlash, string sound)
|
||||
public Teleport(Actor teleporter, CPos destination, int? maximumDistance,
|
||||
bool killCargo, bool screenFlash, string sound, bool interruptable = true,
|
||||
bool killOnFailure = false, BitSet<DamageType> killDamageTypes = default(BitSet<DamageType>))
|
||||
{
|
||||
var max = teleporter.World.Map.Grid.MaximumTileSearchRange;
|
||||
if (maximumDistance > max)
|
||||
@@ -40,17 +45,32 @@ namespace OpenRA.Mods.Cnc.Activities
|
||||
this.killCargo = killCargo;
|
||||
this.screenFlash = screenFlash;
|
||||
this.sound = sound;
|
||||
this.killOnFailure = killOnFailure;
|
||||
this.killDamageTypes = killDamageTypes;
|
||||
|
||||
if (!interruptable)
|
||||
IsInterruptible = false;
|
||||
}
|
||||
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
var pc = self.TraitOrDefault<PortableChrono>();
|
||||
if (teleporter == self && pc != null && !pc.CanTeleport)
|
||||
{
|
||||
if (killOnFailure)
|
||||
self.Kill(teleporter, killDamageTypes);
|
||||
|
||||
return NextActivity;
|
||||
}
|
||||
|
||||
var bestCell = ChooseBestDestinationCell(self, destination);
|
||||
if (bestCell == null)
|
||||
{
|
||||
if (killOnFailure)
|
||||
self.Kill(teleporter, killDamageTypes);
|
||||
|
||||
return NextActivity;
|
||||
}
|
||||
|
||||
destination = bestCell.Value;
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#endregion
|
||||
|
||||
using System.Drawing;
|
||||
using OpenRA.Activities;
|
||||
using OpenRA.Mods.Cnc.Activities;
|
||||
using OpenRA.Mods.Common.Activities;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
@@ -24,7 +25,8 @@ namespace OpenRA.Mods.Cnc.Traits
|
||||
[Desc("Should the actor die instead of being teleported?")]
|
||||
public readonly bool ExplodeInstead = false;
|
||||
|
||||
[Desc("Types of damage that this trait causes to self when 'ExplodeInstead' is true. Leave empty for no damage types.")]
|
||||
[Desc("Types of damage that this trait causes to self when 'ExplodeInstead' is true",
|
||||
"or the return-to-origin is blocked. Leave empty for no damage types.")]
|
||||
public readonly BitSet<DamageType> DamageTypes = default(BitSet<DamageType>);
|
||||
|
||||
public readonly string ChronoshiftSound = "chrono2.aud";
|
||||
@@ -78,7 +80,10 @@ namespace OpenRA.Mods.Cnc.Traits
|
||||
if (--ReturnTicks == 0)
|
||||
{
|
||||
self.CancelActivity();
|
||||
self.QueueActivity(new Teleport(chronosphere, Origin, null, killCargo, true, Info.ChronoshiftSound));
|
||||
|
||||
// The actor is killed using Info.DamageTypes if the teleport fails
|
||||
self.QueueActivity(new Teleport(chronosphere, Origin, null, true, killCargo, Info.ChronoshiftSound,
|
||||
false, true, Info.DamageTypes));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user