Fix actors being added to world while world actors are being iterated

This commit is contained in:
Gustas
2023-04-12 13:49:58 +03:00
committed by Matthias Mailänder
parent 718c6d03cc
commit 1db982276a

View File

@@ -55,7 +55,12 @@ namespace OpenRA.Mods.Common.Scripting
initDict.Add(new FacingInit(facing)); initDict.Add(new FacingInit(facing));
} }
return Context.World.CreateActor(addToWorld, actorType, initDict); // The actor must be added to the world at the end of the tick.
var a = Context.World.CreateActor(false, actorType, initDict);
if (addToWorld)
Context.World.AddFrameEndTask(w => w.Add(a));
return a;
} }
void Move(Actor actor, CPos dest) void Move(Actor actor, CPos dest)