Add an INotifyKilled interface, which is what most things that used INotifyDamaged actually cared about.

This commit is contained in:
Paul Chote
2011-04-16 10:58:35 +12:00
parent d9fc84b55e
commit 1c2574f4f4
22 changed files with 135 additions and 185 deletions

View File

@@ -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();
}

View File

@@ -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)

View File

@@ -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>()));
}
}

View File

@@ -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;