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 WindMasterRing v1.0.0
WindMasterRing.dll
Decompiled 2 weeks agousing System; using System.Collections.Generic; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using HarmonyLib; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyVersion("0.0.0.0")] namespace WindMasterRing; [NetworkCompatibility(/*Could not decode attribute arguments.*/)] [BepInPlugin("nico.valheim.windmasterring", "Wind Master Ring", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class WindMasterRingPlugin : BaseUnityPlugin { public const string PluginGuid = "nico.valheim.windmasterring"; public const string PluginName = "Wind Master Ring"; public const string PluginVersion = "1.0.0"; public const string PrefabName = "WindMasterRing"; private Harmony _harmony; private void Awake() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown PrefabManager.OnVanillaPrefabsAvailable += OnVanillaPrefabsAvailable; _harmony = new Harmony("nico.valheim.windmasterring"); _harmony.PatchAll(Assembly.GetExecutingAssembly()); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Wind Master Ring 1.0.0 charge; attente des prefabs vanilla."); } private void OnVanillaPrefabsAvailable() { PrefabManager.OnVanillaPrefabsAvailable -= OnVanillaPrefabsAvailable; try { RegisterRing(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Wind Master Ring and recipe registered successfully."); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Error while registering Wind Master Ring: " + ex)); } } private void OnDestroy() { PrefabManager.OnVanillaPrefabsAvailable -= OnVanillaPrefabsAvailable; if (_harmony != null) { _harmony.UnpatchSelf(); } } private void RegisterRing() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Expected O, but got Unknown //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Expected O, but got Unknown Sprite icon = LoadEmbeddedSprite("WindMasterRing.assets.WindMasterRing.png"); ItemConfig val = new ItemConfig(); val.Name = "Wind Master Ring"; val.Description = "A ring fashioned from sea serpent scales and set with a magical pearl. Its wearer stays dry and commands favorable winds at sea."; val.CraftingStation = "piece_workbench"; val.MinStationLevel = 3; val.Amount = 1; val.Icon = icon; val.AddRequirement("TrophyDragonQueen", 1, 0); val.AddRequirement("AmberPearl", 1, 0); val.AddRequirement("SerpentScale", 4, 0); CustomItem val2 = new CustomItem("WindMasterRing", "AmberPearl", val); if (val2 == null) { throw new Exception("CustomItem est null apres clonage de AmberPearl."); } if ((Object)(object)val2.ItemDrop == (Object)null) { throw new Exception("ItemDrop est null apres clonage de AmberPearl."); } if (val2.ItemDrop.m_itemData == null) { throw new Exception("m_itemData est null apres clonage de AmberPearl."); } if (val2.ItemDrop.m_itemData.m_shared == null) { throw new Exception("m_shared est null apres clonage de AmberPearl."); } val2.ItemDrop.m_itemData.m_shared.m_itemType = (ItemType)18; val2.ItemDrop.m_itemData.m_shared.m_weight = 0.1f; val2.ItemDrop.m_itemData.m_shared.m_maxStackSize = 1; StatusEffect val3 = ScriptableObject.CreateInstance<StatusEffect>(); ((Object)val3).name = "SE_WindMasterRing"; val3.m_name = "Wind Master Ring"; val3.m_tooltip = "Waterproof: immune to Wet effect.\nDragon Queen's Last Breath: the wind is always at your back when you sail."; val3.m_icon = icon; CustomStatusEffect val4 = new CustomStatusEffect(val3, false); ItemManager.Instance.AddStatusEffect(val4); val2.ItemDrop.m_itemData.m_shared.m_equipStatusEffect = val4.StatusEffect; ItemManager.Instance.AddItem(val2); } private static Sprite LoadEmbeddedSprite(string resourceName) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) Assembly executingAssembly = Assembly.GetExecutingAssembly(); using Stream stream = executingAssembly.GetManifestResourceStream(resourceName); if (stream == null) { throw new FileNotFoundException("Ressource icone introuvable: " + resourceName); } byte[] array = new byte[stream.Length]; stream.Read(array, 0, array.Length); Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); ((Object)val).name = "WindMasterRing_Icon"; if (!ImageConversion.LoadImage(val, array, false)) { throw new Exception("Impossible de charger l'icone PNG."); } ((Texture)val).wrapMode = (TextureWrapMode)1; return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f); } public static bool IsRingEquipped(Player player) { if ((Object)(object)player == (Object)null) { return false; } Inventory inventory = ((Humanoid)player).GetInventory(); if (inventory == null) { return false; } List<ItemData> equippedItems = inventory.GetEquippedItems(); for (int i = 0; i < equippedItems.Count; i++) { ItemData val = equippedItems[i]; if (val != null && (Object)(object)val.m_dropPrefab != (Object)null && ((Object)val.m_dropPrefab).name == "WindMasterRing") { return true; } } return false; } } [HarmonyPatch(typeof(Player), "UpdateEnvStatusEffects")] internal static class RemoveExistingWetPatch { private static void Postfix(Player __instance) { if (WindMasterRingPlugin.IsRingEquipped(__instance)) { SEMan sEMan = ((Character)__instance).GetSEMan(); if (sEMan.HaveStatusEffect(SEMan.s_statusEffectWet)) { sEMan.RemoveStatusEffect(SEMan.s_statusEffectWet, true); } } } } [HarmonyPatch(typeof(EnvMan), "GetWindDir")] internal static class TailwindPatch { private static void Postfix(ref Vector3 __result) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || !WindMasterRingPlugin.IsRingEquipped(localPlayer)) { return; } Ship val = localPlayer.GetControlledShip(); if ((Object)(object)val == (Object)null) { val = ((Character)localPlayer).GetStandingOnShip(); } if (!((Object)(object)val == (Object)null)) { Vector3 forward = ((Component)val).transform.forward; forward.y = 0f; if (((Vector3)(ref forward)).sqrMagnitude > 0.0001f) { float num = Mathf.Sin(Time.time * 0.12f) * 20f + Mathf.Sin(Time.time * 0.047f) * 10f; __result = Quaternion.Euler(0f, num, 0f) * ((Vector3)(ref forward)).normalized; } } } }