Make lua converters private
This commit is contained in:
+8
-14
@@ -6,16 +6,10 @@ using LuaCsCompatPatchFunc = Barotrauma.LuaCsPatch;
|
|||||||
|
|
||||||
namespace Barotrauma
|
namespace Barotrauma
|
||||||
{
|
{
|
||||||
public delegate DynValue CallLuaFunctionFunc(object function, params object[] args);
|
partial class LuaCsSetup
|
||||||
|
|
||||||
internal static class LuaCustomConverters
|
|
||||||
{
|
{
|
||||||
private static CallLuaFunctionFunc CallLuaFunction;
|
private void RegisterLuaConverters()
|
||||||
|
|
||||||
public static void Initialize(CallLuaFunctionFunc callLuaFunction)
|
|
||||||
{
|
{
|
||||||
CallLuaFunction = callLuaFunction;
|
|
||||||
|
|
||||||
RegisterAction<Item>();
|
RegisterAction<Item>();
|
||||||
RegisterAction<Character>();
|
RegisterAction<Character>();
|
||||||
RegisterAction<Entity>();
|
RegisterAction<Entity>();
|
||||||
@@ -194,7 +188,7 @@ namespace Barotrauma
|
|||||||
: throw new ScriptRuntimeException("use Double(value) to pass primitive type 'double' to C#"));
|
: throw new ScriptRuntimeException("use Double(value) to pass primitive type 'double' to C#"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void RegisterAction<T>()
|
private void RegisterAction<T>()
|
||||||
{
|
{
|
||||||
Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(DataType.Function, typeof(Action<T>), v =>
|
Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(DataType.Function, typeof(Action<T>), v =>
|
||||||
{
|
{
|
||||||
@@ -209,7 +203,7 @@ namespace Barotrauma
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void RegisterAction<T1, T2>()
|
private void RegisterAction<T1, T2>()
|
||||||
{
|
{
|
||||||
Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(DataType.Function, typeof(Action<T1, T2>), v =>
|
Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(DataType.Function, typeof(Action<T1, T2>), v =>
|
||||||
{
|
{
|
||||||
@@ -224,7 +218,7 @@ namespace Barotrauma
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void RegisterAction()
|
private void RegisterAction()
|
||||||
{
|
{
|
||||||
Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(DataType.Function, typeof(Action), v =>
|
Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(DataType.Function, typeof(Action), v =>
|
||||||
{
|
{
|
||||||
@@ -239,7 +233,7 @@ namespace Barotrauma
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void RegisterFunc<T1>()
|
private void RegisterFunc<T1>()
|
||||||
{
|
{
|
||||||
Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(DataType.Function, typeof(Func<T1>), v =>
|
Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(DataType.Function, typeof(Func<T1>), v =>
|
||||||
{
|
{
|
||||||
@@ -254,7 +248,7 @@ namespace Barotrauma
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void RegisterFunc<T1, T2>()
|
private void RegisterFunc<T1, T2>()
|
||||||
{
|
{
|
||||||
Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(DataType.Function, typeof(Func<T1, T2>), v =>
|
Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(DataType.Function, typeof(Func<T1, T2>), v =>
|
||||||
{
|
{
|
||||||
@@ -269,7 +263,7 @@ namespace Barotrauma
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void RegisterFunc<T1, T2, T3, T4, T5>()
|
private void RegisterFunc<T1, T2, T3, T4, T5>()
|
||||||
{
|
{
|
||||||
Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(DataType.Function, typeof(Func<T1, T2, T3, T4, T5>), v =>
|
Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(DataType.Function, typeof(Func<T1, T2, T3, T4, T5>), v =>
|
||||||
{
|
{
|
||||||
@@ -409,7 +409,7 @@ namespace Barotrauma
|
|||||||
LuaScriptLoader = new LuaScriptLoader();
|
LuaScriptLoader = new LuaScriptLoader();
|
||||||
LuaScriptLoader.ModulePaths = new string[] { };
|
LuaScriptLoader.ModulePaths = new string[] { };
|
||||||
|
|
||||||
LuaCustomConverters.Initialize(CallLuaFunction);
|
RegisterLuaConverters();
|
||||||
|
|
||||||
lua = new Script(CoreModules.Preset_SoftSandbox | CoreModules.Debug);
|
lua = new Script(CoreModules.Preset_SoftSandbox | CoreModules.Debug);
|
||||||
lua.Options.DebugPrint = PrintMessage;
|
lua.Options.DebugPrint = PrintMessage;
|
||||||
|
|||||||
Reference in New Issue
Block a user