Add an INotifyKilled interface, which is what most things that used INotifyDamaged actually cared about.
This commit is contained in:
@@ -108,6 +108,10 @@ namespace OpenRA.Traits
|
||||
attacker.Owner.Kills++;
|
||||
self.Owner.Deaths++;
|
||||
|
||||
foreach (var nd in self.TraitsImplementing<INotifyKilled>()
|
||||
.Concat(self.Owner.PlayerActor.TraitsImplementing<INotifyKilled>()))
|
||||
nd.Killed(self, ai);
|
||||
|
||||
if( RemoveOnDeath )
|
||||
self.Destroy();
|
||||
|
||||
|
||||
@@ -57,6 +57,7 @@ namespace OpenRA.Traits
|
||||
public interface IOrderVoice { string VoicePhraseForOrder(Actor self, Order order); }
|
||||
public interface INotifySold { void Selling(Actor self); void Sold(Actor self); }
|
||||
public interface INotifyDamage { void Damaged(Actor self, AttackInfo e); }
|
||||
public interface INotifyKilled { void Killed(Actor self, AttackInfo e); }
|
||||
public interface INotifyAppliedDamage { void AppliedDamage(Actor self, Actor damaged, AttackInfo e); }
|
||||
public interface INotifyBuildComplete { void BuildingComplete(Actor self); }
|
||||
public interface INotifyProduction { void UnitProduced(Actor self, Actor other, int2 exit); }
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace OpenRA.Mods.Cnc
|
||||
public object Create(ActorInitializer init) { return new DeadBuildingState(init.self, this); }
|
||||
}
|
||||
|
||||
class DeadBuildingState : INotifyDamage
|
||||
class DeadBuildingState : INotifyKilled
|
||||
{
|
||||
DeadBuildingStateInfo info;
|
||||
RenderSimple rs;
|
||||
@@ -31,9 +31,7 @@ namespace OpenRA.Mods.Cnc
|
||||
self.Trait<Health>().RemoveOnDeath = !rs.anim.HasSequence("dead");
|
||||
}
|
||||
|
||||
public void Damaged(Actor self, AttackInfo e)
|
||||
{
|
||||
if (e.DamageStateChanged && e.DamageState == DamageState.Dead)
|
||||
public void Killed(Actor self, AttackInfo e)
|
||||
{
|
||||
if (!rs.anim.HasSequence("dead")) return;
|
||||
rs.anim.PlayRepeating("dead");
|
||||
@@ -45,4 +43,3 @@ namespace OpenRA.Mods.Cnc
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace OpenRA.Mods.Cnc
|
||||
public object Create(ActorInitializer init) { return new SpawnViceroid(this); }
|
||||
}
|
||||
|
||||
class SpawnViceroid : INotifyDamage
|
||||
class SpawnViceroid : INotifyKilled
|
||||
{
|
||||
readonly SpawnViceroidInfo Info;
|
||||
|
||||
@@ -34,9 +34,9 @@ namespace OpenRA.Mods.Cnc
|
||||
Info = info;
|
||||
}
|
||||
|
||||
public void Damaged(Actor self, AttackInfo e)
|
||||
public void Killed(Actor self, AttackInfo e)
|
||||
{
|
||||
if (e.DamageState == DamageState.Dead && e.Warhead != null && e.Warhead.InfDeath == Info.InfDeath
|
||||
if (e.Warhead != null && e.Warhead.InfDeath == Info.InfDeath
|
||||
&& self.World.SharedRandom.Next(100) <= Info.Probability)
|
||||
self.World.AddFrameEndTask(w =>
|
||||
{
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace OpenRA.Mods.RA
|
||||
public object Create(ActorInitializer init) { return new ActorLostNotification(this); }
|
||||
}
|
||||
|
||||
class ActorLostNotification : INotifyDamage
|
||||
class ActorLostNotification : INotifyKilled
|
||||
{
|
||||
ActorLostNotificationInfo Info;
|
||||
public ActorLostNotification(ActorLostNotificationInfo info)
|
||||
@@ -28,15 +28,11 @@ namespace OpenRA.Mods.RA
|
||||
Info = info;
|
||||
}
|
||||
|
||||
public void Damaged(Actor self, AttackInfo e)
|
||||
{
|
||||
if (e.DamageState == DamageState.Dead)
|
||||
public void Killed(Actor self, AttackInfo e)
|
||||
{
|
||||
var player = (Info.NotifyAll) ? self.World.LocalPlayer : self.Owner;
|
||||
Sound.PlayToPlayer(player, Info.Notification);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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,9 +88,8 @@ 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();
|
||||
}
|
||||
|
||||
|
||||
@@ -21,37 +21,28 @@ 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 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 pilot = self.World.CreateActor(false, info.PilotActor.ToLowerInvariant(), new TypeDictionary { new OwnerInit(self.Owner) });
|
||||
var r = self.World.SharedRandom.Next(1, 100);
|
||||
var aircraft = a.Trait<IMove>();
|
||||
var aircraft = self.Trait<IMove>();
|
||||
|
||||
if (IsSuitableCell(pilot, a.Location) && r > 100 - info.SuccessRate && aircraft.Altitude > 10)
|
||||
if (IsSuitableCell(pilot, self.Location) && r > 100 - info.SuccessRate && aircraft.Altitude > 10)
|
||||
{
|
||||
var rs = pilot.Trait<RenderSimple>();
|
||||
|
||||
|
||||
a.World.AddFrameEndTask(w => w.Add(
|
||||
self.World.AddFrameEndTask(w => w.Add(
|
||||
new Parachute(pilot.Owner, rs.anim.Name,
|
||||
Util.CenterOfCell(Util.CellContaining(a.CenterLocation)),
|
||||
Util.CenterOfCell(Util.CellContaining(self.CenterLocation)),
|
||||
aircraft.Altitude, pilot)));
|
||||
|
||||
Sound.Play(info.ChuteSound, a.CenterLocation);
|
||||
Sound.Play(info.ChuteSound, self.CenterLocation);
|
||||
}
|
||||
else
|
||||
{
|
||||
pilot.Destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool IsSuitableCell(Actor actorToDrop, int2 p)
|
||||
{
|
||||
|
||||
@@ -23,11 +23,9 @@ namespace OpenRA.Mods.RA.Air
|
||||
public readonly bool Moves = false;
|
||||
}
|
||||
|
||||
class FallsToEarth : INotifyDamage
|
||||
class FallsToEarth : INotifyKilled
|
||||
{
|
||||
public void Damaged(Actor self, AttackInfo e)
|
||||
{
|
||||
if (self.IsDead())
|
||||
public void Killed(Actor self, AttackInfo e)
|
||||
{
|
||||
self.Trait<Health>().RemoveOnDeath = false;
|
||||
|
||||
@@ -35,7 +33,6 @@ namespace OpenRA.Mods.RA.Air
|
||||
self.QueueActivity(new FallToEarth(self, self.Info.Traits.Get<FallsToEarthInfo>()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class FallToEarth : CancelableActivity
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace OpenRA.Mods.RA.Buildings
|
||||
public object Create(ActorInitializer init) { return new ShakeOnDeath(this); }
|
||||
}
|
||||
|
||||
public class ShakeOnDeath : INotifyDamage
|
||||
public class ShakeOnDeath : INotifyKilled
|
||||
{
|
||||
readonly ShakeOnDeathInfo Info;
|
||||
public ShakeOnDeath(ShakeOnDeathInfo info)
|
||||
@@ -29,9 +29,8 @@ namespace OpenRA.Mods.RA.Buildings
|
||||
this.Info = info;
|
||||
}
|
||||
|
||||
public void Damaged(Actor self, AttackInfo e)
|
||||
public void Killed(Actor self, AttackInfo e)
|
||||
{
|
||||
if (e.DamageState == DamageState.Dead)
|
||||
self.World.WorldActor.Trait<ScreenShaker>().AddEffect(Info.Intensity, self.CenterLocation, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace OpenRA.Mods.RA
|
||||
public object Create( ActorInitializer init ) { return new Cargo( init.self ); }
|
||||
}
|
||||
|
||||
public class Cargo : IPips, IIssueOrder, IResolveOrder, IOrderVoice, INotifyDamage
|
||||
public class Cargo : IPips, IIssueOrder, IResolveOrder, IOrderVoice, INotifyKilled
|
||||
{
|
||||
readonly Actor self;
|
||||
List<Actor> cargo = new List<Actor>();
|
||||
@@ -145,9 +145,7 @@ namespace OpenRA.Mods.RA
|
||||
cargo.Add(a);
|
||||
}
|
||||
|
||||
public void Damaged(Actor self, AttackInfo e)
|
||||
{
|
||||
if( e.DamageStateChanged && e.DamageState == DamageState.Dead )
|
||||
public void Killed(Actor self, AttackInfo e)
|
||||
{
|
||||
foreach( var c in cargo )
|
||||
c.Destroy();
|
||||
@@ -155,4 +153,3 @@ namespace OpenRA.Mods.RA
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace OpenRA.Mods.RA
|
||||
{
|
||||
class DemoTruckInfo : TraitInfo<DemoTruck> { }
|
||||
|
||||
class DemoTruck : Chronoshiftable, INotifyDamage
|
||||
class DemoTruck : Chronoshiftable, INotifyKilled
|
||||
{
|
||||
// Explode on chronoshift
|
||||
public override bool Teleport(Actor self, int2 targetLocation, int duration, bool killCargo, Actor chronosphere)
|
||||
@@ -24,9 +24,8 @@ namespace OpenRA.Mods.RA
|
||||
}
|
||||
|
||||
// Fire primary on death
|
||||
public void Damaged(Actor self, AttackInfo e)
|
||||
public void Killed(Actor self, AttackInfo e)
|
||||
{
|
||||
if (e.DamageState == DamageState.Dead)
|
||||
Detonate(self, e.Attacker);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace OpenRA.Mods.RA
|
||||
public readonly string[] ActorTypes = { "e1" };
|
||||
}
|
||||
|
||||
class EmitInfantryOnSell : INotifySold, INotifyDamage
|
||||
class EmitInfantryOnSell : INotifySold, INotifyKilled
|
||||
{
|
||||
public void Selling(Actor self) { }
|
||||
|
||||
@@ -62,9 +62,8 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
public void Sold(Actor self) { Emit(self); }
|
||||
|
||||
public void Damaged(Actor self, AttackInfo e)
|
||||
public void Killed(Actor self, AttackInfo e)
|
||||
{
|
||||
if (e.DamageStateChanged && e.DamageState == DamageState.Dead)
|
||||
Emit(self);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,11 +23,9 @@ namespace OpenRA.Mods.RA
|
||||
public readonly int Chance = 100;
|
||||
}
|
||||
|
||||
class Explodes : INotifyDamage
|
||||
class Explodes : INotifyKilled
|
||||
{
|
||||
public void Damaged(Actor self, AttackInfo e)
|
||||
{
|
||||
if (e.DamageState == DamageState.Dead)
|
||||
public void Killed(Actor self, AttackInfo e)
|
||||
{
|
||||
if (self.World.SharedRandom.Next(100) > self.Info.Traits.Get<ExplodesInfo>().Chance)
|
||||
return;
|
||||
@@ -40,7 +38,6 @@ namespace OpenRA.Mods.RA
|
||||
Combat.DoExplosion(e.Attacker, weapon, self.CenterLocation, altitude);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
string ChooseWeaponForExplosion(Actor self)
|
||||
{
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace OpenRA.Mods.RA
|
||||
public readonly int LevelMod = 125;
|
||||
}
|
||||
|
||||
class GivesBounty : INotifyDamage
|
||||
class GivesBounty : INotifyKilled
|
||||
{
|
||||
|
||||
int GetMultiplier(Actor self)
|
||||
@@ -34,9 +34,7 @@ namespace OpenRA.Mods.RA
|
||||
return (slevel > 0) ? slevel * info.LevelMod : 100;
|
||||
}
|
||||
|
||||
public void Damaged(Actor self, AttackInfo e)
|
||||
{
|
||||
if (e.DamageState == DamageState.Dead)
|
||||
public void Killed(Actor self, AttackInfo e)
|
||||
{
|
||||
var info = self.Info.Traits.Get<GivesBountyInfo>();
|
||||
// Prevent TK from giving Bounty
|
||||
@@ -46,14 +44,12 @@ namespace OpenRA.Mods.RA
|
||||
var valued = self.Info.Traits.GetOrDefault<ValuedInfo>();
|
||||
var cost = valued != null ? valued.Cost : 0;
|
||||
// 2 hundreds because of GetMultiplier and info.Percentage.
|
||||
var bounty = (int)(cost * GetMultiplier(self) * info.Percentage / 10000);
|
||||
var bounty = cost * GetMultiplier(self) * info.Percentage / 10000;
|
||||
|
||||
if (e.Attacker.World.LocalPlayer != null && e.Attacker.Owner.Stances[e.Attacker.World.LocalPlayer] == Stance.Ally)
|
||||
e.Attacker.World.AddFrameEndTask(w => w.Add(new CashTick(bounty, 20, 1, self.CenterLocation, e.Attacker.Owner.ColorRamp.GetColor(0))));
|
||||
|
||||
e.Attacker.Owner.PlayerActor.Trait<PlayerResources>().GiveCash(bounty);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,11 +14,9 @@ namespace OpenRA.Mods.RA
|
||||
{
|
||||
class GivesExperienceInfo : TraitInfo<GivesExperience> { public readonly int Experience = -1; }
|
||||
|
||||
class GivesExperience : INotifyDamage
|
||||
class GivesExperience : INotifyKilled
|
||||
{
|
||||
public void Damaged(Actor self, AttackInfo e)
|
||||
{
|
||||
if (e.DamageState == DamageState.Dead)
|
||||
public void Killed(Actor self, AttackInfo e)
|
||||
{
|
||||
// Prevent TK from giving exp
|
||||
if (e.Attacker == null || e.Attacker.Destroyed || e.Attacker.Owner.Stances[ self.Owner ] == Stance.Ally )
|
||||
@@ -37,4 +35,3 @@ namespace OpenRA.Mods.RA
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,11 +19,10 @@ namespace OpenRA.Mods.RA
|
||||
public readonly string HuskActor = null;
|
||||
}
|
||||
|
||||
class LeavesHusk : INotifyDamage
|
||||
class LeavesHusk : INotifyKilled
|
||||
{
|
||||
public void Damaged(Actor self, AttackInfo e)
|
||||
public void Killed(Actor self, AttackInfo e)
|
||||
{
|
||||
if (e.DamageState == DamageState.Dead)
|
||||
self.World.AddFrameEndTask(w =>
|
||||
{
|
||||
var info = self.Info.Traits.Get<LeavesHuskInfo>();
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace OpenRA.Mods.RA
|
||||
public virtual object Create(ActorInitializer init) { return new OreRefinery(init.self, this); }
|
||||
}
|
||||
|
||||
public class OreRefinery : ITick, IAcceptOre, INotifyDamage, INotifySold, INotifyCapture, IExplodeModifier, ISync
|
||||
public class OreRefinery : ITick, IAcceptOre, INotifyKilled, INotifySold, INotifyCapture, IExplodeModifier, ISync
|
||||
{
|
||||
readonly Actor self;
|
||||
readonly OreRefineryInfo Info;
|
||||
@@ -110,15 +110,12 @@ namespace OpenRA.Mods.RA
|
||||
}
|
||||
}
|
||||
|
||||
public void Damaged (Actor self, AttackInfo e)
|
||||
{
|
||||
if (e.DamageState == DamageState.Dead)
|
||||
public void Killed (Actor self, AttackInfo e)
|
||||
{
|
||||
CancelDock(self);
|
||||
foreach (var harv in GetLinkedHarvesters())
|
||||
harv.Trait.UnlinkProc(harv.Actor, self);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnDock (Actor harv, DeliverResources dockOrder)
|
||||
{
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace OpenRA.Mods.RA.Render
|
||||
public override object Create(ActorInitializer init) { return new RenderInfantry(init.self, this); }
|
||||
}
|
||||
|
||||
public class RenderInfantry : RenderSimple, INotifyAttack, INotifyDamage, INotifyIdle
|
||||
public class RenderInfantry : RenderSimple, INotifyAttack, INotifyKilled, INotifyIdle
|
||||
{
|
||||
public enum AnimationState
|
||||
{
|
||||
@@ -117,9 +117,7 @@ namespace OpenRA.Mods.RA.Render
|
||||
}
|
||||
}
|
||||
|
||||
public void Damaged(Actor self, AttackInfo e)
|
||||
{
|
||||
if (e.DamageState == DamageState.Dead)
|
||||
public void Killed(Actor self, AttackInfo e)
|
||||
{
|
||||
var death = e.Warhead != null ? e.Warhead.InfDeath : 0;
|
||||
Sound.PlayVoice("Die", self, self.Owner.Country.Race);
|
||||
@@ -127,4 +125,3 @@ namespace OpenRA.Mods.RA.Render
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace OpenRA.Mods.RA
|
||||
{
|
||||
class ReservableInfo : TraitInfo<Reservable> {}
|
||||
|
||||
public class Reservable : ITick, INotifyDamage, INotifyCapture, INotifySold
|
||||
public class Reservable : ITick, INotifyKilled, INotifyCapture, INotifySold
|
||||
{
|
||||
Actor reservedFor;
|
||||
Aircraft herp;
|
||||
@@ -52,9 +52,9 @@ namespace OpenRA.Mods.RA
|
||||
return res != null && res.reservedFor != null;
|
||||
}
|
||||
|
||||
public void Damaged(Actor self, AttackInfo e)
|
||||
public void Killed(Actor self, AttackInfo e)
|
||||
{
|
||||
if (herp != null && e.DamageStateChanged && e.DamageState == DamageState.Dead)
|
||||
if (herp != null)
|
||||
herp.UnReserve();
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace OpenRA.Mods.RA
|
||||
public object Create(ActorInitializer init) { return new StoresOre(init.self, this); }
|
||||
}
|
||||
|
||||
class StoresOre : IPips, INotifyCapture, INotifyDamage, IExplodeModifier, IStoreOre, ISync
|
||||
class StoresOre : IPips, INotifyCapture, INotifyKilled, IExplodeModifier, IStoreOre, ISync
|
||||
{
|
||||
readonly StoresOreInfo Info;
|
||||
|
||||
@@ -45,9 +45,8 @@ namespace OpenRA.Mods.RA
|
||||
Player.GiveOre(ore);
|
||||
}
|
||||
|
||||
public void Damaged(Actor self, AttackInfo e)
|
||||
public void Killed(Actor self, AttackInfo e)
|
||||
{
|
||||
if (self.IsDead())
|
||||
Player.TakeOre(Stored); // Lose the stored ore
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace OpenRA.Mods.RA
|
||||
public override object Create(ActorInitializer init) { return new GpsPower(init.self, this); }
|
||||
}
|
||||
|
||||
class GpsPower : SupportPower, INotifyDamage, ISync, INotifyStanceChanged, INotifySold
|
||||
class GpsPower : SupportPower, INotifyKilled, ISync, INotifyStanceChanged, INotifySold
|
||||
{
|
||||
public GpsPower(Actor self, GpsPowerInfo info) : base(self, info) { }
|
||||
|
||||
@@ -48,20 +48,9 @@ namespace OpenRA.Mods.RA
|
||||
});
|
||||
}
|
||||
|
||||
public void Selling(Actor self)
|
||||
{
|
||||
DisableGps();
|
||||
}
|
||||
|
||||
public void Selling(Actor self) { DisableGps(); }
|
||||
public void Sold(Actor self) { }
|
||||
|
||||
public void Damaged(Actor self, AttackInfo e)
|
||||
{
|
||||
if (e.DamageState == DamageState.Dead)
|
||||
{
|
||||
DisableGps();
|
||||
}
|
||||
}
|
||||
public void Killed(Actor self, AttackInfo e) { DisableGps(); }
|
||||
|
||||
void DisableGps()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user