From fe3976b4d690ef233e1c84a43a7e8d5c3941201c Mon Sep 17 00:00:00 2001 From: Shawn Date: Mon, 23 Jan 2023 16:18:32 -0400 Subject: [PATCH 1/2] Add configuration and classes for the Eitr Refinery Uses the same mechanics as the other "smelters", except with different materials. --- README.md | 3 +- ValheimPlus/Configurations/Configuration.cs | 1 + .../Sections/EitrRefineryConfiguration.cs | 13 +++++++++ ValheimPlus/GameClasses/Smelter.cs | 20 ++++++++++++- valheim_plus.cfg | 29 +++++++++++++++++++ 5 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 ValheimPlus/Configurations/Sections/EitrRefineryConfiguration.cs diff --git a/README.md b/README.md index 45363758..398ecad0 100644 --- a/README.md +++ b/README.md @@ -446,4 +446,5 @@ Please see [CONTRIBUTING.md](/CONTRIBUTING.md) for details on compiling V+ for d * An 'Hachidan' N. - https://github.com/ahnguyen09 * Abra - https://github.com/Abrackadabra * Increddibelly - https://github.com/increddibelly -* Radvo - https://github.com/Radvo \ No newline at end of file +* Radvo - https://github.com/Radvo +* Shawn - https://github.com/shawnwallace \ No newline at end of file diff --git a/ValheimPlus/Configurations/Configuration.cs b/ValheimPlus/Configurations/Configuration.cs index 115f6e94..8bd2c17f 100644 --- a/ValheimPlus/Configurations/Configuration.cs +++ b/ValheimPlus/Configurations/Configuration.cs @@ -23,6 +23,7 @@ public class Configuration public KilnConfiguration Kiln { get; set; } public WindmillConfiguration Windmill { get; set; } public SpinningWheelConfiguration SpinningWheel { get; set; } + public EitrRefineryConfiguration EitrRefinery { get; set; } public MapConfiguration Map { get; set; } public PlayerConfiguration Player { get; set; } public ServerConfiguration Server { get; set; } diff --git a/ValheimPlus/Configurations/Sections/EitrRefineryConfiguration.cs b/ValheimPlus/Configurations/Sections/EitrRefineryConfiguration.cs new file mode 100644 index 00000000..321f0192 --- /dev/null +++ b/ValheimPlus/Configurations/Sections/EitrRefineryConfiguration.cs @@ -0,0 +1,13 @@ +namespace ValheimPlus.Configurations.Sections +{ + public class EitrRefineryConfiguration : ServerSyncConfig + { + public int maximumSap { get; internal set; } = 20; + public int maximumSoftTissue { get; internal set; } = 20; + public float productionSpeed { get; internal set; } = 40; + public bool autoDeposit { get; internal set; } = true; + public bool autoFuel { get; internal set; } = true; + public bool ignorePrivateAreaCheck { get; internal set; } = true; + public float autoRange { get; internal set; } = 10; + } +} diff --git a/ValheimPlus/GameClasses/Smelter.cs b/ValheimPlus/GameClasses/Smelter.cs index a374d9b8..5cb24aee 100644 --- a/ValheimPlus/GameClasses/Smelter.cs +++ b/ValheimPlus/GameClasses/Smelter.cs @@ -51,6 +51,12 @@ private static void Prefix(ref Smelter __instance) __instance.m_maxOre = Configuration.Current.SpinningWheel.maximumFlax; __instance.m_secPerProduct = Configuration.Current.SpinningWheel.productionSpeed; } + else if (__instance.m_name.Equals(SmelterDefinitions.EitrRefineryName) && Configuration.Current.EitrRefinery.IsEnabled) + { + __instance.m_maxOre = Configuration.Current.EitrRefinery.maximumSap; + __instance.m_maxFuel = Configuration.Current.EitrRefinery.maximumSoftTissue; + __instance.m_secPerProduct = Configuration.Current.EitrRefinery.productionSpeed; + } } } @@ -82,7 +88,11 @@ private static bool Prefix(string ore, int stack, ref Smelter __instance) } if (__instance.m_name.Equals(SmelterDefinitions.SpinningWheelName) && Configuration.Current.SpinningWheel.IsEnabled && Configuration.Current.SpinningWheel.autoDeposit) { - return spawn(Helper.Clamp(Configuration.Current.SpinningWheel.autoRange, 1, 50), Configuration.Current.Windmill.ignorePrivateAreaCheck); + return spawn(Helper.Clamp(Configuration.Current.SpinningWheel.autoRange, 1, 50), Configuration.Current.SpinningWheel.ignorePrivateAreaCheck); + } + if (__instance.m_name.Equals(SmelterDefinitions.EitrRefineryName) && Configuration.Current.EitrRefinery.IsEnabled && Configuration.Current.EitrRefinery.autoDeposit) + { + return spawn(Helper.Clamp(Configuration.Current.EitrRefinery.autoRange, 1, 50), Configuration.Current.EitrRefinery.ignorePrivateAreaCheck); } bool spawn(float autoDepositRange, bool ignorePrivateAreaCheck) { @@ -196,6 +206,13 @@ static void Prefix(Smelter __instance) autoFuelRange = Configuration.Current.SpinningWheel.autoRange; ignorePrivateAreaCheck = Configuration.Current.SpinningWheel.ignorePrivateAreaCheck; } + else if (__instance.m_name.Equals(SmelterDefinitions.EitrRefineryName)) + { + if (!Configuration.Current.EitrRefinery.IsEnabled || !Configuration.Current.EitrRefinery.autoFuel) + return; + autoFuelRange = Configuration.Current.EitrRefinery.autoRange; + ignorePrivateAreaCheck = Configuration.Current.EitrRefinery.ignorePrivateAreaCheck; + } autoFuelRange = Helper.Clamp(autoFuelRange, 1, 50); @@ -345,6 +362,7 @@ public static class SmelterDefinitions public static readonly string FurnaceName = "$piece_blastfurnace"; public static readonly string WindmillName = "$piece_windmill"; public static readonly string SpinningWheelName = "$piece_spinningwheel"; + public static readonly string EitrRefineryName = "$piece_eitrrefinery"; } public static class FurnaceDefinitions diff --git a/valheim_plus.cfg b/valheim_plus.cfg index 32a8340e..f66fb08e 100644 --- a/valheim_plus.cfg +++ b/valheim_plus.cfg @@ -1001,6 +1001,35 @@ ignorePrivateAreaCheck=true autoRange=10 +[EitrRefinery] + +; Change false to true to enable this section. https://valheim.plus/documentation/list#EitrRefinery +enabled = false + +; Maximum amount of sap in an Eitr Refinery. +maximumSap = 20 + +; Maximum amount of soft tissue in an Eitr Refinery. +maximumSoftTissue = 20 + +; The time it takes for the Eitr Refinery to produce a single eitr in seconds. +productionSpeed = 40 + +; Instead of dropping the items, they will be placed inside the nearest nearby chests. +autoDeposit = true + +; The Eitr Refinery will pull sap and soft tissue from nearby chests to be automatically added to it when it's empty. +autoFuel = true + +; This option prevents the Eitr Refinery to pull items from warded areas if it isn't placed inside of it. +; For convenience, we recommend this to be set to true. +ignorePrivateAreaCheck = true + +; The range of the chest detection for the auto deposit and auto fuel features. +; Maximum is 50 +autoRange = 5 + + [PlayerProjectile] ; Change false to true to enable this section. https://valheim.plus/documentation/list#PlayerProjectile From 1f98b2fdb379526e23954f61a1d3fa1cb7023a76 Mon Sep 17 00:00:00 2001 From: Shawn Date: Tue, 31 Jan 2023 19:51:47 -0400 Subject: [PATCH 2/2] Nits for the config defaults Updating the Eitr Refinery defaults to match others. Also updating the Spinning Wheel. Updated the .csproj to build the new file as well. --- .../Sections/EitrRefineryConfiguration.cs | 10 ++++++++-- .../Sections/SpinningWheelConfiguration.cs | 4 ++-- ValheimPlus/ValheimPlus.csproj | 3 ++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/ValheimPlus/Configurations/Sections/EitrRefineryConfiguration.cs b/ValheimPlus/Configurations/Sections/EitrRefineryConfiguration.cs index 321f0192..136ca858 100644 --- a/ValheimPlus/Configurations/Sections/EitrRefineryConfiguration.cs +++ b/ValheimPlus/Configurations/Sections/EitrRefineryConfiguration.cs @@ -3,11 +3,17 @@ public class EitrRefineryConfiguration : ServerSyncConfig { public int maximumSap { get; internal set; } = 20; + public int maximumSoftTissue { get; internal set; } = 20; + public float productionSpeed { get; internal set; } = 40; - public bool autoDeposit { get; internal set; } = true; - public bool autoFuel { get; internal set; } = true; + + public bool autoDeposit { get; internal set; } = false; + + public bool autoFuel { get; internal set; } = false; + public bool ignorePrivateAreaCheck { get; internal set; } = true; + public float autoRange { get; internal set; } = 10; } } diff --git a/ValheimPlus/Configurations/Sections/SpinningWheelConfiguration.cs b/ValheimPlus/Configurations/Sections/SpinningWheelConfiguration.cs index dc9913e2..064ff417 100644 --- a/ValheimPlus/Configurations/Sections/SpinningWheelConfiguration.cs +++ b/ValheimPlus/Configurations/Sections/SpinningWheelConfiguration.cs @@ -4,8 +4,8 @@ public class SpinningWheelConfiguration : ServerSyncConfigfalse - + ..\packages\HarmonyX.2.10.0\lib\net45\0Harmony.dll @@ -343,6 +343,7 @@ +