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 ProductionCapacities v1.2.0
Production Capacities.dll
Decompiled a day agousing System; 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.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("Production_Capacities")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("Production_Capacities")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("15871073-03ec-40f2-9777-542ac26b2cd2")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace ValheimProductionCapacities { [BepInPlugin("com.Viking.valheim.productioncapacities", "ProductionCapacities", "1.2.0")] public class ProductionCapacitiesPlugin : BaseUnityPlugin { private const string PluginGUID = "com.Viking.valheim.productioncapacities"; private const string PluginName = "ProductionCapacities"; private const string PluginVersion = "1.2.0"; private readonly Harmony harmony = new Harmony("com.Viking.valheim.productioncapacities"); public static ConfigEntry<bool> IsConfigLocked; public static ConfigEntry<bool> ModEnabled; private static ConfigEntry<int> _smelterMaxOre; private static ConfigEntry<int> _smelterMaxCoal; private static ConfigEntry<int> _blastFurnaceMaxOre; private static ConfigEntry<int> _blastFurnaceMaxCoal; private static ConfigEntry<int> _kilnMaxWood; private static ConfigEntry<int> _windmillMaxBarley; private static ConfigEntry<int> _spinningWheelMaxFlax; private static ConfigEntry<int> _refineryMaxTissue; private static ConfigEntry<int> _refineryMaxSap; public static int SmelterMaxOre => ModEnabled.Value ? _smelterMaxOre.Value : 10; public static int SmelterMaxCoal => ModEnabled.Value ? _smelterMaxCoal.Value : 20; public static int BlastFurnaceMaxOre => ModEnabled.Value ? _blastFurnaceMaxOre.Value : 10; public static int BlastFurnaceMaxCoal => ModEnabled.Value ? _blastFurnaceMaxCoal.Value : 20; public static int KilnMaxWood => ModEnabled.Value ? _kilnMaxWood.Value : 25; public static int WindmillMaxBarley => ModEnabled.Value ? _windmillMaxBarley.Value : 50; public static int SpinningWheelMaxFlax => ModEnabled.Value ? _spinningWheelMaxFlax.Value : 40; public static int RefineryMaxTissue => ModEnabled.Value ? _refineryMaxTissue.Value : 20; public static int RefineryMaxSap => ModEnabled.Value ? _refineryMaxSap.Value : 20; private void Awake() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown IsConfigLocked = ((BaseUnityPlugin)this).Config.Bind<bool>("0 - General", "Lock Configuration", true, new ConfigDescription("If true, configuration settings will be locked to server-side values via ConditionalConfigSync for non-admin players.", (AcceptableValueBase)null, new object[1] { new { order = 210 } })); ModEnabled = BindConfig("0 - General", "Mod Enabled", value: true, "If false, all custom capacity modifications are ignored and game default values are used. [Synced with Server]", 200); _smelterMaxOre = BindConfig("1 - Smelter", "Max Ore", 50, "Maximum amount of ore the standard Smelter can hold. [Synced with Server]", 100); _smelterMaxCoal = BindConfig("1 - Smelter", "Max Coal", 100, "Maximum amount of coal the standard Smelter can hold. [Synced with Server]", 99); _blastFurnaceMaxOre = BindConfig("2 - Blast Furnace", "Max Ore", 50, "Maximum amount of ore the Blast Furnace can hold. [Synced with Server]", 90); _blastFurnaceMaxCoal = BindConfig("2 - Blast Furnace", "Max Coal", 100, "Maximum amount of coal the Blast Furnace can hold. [Synced with Server]", 89); _kilnMaxWood = BindConfig("3 - Kiln", "Max Wood", 50, "Maximum amount of wood the Charcoal Kiln can hold. [Synced with Server]", 80); _windmillMaxBarley = BindConfig("4 - Windmill", "Max Barley", 100, "Maximum amount of barley the Windmill can hold. [Synced with Server]", 70); _spinningWheelMaxFlax = BindConfig("5 - Spinning Wheel", "Max Flax", 100, "Maximum amount of flax the Spinning Wheel can hold. [Synced with Server]", 60); _refineryMaxTissue = BindConfig("6 - Eitr Refinery", "Max Soft Tissue", 50, "Maximum amount of soft tissue the Eitr Refinery can hold. [Synced with Server]", 50); _refineryMaxSap = BindConfig("6 - Eitr Refinery", "Max Sap", 50, "Maximum amount of sap the Eitr Refinery can hold. [Synced with Server]", 49); harmony.PatchAll(); } private ConfigEntry<T> BindConfig<T>(string group, string name, T value, string description, int order) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown ConfigEntry<T> val = ((BaseUnityPlugin)this).Config.Bind<T>(group, name, value, new ConfigDescription(description, (AcceptableValueBase)null, new object[1] { new { order } })); val.SettingChanged += OnSettingChanged; return val; } private void OnSettingChanged(object sender, EventArgs e) { UpdateAllExistingStations(); } public static void UpdateAllExistingStations() { Smelter[] array = Object.FindObjectsByType<Smelter>((FindObjectsSortMode)0); foreach (Smelter instance in array) { SmelterPatch.ApplySmelterCapacities(instance); } } } [HarmonyPatch(typeof(Smelter), "Awake")] public static class SmelterPatch { public static void Postfix(Smelter __instance) { ApplySmelterCapacities(__instance); } public static void ApplySmelterCapacities(Smelter instance) { switch (instance.m_name) { case "$piece_smelter": instance.m_maxOre = ProductionCapacitiesPlugin.SmelterMaxOre; instance.m_maxFuel = ProductionCapacitiesPlugin.SmelterMaxCoal; break; case "$piece_blastfurnace": instance.m_maxOre = ProductionCapacitiesPlugin.BlastFurnaceMaxOre; instance.m_maxFuel = ProductionCapacitiesPlugin.BlastFurnaceMaxCoal; break; case "$piece_charcoalkiln": instance.m_maxOre = ProductionCapacitiesPlugin.KilnMaxWood; break; case "$piece_windmill": instance.m_maxOre = ProductionCapacitiesPlugin.WindmillMaxBarley; break; case "$piece_spinningwheel": instance.m_maxOre = ProductionCapacitiesPlugin.SpinningWheelMaxFlax; break; case "$piece_eitrrefinery": instance.m_maxOre = ProductionCapacitiesPlugin.RefineryMaxTissue; instance.m_maxFuel = ProductionCapacitiesPlugin.RefineryMaxSap; break; } } } } namespace Production_Capacities.MonoBehaviours { internal class Production_CapacitiesComponent : MonoBehaviour { public void Awake() { } public void Start() { } public void Update() { } public void LateUpdate() { } } }