Fix damage transition sounds

This commit is contained in:
Paul Chote
2010-07-30 22:23:52 +12:00
parent 8528c5d3a3
commit 62c2c3a1c6
4 changed files with 6 additions and 4 deletions

View File

@@ -110,6 +110,7 @@ namespace OpenRA.Traits
Attacker = attacker,
Damage = damage,
DamageState = this.DamageState,
PreviousDamageState = oldState,
DamageStateChanged = this.DamageState != oldState,
Warhead = warhead
});

View File

@@ -26,6 +26,7 @@ namespace OpenRA.Traits
public WarheadInfo Warhead;
public int Damage;
public DamageState DamageState;
public DamageState PreviousDamageState;
public bool DamageStateChanged;
}

View File

@@ -63,12 +63,12 @@ namespace OpenRA.Mods.RA.Render
if (e.DamageState == DamageState.Dead)
self.World.AddFrameEndTask(w => w.Add(new Explosion(w, self.CenterLocation.ToInt2(), "building", false)));
else if (e.DamageState >= DamageState.Heavy)
else if (e.DamageState >= DamageState.Heavy && e.PreviousDamageState < DamageState.Heavy)
{
anim.ReplaceAnim("damaged-idle");
Sound.Play(self.Info.Traits.Get<BuildingInfo>().DamagedSound, self.CenterLocation);
}
else
else if (e.DamageState < DamageState.Heavy)
anim.ReplaceAnim("idle");
}

View File

@@ -33,12 +33,12 @@ namespace OpenRA.Mods.RA.Render
{
if (!e.DamageStateChanged) return;
if (e.DamageState >= DamageState.Heavy)
if (e.DamageState >= DamageState.Heavy && e.PreviousDamageState < DamageState.Heavy)
{
anim.ReplaceAnim("damaged-idle");
Sound.Play(self.Info.Traits.Get<BuildingInfo>().DamagedSound, self.CenterLocation);
}
else
else if (e.DamageState < DamageState.Heavy)
anim.ReplaceAnim("idle");
}
}