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 Vanilla Belt Bag v1.0.2
plugins/4902-Vanilla_Belt_Bag.dll
Decompiled a year agousing System.Collections.Generic; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Unity.Netcode; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyVersion("0.0.0.0")] namespace cake; [BepInPlugin("4902.Vanilla_Belt_Bag", "Vanilla_Belt_Bag", "1.0.0")] public class v : BaseUnityPlugin { public static readonly Harmony harmony = new Harmony("4902.Vanilla_Belt_Bag"); public static ManualLogSource mls; public static ConfigEntry<int> cfg_display; public static ConfigEntry<float> cfg_delay; public static ConfigEntry<string> cfg_text1; public static ConfigEntry<string> cfg_text2; private void Awake() { cfg_display = ((BaseUnityPlugin)this).Config.Bind<int>("Vanilla", "display", 0, "[Display]\ndetermines what text display tips are shown.\n0 = both disabled.\n1 = display text 1 only.\n2 = display text 2 only.\n3 = both enabled."); cfg_delay = ((BaseUnityPlugin)this).Config.Bind<float>("Vanilla", "seconds", 3f, "[Display cooldown]\ncooldown in seconds for the display text being displayed."); cfg_text1 = ((BaseUnityPlugin)this).Config.Bind<string>("Vanilla", "text1", "they tried to put scrap!!!", "[Display text 1]\ndisplayed when scrap is prevented from being collected with a belt bag. scrap being collected with a belt bag is only prevented while you're the host."); cfg_text2 = ((BaseUnityPlugin)this).Config.Bind<string>("Vanilla", "text2", "they put scrap!!!", "[Display text 2]\ndisplayed when scrap is collected with a belt bag, regardless of if you're host or client."); mls = Logger.CreateLogSource("Vanilla"); mls.LogInfo((object)"Vanilla belt bag loaded!"); harmony.PatchAll(typeof(vanilla)); } } public class vanilla { private static float last = 0f; [HarmonyTranspiler] [HarmonyPatch(typeof(BeltBagItem), "TryAddObjectToBagServerRpc")] private static IEnumerable<CodeInstruction> trn1(IEnumerable<CodeInstruction> Instrs) { List<CodeInstruction> i = new List<CodeInstruction>(Instrs); for (int j = 0; j < i.Count; j++) { yield return i[j]; if (((object)i[j]).ToString() == "call bool Unity.Netcode.NetworkObjectReference::TryGet(Unity.Netcode.NetworkObject& networkObject, Unity.Netcode.NetworkManager networkManager)") { yield return new CodeInstruction(OpCodes.Ldloc_0, (object)null); yield return new CodeInstruction(OpCodes.Ldarg_2, (object)null); yield return new CodeInstruction(OpCodes.Call, (object)typeof(vanilla).GetMethod("return_bool")); } } } public static bool return_bool(bool r, NetworkObject no, int player) { if ((Object)(object)no != (Object)null) { GrabbableObject component = ((Component)no).GetComponent<GrabbableObject>(); if ((Object)(object)component != (Object)null && (Object)(object)component.itemProperties != (Object)null && component.itemProperties.isScrap) { if (v.cfg_display.Value == 1 || v.cfg_display.Value == 3) { display_warning(tried: true, v.cfg_text1.Value, player); } return false; } } return r; } [HarmonyPatch(typeof(BeltBagItem), "TryAddObjectToBagClientRpc")] [HarmonyPostfix] private static void pst1(ref NetworkObjectReference netObjectRef, ref int playerWhoAdded) { NetworkObject val = default(NetworkObject); if ((v.cfg_display.Value == 2 || v.cfg_display.Value == 3) && ((NetworkObjectReference)(ref netObjectRef)).TryGet(ref val, (NetworkManager)null)) { GrabbableObject component = ((Component)val).GetComponent<GrabbableObject>(); if ((Object)(object)component != (Object)null && (Object)(object)component.itemProperties != (Object)null && component.itemProperties.isScrap) { display_warning(tried: false, v.cfg_text2.Value, playerWhoAdded); } } } private static void display_warning(bool tried = true, string text = "temp", int player = 0) { if (Time.realtimeSinceStartup > last) { last = Time.realtimeSinceStartup + v.cfg_delay.Value; if ((Object)(object)StartOfRound.Instance != (Object)null && StartOfRound.Instance.allPlayerScripts.Length > player && (Object)(object)StartOfRound.Instance.allPlayerScripts[player] != (Object)null && (Object)(object)HUDManager.Instance != (Object)null) { string playerUsername = StartOfRound.Instance.allPlayerScripts[player].playerUsername; v.mls.LogInfo((object)("player " + playerUsername + (tried ? " tried collecting" : " collected") + " scrap!!")); HUDManager.Instance.DisplayTip(text, playerUsername, true, false, "LC_Tip1"); } } } [HarmonyPatch(typeof(BeltBagItem), "TryAddObjectToBag")] [HarmonyPrefix] private static bool pre1(ref GrabbableObject gObject) { if ((Object)(object)gObject != (Object)null && (Object)(object)gObject.itemProperties != (Object)null && gObject.itemProperties.isScrap) { return false; } return true; } }