Fix Hook.Add compatibility with C# mods
This commit is contained in:
@@ -409,8 +409,13 @@ namespace Barotrauma
|
|||||||
() =>
|
() =>
|
||||||
{
|
{
|
||||||
if (getValidArgs == null) return null;
|
if (getValidArgs == null) return null;
|
||||||
return getValidArgs().ToObject<string[][]>();
|
var validArgs = getValidArgs();
|
||||||
}, isCheat);
|
if (validArgs is DynValue luaValue)
|
||||||
|
{
|
||||||
|
return luaValue.ToObject<string[][]>();
|
||||||
|
}
|
||||||
|
return (string[][])validArgs;
|
||||||
|
}, isCheat);
|
||||||
|
|
||||||
luaAddedCommand.Add(cmd);
|
luaAddedCommand.Add(cmd);
|
||||||
DebugConsole.Commands.Add(cmd);
|
DebugConsole.Commands.Add(cmd);
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ using Sigil.NonGeneric;
|
|||||||
namespace Barotrauma
|
namespace Barotrauma
|
||||||
{
|
{
|
||||||
public delegate void LuaCsAction(params object[] args);
|
public delegate void LuaCsAction(params object[] args);
|
||||||
public delegate DynValue LuaCsFunc(params object[] args);
|
public delegate object LuaCsFunc(params object[] args);
|
||||||
public delegate DynValue LuaCsPatchFunc(object instance, LuaCsHook.ParameterTable ptable);
|
public delegate DynValue LuaCsPatchFunc(object instance, LuaCsHook.ParameterTable ptable);
|
||||||
|
|
||||||
internal static class SigilExtensions
|
internal static class SigilExtensions
|
||||||
@@ -777,9 +777,13 @@ namespace Barotrauma
|
|||||||
|
|
||||||
var result = tuple.Item1.func(args);
|
var result = tuple.Item1.func(args);
|
||||||
// TODO(BREAKING): change this to !result.IsVoid()
|
// TODO(BREAKING): change this to !result.IsVoid()
|
||||||
if (result != null && !result.IsNil())
|
if (result is DynValue luaResult && !luaResult.IsNil())
|
||||||
{
|
{
|
||||||
lastResult = result.ToObject<T>();
|
lastResult = luaResult.ToObject<T>();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lastResult = (T)result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (luaCs.PerformanceCounter.EnablePerformanceCounter)
|
if (luaCs.PerformanceCounter.EnablePerformanceCounter)
|
||||||
|
|||||||
Reference in New Issue
Block a user