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
@@ -916,6 +916,11 @@ namespace Barotrauma
{ {
result = new LuaResult(null); result = new LuaResult(null);
#if CLIENT
if (GameMain.GameSession?.IsRunning == false && GameMain.IsSingleplayer)
return;
#endif
try try
{ {
var @params = __originalMethod.GetParameters(); var @params = __originalMethod.GetParameters();
@@ -1141,6 +1146,10 @@ namespace Barotrauma
public object Call(string name, params object[] args) 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 (env == null) return null;
if (name == null) return null; if (name == null) return null;
if (args == null) { args = new object[] { }; } if (args == null) { args = new object[] { }; }