Fix crash in RallyPointIndicator.

This commit is contained in:
tovl
2019-12-14 17:21:08 +01:00
committed by Paul Chote
parent 308c64c7b1
commit 0e32cbee5e

View File

@@ -42,6 +42,8 @@ namespace OpenRA.Mods.Common.Effects
circles = new Animation(building.World, rp.Info.Image);
circles.Play(rp.Info.CirclesSequence);
}
UpdateTargetLineNodes(building.World);
}
void IEffect.Tick(World world)
@@ -53,6 +55,18 @@ namespace OpenRA.Mods.Common.Effects
circles.Tick();
if (cachedLocations == null || !cachedLocations.SequenceEqual(rp.Path))
{
UpdateTargetLineNodes(world);
if (circles != null)
circles.Play(rp.Info.CirclesSequence);
}
if (!building.IsInWorld || building.IsDead)
world.AddFrameEndTask(w => w.Remove(this));
}
void UpdateTargetLineNodes(World world)
{
cachedLocations = new List<CPos>(rp.Path);
targetLineNodes.Clear();
@@ -75,13 +89,6 @@ namespace OpenRA.Mods.Common.Effects
}
targetLineNodes.Insert(0, exitPos);
if (circles != null)
circles.Play(rp.Info.CirclesSequence);
}
if (!building.IsInWorld || building.IsDead)
world.AddFrameEndTask(w => w.Remove(this));
}
IEnumerable<IRenderable> IEffect.Render(WorldRenderer wr) { return SpriteRenderable.None; }
@@ -95,7 +102,7 @@ namespace OpenRA.Mods.Common.Effects
return SpriteRenderable.None;
var renderables = SpriteRenderable.None;
if (circles != null || flag != null)
if (targetLineNodes.Count > 0 && (circles != null || flag != null))
{
var palette = wr.Palette(rp.PaletteName);
if (circles != null)
@@ -119,6 +126,9 @@ namespace OpenRA.Mods.Common.Effects
if (!building.World.Selection.Contains(building))
return SpriteRenderable.None;
if (targetLineNodes.Count == 0)
return SpriteRenderable.None;
return RenderInner(wr);
}