Please disclose if your mod was created primarily 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 ResourceFinder v0.1.3
ResourceFinder.dll
Decompiled 11 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Splatform; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("FindThemAll")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("FindThemAll")] [assembly: AssemblyCopyright("Copyright © 2025")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("12c5d984-c127-4a23-8675-d5799b8b8944")] [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")] [BepInPlugin("com.acesgaminguk.resourcefinder", "ResourceFinder", "0.1.3")] public class ResourceFinder : BaseUnityPlugin { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static Func<string, string> <>9__3_1; public static ConsoleEvent <>9__3_0; public static Func<string, string> <>9__8_0; internal void <Awake>b__3_0(ConsoleEventArgs args) { if (args.Length < 2) { args.Context.AddString("Usage: locate [resource], locate storage [item], or locate list"); return; } string text = args[1].ToLower(); Debug.Log((object)("locate command triggered with args: " + string.Join(", ", args.Args))); if (text == "list") { args.Context.AddString("Available hardcoded keywords:"); { foreach (string item in ResourceKeywords.Keys.OrderBy((string k) => k)) { args.Context.AddString("- " + item); } return; } } bool flag = text == "storage"; string text2 = (flag ? string.Join(" ", args.Args.Skip(2)).ToLower() : string.Join(" ", args.Args.Skip(1)).ToLower()); if (flag) { FindInStorage(text2, args); } else if (ResourceKeywords.ContainsKey(text2)) { FindInWorld(text2, args); } else { args.Context.AddString("Unknown resource keyword: " + text2 + ". Try 'locate list'."); } } internal string <Awake>b__3_1(string k) { return k; } internal string <BuildPrefabList>b__8_0(string x) { return x; } } private static ConfigEntry<bool> ShowMapPins; private static ConfigEntry<bool> ShowWorldMarkers; private readonly List<(string prefabName, string localizedName)> AllPrefabs = new List<(string, string)>(); private static readonly Dictionary<string, string> ResourceLabels = new Dictionary<string, string> { { "carrot", "Carrot" }, { "turnip", "Turnip" }, { "onion", "Onion" }, { "flax", "Flax" }, { "thistle", "Thistle" }, { "barley", "Barley" }, { "mushroom", "Mushroom" }, { "yellow_mushroom", "Yellow Mushroom" }, { "blueberry", "Blueberry" }, { "raspberry", "Raspberry" }, { "cloudberry", "Cloudberry" }, { "dandelion", "Dandelion" }, { "copper", "Coper" }, { "tin", "Tin" }, { "iron", "Iron" }, { "silver", "Silver" }, { "obsidian", "Obsidian" }, { "flametal", "Flamtal" }, { "sulphur", "Sulphur" }, { "lava_rock", "Lava Rock" }, { "oak", "Oak Tree" }, { "Yggdrasil", "Yggdrasil Tree" }, { "root", "Yggdrasil root" }, { "dragon_egg", "Dragon Egg" }, { "soft_tissue", "Soft Tissue" }, { "black_marble", "Black Marble" } }; private static readonly Dictionary<string, string[]> ResourceKeywords = new Dictionary<string, string[]> { { "carrot", new string[3] { "carrot", "pickable_carrot", " pickable_seedcarrot" } }, { "turnip", new string[3] { "turnip", "pickable_turnip", "pickable_seedturnip" } }, { "onion", new string[2] { "onionseeds", "onion" } }, { "flax", new string[3] { "flax", "pickable_flax", "pickable_flax_wild" } }, { "thistle", new string[1] { "pickable_thistle" } }, { "barley", new string[3] { "barley", "pickable_barley", "pickable_barley_wild" } }, { "mushroom", new string[2] { "mushroom", "Pickable_Mushroom" } }, { "yellow_mushroom", new string[2] { "GlowingMushroom", "Pickable_Mushroom_yellow" } }, { "blueberry", new string[2] { "blueberry", "BlueberryBush" } }, { "raspberry", new string[2] { "raspberry", "RaspberryBush" } }, { "cloudberry", new string[2] { "cloudberry", "CloudberryBush" } }, { "dandelion", new string[1] { "pickable_dandelion" } }, { "copper", new string[3] { "minerock_copper", "rock4_copper", "rock4_copper_frac" } }, { "tin", new string[1] { "minerock_tin" } }, { "iron", new string[4] { "mudpile2", "mudpile2_frac", "mudpile_beacon", "mudpile_frac" } }, { "silver", new string[4] { "silvervein", "silvervein_frac", "rock3_silver", "rock3_silver_frac" } }, { "obsidian", new string[3] { "minerock_obsidian", "pickable_obsidian", "obsidian" } }, { "flametal", new string[1] { "leviathanlava" } }, { "sulphur", new string[2] { "sulphurarch", "pickable_sulphurrock" } }, { "lava_rock", new string[1] { "unstablelavarock" } }, { "oak", new string[1] { "oak" } }, { "Yggdrasil", new string[1] { "Yggdrasil" } }, { "root", new string[1] { "yggdrasilroot" } }, { "dragon_egg", new string[1] { "pickable_dragonegg" } }, { "soft_tissue", new string[2] { "giant_skull", "giant_skull_frac" } }, { "black_marble", new string[4] { "giant_ribs", "giant_ribs_frac", "giant_skull", "giant_skull_frac" } } }; private void Awake() { //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Expected O, but got Unknown ShowMapPins = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ShowMapPins", true, "Display pins on the minimap for found resources."); ShowWorldMarkers = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ShowWorldMarkers", true, "Display floating text in the world for found resources."); Harmony.CreateAndPatchAll(typeof(ResourceFinder), (string)null); BuildPrefabList(); object obj = <>c.<>9__3_0; if (obj == null) { ConsoleEvent val = delegate(ConsoleEventArgs args) { if (args.Length < 2) { args.Context.AddString("Usage: locate [resource], locate storage [item], or locate list"); } else { string text = args[1].ToLower(); Debug.Log((object)("locate command triggered with args: " + string.Join(", ", args.Args))); if (text == "list") { args.Context.AddString("Available hardcoded keywords:"); { foreach (string item in ResourceKeywords.Keys.OrderBy((string k) => k)) { args.Context.AddString("- " + item); } return; } } bool flag = text == "storage"; string text2 = (flag ? string.Join(" ", args.Args.Skip(2)).ToLower() : string.Join(" ", args.Args.Skip(1)).ToLower()); if (flag) { FindInStorage(text2, args); } else if (ResourceKeywords.ContainsKey(text2)) { FindInWorld(text2, args); } else { args.Context.AddString("Unknown resource keyword: " + text2 + ". Try 'locate list'."); } } }; <>c.<>9__3_0 = val; obj = (object)val; } new ConsoleCommand("locate", "Find resource nodes, trees, or storage items. Usage: locate [resource], locate storage [item], or locate list", (ConsoleEvent)obj, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); } private static void FindInWorld(string keyword, ConsoleEventArgs args) { //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) if (!ResourceKeywords.ContainsKey(keyword)) { args.Context.AddString("Unknown resource keyword: " + keyword + ". Try 'locate list'."); return; } string[] source = ResourceKeywords[keyword]; int num = 0; ZNetView[] array = Object.FindObjectsOfType<ZNetView>(); foreach (ZNetView val in array) { string prefab = Utils.GetPrefabName(((Component)val).gameObject).ToLower(); if (!source.Any((string ms) => prefab.Contains(ms))) { continue; } Vector3 position = ((Component)val).transform.position; num++; if (!ResourceLabels.TryGetValue(keyword.ToLower(), out var value)) { value = keyword.Replace("pickable_", "").Replace("rock4_", "").Replace("vein", "") .Replace("_", " ") .Trim(); value = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(value); } args.Context.AddString($"Found {value} at {position}"); if (ShowMapPins.Value && Object.op_Implicit((Object)(object)Minimap.instance)) { if (keyword != "copper" && keyword != "tin" && keyword != "silver" && keyword != "flametal" && keyword != "scrapiron") { Minimap.instance.AddPin(position, (PinType)3, value, false, false, 0L, default(PlatformUserID)); } else { Minimap.instance.AddPin(position, (PinType)2, value, false, false, 0L, default(PlatformUserID)); } } if (ShowWorldMarkers.Value) { ShowFloatingText(position, value); } } if (num == 0) { args.Context.AddString("No matching resources found."); } } private static void FindInStorage(string keyword, ConsoleEventArgs args) { //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) int num = 0; Container[] array = Object.FindObjectsOfType<Container>(); foreach (Container val in array) { if ((Object)(object)val == (Object)null || val.GetInventory() == null) { continue; } foreach (ItemData allItem in val.GetInventory().GetAllItems()) { if (allItem.m_shared.m_name.ToLower().Contains(keyword)) { Vector3 position = ((Component)val).transform.position; num++; args.Context.AddString($"Found {allItem.m_stack}x {allItem.m_shared.m_name} in container at {position}"); if (ShowMapPins.Value && Object.op_Implicit((Object)(object)Minimap.instance)) { Minimap.instance.AddPin(position, (PinType)1, allItem.m_shared.m_name, false, false, 0L, default(PlatformUserID)); } if (ShowWorldMarkers.Value) { ShowFloatingText(position, allItem.m_shared.m_name); } break; } } } if (num == 0) { args.Context.AddString("No matching items found in nearby storage."); } } private void BuildPrefabList() { AllPrefabs.Clear(); ZNetView[] array = Object.FindObjectsOfType<ZNetView>(); List<string> list = new List<string>(); ZNetView[] array2 = array; foreach (ZNetView val in array2) { if (!((Object)(object)val == (Object)null) && !((Object)(object)((Component)val).gameObject == (Object)null)) { string prefabName = Utils.GetPrefabName(((Component)val).gameObject); if (!string.IsNullOrEmpty(prefabName)) { string text = prefabName; AllPrefabs.Add((prefabName, text)); list.Add(prefabName + ": " + text); } } } try { File.WriteAllLines(Path.Combine(Paths.ConfigPath, "ResourceFinder_Prefabs.txt"), list.OrderBy((string x) => x)); } catch (Exception ex) { ZLog.LogError((object)("[ResourceFinder] Failed to save prefab list: " + ex)); } } private static void ShowFloatingText(Vector3 pos, string label) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) ZLog.Log((object)$"[ResourceFinder] {label} at {pos}"); } }