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 SwimGear v0.1.0
SwimGear.dll
Decompiled 6 hours agousing System; using System.Collections.Generic; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyVersion("0.0.0.0")] namespace SwimGear; [BepInPlugin("j1ga.swimgear", "SwimGear", "0.1.0")] public class SwimGearPlugin : BaseUnityPlugin { [HarmonyPatch(typeof(Character), "IsSwimming")] private static class Character_IsSwimming_Patch { private static bool Prefix(Character __instance, ref bool __result) { if ((Object)(object)_inside == (Object)null || !object.ReferenceEquals(_inside, __instance)) { return true; } __result = false; return false; } } [HarmonyPatch(typeof(Humanoid), "UpdateEquipment")] private static class Humanoid_UpdateEquipment_Patch { private static void Prefix(Humanoid __instance, ItemData ___m_rightItem, ItemData ___m_leftItem, out Character __state) { __state = _inside; if (_enabled.Value && ((Character)__instance).IsPlayer() && !Denied(___m_rightItem) && !Denied(___m_leftItem)) { _inside = (Character)(object)__instance; } } private static Exception Finalizer(Exception __exception, Character __state) { _inside = __state; return __exception; } } [HarmonyPatch(typeof(Humanoid), "EquipItem")] private static class Humanoid_EquipItem_Patch { private static void Prefix(Humanoid __instance, ItemData item, out Character __state) { __state = _inside; if (_enabled.Value && ((Character)__instance).IsPlayer() && !Denied(item)) { _inside = (Character)(object)__instance; } } private static Exception Finalizer(Exception __exception, Character __state) { _inside = __state; return __exception; } } public const string Guid = "j1ga.swimgear"; public const string Name = "SwimGear"; public const string Version = "0.1.0"; private static Character _inside; private static ConfigEntry<bool> _enabled; private static ConfigEntry<string> _deniedTypes; private static ConfigEntry<string> _deniedItems; private static readonly HashSet<ItemType> _types = new HashSet<ItemType>(); private static readonly HashSet<string> _items = new HashSet<string>(StringComparer.OrdinalIgnoreCase); private Harmony _harmony; private void Awake() { //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Expected O, but got Unknown _enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("01 General", "Enabled", true, "Off: the game takes your gear away in the water as usual."); _deniedTypes = ((BaseUnityPlugin)this).Config.Bind<string>("02 Not in water", "ItemTypes", "", "Kinds of items that stay vanilla in the water (put away, cannot be equipped), comma separated: OneHandedWeapon, TwoHandedWeapon, TwoHandedWeaponLeft, Bow, Shield, Torch, Tool. Empty: everything can be used."); _deniedItems = ((BaseUnityPlugin)this).Config.Bind<string>("02 Not in water", "Items", "", "Single items that stay vanilla in the water, by prefab name, comma separated. Example: Tankard,FishingRod"); _deniedTypes.SettingChanged += delegate { ReadLists(); }; _deniedItems.SettingChanged += delegate { ReadLists(); }; ReadLists(); _harmony = new Harmony("j1ga.swimgear"); _harmony.PatchAll(typeof(SwimGearPlugin).Assembly); ((BaseUnityPlugin)this).Logger.LogInfo((object)"SwimGear 0.1.0 loaded."); } private void OnDestroy() { if (_harmony != null) { _harmony.UnpatchSelf(); } } private void ReadLists() { //IL_0074: Unknown result type (might be due to invalid IL or missing references) _types.Clear(); _items.Clear(); string[] array = (_deniedTypes.Value ?? "").Split(',', ';'); foreach (string text in array) { string text2 = text.Trim(); if (text2.Length != 0) { try { _types.Add((ItemType)Enum.Parse(typeof(ItemType), text2, ignoreCase: true)); } catch (Exception) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Unknown item type '" + text2 + "' in ItemTypes; ignored.")); } } } string[] array2 = (_deniedItems.Value ?? "").Split(',', ';'); foreach (string text3 in array2) { string text4 = text3.Trim(); if (text4.Length > 0) { _items.Add(text4); } } } private static bool Denied(ItemData item) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) if (item == null || item.m_shared == null) { return false; } if (_types.Count > 0 && _types.Contains(item.m_shared.m_itemType)) { return true; } if (_items.Count > 0 && (Object)(object)item.m_dropPrefab != (Object)null && _items.Contains(((Object)item.m_dropPrefab).name)) { return true; } return false; } }