/// <summary> /// Sets up Mod-Mot in general, called on game start /// </summary> public static void OnStartUp() { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); ErrorChanger.ChangeError(); // Change error message so that crashes are sent to us and/or the developers of any mods installed instead of the actual game developers if (!Directory.Exists(AssetLoader.GetModsFolderDirectory())) // If the mods folder does not exist, something probably went wrong during installation { throw new DirectoryNotFoundException("Mods folder not found!"); } GameObject gameFlowManager = GameFlowManager.Instance.gameObject; gameFlowManager.AddComponent <UpdateChecker>(); // Checks for new Mod-Bot versions gameFlowManager.AddComponent <ModsPanelManager>(); // Adds the mods button in the main menu and pause screen gameFlowManager.AddComponent <CustomUpgradeManager>(); // Handles modded upgrades gameFlowManager.AddComponent <UpgradeIconDownloader>(); // Downloads images from a URL to be used as an upgrade icon gameFlowManager.AddComponent <ModdedMultiplayerEventListener>(); // Recieves all multiplayer events and sends them to any mods that has configured to recieve them gameFlowManager.AddComponent <ModSharingManager>(); // Handles sharing of mods to all clients on the same server gameFlowManager.AddComponent <ModBotUserIdentifier>(); // Keeps track of what users are currently using Mod-Bot gameFlowManager.AddComponent <UpgradeAngleSetter>(); // Handles setting upgrade angles while in-game gameFlowManager.AddComponent <DebugLineDrawingManager>(); // Handles drawing lines on screen try // If an exception is thrown here, the crash screen wont appear, so we have to implement our own { initilizeUI(); // Initialize all custom UI ModsManager modsManager = gameFlowManager.AddComponent <ModsManager>(); modsManager.Initialize(); // Loads all mods in the mods folder } catch (Exception e) { debug.Log(e.Message + "\n" + e.StackTrace, Color.red); Logger.Instance.Animator.Play("hideConsole"); } GlobalEventManager.Instance.AddEventListener(GlobalEvents.UpgradesRefreshed, new Action <FirstPersonMover>(PassOnToModsManager.AfterUpgradesRefreshed)); GlobalEventManager.Instance.AddEventListener(GlobalEvents.LevelEditorStarted, new Action(ModsManager.Instance.PassOnMod.OnLevelEditorStarted)); IgnoreCrashesManager.Start(); ModBotHarmonyInjectionManager.TryInject(); stopwatch.Stop(); debug.Log("Initialized Mod-Bot in " + stopwatch.Elapsed.TotalSeconds + " seconds"); }
/// <summary> /// The same as <see cref="Mod.OnCommandRan(string)"/>, but called in Mod-Bot /// </summary> /// <param name="command"></param> public static void OnCommandRan(string command) { string[] subCommands = command.ToLower().Split(' '); if (subCommands[0] == "ignoreallcrashes") { if (subCommands.Length < 2) { debug.Log("Usage: ignoreallcrashes [1 - 0], [on - off], [true, false]"); return; } bool value; if (subCommands[1] == "1" || subCommands[1] == "on" || subCommands[1] == "true") { value = true; } else if (subCommands[1] == "0" || subCommands[1] == "off" || subCommands[1] == "false") { value = false; } else { debug.Log("Usage: ignoreallcrashes[1 - 0], [on - off], [true, false]"); return; } IgnoreCrashesManager.SetIsIgnoringCrashes(value); } if (subCommands[0] == "crash") { DelegateScheduler.Instance.Schedule(Crash, 1f); } if (subCommands[0] == "unittest") { if (subCommands.Length > 1) { bool foundUnitTest = ModBotUnitTestManager.TryRunUnitTest(subCommands[1]); if (!foundUnitTest) { debug.Log("Unit test failed: Unit test \"" + subCommands[1] + "\" not found", Color.red); return; } } ModBotUnitTestManager.RunAllUnitTests(); } if (subCommands[0] == "getplayfabids") { debug.Log("spawned players playfabids: "); List <FirstPersonMover> players = CharacterTracker.Instance.GetAllPlayers(); foreach (FirstPersonMover player in players) { string playfabID = player.state.PlayFabID; MultiplayerPlayerInfoManager.Instance.TryGetDisplayName(playfabID, delegate(string displayName) { if (displayName != null) { debug.Log(displayName + ": " + playfabID); } }); } } if (subCommands[0] == "redownloaddata") { StaticCoroutineRunner.StartStaticCoroutine(MultiplayerPlayerNameManager.DownloadDataFromFirebase()); debug.Log("redownloading data..."); } }
public static bool ErrorManager_HandleLog_Prefix() { return(!IgnoreCrashesManager.GetIsIgnoringCrashes()); }