completely destroy long bridges in a chain reaction

This commit is contained in:
Matthias Mailänder
2013-12-11 17:19:39 +01:00
parent c08335b7b2
commit 83915eefb4
2 changed files with 28 additions and 6 deletions

View File

@@ -289,12 +289,34 @@ namespace OpenRA.Mods.RA
return damage;
}
public void Demolish(Actor saboteur)
public void Demolish(Actor saboteur, bool continueNorth, bool continueSouth)
{
// TODO: completely destroy long bridges in a chain reaction
Combat.DoExplosion(saboteur, "Demolish", self.CenterPosition);
self.World.WorldActor.Trait<ScreenShaker>().AddEffect(15, self.CenterPosition, 6);
self.Kill(saboteur);
var initialDamage = Health.DamageState;
self.World.AddFrameEndTask(w =>
{
Combat.DoExplosion(saboteur, "Demolish", self.CenterPosition);
self.World.WorldActor.Trait<ScreenShaker>().AddEffect(15, self.CenterPosition, 6);
self.Kill(saboteur);
});
// Destroy adjacent spans (long bridges)
if (continueNorth && northNeighbour != null)
{
var delay = initialDamage == DamageState.Dead || NeighbourIsDeadShore(northNeighbour) ?
0 : Info.RepairPropagationDelay;
self.World.AddFrameEndTask(w => w.Add(new DelayedAction(delay, () =>
northNeighbour.Demolish(saboteur, true, false))));
}
if (continueSouth && southNeighbour != null)
{
var delay = initialDamage == DamageState.Dead || NeighbourIsDeadShore(southNeighbour) ?
0 : Info.RepairPropagationDelay;
self.World.AddFrameEndTask(w => w.Add(new DelayedAction(delay, () =>
southNeighbour.Demolish(saboteur, false, true))));
}
}
}
}

View File

@@ -33,7 +33,7 @@ namespace OpenRA.Mods.RA
public void Demolish(Actor self, Actor saboteur)
{
bridge.Demolish(saboteur);
bridge.Demolish(saboteur, true, true);
}
public bool IsValidTarget(Actor self, Actor saboteur)