Unload passengers on death
This commit is contained in:
@@ -273,6 +273,11 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
|
|
||||||
// Run inner activity/InsideTick
|
// Run inner activity/InsideTick
|
||||||
inner = inner == this ? InsideTick(self) : Util.RunActivity(self, inner);
|
inner = inner == this ? InsideTick(self) : Util.RunActivity(self, inner);
|
||||||
|
|
||||||
|
// If we are finished, move on to next activity
|
||||||
|
if (inner == null && nextState == State.Done)
|
||||||
|
return NextActivity;
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,9 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
[Desc("When this actor is sold should all of its passengers be unloaded?")]
|
[Desc("When this actor is sold should all of its passengers be unloaded?")]
|
||||||
public readonly bool EjectOnSell = true;
|
public readonly bool EjectOnSell = true;
|
||||||
|
|
||||||
|
[Desc("When this actor dies should all of its passengers be unloaded?")]
|
||||||
|
public readonly bool EjectOnDeath = false;
|
||||||
|
|
||||||
[Desc("Terrain types that this actor is allowed to eject actors onto. Leave empty for all terrain types.")]
|
[Desc("Terrain types that this actor is allowed to eject actors onto. Leave empty for all terrain types.")]
|
||||||
public readonly HashSet<string> UnloadTerrainTypes = new HashSet<string>();
|
public readonly HashSet<string> UnloadTerrainTypes = new HashSet<string>();
|
||||||
|
|
||||||
@@ -317,6 +320,26 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
public void Killed(Actor self, AttackInfo e)
|
public void Killed(Actor self, AttackInfo e)
|
||||||
{
|
{
|
||||||
|
if (Info.EjectOnDeath)
|
||||||
|
while (!IsEmpty(self) && CanUnload())
|
||||||
|
{
|
||||||
|
var passenger = Unload(self);
|
||||||
|
var cp = self.CenterPosition;
|
||||||
|
var inAir = self.World.Map.DistanceAboveTerrain(cp).Length != 0;
|
||||||
|
var positionable = passenger.Trait<IPositionable>();
|
||||||
|
positionable.SetPosition(passenger, self.Location);
|
||||||
|
|
||||||
|
if (!inAir && positionable.CanEnterCell(self.Location, self, false))
|
||||||
|
{
|
||||||
|
self.World.AddFrameEndTask(w => w.Add(passenger));
|
||||||
|
var nbm = passenger.TraitOrDefault<INotifyBlockingMove>();
|
||||||
|
if (nbm != null)
|
||||||
|
nbm.OnNotifyBlockingMove(passenger, passenger);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
passenger.Kill(e.Attacker);
|
||||||
|
}
|
||||||
|
|
||||||
foreach (var c in cargo)
|
foreach (var c in cargo)
|
||||||
c.Kill(e.Attacker);
|
c.Kill(e.Attacker);
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ DPOD:
|
|||||||
MaxWeight: 1
|
MaxWeight: 1
|
||||||
PipCount: 1
|
PipCount: 1
|
||||||
UnloadVoice: Move
|
UnloadVoice: Move
|
||||||
|
EjectOnDeath: true
|
||||||
Armament:
|
Armament:
|
||||||
Weapon: Vulcan2
|
Weapon: Vulcan2
|
||||||
AttackHeli:
|
AttackHeli:
|
||||||
@@ -59,6 +60,7 @@ DSHP:
|
|||||||
MaxWeight: 5
|
MaxWeight: 5
|
||||||
PipCount: 5
|
PipCount: 5
|
||||||
UnloadVoice: Move
|
UnloadVoice: Move
|
||||||
|
EjectOnDeath: true
|
||||||
SpawnActorOnDeath:
|
SpawnActorOnDeath:
|
||||||
Actor: DSHP.Husk
|
Actor: DSHP.Husk
|
||||||
|
|
||||||
@@ -183,6 +185,7 @@ ORCATRAN:
|
|||||||
MaxWeight: 5
|
MaxWeight: 5
|
||||||
PipCount: 5
|
PipCount: 5
|
||||||
UnloadVoice: Move
|
UnloadVoice: Move
|
||||||
|
EjectOnDeath: true
|
||||||
SpawnActorOnDeath:
|
SpawnActorOnDeath:
|
||||||
Actor: ORCATRAN.Husk
|
Actor: ORCATRAN.Husk
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ APC:
|
|||||||
PipCount: 5
|
PipCount: 5
|
||||||
UnloadVoice: Unload
|
UnloadVoice: Unload
|
||||||
LoadingUpgrades: notmobile
|
LoadingUpgrades: notmobile
|
||||||
|
EjectOnDeath: true
|
||||||
-WithVoxelBody:
|
-WithVoxelBody:
|
||||||
WithVoxelWaterBody:
|
WithVoxelWaterBody:
|
||||||
LeavesTrails:
|
LeavesTrails:
|
||||||
|
|||||||
@@ -227,6 +227,7 @@ SAPC:
|
|||||||
PipCount: 5
|
PipCount: 5
|
||||||
UnloadVoice: Unload
|
UnloadVoice: Unload
|
||||||
LoadingUpgrades: notmobile
|
LoadingUpgrades: notmobile
|
||||||
|
EjectOnDeath: true
|
||||||
|
|
||||||
SUBTANK:
|
SUBTANK:
|
||||||
Inherits: ^VoxelTank
|
Inherits: ^VoxelTank
|
||||||
|
|||||||
Reference in New Issue
Block a user