Add scripting support for TimeLimitManager

This commit is contained in:
Oliver Brakmann
2019-01-26 19:28:52 +01:00
committed by abcdefg30
parent 47d88983fb
commit 26d712728a
4 changed files with 101 additions and 5 deletions

View File

@@ -24,7 +24,7 @@ namespace OpenRA.Mods.Common.Scripting
OnIdle, OnDamaged, OnKilled, OnProduction, OnOtherProduction, OnPlayerWon, OnPlayerLost,
OnObjectiveAdded, OnObjectiveCompleted, OnObjectiveFailed, OnCapture, OnInfiltrated,
OnAddedToWorld, OnRemovedFromWorld, OnDiscovered, OnPlayerDiscovered,
OnPassengerEntered, OnPassengerExited, OnSold
OnPassengerEntered, OnPassengerExited, OnSold, OnTimerExpired
}
[Desc("Allows map scripts to attach triggers to this actor via the Triggers global.")]
@@ -35,7 +35,7 @@ namespace OpenRA.Mods.Common.Scripting
public sealed class ScriptTriggers : INotifyIdle, INotifyDamage, INotifyKilled, INotifyProduction, INotifyOtherProduction,
INotifyObjectivesUpdated, INotifyCapture, INotifyInfiltrated, INotifyAddedToWorld, INotifyRemovedFromWorld, INotifyDiscovered, INotifyActorDisposing,
INotifyPassengerEntered, INotifyPassengerExited, INotifySold, INotifyWinStateChanged
INotifyPassengerEntered, INotifyPassengerExited, INotifySold, INotifyWinStateChanged, INotifyTimeLimit
{
readonly World world;
readonly Actor self;
@@ -493,6 +493,25 @@ namespace OpenRA.Mods.Common.Scripting
}
}
void INotifyTimeLimit.NotifyTimerExpired(Actor self)
{
if (world.Disposing)
return;
foreach (var f in Triggerables(Trigger.OnTimerExpired))
{
try
{
f.Function.Call().Dispose();
}
catch (Exception ex)
{
f.Context.FatalError(ex.Message);
return;
}
}
}
public void Clear(Trigger trigger)
{
world.AddFrameEndTask(w =>