Clean up after LuaScript when tearing down the world.
This commit is contained in:
@@ -24,7 +24,7 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
public object Create(ActorInitializer init) { return new LuaScript(this); }
|
public object Create(ActorInitializer init) { return new LuaScript(this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public sealed class LuaScript : ITick, IWorldLoaded, IDisposable
|
public class LuaScript : ITick, IWorldLoaded, INotifyActorDisposing
|
||||||
{
|
{
|
||||||
readonly LuaScriptInfo info;
|
readonly LuaScriptInfo info;
|
||||||
ScriptContext context;
|
ScriptContext context;
|
||||||
@@ -46,10 +46,16 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
context.Tick(self);
|
context.Tick(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
bool disposed;
|
||||||
|
public void Disposing(Actor self)
|
||||||
{
|
{
|
||||||
|
if (disposed)
|
||||||
|
return;
|
||||||
|
|
||||||
if (context != null)
|
if (context != null)
|
||||||
context.Dispose();
|
context.Dispose();
|
||||||
|
|
||||||
|
disposed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool FatalErrorOccurred { get { return context.FatalErrorOccurred; } }
|
public bool FatalErrorOccurred { get { return context.FatalErrorOccurred; } }
|
||||||
|
|||||||
Reference in New Issue
Block a user