port allies-02 to new Lua API

This commit is contained in:
Matthias Mailänder
2014-08-31 10:48:22 +02:00
parent 15b358afa5
commit 24732ae635
7 changed files with 202 additions and 75 deletions

View File

@@ -171,6 +171,27 @@ namespace OpenRA.Mods.RA.Scripting
GetScriptTriggers(a).RegisterCallback(Trigger.OnRemovedFromWorld, func, context);
}
[Desc("Call a function when all of the actors in a group have been removed from the world. " +
"The callback function will be called as func().")]
public void OnAllRemovedFromWorld(Actor[] actors, LuaFunction func)
{
var group = actors.ToList();
var copy = (LuaFunction)func.CopyReference();
Action<Actor> OnMemberRemoved = m =>
{
group.Remove(m);
if (!group.Any())
{
copy.Call().Dispose();
copy.Dispose();
}
};
foreach (var a in group)
GetScriptTriggers(a).OnRemovedInternal += OnMemberRemoved;
}
[Desc("Call a function when this actor is captured. The callback function " +
"will be called as func(Actor self, Actor captor, Player oldOwner, Player newOwner).")]
public void OnCapture(Actor a, LuaFunction func)