Fix crash in Beacon ctor when it runs during instead of between ticks

Causes an exception like below, for example when calling the Lua API's Beacon.New() method.

``Exception of type `System.InvalidOperationException`: Collection was modified; enumeration operation may not execute.``
This commit is contained in:
Oliver Brakmann
2016-05-19 23:05:01 +02:00
parent 6e7bce9571
commit 0192919501

View File

@@ -55,7 +55,7 @@ namespace OpenRA.Mods.Common.Effects
}
if (duration > 0)
owner.World.Add(new DelayedAction(duration, () => owner.World.Remove(this)));
owner.World.AddFrameEndTask(w => w.Add(new DelayedAction(duration, () => owner.World.Remove(this))));
}
// Support power beacons are expected to clean themselves up