Kill any units on a bridge piece when it dies. Todo: need to mask the death regions for cnc bridges

This commit is contained in:
Paul Chote
2010-06-28 13:05:52 +12:00
parent 797b1b4a84
commit 272e03603a

View File

@@ -152,6 +152,8 @@ namespace OpenRA.Mods.RA
return b != null && b.self.IsInWorld && b.self.Health > 0;
}
bool dead = false;
void UpdateState()
{
var ds = self.GetDamageState();
@@ -165,6 +167,15 @@ namespace OpenRA.Mods.RA
ds = DamageState.Dead;
}
if (ds == DamageState.Dead && !dead)
{
dead = true;
// Kill any units on the bridge
foreach (var c in TileSprites[currentTemplate].Keys)
self.World.WorldActor.traits.Get<UnitInfluence>().GetUnitsAt(c).Do(a => a.InflictDamage(self, a.Health, null));
}
currentTemplate = (ds == DamageState.Half && Info.DamagedTemplate > 0) ? Info.DamagedTemplate :
(ds == DamageState.Dead && Info.DestroyedTemplate > 0) ? Info.DestroyedTemplate : Info.Template;