Merge pull request #4045 from Mailaender/pilot-nudge
Cleanup EjectOnDeath and nudge pilots
This commit is contained in:
@@ -10,10 +10,12 @@
|
|||||||
|
|
||||||
using OpenRA.FileFormats;
|
using OpenRA.FileFormats;
|
||||||
using OpenRA.Mods.RA.Effects;
|
using OpenRA.Mods.RA.Effects;
|
||||||
|
using OpenRA.Mods.RA.Move;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA.Mods.RA
|
namespace OpenRA.Mods.RA
|
||||||
{
|
{
|
||||||
|
[Desc("Eject a ground soldier or a paratrooper while in the air.")]
|
||||||
public class EjectOnDeathInfo : TraitInfo<EjectOnDeath>
|
public class EjectOnDeathInfo : TraitInfo<EjectOnDeath>
|
||||||
{
|
{
|
||||||
[ActorReference]
|
[ActorReference]
|
||||||
@@ -38,6 +40,8 @@ namespace OpenRA.Mods.RA
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
var cp = self.CenterPosition;
|
var cp = self.CenterPosition;
|
||||||
|
if ((cp.Z > 0 && !info.EjectInAir) || (cp.Z == 0 && !info.EjectOnGround))
|
||||||
|
return;
|
||||||
|
|
||||||
var pilot = self.World.CreateActor(false, info.PilotActor.ToLowerInvariant(),
|
var pilot = self.World.CreateActor(false, info.PilotActor.ToLowerInvariant(),
|
||||||
new TypeDictionary { new OwnerInit(self.Owner), new LocationInit(self.Location) });
|
new TypeDictionary { new OwnerInit(self.Owner), new LocationInit(self.Location) });
|
||||||
@@ -51,7 +55,12 @@ namespace OpenRA.Mods.RA
|
|||||||
Sound.Play(info.ChuteSound, cp);
|
Sound.Play(info.ChuteSound, cp);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
self.World.AddFrameEndTask(w => w.Add(pilot));
|
self.World.AddFrameEndTask(w => w.Add(pilot));
|
||||||
|
var pilotMobile = pilot.TraitOrDefault<Mobile>();
|
||||||
|
if (pilotMobile != null)
|
||||||
|
pilotMobile.Nudge(pilot, pilot, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
pilot.Destroy();
|
pilot.Destroy();
|
||||||
|
|||||||
Reference in New Issue
Block a user