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 FishMagnet v1.0.0
FishMagnet.dll
Decompiled 17 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("FishMagnet")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("FishMagnet")] [assembly: AssemblyTitle("FishMagnet")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace FishMagnet { internal sealed class FishCollector { private const float ScanInterval = 0.2f; private const float RequestCooldown = 2f; private readonly List<Fish> _buffer = new List<Fish>(); private readonly Dictionary<ZDOID, float> _requested = new Dictionary<ZDOID, float>(); private readonly List<ZDOID> _expired = new List<ZDOID>(); private float _timer; public void Tick(float deltaTime) { //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) _timer -= deltaTime; if (_timer > 0f) { return; } _timer = 0.2f; Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || ((Character)localPlayer).IsDead()) { return; } PruneRequests(); _buffer.Clear(); foreach (IMonoUpdater instance in Fish.Instances) { Fish val = (Fish)(object)((instance is Fish) ? instance : null); if (val != null && (Object)(object)val != (Object)null) { _buffer.Add(val); } } float value = Plugin.Range.Value; float num = value * value; Vector3 position = ((Component)localPlayer).transform.position; Inventory inventory = ((Humanoid)localPlayer).GetInventory(); foreach (Fish item in _buffer) { if ((Object)(object)item == (Object)null) { continue; } Vector3 val2 = ((Component)item).transform.position - position; if (((Vector3)(ref val2)).sqrMagnitude > num) { continue; } ZNetView component = ((Component)item).GetComponent<ZNetView>(); if (!((Object)(object)component == (Object)null) && component.IsValid() && (!Plugin.SkipHookedFish.Value || !IsHooked(component))) { ZDOID uid = component.GetZDO().m_uid; if (!_requested.ContainsKey(uid) && (!((Object)(object)item.m_pickupItem != (Object)null) || inventory.CanAddItem(item.m_pickupItem, item.m_pickupItemStackSize)) && item.Pickup((Humanoid)(object)localPlayer)) { _requested[uid] = Time.time; } } } } private static bool IsHooked(ZNetView nview) { return nview.GetZDO().GetInt(ZDOVars.s_hooked, 0) != 0; } private void PruneRequests() { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) if (_requested.Count == 0) { return; } float time = Time.time; _expired.Clear(); foreach (KeyValuePair<ZDOID, float> item in _requested) { if (time - item.Value >= 2f) { _expired.Add(item.Key); } } foreach (ZDOID item2 in _expired) { _requested.Remove(item2); } } } [BepInPlugin("matheba.fishmagnet", "FishMagnet", "1.0.0")] [BepInProcess("valheim.exe")] public class Plugin : BaseUnityPlugin { internal static ManualLogSource Log; internal static ConfigEntry<bool> ModEnabled; internal static ConfigEntry<KeyboardShortcut> ToggleKey; internal static ConfigEntry<bool> ShowToggleMessage; internal static ConfigEntry<float> Range; internal static ConfigEntry<bool> SkipHookedFish; private FishCollector _collector; private void Awake() { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Expected O, but got Unknown //IL_011a: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; ModEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("1 - General", "Fish magnet", false, "Turns the fish magnet on and off. Applies only to your own character, on your client."); ToggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("1 - General", "Toggle hotkey", new KeyboardShortcut((KeyCode)288, Array.Empty<KeyCode>()), "Key that turns the magnet on and off in game. Ignored while you are typing in chat or the console."); ShowToggleMessage = ((BaseUnityPlugin)this).Config.Bind<bool>("1 - General", "Show on-screen message", true, "Shows a centre-screen message when you toggle the magnet with the hotkey."); Range = ((BaseUnityPlugin)this).Config.Bind<float>("2 - Behaviour", "Range", 20f, new ConfigDescription("How far away fish are collected from, in metres. Measured from you, so it works the same standing on shore or sailing a boat.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(2f, 100f), Array.Empty<object>())); SkipHookedFish = ((BaseUnityPlugin)this).Config.Bind<bool>("2 - Behaviour", "Skip hooked fish", true, "Leaves fish alone while someone has them on a fishing line, so the magnet does not steal a catch another player is reeling in."); _collector = new FishCollector(); Log.LogInfo((object)string.Format("{0} {1} loaded. Enabled: {2}, hotkey: {3}", "FishMagnet", "1.0.0", ModEnabled.Value, ToggleKey.Value)); } private void Update() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) KeyboardShortcut value = ToggleKey.Value; if (((KeyboardShortcut)(ref value)).IsDown() && !IsTyping()) { ModEnabled.Value = !ModEnabled.Value; Log.LogInfo((object)("Fish magnet: " + (ModEnabled.Value ? "on" : "off"))); if (ShowToggleMessage.Value && (Object)(object)Player.m_localPlayer != (Object)null) { ((Character)Player.m_localPlayer).Message((MessageType)2, ModEnabled.Value ? $"Fish magnet: ON ({Range.Value:0}m)" : "Fish magnet: OFF", 0, (Sprite)null); } } if (ModEnabled.Value) { _collector.Tick(Time.deltaTime); } } private static bool IsTyping() { if (Console.IsVisible() || TextInput.IsVisible()) { return true; } if ((Object)(object)Chat.instance != (Object)null) { return Chat.instance.HasFocus(); } return false; } } internal static class PluginInfo { internal const string Guid = "matheba.fishmagnet"; internal const string Name = "FishMagnet"; internal const string Version = "1.0.0"; } }