only kill units on bridge death which cannot exist on their cell(s)' new terrain types
This commit is contained in:
@@ -48,8 +48,9 @@ namespace OpenRA.Mods.RA
|
|||||||
public object Create(ActorInitializer init) { return new Bridge(init.self, this); }
|
public object Create(ActorInitializer init) { return new Bridge(init.self, this); }
|
||||||
|
|
||||||
public IEnumerable<ushort> Templates
|
public IEnumerable<ushort> Templates
|
||||||
{ get {
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
if (Template != 0)
|
if (Template != 0)
|
||||||
yield return Template;
|
yield return Template;
|
||||||
|
|
||||||
@@ -67,7 +68,8 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
if (DestroyedPlusBothTemplate != 0)
|
if (DestroyedPlusBothTemplate != 0)
|
||||||
yield return DestroyedPlusBothTemplate;
|
yield return DestroyedPlusBothTemplate;
|
||||||
} }
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Bridge: IRender, INotifyDamage
|
class Bridge: IRender, INotifyDamage
|
||||||
@@ -152,6 +154,15 @@ namespace OpenRA.Mods.RA
|
|||||||
return b != null && b.self.IsInWorld && b.self.Health > 0;
|
return b != null && b.self.IsInWorld && b.self.Health > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void KillUnitsOnBridge()
|
||||||
|
{
|
||||||
|
var uim = self.World.WorldActor.traits.Get<UnitInfluence>();
|
||||||
|
|
||||||
|
foreach (var c in TileSprites[currentTemplate].Keys)
|
||||||
|
foreach (var a in uim.GetUnitsAt(c))
|
||||||
|
if (!a.traits.Get<IMove>().CanEnterCell(c))
|
||||||
|
a.InflictDamage(self, a.Health, null);
|
||||||
|
}
|
||||||
|
|
||||||
bool dead = false;
|
bool dead = false;
|
||||||
void UpdateState()
|
void UpdateState()
|
||||||
@@ -167,21 +178,11 @@ namespace OpenRA.Mods.RA
|
|||||||
ds = DamageState.Dead;
|
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 :
|
currentTemplate = (ds == DamageState.Half && Info.DamagedTemplate > 0) ? Info.DamagedTemplate :
|
||||||
(ds == DamageState.Dead && Info.DestroyedTemplate > 0) ? Info.DestroyedTemplate : Info.Template;
|
(ds == DamageState.Dead && Info.DestroyedTemplate > 0) ? Info.DestroyedTemplate : Info.Template;
|
||||||
|
|
||||||
if (!(Info.Long && ds == DamageState.Dead))
|
if (Info.Long && ds == DamageState.Dead)
|
||||||
return;
|
{
|
||||||
|
|
||||||
// Long bridges have custom art for multiple segments being destroyed
|
// Long bridges have custom art for multiple segments being destroyed
|
||||||
bool waterToSouth = !IsIntact(southNeighbour);
|
bool waterToSouth = !IsIntact(southNeighbour);
|
||||||
bool waterToNorth = !IsIntact(northNeighbour);
|
bool waterToNorth = !IsIntact(northNeighbour);
|
||||||
@@ -194,6 +195,13 @@ namespace OpenRA.Mods.RA
|
|||||||
currentTemplate = Info.DestroyedPlusSouthTemplate;
|
currentTemplate = Info.DestroyedPlusSouthTemplate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ds == DamageState.Dead && !dead)
|
||||||
|
{
|
||||||
|
dead = true;
|
||||||
|
KillUnitsOnBridge();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void Damaged(Actor self, AttackInfo e)
|
public void Damaged(Actor self, AttackInfo e)
|
||||||
{
|
{
|
||||||
if (e.DamageStateChanged)
|
if (e.DamageStateChanged)
|
||||||
|
|||||||
Reference in New Issue
Block a user