Skip to content

Commit

Permalink
Fix not working on exiting to main menu
Browse files Browse the repository at this point in the history
  • Loading branch information
Egor Aralov committed Aug 22, 2015
1 parent 89ebf3c commit d4374ef
Showing 1 changed file with 24 additions and 10 deletions.
34 changes: 24 additions & 10 deletions Debugger/Mod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ public class ModToolsBootstrap

private static GameObject modToolsGameObject;
private static ModTools modTools;
public static bool initialized;
private static bool bootstrapped;
public static bool inMainMenu = true;

public static bool IsModToolsActive()
{
Expand All @@ -38,21 +40,26 @@ public static bool IsModToolsActive()

public static void Bootstrap()
{
if (bootstrapped)
if (initialized)
{
return;
}
try
{
CODebugBase<LogChannel>.verbose = true;
CODebugBase<LogChannel>.EnableChannels(LogChannel.All);

InitModTools(SimulationManager.UpdateMode.Undefined);

RedirectionHelper.RedirectCalls(
typeof(LoadingWrapper).GetMethod("OnLevelLoaded", new[] { typeof(SimulationManager.UpdateMode) }),
typeof(IsolatedFailures).GetMethod("OnLevelLoaded", new[] { typeof(SimulationManager.UpdateMode) }));
bootstrapped = true;
if (!bootstrapped)
{
CODebugBase<LogChannel>.verbose = true;
CODebugBase<LogChannel>.EnableChannels(LogChannel.All);
RedirectionHelper.RedirectCalls(
typeof(LoadingWrapper).GetMethod("OnLevelLoaded", new[] { typeof(SimulationManager.UpdateMode) }),
typeof(IsolatedFailures).GetMethod("OnLevelLoaded", new[] { typeof(SimulationManager.UpdateMode) }));
bootstrapped = true;
}
if (inMainMenu)
{
InitModTools(SimulationManager.UpdateMode.Undefined);
}
initialized = true;
}
catch (Exception ex)
{
Expand Down Expand Up @@ -94,8 +101,15 @@ public string Description

public override void OnLevelLoaded(LoadMode mode)
{
ModToolsBootstrap.inMainMenu = false;
ModToolsBootstrap.InitModTools((SimulationManager.UpdateMode)mode);
}

public override void OnLevelUnloading()
{
ModToolsBootstrap.initialized = false;
ModToolsBootstrap.inMainMenu = true;
}
}

}

0 comments on commit d4374ef

Please sign in to comment.