Add SpawnActorEffect

And use it to drop DelayedAction from ReinforcementsGlobal.
This commit is contained in:
reaperrr
2019-01-06 07:40:41 +01:00
committed by abcdefg30
parent ab4268025a
commit ea2e452075
3 changed files with 78 additions and 15 deletions

View File

@@ -16,6 +16,7 @@ using Eluant;
using OpenRA.Activities;
using OpenRA.Effects;
using OpenRA.Mods.Common.Activities;
using OpenRA.Mods.Common.Effects;
using OpenRA.Mods.Common.Traits;
using OpenRA.Primitives;
using OpenRA.Scripting;
@@ -84,24 +85,21 @@ namespace OpenRA.Mods.Common.Scripting
actors.Add(actor);
var actionDelay = i * interval;
Action actorAction = () =>
Activity queuedActivity = null;
if (af != null)
{
Context.World.Add(actor);
for (var j = 1; j < entryPath.Length; j++)
Move(actor, entryPath[j]);
if (af != null)
queuedActivity = new CallFunc(() =>
{
actor.QueueActivity(new CallFunc(() =>
{
using (af)
using (var a = actor.ToLuaValue(Context))
af.Call(a);
}));
}
};
using (af)
using (var a = actor.ToLuaValue(Context))
af.Call(a);
});
}
Context.World.AddFrameEndTask(w => w.Add(new DelayedAction(actionDelay, actorAction)));
// We need to exclude the spawn location from the movement path
var path = entryPath.Skip(1).ToArray();
Context.World.AddFrameEndTask(w => w.Add(new SpawnActorEffect(actor, actionDelay, path, queuedActivity)));
}
return actors.ToArray();