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 ItemDropLister v1.0.0
plugins\ItemDropLister.dll
Decompiled 2 years agousing System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security.Permissions; using BepInEx; using JetBrains.Annotations; using Jotunn; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("FixItFelix.ItemDropLister")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("FixItFelix.ItemDropLister")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")] [assembly: AssemblyFileVersion("1.0.8")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.8.0")] namespace ItemDropLister; [BepInPlugin("FixItFelix.ItemDropLister", "ItemDropLister", "1.0.8")] [BepInDependency(/*Could not decode attribute arguments.*/)] internal class ItemDropListerPlugin : BaseUnityPlugin { private class TranslationsPrinterController : ConsoleCommand { public override string Name => "print_items_to_file"; public override string Help => "Write all ItemDrop prefabs loaded in-game into a YAML file inside the BepInEx root folder 'BepInEx/Debug'"; public override void Run(string[] args) { ItemDropPrinter.WriteData((args.Length != 0) ? args[0] : ""); } } private const string PluginAuthor = "FixItFelix"; private const string PluginName = "ItemDropLister"; internal const string PluginVersion = "1.0.8"; internal const string PluginGuid = "FixItFelix.ItemDropLister"; private void Awake() { ModQuery.Enable(); PrefabManager.OnPrefabsRegistered += ItemDropRegistry.Initialize; CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new TranslationsPrinterController()); } } public static class ItemDropPrinter { private static readonly string OutputPath = Path.Combine(Paths.BepInExRootPath, "Debug"); private const string FileSuffix = ".yaml"; public static void WriteData(string prefabNamePrefixFilter) { IEnumerable<KeyValuePair<string, List<ItemDropModel>>> enumerable; if (!(prefabNamePrefixFilter == "")) { enumerable = ItemDropRegistry.ItemDrops.Where((KeyValuePair<string, List<ItemDropModel>> pair) => pair.Key.StartsWith(prefabNamePrefixFilter)); } else { IEnumerable<KeyValuePair<string, List<ItemDropModel>>> itemDrops = ItemDropRegistry.ItemDrops; enumerable = itemDrops; } foreach (KeyValuePair<string, List<ItemDropModel>> item in enumerable) { if (item.Value.Count > 0) { string filPath = Path.Combine(OutputPath, item.Key + ".yaml"); WriteFile((from item in item.Value group item by item.ItemCategory).ToDictionary((IGrouping<string, ItemDropModel> group) => group.Key, (IGrouping<string, ItemDropModel> group) => (from line in @group.Select((ItemDropModel item) => item.ItemPrefabName).Distinct() orderby line select line).ToList()), filPath); } else { Logger.LogWarning((object)("mod '" + item.Key + "' does not contain any prefabs having ItemDrop component")); } } } private static void WriteFile(Dictionary<string, List<string>> itemDrops, string filPath) { if (!Directory.Exists(OutputPath)) { Directory.CreateDirectory(OutputPath); } List<string> list = new List<string>(); foreach (KeyValuePair<string, List<string>> itemDrop in itemDrops) { list.Add(itemDrop.Key + ":"); list.AddRange(itemDrop.Value.Select((string item) => " - " + item)); } File.WriteAllText(filPath, string.Join("\n", list)); Logger.LogInfo((object)("wrote item drops to file '" + filPath + "'")); } } public class ItemDropModel { [UsedImplicitly] public string ItemPrefabName; [UsedImplicitly] public string ItemCategory; public static ItemDropModel FromItemDrop(ItemDrop original) { return new ItemDropModel { ItemPrefabName = ((Object)original).name, ItemCategory = ((object)(ItemType)(ref original.m_itemData.m_shared.m_itemType)).ToString() }; } } public static class ItemDropRegistry { public static readonly Dictionary<string, List<ItemDropModel>> ItemDrops = new Dictionary<string, List<ItemDropModel>>(); public static void Initialize() { ItemDrop original = default(ItemDrop); foreach (KeyValuePair<string, List<ItemDropModel>> item in (from pair in ModQuery.GetPrefabs() group pair by pair.SourceMod.Name).ToDictionary((IGrouping<string, IModPrefab> group) => group.Key, (IGrouping<string, IModPrefab> group) => (from prefab in @group select prefab.Prefab.TryGetComponent<ItemDrop>(ref original) ? ItemDropModel.FromItemDrop(original) : null into prefab where prefab != null select prefab).ToList())) { ItemDrops.Add(item.Key, item.Value); } } }