Add OnBuildingPlaced lua trigger.
This commit is contained in:
committed by
Gustas Kažukauskas
parent
eb550bbbbb
commit
3177de7b2c
@@ -21,7 +21,7 @@ namespace OpenRA.Mods.Common.Scripting
|
||||
{
|
||||
public enum Trigger
|
||||
{
|
||||
OnIdle, OnDamaged, OnKilled, OnProduction, OnOtherProduction, OnPlayerWon, OnPlayerLost,
|
||||
OnIdle, OnDamaged, OnKilled, OnProduction, OnOtherProduction, OnBuildingPlaced, OnPlayerWon, OnPlayerLost,
|
||||
OnObjectiveAdded, OnObjectiveCompleted, OnObjectiveFailed, OnCapture, OnInfiltrated,
|
||||
OnAddedToWorld, OnRemovedFromWorld, OnDiscovered, OnPlayerDiscovered,
|
||||
OnPassengerEntered, OnPassengerExited, OnSold, OnTimerExpired
|
||||
@@ -33,7 +33,7 @@ namespace OpenRA.Mods.Common.Scripting
|
||||
public override object Create(ActorInitializer init) { return new ScriptTriggers(init.World, init.Self); }
|
||||
}
|
||||
|
||||
public sealed class ScriptTriggers : INotifyIdle, INotifyDamage, INotifyKilled, INotifyProduction, INotifyOtherProduction,
|
||||
public sealed class ScriptTriggers : INotifyIdle, INotifyDamage, INotifyKilled, INotifyProduction, INotifyBuildingPlaced, INotifyOtherProduction,
|
||||
INotifyObjectivesUpdated, INotifyCapture, INotifyInfiltrated, INotifyAddedToWorld, INotifyRemovedFromWorld, INotifyDiscovered, INotifyActorDisposing,
|
||||
INotifyPassengerEntered, INotifyPassengerExited, INotifySold, INotifyWinStateChanged, INotifyTimeLimit
|
||||
{
|
||||
@@ -280,6 +280,28 @@ namespace OpenRA.Mods.Common.Scripting
|
||||
}
|
||||
}
|
||||
|
||||
void INotifyBuildingPlaced.BuildingPlaced(Actor self, Actor building)
|
||||
{
|
||||
if (world.Disposing)
|
||||
return;
|
||||
|
||||
// Run Lua callbacks
|
||||
foreach (var f in Triggerables(Trigger.OnBuildingPlaced))
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var a = self.Owner.ToLuaValue(f.Context))
|
||||
using (var b = building.ToLuaValue(f.Context))
|
||||
f.Function.Call(a, b).Dispose();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
f.Context.FatalError(ex);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void INotifyCapture.OnCapture(Actor self, Actor captor, Player oldOwner, Player newOwner, BitSet<CaptureType> captureTypes)
|
||||
{
|
||||
if (world.Disposing)
|
||||
|
||||
Reference in New Issue
Block a user