Merge the two DamageState types

This commit is contained in:
Paul Chote
2010-07-30 21:26:46 +12:00
parent 41c0d175bd
commit 028c5b5201
19 changed files with 37 additions and 57 deletions

View File

@@ -78,7 +78,7 @@ namespace OpenRA.Traits
public void Damaged(Actor self, AttackInfo e)
{
if (e.DamageState == DamageState.Dead)
if (e.ExtendedDamageState == ExtendedDamageState.Dead)
{
self.World.WorldActor.traits.Get<ScreenShaker>().AddEffect(10, self.CenterLocation, 1);
Sound.Play(Info.DestroyedSound, self.CenterLocation);

View File

@@ -52,21 +52,7 @@ namespace OpenRA.Traits
public bool IsDead { get { return hp <= 0; } }
public bool RemoveOnDeath = true;
public DamageState DamageState
{
get
{
if (hp <= 0)
return DamageState.Dead;
if (hp < MaxHP * 0.5f)
return DamageState.Half;
return DamageState.Normal;
}
}
public ExtendedDamageState ExtendedDamageState
{
get
@@ -94,7 +80,6 @@ namespace OpenRA.Traits
{
if (IsDead) return; /* overkill! don't count extra hits as more kills! */
var oldState = this.DamageState;
var oldExtendedState = this.ExtendedDamageState;
/* apply the damage modifiers, if we have any. */
@@ -124,9 +109,7 @@ namespace OpenRA.Traits
{
Attacker = attacker,
Damage = damage,
DamageState = this.DamageState,
ExtendedDamageState = this.ExtendedDamageState,
DamageStateChanged = this.DamageState != oldState,
ExtendedDamageStateChanged = this.ExtendedDamageState != oldExtendedState,
Warhead = warhead
});

View File

@@ -15,8 +15,6 @@ using OpenRA.Graphics;
namespace OpenRA.Traits
{
public enum DamageState { Normal, Half, Dead };
// depends on the order of pips in WorldRenderer.cs!
public enum PipType { Transparent, Green, Yellow, Red, Gray };
public enum TagType { None, Fake, Primary };
@@ -27,9 +25,7 @@ namespace OpenRA.Traits
public Actor Attacker;
public WarheadInfo Warhead;
public int Damage;
public DamageState DamageState;
public ExtendedDamageState ExtendedDamageState;
public bool DamageStateChanged;
public bool ExtendedDamageStateChanged;
}

View File

@@ -32,7 +32,7 @@ namespace OpenRA.Traits
public void Damaged(Actor self, AttackInfo e)
{
if (e.DamageState == DamageState.Dead)
if (e.ExtendedDamageState == ExtendedDamageState.Dead)
if (self.Owner == self.World.LocalPlayer)
Sound.PlayVoice("Lost", self);
}