Automatically convert Lua types in HookMethod
This commit is contained in:
@@ -100,8 +100,17 @@ namespace Barotrauma
|
|||||||
_hookLuaPatch(__originalMethod, __args, __instance, out LuaResult result, HookMethodType.Before);
|
_hookLuaPatch(__originalMethod, __args, __instance, out LuaResult result, HookMethodType.Before);
|
||||||
|
|
||||||
if (!result.IsNull())
|
if (!result.IsNull())
|
||||||
|
{
|
||||||
|
|
||||||
|
if (__originalMethod is MethodInfo mi)
|
||||||
|
{
|
||||||
|
__result = result.DynValue().ToObject(mi.ReturnType);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
__result = result.Object();
|
__result = result.Object();
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,8 +127,17 @@ namespace Barotrauma
|
|||||||
_hookLuaPatch(__originalMethod, __args, __instance, out LuaResult result, HookMethodType.After);
|
_hookLuaPatch(__originalMethod, __args, __instance, out LuaResult result, HookMethodType.After);
|
||||||
|
|
||||||
if (!result.IsNull())
|
if (!result.IsNull())
|
||||||
|
{
|
||||||
|
if (__originalMethod is MethodInfo mi)
|
||||||
|
{
|
||||||
|
__result = result.DynValue().ToObject(mi.ReturnType);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
__result = result.Object();
|
__result = result.Object();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private const BindingFlags DefaultBindingFlags = BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
|
private const BindingFlags DefaultBindingFlags = BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
|
||||||
private static MethodInfo _miHookLuaPatchPrefix = typeof(LuaHook).GetMethod("HookLuaPatchPrefix", BindingFlags.NonPublic | BindingFlags.Static);
|
private static MethodInfo _miHookLuaPatchPrefix = typeof(LuaHook).GetMethod("HookLuaPatchPrefix", BindingFlags.NonPublic | BindingFlags.Static);
|
||||||
|
|||||||
Reference in New Issue
Block a user