public override void Execute(List <string> parameters, CommandSenderInfo senderInfo) { TelemetryTools.CollectEvent("command", "execute", GetCommands()[0]); try { if (parameters.Count == 0) { SdtdConsole.Instance.Output($"Patch for {CorpseDupe.PatchName} is {(PersistentData.Instance.PatchCorpseItemDupeExploit ? "ENABLED" : "DISABLED")}."); return; } if (parameters.Count == 1 || parameters.Count > 2) { throw new FriendlyMessageException(Resources.ErrorParameerCountNotValid); } var patchName = parameters[0]; string mode = parameters[1]; if (mode != "/on" && mode != "/off") { throw new FriendlyMessageException($"Wrong second parameter \"{parameters[1]}\". See help."); } switch (patchName) { case "corpse-dupe": if (mode == "/on") { if (PersistentData.Instance.PatchCorpseItemDupeExploit) { throw new FriendlyMessageException($"Patch for {CorpseDupe.PatchName} is already enabled."); } PersistentData.Instance.PatchCorpseItemDupeExploit = true; PatchTools.ApplyPatches(); PersistentData.Instance.Save(); // save after patching in case something crashes SdtdConsole.Instance.Output($"Patch for {CorpseDupe.PatchName} enabled."); } else if (mode == "/off") { if (!PersistentData.Instance.PatchCorpseItemDupeExploit) { throw new FriendlyMessageException($"Patch for {CorpseDupe.PatchName} is already disabled."); } PersistentData.Instance.PatchCorpseItemDupeExploit = false; PersistentData.Instance.Save(); SdtdConsole.Instance.Output($"Patch for {CorpseDupe.PatchName} disabled."); } break; default: throw new FriendlyMessageException($"Unknown patch name \"{patchName}\". See help."); } } catch (Exception ex) { CommandTools.HandleCommandException(ex); } }
private void UpdateAllEvents(bool isModeOn) { PersistentData.Instance.LogEvents = isModeOn ? new HashSet <ScriptEvent>(Enum.GetValues(typeof(ScriptEvent)).Cast <ScriptEvent>()) : new HashSet <ScriptEvent>(); PersistentData.Instance.Save(); PatchTools.ApplyPatches(); SdtdConsole.Instance.Output($"Logging for all events {(isModeOn ? "enabled" : "disabled")}."); }
/// <summary> /// Called during game start on every mod, before the World is ready (GameManager.Instance.World == null) /// </summary> public override void GameAwake() { try { Log.Debug("Api.GameAwake called."); Log.Out("Initializing phase 2/3 ..."); CommandTools.InitScripts(); PatchTools.ApplyPatches(); CommandTools.InitScriptsMonitoring(); CommandTools.InvokeScriptEvents(ScriptEvent.gameAwake, () => new ScriptEventArgs()); } catch (Exception ex) { CommandTools.HandleEventException(ex); } }