Fix damaged-building artwork and don't show healthbar for dead units (cnc critical-building state)
This commit is contained in:
@@ -26,7 +26,7 @@ namespace OpenRA.Traits
|
||||
public virtual object Create(ActorInitializer init) { return new Health(init, this); }
|
||||
}
|
||||
|
||||
public enum ExtendedDamageState { Undamaged, Normal, ThreeQuarter, Half, Quarter, Dead };
|
||||
public enum ExtendedDamageState { Dead, Quarter, Half, ThreeQuarter, Normal, Undamaged };
|
||||
|
||||
public class Health
|
||||
{
|
||||
@@ -140,24 +140,12 @@ namespace OpenRA.Traits
|
||||
|
||||
public static class HealthExts
|
||||
{
|
||||
public static int Health(this Actor self)
|
||||
{
|
||||
var health = self.traits.GetOrDefault<Health>();
|
||||
return (health == null) ? 0 : health.HP;
|
||||
}
|
||||
|
||||
public static bool IsDead(this Actor self)
|
||||
{
|
||||
var health = self.traits.GetOrDefault<Health>();
|
||||
return (health == null) ? true : health.IsDead;
|
||||
}
|
||||
|
||||
public static DamageState GetDamageState(this Actor self)
|
||||
{
|
||||
var health = self.traits.GetOrDefault<Health>();
|
||||
return (health == null) ? DamageState.Normal : health.DamageState;
|
||||
}
|
||||
|
||||
|
||||
public static ExtendedDamageState GetExtendedDamageState(this Actor self)
|
||||
{
|
||||
var health = self.traits.GetOrDefault<Health>();
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace OpenRA.Traits
|
||||
|
||||
protected virtual string GetPrefix(Actor self)
|
||||
{
|
||||
return self.GetDamageState() == DamageState.Half ? "damaged-" : "";
|
||||
return self.GetExtendedDamageState() <= ExtendedDamageState.Half ? "damaged-" : "";
|
||||
}
|
||||
|
||||
public void PlayCustomAnim(Actor self, string name)
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace OpenRA.Traits
|
||||
void DrawHealthBar(Actor self, float2 xy, float2 Xy)
|
||||
{
|
||||
var health = self.traits.GetOrDefault<Health>();
|
||||
if (health == null)
|
||||
if (self.IsDead() || health == null)
|
||||
return;
|
||||
|
||||
var c = Color.Gray;
|
||||
|
||||
Reference in New Issue
Block a user