diff --git a/Projects/BlacksmithMaster/BlacksmithMaster/Class1.cs b/Projects/BlacksmithMaster/BlacksmithMaster/Class1.cs index 3d1fac3..a9dbe23 100644 --- a/Projects/BlacksmithMaster/BlacksmithMaster/Class1.cs +++ b/Projects/BlacksmithMaster/BlacksmithMaster/Class1.cs @@ -14,6 +14,15 @@ namespace BlacksmithMaster { private const string PluginVersion = "1.0.0"; public static ConfigEntry debug; + public static ConfigEntry debugXp; + public static ConfigEntry debugMoney; + public static ConfigEntry debugResearch; + public static ConfigEntry debugSalary; + public static ConfigEntry debugCustomers; + public static ConfigEntry debugDecorations; + public static ConfigEntry debugSpeed; + public static ConfigEntry debugHiring; + public static ConfigEntry debugMining; public static ConfigEntry xpMultiplier; public static ConfigEntry moneyMultiplier; @@ -31,7 +40,16 @@ namespace BlacksmithMaster { public static ConfigEntry alwaysChad; public void Awake() { - debug = Config.Bind("General", "Debug", false); + debug = Config.Bind("Debug", "Global Debug", false); + debugXp = Config.Bind("Debug", "XP Debug", false); + debugMoney = Config.Bind("Debug", "Money Debug", false); + debugResearch = Config.Bind("Debug", "Research Debug", false); + debugSalary = Config.Bind("Debug", "Salary Debug", false); + debugCustomers = Config.Bind("Debug", "Customers Debug", false); + debugDecorations = Config.Bind("Debug", "Decorations Debug", false); + debugSpeed = Config.Bind("Debug", "Speed Debug", false); + debugHiring = Config.Bind("Debug", "Hiring Debug", false); + debugMining = Config.Bind("Debug", "Mining Debug", false); xpMultiplier = Config.Bind("General", "XP Multiplier", 1f, @@ -66,9 +84,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))); + 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))); @@ -83,8 +101,8 @@ namespace BlacksmithMaster { Logger.LogInfo("Patched " + originalMethods.Count() + " methods"); } - public static void LogDebug(string message) { - if (Main.debug.Value) + public static void LogDebug(string message, ConfigEntry debugFlag = null) { + if (debug.Value || (debugFlag != null && debugFlag.Value)) Console.WriteLine(message); } } @@ -92,81 +110,81 @@ namespace BlacksmithMaster { [HarmonyPatch(typeof(StaffBase), "AddXp")] public class TavernData_AddXp { public static void Prefix(ref int amount) { - Main.LogDebug("Original XP amount: " + amount); + Main.LogDebug("Original XP amount: " + amount, Main.debugXp); amount = (int)((float)amount * Main.xpMultiplier.Value); - Main.LogDebug("Modified XP amount: " + amount); + Main.LogDebug("Modified XP amount: " + amount, Main.debugXp); } } [HarmonyPatch(typeof(TavernModel), "ChangeMoney")] public class TavernModel_ChangeMoney { public static void Prefix(ref int value) { - Main.LogDebug("Original money amount: " + value); + Main.LogDebug("Original money amount: " + value, Main.debugMoney); if (value > 0) value = (int)((float)value * Main.moneyMultiplier.Value); - Main.LogDebug("Modified money amount: " + value); + Main.LogDebug("Modified money amount: " + value, Main.debugMoney); } } [HarmonyPatch(typeof(ResourcesModel), "ChangeResearchPoints")] public class ResourcesModel_ChangeResearchPoints { public static void Prefix(ref int value) { - Main.LogDebug("Original research amount: " + value); + Main.LogDebug("Original research amount: " + value, Main.debugResearch); if (value > 0) value = (int)((float)value * Main.researchMultiplier.Value); - Main.LogDebug("Modified research amount: " + value); + Main.LogDebug("Modified research amount: " + value, Main.debugResearch); } } [HarmonyPatch(typeof(StaffInfo), "Salary", MethodType.Getter)] public class StaffInfo_GetSalary { public static void Postfix(ref int __result) { - Main.LogDebug("Original salary: " + __result); + Main.LogDebug("Original salary: " + __result, Main.debugSalary); __result = (int)((float)__result * Main.salaryMultiplier.Value); - Main.LogDebug("Modified salary: " + __result); + Main.LogDebug("Modified salary: " + __result, Main.debugSalary); } } [HarmonyPatch(typeof(TavernModel), "GetNumberOfCustomersPerDay")] public class TavernModel_GetNumberOfCustomersPerDay { public static void Postfix(ref int __result) { - Main.LogDebug("Original number of customers per day: " + __result); + Main.LogDebug("Original number of customers per day: " + __result, Main.debugCustomers); __result = (int)(__result * Main.dailyCustomerMultiplier.Value + Main.dailyCustomerOffset.Value); - Main.LogDebug("Modified number of customers per day: " + __result); + Main.LogDebug("Modified number of customers per day: " + __result, Main.debugCustomers); } } [HarmonyPatch(typeof(TavernModel), "GetBonusPercentageFromDecorations")] public class TavernModel_GetBonusPercentageFromDecorations { public static void Postfix(ref int __result) { - Main.LogDebug("Original bonus percentage from decorations: " + __result); + Main.LogDebug("Original bonus percentage from decorations: " + __result, Main.debugDecorations); __result = (int)(__result * Main.decorationAdditionMultiplier.Value + Main.decorationAdditionOffset.Value); - Main.LogDebug("Modified bonus percentage from decorations: " + __result); + Main.LogDebug("Modified bonus percentage from decorations: " + __result, Main.debugDecorations); } } [HarmonyPatch(typeof(Economy), "GetWalkingSpeed")] public class Economy_GetWalkingSpeed { public static void Postfix(ref float __result) { - Main.LogDebug("Original walking speed: " + __result); + Main.LogDebug("Original walking speed: " + __result, Main.debugSpeed); __result = __result * Main.globalSpeedMultiplier.Value + Main.globalSpeedOffset.Value; - Main.LogDebug("Modified walking speed: " + __result); + Main.LogDebug("Modified walking speed: " + __result, Main.debugSpeed); } } [HarmonyPatch(typeof(StaffModel), "GetCostToHire")] public class StaffModel_GetCostToHire { public static void Postfix(ref int __result) { - Main.LogDebug("Original hiring cost: " + __result); + Main.LogDebug("Original hiring cost: " + __result, Main.debugHiring); __result = (int)(__result * Main.hiringCostMultiplier.Value); - Main.LogDebug("Modified hiring cost: " + __result); + Main.LogDebug("Modified hiring cost: " + __result, Main.debugHiring); } } [HarmonyPatch(typeof(StaffUtil), "FillBasicInfo")] public class StaffUtil_FillBasicInfo { public static void Postfix(TavernData.StaffType staffType, Random rnd, ref TavernData.StaffInfo newPerson) { - Main.LogDebug("Setting skill assignment strategy to evenly"); + Main.LogDebug("Setting skill assignment strategy to evenly", Main.debug); if (Main.alwaysEvenly.Value) newPerson.SkillAssignmentStrategy = TavernData.SkillAssignmentStrategyType.Balanced; } @@ -176,7 +194,7 @@ namespace BlacksmithMaster { public class TavernData_GetStaffInfo { public static void Prefix(Random rnd, int id, string staffName, bool isMale, ref bool shouldBeSuperWorker, ref EliteTraitType forcedEliteTrait) { - Main.LogDebug("Setting shouldBeSuperWorker to true"); + Main.LogDebug("Setting shouldBeSuperWorker to true", Main.debug); if (Main.alwaysChad.Value) shouldBeSuperWorker = true; } @@ -188,17 +206,17 @@ namespace BlacksmithMaster { public static void Prefix(ref MineBoxController __instance) { var trav = Traverse.Create(__instance); var piecesInsideAmount = trav.Field("PiecesInsideAmount"); - Main.LogDebug("Original pieces: " + piecesInsideAmount.GetValue()); + Main.LogDebug("Original pieces: " + piecesInsideAmount.GetValue(), Main.debugMining); 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()); + Main.LogDebug("Original pieces: " + piecesInsideAmount.GetValue(), Main.debugMining); var delta = piecesInsideAmount.GetValue() - before; piecesInsideAmount.SetValue(before + (int)(delta * Main.miningMultiplier.Value)); - Main.LogDebug("Modified pieces: " + piecesInsideAmount.GetValue()); + Main.LogDebug("Modified pieces: " + piecesInsideAmount.GetValue(), Main.debugMining); } } }