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 mIsTaJoEyS Clown Horn v1.3.0
BuyableClownHorn/BuyableClownHorn.dll
Decompiled 5 months agousing System; using System.Collections.Generic; 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 BuyableClownHorn.Patches; using GameNetcodeStuff; using HarmonyLib; using LethalLib.Modules; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("BuyableClownHorn")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("BuyableClownHorn")] [assembly: AssemblyCopyright("Copyright © 2025")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("1201aa77-71cd-462e-9101-0aab45cb0246")] [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 BuyableClownHorn { [BepInPlugin("mIsTaJoEy.BuyableClownHorn", "Buyable Clown Horn in Terminal", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public class ClonedItem : Item { public Item original; } public const string modGUID = "mIsTaJoEy.BuyableClownHorn"; public const string modName = "Buyable Clown Horn in Terminal"; public const string modVersion = "1.0.0"; private readonly Harmony harmony = new Harmony("mIsTaJoEy.BuyableClownHorn"); private static Plugin Instance; internal static ManualLogSource mls; public static bool sentWarning = false; public static bool detonated = false; public static float detonateTimer = 3f; public static bool hasPickedUp = false; public static GameObject landmine = null; public static List<Item> AllItems => Resources.FindObjectsOfTypeAll<Item>().Reverse().ToList(); public static Landmine Landmine { get { List<Landmine> list = Resources.FindObjectsOfTypeAll<Landmine>().Reverse().ToList(); if (list.Count > 0) { return list[0]; } return null; } } public static Item ClownHorn => ((IEnumerable<Item>)AllItems).FirstOrDefault((Func<Item, bool>)((Item item) => ((Object)item).name.Equals("ClownHorn") && (Object)(object)item.spawnPrefab != (Object)null)); public static ClonedItem ClownHornClone { get; set; } private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } mls = Logger.CreateLogSource("mIsTaJoEy.BuyableClownHorn"); mls.LogInfo((object)"BuyableClownHorn has loaded successfully!"); mls.LogInfo((object)"Applying Harmony patches..."); try { harmony.PatchAll(typeof(PlayerControllerBPatch)); harmony.PatchAll(typeof(GameNetworkManagerPatch)); harmony.PatchAll(typeof(StartOfRoundPatch)); mls.LogInfo((object)"All Harmony patches applied successfully!"); } catch (Exception arg) { mls.LogError((object)$"Failed to apply patches: {arg}"); } } public static void ResetMine() { sentWarning = false; detonated = false; detonateTimer = 3f; if ((Object)(object)landmine != (Object)null) { Object.Destroy((Object)(object)landmine); landmine = null; } mls.LogInfo((object)"Mine Reset."); } } } namespace BuyableClownHorn.Patches { [HarmonyPatch(typeof(PlayerControllerB))] internal class PlayerControllerBPatch { [HarmonyPatch("Update")] [HarmonyPostfix] private static void GrabPatch(PlayerControllerB __instance) { //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) GrabbableObject currentlyHeldObjectServer = __instance.currentlyHeldObjectServer; if (__instance.playerUsername != "mIsTaJoEy" && !Plugin.sentWarning && (Object)(object)currentlyHeldObjectServer != (Object)null && ((Object)currentlyHeldObjectServer.itemProperties).name == "BuyableClownHorn") { HUDManager.Instance.DisplayTip("Warning:", "Fingerprint identification unsuccessful. You are not mIsTaJoEy. You have moments left to live.", true, false, "LC_Tip1"); Plugin.sentWarning = true; } if (Plugin.detonated || Plugin.sentWarning) { __instance.sprintMeter = 0f; } if (!Plugin.sentWarning || Plugin.detonated) { return; } if (Plugin.detonateTimer > 0f) { Plugin.detonateTimer -= Time.deltaTime; return; } Plugin.landmine = Object.Instantiate<GameObject>(((Component)Plugin.Landmine).gameObject, ((Component)__instance).transform.position, Quaternion.Euler(-90f, 0f, 0f)); HideMine(Plugin.landmine); Plugin.detonated = true; MethodInfo method = typeof(Landmine).GetMethod("OnTriggerExit", BindingFlags.Instance | BindingFlags.NonPublic); if (method != null) { Collider component = ((Component)__instance).GetComponent<Collider>(); method.Invoke(Plugin.landmine.GetComponent<Landmine>(), new object[1] { component }); Plugin.mls.LogInfo((object)"Successfully triggered OnTriggerExit via reflection"); } else { Plugin.mls.LogError((object)"Could not find OnTriggerExit method"); } } [HarmonyPatch("Start")] [HarmonyPostfix] private static void StartPatch(PlayerControllerB __instance) { Plugin.ResetMine(); } [HarmonyPatch("KillPlayer")] [HarmonyPostfix] private static void KillPatch() { Plugin.ResetMine(); } private static void HideMine(GameObject landmine) { Renderer[] componentsInChildren = landmine.GetComponentsInChildren<Renderer>(true); Renderer[] array = componentsInChildren; foreach (Renderer val in array) { Object.Destroy((Object)(object)val); } MeshFilter[] componentsInChildren2 = landmine.GetComponentsInChildren<MeshFilter>(true); MeshFilter[] array2 = componentsInChildren2; foreach (MeshFilter val2 in array2) { Object.Destroy((Object)(object)val2); } SkinnedMeshRenderer[] componentsInChildren3 = landmine.GetComponentsInChildren<SkinnedMeshRenderer>(true); SkinnedMeshRenderer[] array3 = componentsInChildren3; foreach (SkinnedMeshRenderer val3 in array3) { Object.Destroy((Object)(object)val3); } } } [HarmonyPatch(typeof(GameNetworkManager))] internal class GameNetworkManagerPatch { internal class Unflagger : MonoBehaviour { public void Awake() { ((Object)((Component)this).gameObject).hideFlags = (HideFlags)0; } } private static Dictionary<string, TerminalNode> infoNodes = new Dictionary<string, TerminalNode>(); [HarmonyPatch("Start")] [HarmonyPostfix] private static void StartPatch(GameNetworkManager __instance) { Plugin.mls.LogInfo((object)"GameNetworkManager Start"); Item clownHorn = Plugin.ClownHorn; if ((Object)(object)clownHorn != (Object)null) { if ((Object)(object)Plugin.ClownHornClone == (Object)null) { Plugin.ClownHornClone = CloneScrapToBuyable(clownHorn, 5); ((Item)Plugin.ClownHornClone).itemName = "mIsTaJoEy'S Clown Horn"; } TerminalNode val = null; TerminalNode val2 = null; Items.RegisterShopItem((Item)(object)Plugin.ClownHornClone, val, val2, CreateInfoNode("Clown Horn", "[ H O N K ]"), ((Item)Plugin.ClownHornClone).creditsWorth); Plugin.mls.LogInfo((object)"Clown horn successfully registered as purchasable item!"); } else { Plugin.mls.LogError((object)"Could not find clown horn item in game assets!"); } } private static Plugin.ClonedItem CloneScrapToBuyable(Item original, int price) { Plugin.ClonedItem clonedItem = ScriptableObject.CreateInstance<Plugin.ClonedItem>(); Object.DontDestroyOnLoad((Object)(object)clonedItem); clonedItem.original = original; GameObject val = NetworkPrefabs.CloneNetworkPrefab(original.spawnPrefab, "Buyable" + ((Object)original).name); val.AddComponent<Unflagger>(); Object.DontDestroyOnLoad((Object)(object)val); CopyFields(original, (Item)(object)clonedItem); val.GetComponent<GrabbableObject>().itemProperties = (Item)(object)clonedItem; ((Item)clonedItem).spawnPrefab = val; ((Object)clonedItem).name = "Buyable" + ((Object)original).name; ((Item)clonedItem).creditsWorth = price; ((Item)clonedItem).isScrap = false; return clonedItem; } public static void CopyFields(Item source, Item destination) { FieldInfo[] fields = typeof(Item).GetFields(); FieldInfo[] array = fields; foreach (FieldInfo fieldInfo in array) { fieldInfo.SetValue(destination, fieldInfo.GetValue(source)); } } private static TerminalNode CreateInfoNode(string name, string description) { if (infoNodes.ContainsKey(name)) { return infoNodes[name]; } TerminalNode val = ScriptableObject.CreateInstance<TerminalNode>(); val.clearPreviousText = true; ((Object)val).name = name + "InfoNode"; val.displayText = description + "\n\n"; infoNodes.Add(name, val); return val; } } [HarmonyPatch(typeof(StartOfRound))] internal class StartOfRoundPatch { [HarmonyPatch("Awake")] [HarmonyPostfix] private static void AwakePatch(PlayerControllerB __instance) { Plugin.ResetMine(); } } }