Add OnSelling and OnSold to the Lua API.

This commit is contained in:
Matthias Mailänder
2016-07-24 07:36:14 +02:00
parent e3df47d6d2
commit abbcdbd5df

View File

@@ -23,7 +23,7 @@ namespace OpenRA.Mods.Common.Scripting
OnIdle, OnDamaged, OnKilled, OnProduction, OnOtherProduction, OnPlayerWon, OnPlayerLost, OnIdle, OnDamaged, OnKilled, OnProduction, OnOtherProduction, OnPlayerWon, OnPlayerLost,
OnObjectiveAdded, OnObjectiveCompleted, OnObjectiveFailed, OnCapture, OnInfiltrated, OnObjectiveAdded, OnObjectiveCompleted, OnObjectiveFailed, OnCapture, OnInfiltrated,
OnAddedToWorld, OnRemovedFromWorld, OnDiscovered, OnPlayerDiscovered, OnAddedToWorld, OnRemovedFromWorld, OnDiscovered, OnPlayerDiscovered,
OnPassengerEntered, OnPassengerExited OnPassengerEntered, OnPassengerExited, OnSelling, OnSold
} }
[Desc("Allows map scripts to attach triggers to this actor via the Triggers global.")] [Desc("Allows map scripts to attach triggers to this actor via the Triggers global.")]
@@ -34,7 +34,7 @@ namespace OpenRA.Mods.Common.Scripting
public sealed class ScriptTriggers : INotifyIdle, INotifyDamage, INotifyKilled, INotifyProduction, INotifyOtherProduction, public sealed class ScriptTriggers : INotifyIdle, INotifyDamage, INotifyKilled, INotifyProduction, INotifyOtherProduction,
INotifyObjectivesUpdated, INotifyCapture, INotifyInfiltrated, INotifyAddedToWorld, INotifyRemovedFromWorld, INotifyDiscovered, INotifyActorDisposing, INotifyObjectivesUpdated, INotifyCapture, INotifyInfiltrated, INotifyAddedToWorld, INotifyRemovedFromWorld, INotifyDiscovered, INotifyActorDisposing,
INotifyPassengerEntered, INotifyPassengerExited INotifyPassengerEntered, INotifyPassengerExited, INotifySold
{ {
readonly World world; readonly World world;
readonly Actor self; readonly Actor self;
@@ -364,6 +364,46 @@ namespace OpenRA.Mods.Common.Scripting
OnRemovedInternal(self); OnRemovedInternal(self);
} }
void INotifySold.Selling(Actor self)
{
if (world.Disposing)
return;
// Run Lua callbacks
foreach (var f in Triggerables(Trigger.OnSelling))
{
try
{
f.Function.Call(f.Self).Dispose();
}
catch (Exception ex)
{
f.Context.FatalError(ex.Message);
return;
}
}
}
void INotifySold.Sold(Actor self)
{
if (world.Disposing)
return;
// Run Lua callbacks
foreach (var f in Triggerables(Trigger.OnSold))
{
try
{
f.Function.Call(f.Self).Dispose();
}
catch (Exception ex)
{
f.Context.FatalError(ex.Message);
return;
}
}
}
public void UnitProducedByOther(Actor self, Actor producee, Actor produced) public void UnitProducedByOther(Actor self, Actor producee, Actor produced)
{ {
if (world.Disposing) if (world.Disposing)