Please disclose if your mod was created primarily 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 LCImposterMod v0.0.1
LCImposterMod.dll
Decompiled 2 years agousing System; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using HarmonyLib; using LCImposterMod.Patches; using LethalNetworkAPI; using TMPro; using TerminalApi; using TerminalApi.Classes; using Unity.Netcode; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("LCImposterMod")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("LCImposterMod")] [assembly: AssemblyCopyright("Copyright © 2024")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("1c4b7453-27c2-4340-82b7-07157e4815c6")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] namespace LCImposterMod { [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("NecronWasTaken.LCImposterMod", "LC Imposter Mod", "0.0.1")] public class ImposterModBase : BaseUnityPlugin { private const string modGUID = "NecronWasTaken.LCImposterMod"; private const string modName = "LC Imposter Mod"; private const string modVersion = "0.0.1"; private const string modAuthor = "NecronWasTaken"; private readonly Harmony harmony = new Harmony("NecronWasTaken.LCImposterMod"); private static ImposterModBase Instance; internal static ManualLogSource mls; private void Awake() { //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Expected O, but got Unknown if ((Object)(object)Instance == (Object)null) { Instance = this; } mls = Logger.CreateLogSource("NecronWasTaken.LCImposterMod"); harmony.PatchAll(typeof(ImposterModBase)); harmony.PatchAll(typeof(MainPatch)); TerminalKeyword val = TerminalApi.CreateTerminalKeyword("imposter", true, (TerminalNode)null); TerminalKeyword val2 = TerminalApi.CreateTerminalKeyword("chance", false, (TerminalNode)null); TerminalKeyword val3 = TerminalApi.CreateTerminalKeyword("nickname", false, (TerminalNode)null); TerminalKeyword val4 = TerminalApi.CreateTerminalKeyword("status", false, (TerminalNode)null); TerminalKeyword val5 = TerminalApi.CreateTerminalKeyword("enable", false, (TerminalNode)null); TerminalKeyword val6 = TerminalApi.CreateTerminalKeyword("disable", false, (TerminalNode)null); TerminalKeyword val7 = TerminalApi.CreateTerminalKeyword("reset", false, (TerminalNode)null); TerminalNode val8 = TerminalApi.CreateTerminalNode("Something went wrong, I suppose...", true, ""); val = TerminalExtenstionMethods.AddCompatibleNoun(val, val2, val8); val = TerminalExtenstionMethods.AddCompatibleNoun(val, val3, val8); val = TerminalExtenstionMethods.AddCompatibleNoun(val, val4, val8); val = TerminalExtenstionMethods.AddCompatibleNoun(val, val5, val8); val = TerminalExtenstionMethods.AddCompatibleNoun(val, val6, val8); val = TerminalExtenstionMethods.AddCompatibleNoun(val, val7, val8); TerminalApi.AddTerminalKeyword(val); TerminalApi.AddTerminalKeyword(val2); TerminalApi.AddTerminalKeyword(val3); TerminalApi.AddTerminalKeyword(val5); TerminalApi.AddTerminalKeyword(val6); TerminalApi.AddTerminalKeyword(val7); CommandInfo val9 = new CommandInfo(); val9.TriggerNode = val8; val9.Category = "other"; val9.Description = "Set an imposter mode settings."; val9.DisplayTextSupplier = MainPatch.SetImposterSettings; TerminalApi.AddTerminalKeyword(val4, val9); } } } namespace LCImposterMod.Patches { [HarmonyPatch] public class MainPatch : NetworkBehaviour { private static string nickname = "imposter"; private static int spawnChance = 30; private static bool isRoundStarted = false; private static TextMeshProUGUI _roleText; private static readonly LethalServerMessage<string> customServerMessage = new LethalServerMessage<string>("role", (Action<string, ulong>)ReceiveByServer); private static readonly LethalClientMessage<string> customClientMessage = new LethalClientMessage<string>("role", (Action<string>)ReceiveFromServer, (Action<string, ulong>)null); [HarmonyPatch(typeof(HUDManager), "Start")] [HarmonyPostfix] private static void StartHudPatch(ref HUDManager __instance) { if (!Object.op_Implicit((Object)(object)_roleText)) { AddRoleToHUD(__instance); } } [HarmonyPatch(typeof(StartOfRound), "StartGame")] [HarmonyPostfix] private static void StartGamePatch(ref StartOfRound __instance) { int count = __instance.ClientPlayerList.Count; ulong[] array = __instance.ClientPlayerList.Keys.ToArray(); int num = Random.Range(0, 100); if (num < spawnChance) { num = Random.Range(0, count); customServerMessage.SendClient(nickname, (ulong)num); } isRoundStarted = true; } [HarmonyPatch(typeof(StartOfRound), "EndOfGame")] [HarmonyPostfix] private static void EndOfGamePatch(ref StartOfRound __instance) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) ((TMP_Text)_roleText).text = "crewmate"; ((Graphic)_roleText).color = Color.white; isRoundStarted = false; } private static void AddRoleToHUD(HUDManager __instance) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_003f: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("RoleHUDDisplay"); val.AddComponent<RectTransform>(); TextMeshProUGUI val2 = val.AddComponent<TextMeshProUGUI>(); RectTransform rectTransform = ((TMP_Text)val2).rectTransform; ((Transform)rectTransform).SetParent(((Component)__instance.PTTIcon).transform, false); rectTransform.anchoredPosition = new Vector2(0f, -5f); ((TMP_Text)val2).font = ((TMP_Text)__instance.controlTipLines[0]).font; ((TMP_Text)val2).fontSize = 12f; ((TMP_Text)val2).text = "crewmate"; ((TMP_Text)val2).overflowMode = (TextOverflowModes)0; ((Behaviour)val2).enabled = true; _roleText = val2; } private static void ReceiveByServer(string data, ulong id) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) ((TMP_Text)_roleText).text = data; ((Graphic)_roleText).color = Color.red; } private static void ReceiveFromServer(string data) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) ((TMP_Text)_roleText).text = data; ((Graphic)_roleText).color = Color.red; } private static void ResetSettings() { nickname = "imposter"; spawnChance = 30; ((Behaviour)_roleText).enabled = true; } public static string SetImposterSettings() { if (!((NetworkBehaviour)StartOfRound.Instance).IsServer) { return "Only lobby owner can use these commands.\n"; } string terminalInput = TerminalApi.GetTerminalInput(); string[] array = terminalInput.Split(' ', '\u0001'); if (array[1] == "status") { return $"Enabled: {((Behaviour)_roleText).enabled}\nNickname: {nickname}\nSpawn chance: {spawnChance}%\n"; } if (isRoundStarted) { return "You can't change mod settings during the round.\n"; } try { switch (array[1]) { case "enable": ((Behaviour)_roleText).enabled = true; return "Imposter mod enabled.\n"; case "disable": ((Behaviour)_roleText).enabled = false; return "Imposter mod disabled.\n"; case "reset": ResetSettings(); return "Imposter mod settings are reset to default.\n"; case "nickname": nickname = array[2]; return "Imposter nickname are set to: '" + nickname + "'\n"; case "chance": { int num = int.Parse(array[2]); if (num < 0 || num > 100) { return "Invalid spawn chance value (0-100).\n"; } spawnChance = num; return "Imposter spawn chance are set to: " + array[2] + "%\n"; } default: return "Something went wrong?\n"; } } catch (FormatException) { return "Invalid input format.\n"; } } } }