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 Trawlheim v1.0.1
Trawlheim.dll
Decompiled a day agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("Trawlheim")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("Trawlheim")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("94060e81-f7da-49f6-9e50-48233486ea80")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] namespace Trawlheim; [BepInPlugin("com.detromental.trawlheim", "Trawlheim", "1.0.0")] public class TrawlheimPlugin : BaseUnityPlugin { public const string ModGUID = "com.detromental.trawlheim"; public const string ModName = "Trawlheim"; public const string ModVersion = "1.0.0"; private static ConfigEntry<bool> modEnabled; private static ConfigEntry<float> vacuumRadius; private static ConfigEntry<float> updateInterval; private static ConfigEntry<bool> enableVisualEffects; private float timer; private static MethodInfo containerCheckAccessMethod; private static MethodInfo inventoryGuiUpdateContainerMethod; private static readonly string[] CatchMessages = new string[60] { "Njord smiles upon your vessel, filling your nets with flashing fins!", "The sea-mother Ran yields a harvest of scales to your hold!", "A heavy catch thumps against the hull by Thor's mighty grip!", "Odin provides a bountiful haul of fresh fish!", "The ocean surrenders its slippery bounty to your nets!", "A glorious catch settles into your vessel's hold!", "Trawl nets drag true, securing a fine aquatic feast!", "The cold depths yield their prizes to the living!", "Nets strain tight with the ocean's scaled treasures!", "Your nets bite deep, pulling fresh fish from Aegir's domain!", "Njord's gentle breath guides a flurry of fins into your nets!", "The lord of the waves fills your holds with the sea's bounty!", "Aegir demands your nets stay full — fresh fish secured!", "Njord's bounty thumps heavily against your ship's floorboards!", "The brewer of the deep, Aegir, parts with his swimming prizes!", "A gift of fins from Njord settles into your boat!", "Aegir's cold halls surrender a marvelous catch!", "The god of ships smiles upon your nets this day!", "Njord guides the school directly into your trawl lines!", "A rich harvest of scales from Aegir's personal currents!", "Ran opens her webbed fingers, letting a catch slip into your nets!", "The sea-mother's nets share their scaled harvest with your own!", "You have robbed Ran's dark treasury of its swimming wealth!", "Ran's deep currents sweep a bountiful catch into your hold!", "The goddess of the depths permits you a fine feast of fish!", "Ran's cold grip loosens, surrendering a heavy haul of scales!", "A prize stolen directly from the sea-mother's cold embrace!", "The tides of Ran wash a fresh catch onto your deck!", "Before she pulls them deep, your net claims Ran's scaled prizes!", "The sea-queen's domain yields a magnificent aquatic harvest!", "By Thor's thunderous stride, the hull shakes with a heavy catch!", "Odin's gaze pierces the deep, revealing a bounty of fish!", "A haul so heavy it would test the mighty arms of Thor!", "The Allfather fills your thoughts with victory and your hold with fish!", "Thor blesses your strength as you drag a great catch aboard!", "The wisdom of the ravens guides your nets to a massive school!", "A thunderous thump in the hold signals Thor's approval!", "Odin's favor ensures your clan will feast on fresh fish tonight!", "By Mjolnir's echo, the nets pull true with flashing fins!", "The Allfather watches over the harvest of the shifting tides!", "The World Serpent stirs, sending a school of fish into your path!", "From the shadow of the great serpent, a prize is won!", "Jormungandr's wake drives a rich harvest into your nets!", "The deep waters churn, delivering a bounty of scaled treasures!", "A catch born from the turbulent currents of the Great Serpent!", "The roots of Yggdrasil reach deep, but your nets reach deeper!", "The ocean's ancient depths yield their wild, swimming prizes!", "A magnificent catch dragged straight from the primordial waves!", "The great sea-beasts part way for your splendid harvest!", "Nets plunge into the abyss and return heavy with life!", "A catch worthy of the high benches in the Great Hall!", "The Valkyries sing of a magnificent aquatic feast!", "Nets strain under the weight of a legendary catch!", "Fresh scales glisten on deck—a glorious day for the clan!", "Your vessel rides lower, laden with a magnificent haul of fish!", "The smoke of the hearth fires awaits this fine, scaled bounty!", "A bountiful catch settles in, ensuring a splendid feast!", "The spirits of the ancestors cheer for a heavy net!", "Freya blesses your voyage with a bountiful harvest of fins!", "Your net bites deep, claiming glory from the churning foam!" }; private static readonly Random random = new Random(); private void Awake() { //IL_00e7: Unknown result type (might be due to invalid IL or missing references) modEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Enable or disable the mod."); vacuumRadius = ((BaseUnityPlugin)this).Config.Bind<float>("General", "VacuumRadius", 30f, "Radius around the boat to pull fish from."); updateInterval = ((BaseUnityPlugin)this).Config.Bind<float>("General", "UpdateInterval", 2f, "How many seconds between vacuum scans."); enableVisualEffects = ((BaseUnityPlugin)this).Config.Bind<bool>("Visuals", "EnableFlashEffect", true, "Play a splash flash and text notification around the player when a fish is successfully added."); containerCheckAccessMethod = AccessTools.Method(typeof(Container), "CheckAccess", new Type[1] { typeof(long) }, (Type[])null); inventoryGuiUpdateContainerMethod = AccessTools.Method(typeof(InventoryGui), "UpdateContainer", new Type[1] { typeof(Player) }, (Type[])null); new Harmony("com.detromental.trawlheim").PatchAll(); } private void Update() { if (modEnabled.Value && !((Object)(object)Player.m_localPlayer == (Object)null)) { timer += Time.deltaTime; if (timer >= updateInterval.Value) { timer = 0f; VacuumFishToBoats(); } } } private void VacuumFishToBoats() { //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Invalid comparison between Unknown and I4 if ((Object)(object)ZNetScene.instance == (Object)null || (Object)(object)Player.m_localPlayer == (Object)null) { return; } Ship[] array = Object.FindObjectsByType<Ship>((FindObjectsSortMode)0); if (array == null || array.Length == 0) { return; } long sessionID = ZDOMan.GetSessionID(); Ship[] array2 = array; foreach (Ship val in array2) { if ((Object)(object)val == (Object)null || !Object.op_Implicit((Object)(object)((Component)val).gameObject)) { continue; } Rigidbody component = ((Component)val).GetComponent<Rigidbody>(); if ((Object)(object)component == (Object)null) { continue; } Vector3 linearVelocity = component.linearVelocity; if (((Vector3)(ref linearVelocity)).magnitude < 1f || Vector3.Distance(((Component)Player.m_localPlayer).transform.position, ((Component)val).transform.position) > 50f) { continue; } Container componentInChildren = ((Component)val).gameObject.GetComponentInChildren<Container>(); if ((Object)(object)componentInChildren == (Object)null || (containerCheckAccessMethod != null && !(bool)containerCheckAccessMethod.Invoke(componentInChildren, new object[1] { Player.m_localPlayer.GetPlayerID() }))) { continue; } Inventory inventory = componentInChildren.GetInventory(); if (inventory == null || inventory.GetEmptySlots() == 0) { continue; } Collider[] array3 = Physics.OverlapSphere(((Component)val).transform.position, vacuumRadius.Value); if (array3 == null || array3.Length == 0) { continue; } HashSet<GameObject> hashSet = new HashSet<GameObject>(); Collider[] array4 = array3; foreach (Collider val2 in array4) { if ((Object)(object)val2 == (Object)null) { continue; } GameObject gameObject = ((Component)((Component)val2).transform.root).gameObject; if ((Object)(object)gameObject == (Object)null || hashSet.Contains(gameObject)) { continue; } hashSet.Add(gameObject); ZNetView componentInParent = gameObject.GetComponentInParent<ZNetView>(); if ((Object)(object)componentInParent == (Object)null || !componentInParent.IsValid() || (componentInParent.GetZDO().GetOwner() == sessionID && componentInParent.GetZDO().GetBool("VacuumedProcessing", false))) { continue; } bool flag = false; ItemData val3 = null; try { if ((Object)(object)gameObject.GetComponentInParent<Fish>() != (Object)null) { ItemDrop componentInParent2 = gameObject.GetComponentInParent<ItemDrop>(); if ((Object)(object)componentInParent2 != (Object)null && componentInParent2.m_itemData != null) { val3 = componentInParent2.m_itemData.Clone(); val3.m_stack = 1; flag = true; } } if (!flag) { ItemDrop componentInParent3 = gameObject.GetComponentInParent<ItemDrop>(); if ((Object)(object)componentInParent3 != (Object)null && componentInParent3.m_itemData != null && (componentInParent3.m_itemData.m_shared.m_name.StartsWith("Fish", StringComparison.OrdinalIgnoreCase) || (int)componentInParent3.m_itemData.m_shared.m_itemType == 21)) { val3 = componentInParent3.m_itemData.Clone(); val3.m_stack = 1; flag = true; } } } catch (Exception) { flag = false; } if (!flag || val3 == null || !inventory.HaveItem(val3.m_shared.m_name, true) || !inventory.CanAddItem(val3, val3.m_stack)) { continue; } componentInParent.GetZDO().SetOwner(sessionID); componentInParent.GetZDO().Set("VacuumedProcessing", true); if (inventory.AddItem(val3)) { ZNetView component2 = ((Component)componentInChildren).GetComponent<ZNetView>(); if ((Object)(object)component2 != (Object)null && component2.IsValid()) { component2.GetZDO().SetOwner(sessionID); component2.InvokeRPC(ZNetView.Everybody, "RPC_OnInventoryChanged", Array.Empty<object>()); } if ((Object)(object)InventoryGui.instance != (Object)null && InventoryGui.instance.IsContainerOpen() && inventoryGuiUpdateContainerMethod != null) { inventoryGuiUpdateContainerMethod.Invoke(InventoryGui.instance, new object[1] { Player.m_localPlayer }); } if (enableVisualEffects.Value) { TriggerNativePlayerEffects(); } ZNetScene.instance.Destroy(((Component)componentInParent).gameObject); break; } componentInParent.GetZDO().Set("VacuumedProcessing", false); } } } private static void TriggerNativePlayerEffects() { if (!((Object)(object)Player.m_localPlayer == (Object)null)) { int num = random.Next(CatchMessages.Length); string text = CatchMessages[num]; ((Character)Player.m_localPlayer).Message((MessageType)2, text, 0, (Sprite)null, false); } } }