From dea6ae77666c5020f4a4d8f4f0f1f226499751a4 Mon Sep 17 00:00:00 2001 From: Shawn Date: Mon, 23 Jan 2023 15:27:44 -0400 Subject: [PATCH 1/3] Update Player.cs Fix food degradation for eitr. --- ValheimPlus/GameClasses/Player.cs | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/ValheimPlus/GameClasses/Player.cs b/ValheimPlus/GameClasses/Player.cs index a9a51141..42753e70 100644 --- a/ValheimPlus/GameClasses/Player.cs +++ b/ValheimPlus/GameClasses/Player.cs @@ -323,12 +323,14 @@ private static bool IsInsideNoBuildLocation(Vector3 point) [HarmonyPatch(typeof(Player), nameof(Player.GetTotalFoodValue))] public static class Player_GetTotalFoodValue_Transpiler { - private static FieldInfo field_Food_m_health = AccessTools.Field(typeof(Player.Food), nameof(Player.Food.m_health)); - private static FieldInfo field_Food_m_stamina = AccessTools.Field(typeof(Player.Food), nameof(Player.Food.m_stamina)); - private static FieldInfo field_Food_m_item = AccessTools.Field(typeof(Player.Food), nameof(Player.Food.m_item)); - private static FieldInfo field_ItemData_m_shared = AccessTools.Field(typeof(ItemDrop.ItemData), nameof(ItemDrop.ItemData.m_shared)); - private static FieldInfo field_SharedData_m_food = AccessTools.Field(typeof(ItemDrop.ItemData.SharedData), nameof(ItemDrop.ItemData.SharedData.m_food)); - private static FieldInfo field_SharedData_m_foodStamina = AccessTools.Field(typeof(ItemDrop.ItemData.SharedData), nameof(ItemDrop.ItemData.SharedData.m_foodStamina)); + private static readonly FieldInfo field_Food_m_health = AccessTools.Field(typeof(Player.Food), nameof(Player.Food.m_health)); + private static readonly FieldInfo field_Food_m_stamina = AccessTools.Field(typeof(Player.Food), nameof(Player.Food.m_stamina)); + private static readonly FieldInfo field_Food_m_eitr = AccessTools.Field(typeof(Player.Food), nameof(Player.Food.m_eitr)); + private static readonly FieldInfo field_Food_m_item = AccessTools.Field(typeof(Player.Food), nameof(Player.Food.m_item)); + private static readonly FieldInfo field_ItemData_m_shared = AccessTools.Field(typeof(ItemDrop.ItemData), nameof(ItemDrop.ItemData.m_shared)); + private static readonly FieldInfo field_SharedData_m_food = AccessTools.Field(typeof(ItemDrop.ItemData.SharedData), nameof(ItemDrop.ItemData.SharedData.m_food)); + private static readonly FieldInfo field_SharedData_m_foodStamina = AccessTools.Field(typeof(ItemDrop.ItemData.SharedData), nameof(ItemDrop.ItemData.SharedData.m_foodStamina)); + private static readonly FieldInfo field_SharedData_m_foodEitr = AccessTools.Field(typeof(ItemDrop.ItemData.SharedData), nameof(ItemDrop.ItemData.SharedData.m_foodEitr)); /// /// Replaces loads to the current health/stamina for food with loads to the original health/stamina for food @@ -347,12 +349,23 @@ public static IEnumerable Transpiler(IEnumerable Date: Mon, 23 Jan 2023 16:18:32 -0400 Subject: [PATCH 2/3] 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 34e98ed54c755e3308b613a51a00f41dbde8a770 Mon Sep 17 00:00:00 2001 From: Shawn Date: Mon, 23 Jan 2023 16:23:55 -0400 Subject: [PATCH 3/3] Revert "Add configuration and classes for the Eitr Refinery" This reverts commit 3f9d35cd9141bd88951098ca8105eafdb1302d1b. --- README.md | 3 +- ValheimPlus/Configurations/Configuration.cs | 1 - .../Sections/EitrRefineryConfiguration.cs | 13 --------- ValheimPlus/GameClasses/Smelter.cs | 20 +------------ valheim_plus.cfg | 29 ------------------- 5 files changed, 2 insertions(+), 64 deletions(-) delete mode 100644 ValheimPlus/Configurations/Sections/EitrRefineryConfiguration.cs diff --git a/README.md b/README.md index 398ecad0..45363758 100644 --- a/README.md +++ b/README.md @@ -446,5 +446,4 @@ 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 -* Shawn - https://github.com/shawnwallace \ No newline at end of file +* Radvo - https://github.com/Radvo \ No newline at end of file diff --git a/ValheimPlus/Configurations/Configuration.cs b/ValheimPlus/Configurations/Configuration.cs index 8bd2c17f..115f6e94 100644 --- a/ValheimPlus/Configurations/Configuration.cs +++ b/ValheimPlus/Configurations/Configuration.cs @@ -23,7 +23,6 @@ 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 deleted file mode 100644 index 321f0192..00000000 --- a/ValheimPlus/Configurations/Sections/EitrRefineryConfiguration.cs +++ /dev/null @@ -1,13 +0,0 @@ -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 5cb24aee..a374d9b8 100644 --- a/ValheimPlus/GameClasses/Smelter.cs +++ b/ValheimPlus/GameClasses/Smelter.cs @@ -51,12 +51,6 @@ 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; - } } } @@ -88,11 +82,7 @@ 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.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); + return spawn(Helper.Clamp(Configuration.Current.SpinningWheel.autoRange, 1, 50), Configuration.Current.Windmill.ignorePrivateAreaCheck); } bool spawn(float autoDepositRange, bool ignorePrivateAreaCheck) { @@ -206,13 +196,6 @@ 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); @@ -362,7 +345,6 @@ 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 f66fb08e..32a8340e 100644 --- a/valheim_plus.cfg +++ b/valheim_plus.cfg @@ -1001,35 +1001,6 @@ 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