Add an INotifyKilled interface, which is what most things that used INotifyDamaged actually cared about.
This commit is contained in:
@@ -75,7 +75,7 @@ namespace OpenRA.Mods.RA.Air
|
||||
public virtual object Create( ActorInitializer init ) { return new Aircraft( init , this ); }
|
||||
}
|
||||
|
||||
public class Aircraft : IMove, IFacing, IOccupySpace, ISync, INotifyDamage
|
||||
public class Aircraft : IMove, IFacing, IOccupySpace, ISync, INotifyKilled
|
||||
{
|
||||
public IDisposable reservation;
|
||||
|
||||
@@ -88,10 +88,9 @@ namespace OpenRA.Mods.RA.Air
|
||||
}
|
||||
}
|
||||
|
||||
public void Damaged(Actor self, AttackInfo e)
|
||||
public void Killed(Actor self, AttackInfo e)
|
||||
{
|
||||
if (e.DamageState == DamageState.Dead)
|
||||
UnReserve();
|
||||
UnReserve();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -21,36 +21,27 @@ namespace OpenRA.Mods.RA
|
||||
public readonly string ChuteSound = "chute1.aud";
|
||||
}
|
||||
|
||||
public class EjectOnDeath : INotifyDamage
|
||||
public class EjectOnDeath : INotifyKilled
|
||||
{
|
||||
|
||||
public void Damaged(Actor self, AttackInfo e)
|
||||
public void Killed(Actor self, AttackInfo e)
|
||||
{
|
||||
if (self.IsDead())
|
||||
var info = self.Info.Traits.Get<EjectOnDeathInfo>();
|
||||
var pilot = self.World.CreateActor(false, info.PilotActor.ToLowerInvariant(), new TypeDictionary { new OwnerInit(self.Owner) });
|
||||
var r = self.World.SharedRandom.Next(1, 100);
|
||||
var aircraft = self.Trait<IMove>();
|
||||
|
||||
if (IsSuitableCell(pilot, self.Location) && r > 100 - info.SuccessRate && aircraft.Altitude > 10)
|
||||
{
|
||||
var a = self;
|
||||
var info = self.Info.Traits.Get<EjectOnDeathInfo>();
|
||||
var pilot = a.World.CreateActor(false, info.PilotActor.ToLowerInvariant(), new TypeDictionary { new OwnerInit(a.Owner) });
|
||||
var r = self.World.SharedRandom.Next(1, 100);
|
||||
var aircraft = a.Trait<IMove>();
|
||||
var rs = pilot.Trait<RenderSimple>();
|
||||
self.World.AddFrameEndTask(w => w.Add(
|
||||
new Parachute(pilot.Owner, rs.anim.Name,
|
||||
Util.CenterOfCell(Util.CellContaining(self.CenterLocation)),
|
||||
aircraft.Altitude, pilot)));
|
||||
|
||||
if (IsSuitableCell(pilot, a.Location) && r > 100 - info.SuccessRate && aircraft.Altitude > 10)
|
||||
{
|
||||
var rs = pilot.Trait<RenderSimple>();
|
||||
|
||||
|
||||
a.World.AddFrameEndTask(w => w.Add(
|
||||
new Parachute(pilot.Owner, rs.anim.Name,
|
||||
Util.CenterOfCell(Util.CellContaining(a.CenterLocation)),
|
||||
aircraft.Altitude, pilot)));
|
||||
|
||||
Sound.Play(info.ChuteSound, a.CenterLocation);
|
||||
}
|
||||
else
|
||||
{
|
||||
pilot.Destroy();
|
||||
}
|
||||
Sound.Play(info.ChuteSound, self.CenterLocation);
|
||||
}
|
||||
else
|
||||
pilot.Destroy();
|
||||
}
|
||||
|
||||
bool IsSuitableCell(Actor actorToDrop, int2 p)
|
||||
|
||||
@@ -23,17 +23,14 @@ namespace OpenRA.Mods.RA.Air
|
||||
public readonly bool Moves = false;
|
||||
}
|
||||
|
||||
class FallsToEarth : INotifyDamage
|
||||
class FallsToEarth : INotifyKilled
|
||||
{
|
||||
public void Damaged(Actor self, AttackInfo e)
|
||||
public void Killed(Actor self, AttackInfo e)
|
||||
{
|
||||
if (self.IsDead())
|
||||
{
|
||||
self.Trait<Health>().RemoveOnDeath = false;
|
||||
self.Trait<Health>().RemoveOnDeath = false;
|
||||
|
||||
self.CancelActivity();
|
||||
self.QueueActivity(new FallToEarth(self, self.Info.Traits.Get<FallsToEarthInfo>()));
|
||||
}
|
||||
self.CancelActivity();
|
||||
self.QueueActivity(new FallToEarth(self, self.Info.Traits.Get<FallsToEarthInfo>()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace OpenRA.Mods.RA.Air
|
||||
public override object Create( ActorInitializer init ) { return new Plane( init, this ); }
|
||||
}
|
||||
|
||||
public class Plane : Aircraft, IIssueOrder, IResolveOrder, IOrderVoice, ITick, INotifyDamage, ISync
|
||||
public class Plane : Aircraft, IIssueOrder, IResolveOrder, IOrderVoice, ITick, ISync
|
||||
{
|
||||
[Sync]
|
||||
public int2 RTBPathHash;
|
||||
|
||||
Reference in New Issue
Block a user