Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of NewRestartMod v1.0.2
NewRestartMod.dll
Decompiled 4 hours agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using Unity.Netcode; using UnityEngine; using UnityEngine.InputSystem; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: AssemblyCompany("NewRestartMod")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("NewRestartMod")] [assembly: AssemblyTitle("NewRestartMod")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace NewRestartMod { [BepInPlugin("thebukaro.newrestartmod", "NewRestartMod", "1.0.0")] public class Plugin : BaseUnityPlugin { public static bool verifying; private Harmony harmony; private static MethodInfo chatMethod; public static ManualLogSource Log; private void Awake() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; harmony = new Harmony("thebukaro.newrestartmod"); harmony.PatchAll(); chatMethod = AccessTools.Method(typeof(HUDManager), "AddChatMessage", (Type[])null, (Type[])null); Log.LogInfo((object)"NewRestartMod loaded!"); } public static void SendChatMessage(string message) { chatMethod?.Invoke(HUDManager.Instance, new object[4] { message, "", -1, false }); HUDManager.Instance.lastChatMessage = ""; } public static void ConfirmRestart() { verifying = true; SendChatMessage("Are you sure? Type CONFIRM or DENY."); } public static void AcceptRestart(StartOfRound manager) { SendChatMessage("Restart confirmed."); verifying = false; int[] array = new int[4] { manager.gameStats.daysSpent, manager.gameStats.scrapValueCollected, manager.gameStats.deaths, manager.gameStats.allStepsTaken }; manager.FirePlayersAfterDeadlineClientRpc(array, false); } public static void DeclineRestart() { SendChatMessage("Restart cancelled."); verifying = false; } } } namespace NewRestartMod.Patches { [HarmonyPatch(typeof(HUDManager), "SubmitChat_performed")] public class ChatCommandPatch { private static bool Prefix(HUDManager __instance, ref CallbackContext context) { if (!((CallbackContext)(ref context)).performed) { return true; } if (string.IsNullOrEmpty(__instance.chatTextField.text)) { return true; } string text = __instance.chatTextField.text.Trim(); PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController; if (text.Equals("/restart", StringComparison.OrdinalIgnoreCase)) { if ((Object)(object)val == (Object)null) { return true; } if (!((NetworkBehaviour)val).IsHost) { Plugin.SendChatMessage("Only the host can initiate a restart."); CloseChatInput(__instance); return false; } if (!StartOfRound.Instance.inShipPhase) { Plugin.SendChatMessage("The ship must be in orbit to restart."); CloseChatInput(__instance); return false; } Plugin.ConfirmRestart(); CloseChatInput(__instance); return false; } if (Plugin.verifying) { if (text.Equals("CONFIRM", StringComparison.OrdinalIgnoreCase)) { Plugin.AcceptRestart(StartOfRound.Instance); CloseChatInput(__instance); return false; } if (text.Equals("DENY", StringComparison.OrdinalIgnoreCase)) { Plugin.DeclineRestart(); CloseChatInput(__instance); return false; } } return true; } private static void CloseChatInput(HUDManager instance) { instance.chatTextField.text = ""; instance.chatTextField.ReleaseSelection(); instance.chatTextField.DeactivateInputField(false); } } } namespace RestartMod { public class Class1 { } public static class MyPluginInfo { public const string PLUGIN_GUID = "NewRestartMod"; public const string PLUGIN_NAME = "NewRestartMod"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }