From fbcabc90b7f3382f80b501ef0bb092d23f7505c2 Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Sat, 17 May 2025 13:52:38 +0200 Subject: [PATCH] Add mining multiplier --- .../BlacksmithMaster/Class1.cs | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Projects/BlacksmithMaster/BlacksmithMaster/Class1.cs b/Projects/BlacksmithMaster/BlacksmithMaster/Class1.cs index ad1e654..3d1fac3 100644 --- a/Projects/BlacksmithMaster/BlacksmithMaster/Class1.cs +++ b/Projects/BlacksmithMaster/BlacksmithMaster/Class1.cs @@ -26,6 +26,7 @@ namespace BlacksmithMaster { public static ConfigEntry globalSpeedMultiplier; public static ConfigEntry globalSpeedOffset; public static ConfigEntry hiringCostMultiplier; + public static ConfigEntry miningMultiplier; public static ConfigEntry alwaysEvenly; public static ConfigEntry alwaysChad; @@ -65,6 +66,9 @@ namespace BlacksmithMaster { hiringCostMultiplier = Config.Bind( "General", "Hiring Cost Multiplier", 1f, new ConfigDescription("Hiring Cost Multiplier", new AcceptableValueRange(0.01f, 1024f))); + miningMultiplier = Config.Bind( + "General", "Mining Multiplier", 1f, + new ConfigDescription("Mining Multiplier", new AcceptableValueRange(0.01f, 1024f))); alwaysEvenly = Config.Bind("General", "Always Evenly", false, new ConfigDescription("Always Evenly", new AcceptableValueRange(false, true))); @@ -177,4 +181,24 @@ namespace BlacksmithMaster { shouldBeSuperWorker = true; } } + + [HarmonyPatch(typeof(MineBoxController), "AddMineralPiece")] + public class MineBoxController_AddMineralPiece { + private static int before; + public static void Prefix(ref MineBoxController __instance) { + var trav = Traverse.Create(__instance); + var piecesInsideAmount = trav.Field("PiecesInsideAmount"); + Main.LogDebug("Original pieces: " + piecesInsideAmount.GetValue()); + before = piecesInsideAmount.GetValue(); + } + + public static void Postfix(ref MineBoxController __instance) { + var trav = Traverse.Create(__instance); + var piecesInsideAmount = trav.Field("PiecesInsideAmount"); + Main.LogDebug("Original pieces: " + piecesInsideAmount.GetValue()); + var delta = piecesInsideAmount.GetValue() - before; + piecesInsideAmount.SetValue(before + (int)(delta * Main.miningMultiplier.Value)); + Main.LogDebug("Modified pieces: " + piecesInsideAmount.GetValue()); + } + } }