Workaround: Hooks aren't called while in singlepalyer loading screen (fixes weird threading error)

This commit is contained in:
Evil Factory
2022-03-06 18:44:19 -03:00
parent 509b35352f
commit e7ceaf9f78

View File

@@ -915,7 +915,12 @@ namespace Barotrauma
static void _hookLuaPatch(MethodBase __originalMethod, object[] __args, object __instance, out LuaResult result, HookMethodType hookMethodType)
{
result = new LuaResult(null);
#if CLIENT
if (GameMain.GameSession?.IsRunning == false && GameMain.IsSingleplayer)
return;
#endif
try
{
var @params = __originalMethod.GetParameters();
@@ -1141,6 +1146,10 @@ namespace Barotrauma
public object Call(string name, params object[] args)
{
#if CLIENT
if (GameMain.GameSession?.IsRunning == false && GameMain.IsSingleplayer)
return null;
#endif
if (env == null) return null;
if (name == null) return null;
if (args == null) { args = new object[] { }; }