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 ShipExploration v1.2.1
ValheimShipExploration.dll
Decompiled a day agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("ValheimShipExploration")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("ValheimShipExploration")] [assembly: AssemblyCopyright("Copyright © 2022")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("8df91501-b191-47a1-a91c-571b1dd672ec")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyVersion("1.0.0.0")] namespace ValheimShipExploration; [BepInProcess("valheim.exe")] [BepInPlugin("GemHunter1.ShipExploration", "ShipExploration", "1.2.1")] public class ShipExploration : BaseUnityPlugin { [HarmonyPatch(typeof(Ship), "OnTriggerEnter")] private class ShipTriggerEnter { [HarmonyPostfix] public static void Postfix(ref Collider collider, ref Ship __instance) { if ((Object)(object)collider == (Object)null) { return; } Player component = ((Component)collider).GetComponent<Player>(); if (!((Object)(object)component != (Object)null) || !((Object)(object)component == (Object)(object)Player.m_localPlayer)) { return; } onBoat = true; string text = ((Object)((Component)__instance).gameObject).name.ToLower(); logger.LogMessage((object)("Ship.OnTriggerEnter, " + text)); foreach (KeyValuePair<string, ConfigEntry<float>> ship in ships) { if (text.Contains(ship.Key)) { mult = ship.Value.Value; doApplyMult = true; break; } } foreach (KeyValuePair<string, float> customShip in customShips) { if (text.Contains(customShip.Key)) { mult = customShip.Value; doApplyMult = true; break; } } } } [HarmonyPatch(typeof(Ship), "OnTriggerExit")] private class ShipTriggerExit { [HarmonyPostfix] public static void Postfix(ref Collider collider, ref Ship __instance) { if (!((Object)(object)collider != (Object)null)) { return; } Player component = ((Component)collider).GetComponent<Player>(); if ((Object)(object)component != (Object)null && (Object)(object)component == (Object)(object)Player.m_localPlayer) { logger.LogMessage((object)"Ship.OnTriggerExit"); onBoat = false; mult = 1f; if ((Object)(object)Minimap.instance != (Object)null) { logger.LogMessage((object)$"Resetting explore radius to {originalRadius}"); Minimap.instance.m_exploreRadius = originalRadius; isCurrentlyApplied = false; } } } } [HarmonyPatch(typeof(Ship), "OnDestroyed")] private class ShipOnDestroyedPatch { public static void Prefix() { if (onBoat) { onBoat = false; mult = 1f; if ((Object)(object)Minimap.instance != (Object)null) { logger.LogMessage((object)$"Ship destroyed, Resetting explore radius to {originalRadius}"); Minimap.instance.m_exploreRadius = originalRadius; isCurrentlyApplied = false; } } } } [HarmonyPatch(typeof(Player), "OnDeath")] private class PlayerOnDeathPatch { public static void Prefix() { if (onBoat) { onBoat = false; mult = 1f; if ((Object)(object)Minimap.instance != (Object)null) { logger.LogMessage((object)$"Player killed, Resetting explore radius to {originalRadius}"); Minimap.instance.m_exploreRadius = originalRadius; isCurrentlyApplied = false; } } } } private readonly Harmony harmony = new Harmony("GemHunter1.ShipExploration"); public static ManualLogSource logger; public static bool onBoat = false; public static bool doApplyMult = false; public static bool isCurrentlyApplied = false; public static float mult = 1f; public static float originalRadius = 50f; public static float newRadius = 50f; public static ConfigEntry<float> RaftMul; public static ConfigEntry<float> KarveMul; public static ConfigEntry<float> LongshipMul; public static Dictionary<string, ConfigEntry<float>> ships = new Dictionary<string, ConfigEntry<float>>(); public static Dictionary<string, float> customShips = new Dictionary<string, float>(); public static ConfigEntry<string> CustomMul; private void Awake() { logger = ((BaseUnityPlugin)this).Logger; harmony.PatchAll(); RaftMul = ((BaseUnityPlugin)this).Config.Bind<float>("General", "RaftMultiplier", 1.5f, "Exploration multiplier when on Raft"); KarveMul = ((BaseUnityPlugin)this).Config.Bind<float>("General", "KarveMultiplier", 2f, "Exploration multiplier when on Karve"); LongshipMul = ((BaseUnityPlugin)this).Config.Bind<float>("General", "LongshipMultiplier", 3f, "Exploration multiplier when on Longship"); ships.Add("raft", RaftMul); ships.Add("karve", KarveMul); ships.Add("viking", LongshipMul); ships.Add("littleboat", ((BaseUnityPlugin)this).Config.Bind<float>("OdinShip Mod", "LittleBoatMul", 1.75f, (ConfigDescription)null)); ships.Add("cargoship", ((BaseUnityPlugin)this).Config.Bind<float>("OdinShip Mod", "CargoShipMul", 2.5f, (ConfigDescription)null)); ships.Add("bigcargoship", ((BaseUnityPlugin)this).Config.Bind<float>("OdinShip Mod", "BigCargoShipMul", 3f, (ConfigDescription)null)); CustomMul = ((BaseUnityPlugin)this).Config.Bind<string>("Custom Ship Mod", "CustomShips", "", "List containing custom ships, format: 'shipname=2.0;othership=3.0' To find ship name use search output console for Ship.OnTriggerEnter, {name}"); CustomMul.SettingChanged += CustomMul_SettingChanged; CustomMul_SettingChanged(null, null); } private void CustomMul_SettingChanged(object sender, EventArgs e) { customShips = (from x in CustomMul.Value.Trim().Split(';') select x.Split('=') into x where x.Length == 2 select x).ToDictionary((string[] x) => x[0], (string[] y) => float.Parse(y[1].Replace(",", "."), CultureInfo.InvariantCulture)); } private void OnDestroy() { harmony.UnpatchSelf(); } private void FixedUpdate() { if (onBoat) { if (doApplyMult && !isCurrentlyApplied) { originalRadius = Minimap.instance.m_exploreRadius; newRadius = originalRadius * mult; Minimap.instance.m_exploreRadius = newRadius; logger.LogMessage((object)string.Format("Setting explore radius {0}x to {1}", mult.ToString("0.0"), Minimap.instance.m_exploreRadius)); doApplyMult = false; isCurrentlyApplied = true; } if (isCurrentlyApplied && newRadius != Minimap.instance.m_exploreRadius) { doApplyMult = true; isCurrentlyApplied = false; } } } }