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