Fix #225 and some other uses of a.IsInWorld / a.IsDead()
This commit is contained in:
@@ -140,6 +140,8 @@ namespace OpenRA.Traits
|
|||||||
{
|
{
|
||||||
public static bool IsDead(this Actor self)
|
public static bool IsDead(this Actor self)
|
||||||
{
|
{
|
||||||
|
if (self.Destroyed) return true;
|
||||||
|
|
||||||
var health = self.TraitOrDefault<Health>();
|
var health = self.TraitOrDefault<Health>();
|
||||||
return (health == null) ? true : health.IsDead;
|
return (health == null) ? true : health.IsDead;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,9 +61,10 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
void DrawHealthBar(Actor self, float2 xy, float2 Xy)
|
void DrawHealthBar(Actor self, float2 xy, float2 Xy)
|
||||||
{
|
{
|
||||||
|
if (!self.IsInWorld) return;
|
||||||
|
|
||||||
var health = self.TraitOrDefault<Health>();
|
var health = self.TraitOrDefault<Health>();
|
||||||
if (self.IsDead() || health == null)
|
if (health == null || health.IsDead) return;
|
||||||
return;
|
|
||||||
|
|
||||||
var c = Color.Gray;
|
var c = Color.Gray;
|
||||||
Game.Renderer.LineRenderer.DrawLine(xy + new float2(0, -2), xy + new float2(0, -4), c, c);
|
Game.Renderer.LineRenderer.DrawLine(xy + new float2(0, -2), xy + new float2(0, -4), c, c);
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ namespace OpenRA.Mods.RA
|
|||||||
}
|
}
|
||||||
// GoodGuy win conditions
|
// GoodGuy win conditions
|
||||||
// BadGuy is dead
|
// 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)
|
if (badcount != lastBadCount)
|
||||||
{
|
{
|
||||||
Game.Debug("{0} badguys remain".F(badcount));
|
Game.Debug("{0} badguys remain".F(badcount));
|
||||||
@@ -137,7 +137,7 @@ namespace OpenRA.Mods.RA
|
|||||||
}
|
}
|
||||||
|
|
||||||
//GoodGuy lose conditions
|
//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);
|
OnLose(self.World);
|
||||||
|
|
||||||
// GoodGuy reinforcements
|
// GoodGuy reinforcements
|
||||||
|
|||||||
@@ -55,8 +55,9 @@ namespace OpenRA.Mods.Cnc
|
|||||||
a.QueueActivity(new Land(Target.FromActor(self)));
|
a.QueueActivity(new Land(Target.FromActor(self)));
|
||||||
a.QueueActivity(new CallFunc(() =>
|
a.QueueActivity(new CallFunc(() =>
|
||||||
{
|
{
|
||||||
if (self.IsDead())
|
if (!self.IsInWorld || self.IsDead())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
rb.PlayCustomAnimRepeating(self, "idle");
|
rb.PlayCustomAnimRepeating(self, "idle");
|
||||||
self.World.AddFrameEndTask(ww => DoProduction(self, producee, exit));
|
self.World.AddFrameEndTask(ww => DoProduction(self, producee, exit));
|
||||||
}));
|
}));
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
public override IActivity Tick(Actor self)
|
public override IActivity Tick(Actor self)
|
||||||
{
|
{
|
||||||
if (IsCanceled) return NextActivity;
|
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;
|
if (target.Owner == self.Owner) return NextActivity;
|
||||||
|
|
||||||
foreach (var t in target.TraitsImplementing<IAcceptSpy>())
|
foreach (var t in target.TraitsImplementing<IAcceptSpy>())
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
return inRange
|
return inRange
|
||||||
.Where(a => a != self && self.Owner.Stances[a.Owner] == Stance.Ally)
|
.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<Health>() && a.GetDamageState() > DamageState.Undamaged)
|
.Where(a => a.HasTrait<Health>() && a.GetDamageState() > DamageState.Undamaged)
|
||||||
.Where(a => attack.HasAnyValidWeapons(Target.FromActor(a)))
|
.Where(a => attack.HasAnyValidWeapons(Target.FromActor(a)))
|
||||||
.OrderBy(a => (a.Location - self.Location).LengthSquared)
|
.OrderBy(a => (a.Location - self.Location).LengthSquared)
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
bool IsIntact(Bridge b)
|
bool IsIntact(Bridge b)
|
||||||
{
|
{
|
||||||
return b != null && b.self.IsInWorld && !b.self.IsDead();
|
return b != null && !b.self.IsDead();
|
||||||
}
|
}
|
||||||
|
|
||||||
void KillUnitsOnBridge()
|
void KillUnitsOnBridge()
|
||||||
|
|||||||
@@ -237,9 +237,16 @@ namespace OpenRA.Mods.RA
|
|||||||
return a.TraitsImplementing<IDisable>().Any(d => d.Disabled);
|
return a.TraitsImplementing<IDisable>().Any(d => d.Disabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Builds a unit from the actor that holds this queue (1 queue per building)
|
||||||
protected virtual void BuildUnit( string name )
|
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<Production>().Where(p => p.Info.Produces.Contains(Info.Type)).FirstOrDefault();
|
var sp = self.TraitsImplementing<Production>().Where(p => p.Info.Produces.Contains(Info.Type)).FirstOrDefault();
|
||||||
if (sp != null && !IsDisabledBuilding(self) && sp.Produce(self, Rules.Info[ name ]))
|
if (sp != null && !IsDisabledBuilding(self) && sp.Produce(self, Rules.Info[ name ]))
|
||||||
FinishProduction();
|
FinishProduction();
|
||||||
|
|||||||
Reference in New Issue
Block a user