Move trigger lists into a dictionary for easier access and enumeration
This commit is contained in:
@@ -56,21 +56,21 @@ namespace OpenRA.Mods.RA.Scripting
|
||||
"The callback function will be called as func(Actor self).")]
|
||||
public void OnIdle(Actor a, LuaFunction func)
|
||||
{
|
||||
GetScriptTriggers(a).RegisterIdleCallback(func, context);
|
||||
GetScriptTriggers(a).RegisterCallback(Trigger.OnIdle, func, context);
|
||||
}
|
||||
|
||||
[Desc("Call a function when the actor is damaged. The callback " +
|
||||
"function will be called as func(Actor self, Actor attacker).")]
|
||||
public void OnDamaged(Actor a, LuaFunction func)
|
||||
{
|
||||
GetScriptTriggers(a).RegisterDamagedCallback(func, context);
|
||||
GetScriptTriggers(a).RegisterCallback(Trigger.OnDamaged, func, context);
|
||||
}
|
||||
|
||||
[Desc("Call a function when the actor is killed. The callback " +
|
||||
"function will be called as func(Actor self, Actor killer).")]
|
||||
public void OnKilled(Actor a, LuaFunction func)
|
||||
{
|
||||
GetScriptTriggers(a).RegisterKilledCallback(func, context);
|
||||
GetScriptTriggers(a).RegisterCallback(Trigger.OnKilled, func, context);
|
||||
}
|
||||
|
||||
[Desc("Call a function when all of the actors in a group are killed. The callback " +
|
||||
@@ -106,7 +106,21 @@ namespace OpenRA.Mods.RA.Scripting
|
||||
"The callback function will be called as func(Actor producer, Actor produced).")]
|
||||
public void OnProduction(Actor a, LuaFunction func)
|
||||
{
|
||||
GetScriptTriggers(a).RegisterProductionCallback(func, context);
|
||||
GetScriptTriggers(a).RegisterCallback(Trigger.OnProduction, func, context);
|
||||
}
|
||||
|
||||
[Desc("Removes all triggers from this actor")]
|
||||
public void ClearAll(Actor a)
|
||||
{
|
||||
GetScriptTriggers(a).ClearAll();
|
||||
}
|
||||
|
||||
[Desc("Removes the specified trigger from this actor")]
|
||||
public void Clear(Actor a, string triggerName)
|
||||
{
|
||||
var trigger = (Trigger)Enum.Parse(typeof(Trigger), triggerName);
|
||||
|
||||
GetScriptTriggers(a).Clear(trigger);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user