Add debug option for every other config option
This commit is contained in:
@@ -14,6 +14,15 @@ namespace BlacksmithMaster {
|
|||||||
private const string PluginVersion = "1.0.0";
|
private const string PluginVersion = "1.0.0";
|
||||||
|
|
||||||
public static ConfigEntry<bool> debug;
|
public static ConfigEntry<bool> debug;
|
||||||
|
public static ConfigEntry<bool> debugXp;
|
||||||
|
public static ConfigEntry<bool> debugMoney;
|
||||||
|
public static ConfigEntry<bool> debugResearch;
|
||||||
|
public static ConfigEntry<bool> debugSalary;
|
||||||
|
public static ConfigEntry<bool> debugCustomers;
|
||||||
|
public static ConfigEntry<bool> debugDecorations;
|
||||||
|
public static ConfigEntry<bool> debugSpeed;
|
||||||
|
public static ConfigEntry<bool> debugHiring;
|
||||||
|
public static ConfigEntry<bool> debugMining;
|
||||||
|
|
||||||
public static ConfigEntry<float> xpMultiplier;
|
public static ConfigEntry<float> xpMultiplier;
|
||||||
public static ConfigEntry<float> moneyMultiplier;
|
public static ConfigEntry<float> moneyMultiplier;
|
||||||
@@ -31,7 +40,16 @@ namespace BlacksmithMaster {
|
|||||||
public static ConfigEntry<bool> alwaysChad;
|
public static ConfigEntry<bool> alwaysChad;
|
||||||
|
|
||||||
public void Awake() {
|
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 =
|
xpMultiplier =
|
||||||
Config.Bind("General", "XP Multiplier", 1f,
|
Config.Bind("General", "XP Multiplier", 1f,
|
||||||
@@ -66,9 +84,9 @@ namespace BlacksmithMaster {
|
|||||||
hiringCostMultiplier = Config.Bind(
|
hiringCostMultiplier = Config.Bind(
|
||||||
"General", "Hiring Cost Multiplier", 1f,
|
"General", "Hiring Cost Multiplier", 1f,
|
||||||
new ConfigDescription("Hiring Cost Multiplier", new AcceptableValueRange<float>(0.01f, 1024f)));
|
new ConfigDescription("Hiring Cost Multiplier", new AcceptableValueRange<float>(0.01f, 1024f)));
|
||||||
miningMultiplier = Config.Bind(
|
miningMultiplier =
|
||||||
"General", "Mining Multiplier", 1f,
|
Config.Bind("General", "Mining Multiplier", 1f,
|
||||||
new ConfigDescription("Mining Multiplier", new AcceptableValueRange<float>(0.01f, 1024f)));
|
new ConfigDescription("Mining Multiplier", new AcceptableValueRange<float>(0.01f, 1024f)));
|
||||||
alwaysEvenly =
|
alwaysEvenly =
|
||||||
Config.Bind("General", "Always Evenly", false,
|
Config.Bind("General", "Always Evenly", false,
|
||||||
new ConfigDescription("Always Evenly", new AcceptableValueRange<bool>(false, true)));
|
new ConfigDescription("Always Evenly", new AcceptableValueRange<bool>(false, true)));
|
||||||
@@ -83,8 +101,8 @@ namespace BlacksmithMaster {
|
|||||||
Logger.LogInfo("Patched " + originalMethods.Count() + " methods");
|
Logger.LogInfo("Patched " + originalMethods.Count() + " methods");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void LogDebug(string message) {
|
public static void LogDebug(string message, ConfigEntry<bool> debugFlag = null) {
|
||||||
if (Main.debug.Value)
|
if (debug.Value || (debugFlag != null && debugFlag.Value))
|
||||||
Console.WriteLine(message);
|
Console.WriteLine(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -92,81 +110,81 @@ namespace BlacksmithMaster {
|
|||||||
[HarmonyPatch(typeof(StaffBase), "AddXp")]
|
[HarmonyPatch(typeof(StaffBase), "AddXp")]
|
||||||
public class TavernData_AddXp {
|
public class TavernData_AddXp {
|
||||||
public static void Prefix(ref int amount) {
|
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);
|
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")]
|
[HarmonyPatch(typeof(TavernModel), "ChangeMoney")]
|
||||||
public class TavernModel_ChangeMoney {
|
public class TavernModel_ChangeMoney {
|
||||||
public static void Prefix(ref int value) {
|
public static void Prefix(ref int value) {
|
||||||
Main.LogDebug("Original money amount: " + value);
|
Main.LogDebug("Original money amount: " + value, Main.debugMoney);
|
||||||
if (value > 0)
|
if (value > 0)
|
||||||
value = (int)((float)value * Main.moneyMultiplier.Value);
|
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")]
|
[HarmonyPatch(typeof(ResourcesModel), "ChangeResearchPoints")]
|
||||||
public class ResourcesModel_ChangeResearchPoints {
|
public class ResourcesModel_ChangeResearchPoints {
|
||||||
public static void Prefix(ref int value) {
|
public static void Prefix(ref int value) {
|
||||||
Main.LogDebug("Original research amount: " + value);
|
Main.LogDebug("Original research amount: " + value, Main.debugResearch);
|
||||||
if (value > 0)
|
if (value > 0)
|
||||||
value = (int)((float)value * Main.researchMultiplier.Value);
|
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)]
|
[HarmonyPatch(typeof(StaffInfo), "Salary", MethodType.Getter)]
|
||||||
public class StaffInfo_GetSalary {
|
public class StaffInfo_GetSalary {
|
||||||
public static void Postfix(ref int __result) {
|
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);
|
__result = (int)((float)__result * Main.salaryMultiplier.Value);
|
||||||
Main.LogDebug("Modified salary: " + __result);
|
Main.LogDebug("Modified salary: " + __result, Main.debugSalary);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[HarmonyPatch(typeof(TavernModel), "GetNumberOfCustomersPerDay")]
|
[HarmonyPatch(typeof(TavernModel), "GetNumberOfCustomersPerDay")]
|
||||||
public class TavernModel_GetNumberOfCustomersPerDay {
|
public class TavernModel_GetNumberOfCustomersPerDay {
|
||||||
public static void Postfix(ref int __result) {
|
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);
|
__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")]
|
[HarmonyPatch(typeof(TavernModel), "GetBonusPercentageFromDecorations")]
|
||||||
public class TavernModel_GetBonusPercentageFromDecorations {
|
public class TavernModel_GetBonusPercentageFromDecorations {
|
||||||
public static void Postfix(ref int __result) {
|
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);
|
__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")]
|
[HarmonyPatch(typeof(Economy), "GetWalkingSpeed")]
|
||||||
public class Economy_GetWalkingSpeed {
|
public class Economy_GetWalkingSpeed {
|
||||||
public static void Postfix(ref float __result) {
|
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;
|
__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")]
|
[HarmonyPatch(typeof(StaffModel), "GetCostToHire")]
|
||||||
public class StaffModel_GetCostToHire {
|
public class StaffModel_GetCostToHire {
|
||||||
public static void Postfix(ref int __result) {
|
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);
|
__result = (int)(__result * Main.hiringCostMultiplier.Value);
|
||||||
Main.LogDebug("Modified hiring cost: " + __result);
|
Main.LogDebug("Modified hiring cost: " + __result, Main.debugHiring);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[HarmonyPatch(typeof(StaffUtil), "FillBasicInfo")]
|
[HarmonyPatch(typeof(StaffUtil), "FillBasicInfo")]
|
||||||
public class StaffUtil_FillBasicInfo {
|
public class StaffUtil_FillBasicInfo {
|
||||||
public static void Postfix(TavernData.StaffType staffType, Random rnd, ref TavernData.StaffInfo newPerson) {
|
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)
|
if (Main.alwaysEvenly.Value)
|
||||||
newPerson.SkillAssignmentStrategy = TavernData.SkillAssignmentStrategyType.Balanced;
|
newPerson.SkillAssignmentStrategy = TavernData.SkillAssignmentStrategyType.Balanced;
|
||||||
}
|
}
|
||||||
@@ -176,7 +194,7 @@ namespace BlacksmithMaster {
|
|||||||
public class TavernData_GetStaffInfo {
|
public class TavernData_GetStaffInfo {
|
||||||
public static void Prefix(Random rnd, int id, string staffName, bool isMale, ref bool shouldBeSuperWorker,
|
public static void Prefix(Random rnd, int id, string staffName, bool isMale, ref bool shouldBeSuperWorker,
|
||||||
ref EliteTraitType forcedEliteTrait) {
|
ref EliteTraitType forcedEliteTrait) {
|
||||||
Main.LogDebug("Setting shouldBeSuperWorker to true");
|
Main.LogDebug("Setting shouldBeSuperWorker to true", Main.debug);
|
||||||
if (Main.alwaysChad.Value)
|
if (Main.alwaysChad.Value)
|
||||||
shouldBeSuperWorker = true;
|
shouldBeSuperWorker = true;
|
||||||
}
|
}
|
||||||
@@ -188,17 +206,17 @@ namespace BlacksmithMaster {
|
|||||||
public static void Prefix(ref MineBoxController __instance) {
|
public static void Prefix(ref MineBoxController __instance) {
|
||||||
var trav = Traverse.Create(__instance);
|
var trav = Traverse.Create(__instance);
|
||||||
var piecesInsideAmount = trav.Field("PiecesInsideAmount");
|
var piecesInsideAmount = trav.Field("PiecesInsideAmount");
|
||||||
Main.LogDebug("Original pieces: " + piecesInsideAmount.GetValue<int>());
|
Main.LogDebug("Original pieces: " + piecesInsideAmount.GetValue<int>(), Main.debugMining);
|
||||||
before = piecesInsideAmount.GetValue<int>();
|
before = piecesInsideAmount.GetValue<int>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Postfix(ref MineBoxController __instance) {
|
public static void Postfix(ref MineBoxController __instance) {
|
||||||
var trav = Traverse.Create(__instance);
|
var trav = Traverse.Create(__instance);
|
||||||
var piecesInsideAmount = trav.Field("PiecesInsideAmount");
|
var piecesInsideAmount = trav.Field("PiecesInsideAmount");
|
||||||
Main.LogDebug("Original pieces: " + piecesInsideAmount.GetValue<int>());
|
Main.LogDebug("Original pieces: " + piecesInsideAmount.GetValue<int>(), Main.debugMining);
|
||||||
var delta = piecesInsideAmount.GetValue<int>() - before;
|
var delta = piecesInsideAmount.GetValue<int>() - before;
|
||||||
piecesInsideAmount.SetValue(before + (int)(delta * Main.miningMultiplier.Value));
|
piecesInsideAmount.SetValue(before + (int)(delta * Main.miningMultiplier.Value));
|
||||||
Main.LogDebug("Modified pieces: " + piecesInsideAmount.GetValue<int>());
|
Main.LogDebug("Modified pieces: " + piecesInsideAmount.GetValue<int>(), Main.debugMining);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user