From 1c2574f4f4d0a1e7990ccf8ce359ef7dbc483602 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sat, 16 Apr 2011 10:58:35 +1200 Subject: [PATCH] Add an INotifyKilled interface, which is what most things that used INotifyDamaged actually cared about. --- OpenRA.Game/Traits/Health.cs | 6 +++- OpenRA.Game/Traits/TraitsInterfaces.cs | 1 + OpenRA.Mods.Cnc/DeadBuildingState.cs | 21 ++++++------ OpenRA.Mods.Cnc/SpawnViceroid.cs | 6 ++-- OpenRA.Mods.RA/ActorLostNotification.cs | 12 +++---- OpenRA.Mods.RA/Air/Aircraft.cs | 7 ++-- OpenRA.Mods.RA/Air/EjectOnDeath.cs | 41 +++++++++--------------- OpenRA.Mods.RA/Air/FallsToEarth.cs | 13 +++----- OpenRA.Mods.RA/Air/Plane.cs | 2 +- OpenRA.Mods.RA/Buildings/ShakeOnDeath.cs | 7 ++-- OpenRA.Mods.RA/Cargo.cs | 13 +++----- OpenRA.Mods.RA/DemoTruck.cs | 7 ++-- OpenRA.Mods.RA/EmitInfantryOnSell.cs | 7 ++-- OpenRA.Mods.RA/Explodes.cs | 23 ++++++------- OpenRA.Mods.RA/GivesBounty.cs | 30 ++++++++--------- OpenRA.Mods.RA/GivesExperience.cs | 29 ++++++++--------- OpenRA.Mods.RA/LeavesHusk.cs | 39 +++++++++++----------- OpenRA.Mods.RA/OreRefinery.cs | 13 +++----- OpenRA.Mods.RA/Render/RenderInfantry.cs | 13 +++----- OpenRA.Mods.RA/Reservable.cs | 6 ++-- OpenRA.Mods.RA/StoresOre.cs | 7 ++-- OpenRA.Mods.RA/SupportPowers/GpsPower.cs | 17 ++-------- 22 files changed, 135 insertions(+), 185 deletions(-) diff --git a/OpenRA.Game/Traits/Health.cs b/OpenRA.Game/Traits/Health.cs index 19e565f3f7..8a081c79ee 100755 --- a/OpenRA.Game/Traits/Health.cs +++ b/OpenRA.Game/Traits/Health.cs @@ -107,7 +107,11 @@ namespace OpenRA.Traits { attacker.Owner.Kills++; self.Owner.Deaths++; - + + foreach (var nd in self.TraitsImplementing() + .Concat(self.Owner.PlayerActor.TraitsImplementing())) + nd.Killed(self, ai); + if( RemoveOnDeath ) self.Destroy(); diff --git a/OpenRA.Game/Traits/TraitsInterfaces.cs b/OpenRA.Game/Traits/TraitsInterfaces.cs index 1f19d67cc7..f58595045e 100755 --- a/OpenRA.Game/Traits/TraitsInterfaces.cs +++ b/OpenRA.Game/Traits/TraitsInterfaces.cs @@ -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); } diff --git a/OpenRA.Mods.Cnc/DeadBuildingState.cs b/OpenRA.Mods.Cnc/DeadBuildingState.cs index 74521d6942..5f8fa0ae50 100644 --- a/OpenRA.Mods.Cnc/DeadBuildingState.cs +++ b/OpenRA.Mods.Cnc/DeadBuildingState.cs @@ -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,18 +31,15 @@ namespace OpenRA.Mods.Cnc self.Trait().RemoveOnDeath = !rs.anim.HasSequence("dead"); } - public void Damaged(Actor self, AttackInfo e) + public void Killed(Actor self, AttackInfo e) { - if (e.DamageStateChanged && e.DamageState == DamageState.Dead) - { - if (!rs.anim.HasSequence("dead")) return; - rs.anim.PlayRepeating("dead"); - if (!info.Zombie) - self.World.AddFrameEndTask( - w => w.Add( - new DelayedAction(info.LingerTime, - () => self.Destroy()))); - } + if (!rs.anim.HasSequence("dead")) return; + rs.anim.PlayRepeating("dead"); + if (!info.Zombie) + self.World.AddFrameEndTask( + w => w.Add( + new DelayedAction(info.LingerTime, + () => self.Destroy()))); } } } diff --git a/OpenRA.Mods.Cnc/SpawnViceroid.cs b/OpenRA.Mods.Cnc/SpawnViceroid.cs index 98baf9c790..0fb144f5b3 100644 --- a/OpenRA.Mods.Cnc/SpawnViceroid.cs +++ b/OpenRA.Mods.Cnc/SpawnViceroid.cs @@ -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 => { diff --git a/OpenRA.Mods.RA/ActorLostNotification.cs b/OpenRA.Mods.RA/ActorLostNotification.cs index 76ad520b39..ef2bfe6275 100644 --- a/OpenRA.Mods.RA/ActorLostNotification.cs +++ b/OpenRA.Mods.RA/ActorLostNotification.cs @@ -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) + public void Killed(Actor self, AttackInfo e) { - if (e.DamageState == DamageState.Dead) - { - var player = (Info.NotifyAll) ? self.World.LocalPlayer : self.Owner; - Sound.PlayToPlayer(player, Info.Notification); - } + var player = (Info.NotifyAll) ? self.World.LocalPlayer : self.Owner; + Sound.PlayToPlayer(player, Info.Notification); } - } } diff --git a/OpenRA.Mods.RA/Air/Aircraft.cs b/OpenRA.Mods.RA/Air/Aircraft.cs index 99ca5e06cf..806f1e3a42 100755 --- a/OpenRA.Mods.RA/Air/Aircraft.cs +++ b/OpenRA.Mods.RA/Air/Aircraft.cs @@ -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(); } diff --git a/OpenRA.Mods.RA/Air/EjectOnDeath.cs b/OpenRA.Mods.RA/Air/EjectOnDeath.cs index 76ca9837f5..fb52a15e78 100644 --- a/OpenRA.Mods.RA/Air/EjectOnDeath.cs +++ b/OpenRA.Mods.RA/Air/EjectOnDeath.cs @@ -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(); + 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(); + + if (IsSuitableCell(pilot, self.Location) && r > 100 - info.SuccessRate && aircraft.Altitude > 10) { - var a = self; - var info = self.Info.Traits.Get(); - 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(); + var rs = pilot.Trait(); + 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(); - - - 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) diff --git a/OpenRA.Mods.RA/Air/FallsToEarth.cs b/OpenRA.Mods.RA/Air/FallsToEarth.cs index a92029a418..7cca25263c 100755 --- a/OpenRA.Mods.RA/Air/FallsToEarth.cs +++ b/OpenRA.Mods.RA/Air/FallsToEarth.cs @@ -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().RemoveOnDeath = false; + self.Trait().RemoveOnDeath = false; - self.CancelActivity(); - self.QueueActivity(new FallToEarth(self, self.Info.Traits.Get())); - } + self.CancelActivity(); + self.QueueActivity(new FallToEarth(self, self.Info.Traits.Get())); } } diff --git a/OpenRA.Mods.RA/Air/Plane.cs b/OpenRA.Mods.RA/Air/Plane.cs index 5e39bad8cb..627a9c79ff 100755 --- a/OpenRA.Mods.RA/Air/Plane.cs +++ b/OpenRA.Mods.RA/Air/Plane.cs @@ -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; diff --git a/OpenRA.Mods.RA/Buildings/ShakeOnDeath.cs b/OpenRA.Mods.RA/Buildings/ShakeOnDeath.cs index 3c32c1e194..b7816442b6 100644 --- a/OpenRA.Mods.RA/Buildings/ShakeOnDeath.cs +++ b/OpenRA.Mods.RA/Buildings/ShakeOnDeath.cs @@ -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,10 +29,9 @@ 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().AddEffect(Info.Intensity, self.CenterLocation, 1); + self.World.WorldActor.Trait().AddEffect(Info.Intensity, self.CenterLocation, 1); } } } diff --git a/OpenRA.Mods.RA/Cargo.cs b/OpenRA.Mods.RA/Cargo.cs index 4121fe820a..1f93c31a63 100644 --- a/OpenRA.Mods.RA/Cargo.cs +++ b/OpenRA.Mods.RA/Cargo.cs @@ -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 cargo = new List(); @@ -145,14 +145,11 @@ namespace OpenRA.Mods.RA cargo.Add(a); } - public void Damaged(Actor self, AttackInfo e) + public void Killed(Actor self, AttackInfo e) { - if( e.DamageStateChanged && e.DamageState == DamageState.Dead ) - { - foreach( var c in cargo ) - c.Destroy(); - cargo.Clear(); - } + foreach( var c in cargo ) + c.Destroy(); + cargo.Clear(); } } } diff --git a/OpenRA.Mods.RA/DemoTruck.cs b/OpenRA.Mods.RA/DemoTruck.cs index 000c934124..aff206a862 100644 --- a/OpenRA.Mods.RA/DemoTruck.cs +++ b/OpenRA.Mods.RA/DemoTruck.cs @@ -14,7 +14,7 @@ namespace OpenRA.Mods.RA { class DemoTruckInfo : TraitInfo { } - 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,10 +24,9 @@ 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); + Detonate(self, e.Attacker); } public void Detonate(Actor self, Actor detonatedBy) diff --git a/OpenRA.Mods.RA/EmitInfantryOnSell.cs b/OpenRA.Mods.RA/EmitInfantryOnSell.cs index 24f0e12c63..ce8497cefe 100644 --- a/OpenRA.Mods.RA/EmitInfantryOnSell.cs +++ b/OpenRA.Mods.RA/EmitInfantryOnSell.cs @@ -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,10 +62,9 @@ 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); + Emit(self); } } } diff --git a/OpenRA.Mods.RA/Explodes.cs b/OpenRA.Mods.RA/Explodes.cs index d3e3be9e11..47a1914d0b 100644 --- a/OpenRA.Mods.RA/Explodes.cs +++ b/OpenRA.Mods.RA/Explodes.cs @@ -23,22 +23,19 @@ namespace OpenRA.Mods.RA public readonly int Chance = 100; } - class Explodes : INotifyDamage + class Explodes : INotifyKilled { - public void Damaged(Actor self, AttackInfo e) + public void Killed(Actor self, AttackInfo e) { - if (e.DamageState == DamageState.Dead) - { - if (self.World.SharedRandom.Next(100) > self.Info.Traits.Get().Chance) - return; + if (self.World.SharedRandom.Next(100) > self.Info.Traits.Get().Chance) + return; - var weapon = ChooseWeaponForExplosion(self); - if (weapon != null) - { - var move = self.TraitOrDefault(); - var altitude = move != null ? move.Altitude : 0; - Combat.DoExplosion(e.Attacker, weapon, self.CenterLocation, altitude); - } + var weapon = ChooseWeaponForExplosion(self); + if (weapon != null) + { + var move = self.TraitOrDefault(); + var altitude = move != null ? move.Altitude : 0; + Combat.DoExplosion(e.Attacker, weapon, self.CenterLocation, altitude); } } diff --git a/OpenRA.Mods.RA/GivesBounty.cs b/OpenRA.Mods.RA/GivesBounty.cs index 42e59da3b5..31330b6b39 100644 --- a/OpenRA.Mods.RA/GivesBounty.cs +++ b/OpenRA.Mods.RA/GivesBounty.cs @@ -19,7 +19,7 @@ namespace OpenRA.Mods.RA public readonly int LevelMod = 125; } - class GivesBounty : INotifyDamage + class GivesBounty : INotifyKilled { int GetMultiplier(Actor self) @@ -34,26 +34,22 @@ namespace OpenRA.Mods.RA return (slevel > 0) ? slevel * info.LevelMod : 100; } - public void Damaged(Actor self, AttackInfo e) + public void Killed(Actor self, AttackInfo e) { - if (e.DamageState == DamageState.Dead) - { - var info = self.Info.Traits.Get(); - // Prevent TK from giving Bounty - if (e.Attacker == null || e.Attacker.Destroyed || e.Attacker.Owner.Stances[self.Owner] == Stance.Ally) - return; + var info = self.Info.Traits.Get(); + // Prevent TK from giving Bounty + if (e.Attacker == null || e.Attacker.Destroyed || e.Attacker.Owner.Stances[self.Owner] == Stance.Ally) + return; - var valued = self.Info.Traits.GetOrDefault(); - 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 valued = self.Info.Traits.GetOrDefault(); + var cost = valued != null ? valued.Cost : 0; + // 2 hundreds because of GetMultiplier and info.Percentage. + 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)))); + 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().GiveCash(bounty); - - } + e.Attacker.Owner.PlayerActor.Trait().GiveCash(bounty); } } diff --git a/OpenRA.Mods.RA/GivesExperience.cs b/OpenRA.Mods.RA/GivesExperience.cs index e6081056a5..570870b24e 100644 --- a/OpenRA.Mods.RA/GivesExperience.cs +++ b/OpenRA.Mods.RA/GivesExperience.cs @@ -14,27 +14,24 @@ namespace OpenRA.Mods.RA { class GivesExperienceInfo : TraitInfo { public readonly int Experience = -1; } - class GivesExperience : INotifyDamage + class GivesExperience : INotifyKilled { - public void Damaged(Actor self, AttackInfo e) + public void Killed(Actor self, AttackInfo e) { - if (e.DamageState == DamageState.Dead) - { - // Prevent TK from giving exp - if (e.Attacker == null || e.Attacker.Destroyed || e.Attacker.Owner.Stances[ self.Owner ] == Stance.Ally ) - return; + // Prevent TK from giving exp + if (e.Attacker == null || e.Attacker.Destroyed || e.Attacker.Owner.Stances[ self.Owner ] == Stance.Ally ) + return; - var info = self.Info.Traits.Get(); - var valued = self.Info.Traits.GetOrDefault(); + var info = self.Info.Traits.Get(); + var valued = self.Info.Traits.GetOrDefault(); - var exp = info.Experience >= 0 - ? info.Experience - : valued != null ? valued.Cost : 0; + var exp = info.Experience >= 0 + ? info.Experience + : valued != null ? valued.Cost : 0; - var killer = e.Attacker.TraitOrDefault(); - if (killer != null) - killer.GiveExperience(exp); - } + var killer = e.Attacker.TraitOrDefault(); + if (killer != null) + killer.GiveExperience(exp); } } } diff --git a/OpenRA.Mods.RA/LeavesHusk.cs b/OpenRA.Mods.RA/LeavesHusk.cs index 3bc608c243..621756c8cc 100644 --- a/OpenRA.Mods.RA/LeavesHusk.cs +++ b/OpenRA.Mods.RA/LeavesHusk.cs @@ -19,30 +19,29 @@ 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 => + self.World.AddFrameEndTask(w => + { + var info = self.Info.Traits.Get(); + var td = new TypeDictionary { - var info = self.Info.Traits.Get(); - var td = new TypeDictionary - { - new LocationInit( self.Location ), - new OwnerInit( self.Owner ), - new SkipMakeAnimsInit() - }; - - if (self.HasTrait()) - td.Add(new FacingInit( self.Trait().Facing )); + new LocationInit( self.Location ), + new OwnerInit( self.Owner ), + new SkipMakeAnimsInit() + }; + + if (self.HasTrait()) + td.Add(new FacingInit( self.Trait().Facing )); - var husk = w.CreateActor(info.HuskActor, td); - var turreted = self.TraitOrDefault(); - if (turreted != null) - foreach (var p in husk.TraitsImplementing()) - p.InitialFacing = turreted.turretFacing; - }); + var husk = w.CreateActor(info.HuskActor, td); + var turreted = self.TraitOrDefault(); + if (turreted != null) + foreach (var p in husk.TraitsImplementing()) + p.InitialFacing = turreted.turretFacing; + }); } } } diff --git a/OpenRA.Mods.RA/OreRefinery.cs b/OpenRA.Mods.RA/OreRefinery.cs index 029610457c..1aaf0366ad 100644 --- a/OpenRA.Mods.RA/OreRefinery.cs +++ b/OpenRA.Mods.RA/OreRefinery.cs @@ -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,14 +110,11 @@ namespace OpenRA.Mods.RA } } - public void Damaged (Actor self, AttackInfo e) + public void Killed (Actor self, AttackInfo e) { - if (e.DamageState == DamageState.Dead) - { - CancelDock(self); - foreach (var harv in GetLinkedHarvesters()) - harv.Trait.UnlinkProc(harv.Actor, self); - } + CancelDock(self); + foreach (var harv in GetLinkedHarvesters()) + harv.Trait.UnlinkProc(harv.Actor, self); } public void OnDock (Actor harv, DeliverResources dockOrder) diff --git a/OpenRA.Mods.RA/Render/RenderInfantry.cs b/OpenRA.Mods.RA/Render/RenderInfantry.cs index 1345b10bcf..d9397f1fa5 100644 --- a/OpenRA.Mods.RA/Render/RenderInfantry.cs +++ b/OpenRA.Mods.RA/Render/RenderInfantry.cs @@ -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,14 +117,11 @@ namespace OpenRA.Mods.RA.Render } } - public void Damaged(Actor self, AttackInfo e) + public void Killed(Actor self, AttackInfo e) { - if (e.DamageState == DamageState.Dead) - { - var death = e.Warhead != null ? e.Warhead.InfDeath : 0; - Sound.PlayVoice("Die", self, self.Owner.Country.Race); - self.World.AddFrameEndTask(w => w.Add(new Corpse(self, death))); - } + var death = e.Warhead != null ? e.Warhead.InfDeath : 0; + Sound.PlayVoice("Die", self, self.Owner.Country.Race); + self.World.AddFrameEndTask(w => w.Add(new Corpse(self, death))); } } } diff --git a/OpenRA.Mods.RA/Reservable.cs b/OpenRA.Mods.RA/Reservable.cs index 31cd57dcbd..daf86d50d1 100755 --- a/OpenRA.Mods.RA/Reservable.cs +++ b/OpenRA.Mods.RA/Reservable.cs @@ -16,7 +16,7 @@ namespace OpenRA.Mods.RA { class ReservableInfo : TraitInfo {} - 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(); } diff --git a/OpenRA.Mods.RA/StoresOre.cs b/OpenRA.Mods.RA/StoresOre.cs index ed5720302f..28d4fac516 100644 --- a/OpenRA.Mods.RA/StoresOre.cs +++ b/OpenRA.Mods.RA/StoresOre.cs @@ -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,10 +45,9 @@ 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 + Player.TakeOre(Stored); // Lose the stored ore } public IEnumerable GetPips(Actor self) diff --git a/OpenRA.Mods.RA/SupportPowers/GpsPower.cs b/OpenRA.Mods.RA/SupportPowers/GpsPower.cs index 95308724be..ee91c7dc4e 100755 --- a/OpenRA.Mods.RA/SupportPowers/GpsPower.cs +++ b/OpenRA.Mods.RA/SupportPowers/GpsPower.cs @@ -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() {