diff --git a/OpenRA.Game/Traits/Health.cs b/OpenRA.Game/Traits/Health.cs index a3af9c98fb..1954067d1c 100644 --- a/OpenRA.Game/Traits/Health.cs +++ b/OpenRA.Game/Traits/Health.cs @@ -140,6 +140,8 @@ namespace OpenRA.Traits { public static bool IsDead(this Actor self) { + if (self.Destroyed) return true; + var health = self.TraitOrDefault(); return (health == null) ? true : health.IsDead; } diff --git a/OpenRA.Game/Traits/Selectable.cs b/OpenRA.Game/Traits/Selectable.cs index 4beb6b42d8..f7a6d0be87 100644 --- a/OpenRA.Game/Traits/Selectable.cs +++ b/OpenRA.Game/Traits/Selectable.cs @@ -61,9 +61,10 @@ namespace OpenRA.Traits void DrawHealthBar(Actor self, float2 xy, float2 Xy) { + if (!self.IsInWorld) return; + var health = self.TraitOrDefault(); - if (self.IsDead() || health == null) - return; + if (health == null || health.IsDead) return; var c = Color.Gray; Game.Renderer.LineRenderer.DrawLine(xy + new float2(0, -2), xy + new float2(0, -4), c, c); diff --git a/OpenRA.Mods.Cnc/Missions/Gdi01Script.cs b/OpenRA.Mods.Cnc/Missions/Gdi01Script.cs index f59cd4a162..38df05e2e8 100644 --- a/OpenRA.Mods.Cnc/Missions/Gdi01Script.cs +++ b/OpenRA.Mods.Cnc/Missions/Gdi01Script.cs @@ -126,7 +126,7 @@ namespace OpenRA.Mods.RA } // GoodGuy win conditions // BadGuy is dead - int badcount = self.World.Queries.OwnedBy[Players["BadGuy"]].Count(a => a.IsInWorld && !a.IsDead()); + int badcount = self.World.Queries.OwnedBy[Players["BadGuy"]].Count(a => !a.IsDead()); if (badcount != lastBadCount) { Game.Debug("{0} badguys remain".F(badcount)); @@ -137,7 +137,7 @@ namespace OpenRA.Mods.RA } //GoodGuy lose conditions - if (self.World.Queries.OwnedBy[Players["GoodGuy"]].Count( a => a.IsInWorld && !a.IsDead()) == 0) + if (self.World.Queries.OwnedBy[Players["GoodGuy"]].Count( a => !a.IsDead()) == 0) OnLose(self.World); // GoodGuy reinforcements diff --git a/OpenRA.Mods.Cnc/ProductionAirdrop.cs b/OpenRA.Mods.Cnc/ProductionAirdrop.cs index efc2c2faa3..899ec0ef52 100644 --- a/OpenRA.Mods.Cnc/ProductionAirdrop.cs +++ b/OpenRA.Mods.Cnc/ProductionAirdrop.cs @@ -55,8 +55,9 @@ namespace OpenRA.Mods.Cnc a.QueueActivity(new Land(Target.FromActor(self))); a.QueueActivity(new CallFunc(() => { - if (self.IsDead()) + if (!self.IsInWorld || self.IsDead()) return; + rb.PlayCustomAnimRepeating(self, "idle"); self.World.AddFrameEndTask(ww => DoProduction(self, producee, exit)); })); diff --git a/OpenRA.Mods.RA/Activities/Infiltrate.cs b/OpenRA.Mods.RA/Activities/Infiltrate.cs index 2f1fceaf3f..7366af2a3a 100644 --- a/OpenRA.Mods.RA/Activities/Infiltrate.cs +++ b/OpenRA.Mods.RA/Activities/Infiltrate.cs @@ -20,7 +20,7 @@ namespace OpenRA.Mods.RA.Activities public override IActivity Tick(Actor self) { if (IsCanceled) return NextActivity; - if (target == null || target.IsDead()) return NextActivity; + if (target == null || !target.IsInWorld || target.IsDead()) return NextActivity; if (target.Owner == self.Owner) return NextActivity; foreach (var t in target.TraitsImplementing()) diff --git a/OpenRA.Mods.RA/AutoHeal.cs b/OpenRA.Mods.RA/AutoHeal.cs index 0426dc587d..1e536c6c7c 100644 --- a/OpenRA.Mods.RA/AutoHeal.cs +++ b/OpenRA.Mods.RA/AutoHeal.cs @@ -61,7 +61,7 @@ namespace OpenRA.Mods.RA return inRange .Where(a => a != self && self.Owner.Stances[a.Owner] == Stance.Ally) - .Where(a => !a.IsDead()) + .Where(a => a.IsInWorld && !a.IsDead()) .Where(a => a.HasTrait() && a.GetDamageState() > DamageState.Undamaged) .Where(a => attack.HasAnyValidWeapons(Target.FromActor(a))) .OrderBy(a => (a.Location - self.Location).LengthSquared) diff --git a/OpenRA.Mods.RA/Bridge.cs b/OpenRA.Mods.RA/Bridge.cs index 1b82875838..febd85e636 100644 --- a/OpenRA.Mods.RA/Bridge.cs +++ b/OpenRA.Mods.RA/Bridge.cs @@ -139,7 +139,7 @@ namespace OpenRA.Mods.RA bool IsIntact(Bridge b) { - return b != null && b.self.IsInWorld && !b.self.IsDead(); + return b != null && !b.self.IsDead(); } void KillUnitsOnBridge() diff --git a/OpenRA.Mods.RA/Player/ProductionQueue.cs b/OpenRA.Mods.RA/Player/ProductionQueue.cs index 3e32042846..2c11fcedd3 100755 --- a/OpenRA.Mods.RA/Player/ProductionQueue.cs +++ b/OpenRA.Mods.RA/Player/ProductionQueue.cs @@ -237,9 +237,16 @@ namespace OpenRA.Mods.RA return a.TraitsImplementing().Any(d => d.Disabled); } + // Builds a unit from the actor that holds this queue (1 queue per building) protected virtual void BuildUnit( string name ) { - // queue lives on actor; is produced at same actor + // Cannot produce if i'm dead + if (!self.IsInWorld || self.IsDead()) + { + CancelProduction(name, 1); + return; + } + var sp = self.TraitsImplementing().Where(p => p.Info.Produces.Contains(Info.Type)).FirstOrDefault(); if (sp != null && !IsDisabledBuilding(self) && sp.Produce(self, Rules.Info[ name ])) FinishProduction();