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 ExtraBuildMaterialsDrop v1.1.0
ExtraBuildMaterialsDrop.dll
Decompiled 2 days agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("ExtraBuildMaterialsDrop")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.1.0.0")] [assembly: AssemblyInformationalVersion("1.1.0+a0b3c345ada9a1802ab51899dc95b7f427ca4747")] [assembly: AssemblyProduct("ExtraBuildMaterialsDrop")] [assembly: AssemblyTitle("ExtraBuildMaterialsDrop")] [assembly: AssemblyVersion("1.1.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 ExtraBuildMaterialsDrop { [BepInPlugin("com.extrabuildmaterialsdrop.plugin", "Extra Build Materials Drop", "1.1.0")] public sealed class ExtraBuildMaterialsDropPlugin : BaseUnityPlugin { private const string PluginGuid = "com.extrabuildmaterialsdrop.plugin"; private const string PluginName = "Extra Build Materials Drop"; private const string PluginVersion = "1.1.0"; internal static ConfigEntry<float> MaterialDropMultiplier; private void Awake() { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown //IL_0049: Unknown result type (might be due to invalid IL or missing references) MaterialDropMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Material drop multiplier", 2f, new ConfigDescription("Overrides the world's resource rate for these materials from trees and rocks only: Wood, Fine Wood, Core Wood (RoundLog), Ancient Bark, Yggdrasil Wood, Ashwood, Blackwood, Stone, Black Marble, and Grausten. Other sources, such as chests and creatures, are unaffected.", (AcceptableValueBase)(object)new AcceptableValueList<float>(new float[5] { 1f, 1.5f, 2f, 2.5f, 3f }), Array.Empty<object>())); new Harmony("com.extrabuildmaterialsdrop.plugin").PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)$"Tree and rock wood and stone drops use a {MaterialDropMultiplier.Value}x multiplier."); } } [HarmonyPatch(typeof(TreeBase), "Awake")] internal static class TreeBaseAwakePatch { [HarmonyPostfix] private static void Postfix(TreeBase __instance) { ResourceMaterialDropTables.Register(Traverse.Create((object)__instance).Field("m_dropWhenDestroyed").GetValue<DropTable>()); } } [HarmonyPatch(typeof(TreeLog), "Awake")] internal static class TreeLogAwakePatch { [HarmonyPostfix] private static void Postfix(TreeLog __instance) { ResourceMaterialDropTables.Register(Traverse.Create((object)__instance).Field("m_dropWhenDestroyed").GetValue<DropTable>()); } } [HarmonyPatch(typeof(MineRock), "Start")] internal static class MineRockStartPatch { [HarmonyPostfix] private static void Postfix(MineRock __instance) { ResourceMaterialDropTables.Register(Traverse.Create((object)__instance).Field("m_dropItems").GetValue<DropTable>()); } } [HarmonyPatch(typeof(MineRock5), "Awake")] internal static class MineRock5AwakePatch { [HarmonyPostfix] private static void Postfix(MineRock5 __instance) { ResourceMaterialDropTables.Register(Traverse.Create((object)__instance).Field("m_dropItems").GetValue<DropTable>()); } } [HarmonyPatch(typeof(DropTable), "GetDropList", new Type[] { typeof(int) })] internal static class DropTableGetDropListPatch { [HarmonyPostfix] private static void Postfix(DropTable __instance, List<GameObject> __result) { float value = ExtraBuildMaterialsDropPlugin.MaterialDropMultiplier.Value; if (value == 1f || __result == null || !ResourceMaterialDropTables.Contains(__instance)) { return; } Dictionary<GameObject, int> dictionary = new Dictionary<GameObject, int>(); foreach (GameObject item in __result) { if (ResourceMaterialDropTables.IsMaterial(item)) { if (dictionary.TryGetValue(item, out var value2)) { dictionary[item] = value2 + 1; } else { dictionary.Add(item, 1); } } } foreach (KeyValuePair<GameObject, int> item2 in dictionary) { int num = Mathf.RoundToInt((float)item2.Value * value); for (int i = item2.Value; i < num; i++) { __result.Add(item2.Key); } } } } internal static class ResourceMaterialDropTables { private static readonly HashSet<string> BuildMaterials = new HashSet<string>(StringComparer.Ordinal) { "Wood", "FineWood", "RoundLog", "AncientBark", "YggdrasilWood", "Ashwood", "Blackwood", "Stone", "BlackMarble", "Grausten" }; private static readonly HashSet<DropTable> RegisteredTables = new HashSet<DropTable>(); internal static void Register(DropTable table) { if (table == null || !RegisteredTables.Add(table)) { return; } IEnumerable value = Traverse.Create((object)table).Field("m_drops").GetValue<IEnumerable>(); if (value == null) { return; } foreach (object item in value) { Traverse val = Traverse.Create(item); GameObject value2 = val.Field("m_item").GetValue<GameObject>(); if ((Object)(object)value2 != (Object)null && BuildMaterials.Contains(((Object)value2).name)) { val.Field("m_dontScale").SetValue((object)true); } } } internal static bool Contains(DropTable table) { return RegisteredTables.Contains(table); } internal static bool IsMaterial(GameObject prefab) { if ((Object)(object)prefab != (Object)null) { return BuildMaterials.Contains(((Object)prefab).name); } return false; } } public static class MyPluginInfo { public const string PLUGIN_GUID = "ExtraBuildMaterialsDrop"; public const string PLUGIN_NAME = "ExtraBuildMaterialsDrop"; public const string PLUGIN_VERSION = "1.1.0"; } }