181 lines
8.6 KiB
C#
181 lines
8.6 KiB
C#
using System;
|
|
using System.Linq;
|
|
using BepInEx;
|
|
using BepInEx.Configuration;
|
|
using HarmonyLib;
|
|
using HarmonyLib.Tools;
|
|
using static TavernData;
|
|
|
|
namespace BlacksmithMaster {
|
|
[BepInPlugin(PluginGuid, PluginName, PluginVersion)]
|
|
public class Main : BaseUnityPlugin {
|
|
private const string PluginGuid = "Cykasmith";
|
|
private const string PluginName = "Cykasmith";
|
|
private const string PluginVersion = "1.0.0";
|
|
|
|
public static ConfigEntry<bool> debug;
|
|
|
|
public static ConfigEntry<float> xpMultiplier;
|
|
public static ConfigEntry<float> moneyMultiplier;
|
|
public static ConfigEntry<float> researchMultiplier;
|
|
public static ConfigEntry<float> salaryMultiplier;
|
|
public static ConfigEntry<float> dailyCustomerMultiplier;
|
|
public static ConfigEntry<float> dailyCustomerOffset;
|
|
public static ConfigEntry<float> decorationAdditionMultiplier;
|
|
public static ConfigEntry<float> decorationAdditionOffset;
|
|
public static ConfigEntry<float> globalSpeedMultiplier;
|
|
public static ConfigEntry<float> globalSpeedOffset;
|
|
public static ConfigEntry<float> hiringCostMultiplier;
|
|
public static ConfigEntry<bool> alwaysEvenly;
|
|
public static ConfigEntry<bool> alwaysChad;
|
|
|
|
public void Awake() {
|
|
debug = Config.Bind("General", "Debug", false);
|
|
|
|
xpMultiplier =
|
|
Config.Bind("General", "XP Multiplier", 1f,
|
|
new ConfigDescription("XP Multiplier", new AcceptableValueRange<float>(0.01f, 1024f)));
|
|
moneyMultiplier =
|
|
Config.Bind("General", "Money Multiplier", 1f,
|
|
new ConfigDescription("Money Multiplier", new AcceptableValueRange<float>(0.01f, 1024f)));
|
|
researchMultiplier = Config.Bind(
|
|
"General", "Research Multiplier", 1f,
|
|
new ConfigDescription("Research Multiplier", new AcceptableValueRange<float>(0.01f, 1024f)));
|
|
salaryMultiplier =
|
|
Config.Bind("General", "Salary Multiplier", 1f,
|
|
new ConfigDescription("Salary Multiplier", new AcceptableValueRange<float>(0.01f, 1024f)));
|
|
dailyCustomerMultiplier = Config.Bind(
|
|
"General", "Daily Customer Multiplier", 1f,
|
|
new ConfigDescription("Daily Customer Multiplier", new AcceptableValueRange<float>(0.01f, 1024f)));
|
|
dailyCustomerOffset = Config.Bind(
|
|
"General", "Daily Customer Offset", 0f,
|
|
new ConfigDescription("Daily Customer Offset", new AcceptableValueRange<float>(-1024f, 1024f)));
|
|
decorationAdditionMultiplier = Config.Bind(
|
|
"General", "Decoration Addition Multiplier", 1f,
|
|
new ConfigDescription("Decoration Addition Multiplier", new AcceptableValueRange<float>(0.01f, 1024f)));
|
|
decorationAdditionOffset = Config.Bind(
|
|
"General", "Decoration Addition Offset", 0f,
|
|
new ConfigDescription("Decoration Addition Offset", new AcceptableValueRange<float>(-1024f, 1024f)));
|
|
globalSpeedMultiplier = Config.Bind(
|
|
"General", "Global Speed Multiplier", 1f,
|
|
new ConfigDescription("Global Speed Multiplier", new AcceptableValueRange<float>(0.01f, 1024f)));
|
|
globalSpeedOffset = Config.Bind(
|
|
"General", "Global Speed Offset", 0f,
|
|
new ConfigDescription("Global Speed Offset", new AcceptableValueRange<float>(-1024f, 1024f)));
|
|
hiringCostMultiplier = Config.Bind(
|
|
"General", "Hiring Cost Multiplier", 1f,
|
|
new ConfigDescription("Hiring Cost Multiplier", new AcceptableValueRange<float>(0.01f, 1024f)));
|
|
alwaysEvenly =
|
|
Config.Bind("General", "Always Evenly", false,
|
|
new ConfigDescription("Always Evenly", new AcceptableValueRange<bool>(false, true)));
|
|
alwaysChad = Config.Bind("General", "Always Chad", false,
|
|
new ConfigDescription("Always Chad", new AcceptableValueRange<bool>(false, true)));
|
|
|
|
Logger.LogInfo("Cykasmith loaded");
|
|
HarmonyFileLog.Enabled = true;
|
|
Harmony harmony = new Harmony(PluginGuid);
|
|
harmony.PatchAll();
|
|
var originalMethods = harmony.GetPatchedMethods();
|
|
Logger.LogInfo("Patched " + originalMethods.Count() + " methods");
|
|
}
|
|
|
|
public static void LogDebug(string message) {
|
|
if (Main.debug.Value)
|
|
Console.WriteLine(message);
|
|
}
|
|
}
|
|
|
|
[HarmonyPatch(typeof(StaffBase), "AddXp")]
|
|
public class TavernData_AddXp {
|
|
public static void Prefix(ref int amount) {
|
|
Main.LogDebug("Original XP amount: " + amount);
|
|
amount = (int)((float)amount * Main.xpMultiplier.Value);
|
|
Main.LogDebug("Modified XP amount: " + amount);
|
|
}
|
|
}
|
|
|
|
[HarmonyPatch(typeof(TavernModel), "ChangeMoney")]
|
|
public class TavernModel_ChangeMoney {
|
|
public static void Prefix(ref int value) {
|
|
Main.LogDebug("Original money amount: " + value);
|
|
if (value > 0)
|
|
value = (int)((float)value * Main.moneyMultiplier.Value);
|
|
Main.LogDebug("Modified money amount: " + value);
|
|
}
|
|
}
|
|
|
|
[HarmonyPatch(typeof(ResourcesModel), "ChangeResearchPoints")]
|
|
public class ResourcesModel_ChangeResearchPoints {
|
|
public static void Prefix(ref int value) {
|
|
Main.LogDebug("Original research amount: " + value);
|
|
if (value > 0)
|
|
value = (int)((float)value * Main.researchMultiplier.Value);
|
|
Main.LogDebug("Modified research amount: " + value);
|
|
}
|
|
}
|
|
|
|
[HarmonyPatch(typeof(StaffInfo), "Salary", MethodType.Getter)]
|
|
public class StaffInfo_GetSalary {
|
|
public static void Postfix(ref int __result) {
|
|
Main.LogDebug("Original salary: " + __result);
|
|
__result = (int)((float)__result * Main.salaryMultiplier.Value);
|
|
Main.LogDebug("Modified salary: " + __result);
|
|
}
|
|
}
|
|
|
|
[HarmonyPatch(typeof(TavernModel), "GetNumberOfCustomersPerDay")]
|
|
public class TavernModel_GetNumberOfCustomersPerDay {
|
|
public static void Postfix(ref int __result) {
|
|
Main.LogDebug("Original number of customers per day: " + __result);
|
|
__result = (int)(__result * Main.dailyCustomerMultiplier.Value + Main.dailyCustomerOffset.Value);
|
|
Main.LogDebug("Modified number of customers per day: " + __result);
|
|
}
|
|
}
|
|
|
|
[HarmonyPatch(typeof(TavernModel), "GetBonusPercentageFromDecorations")]
|
|
public class TavernModel_GetBonusPercentageFromDecorations {
|
|
public static void Postfix(ref int __result) {
|
|
Main.LogDebug("Original bonus percentage from decorations: " + __result);
|
|
__result = (int)(__result * Main.decorationAdditionMultiplier.Value + Main.decorationAdditionOffset.Value);
|
|
Main.LogDebug("Modified bonus percentage from decorations: " + __result);
|
|
}
|
|
}
|
|
|
|
[HarmonyPatch(typeof(Economy), "GetWalkingSpeed")]
|
|
public class Economy_GetWalkingSpeed {
|
|
public static void Postfix(ref float __result) {
|
|
Main.LogDebug("Original walking speed: " + __result);
|
|
__result = __result * Main.globalSpeedMultiplier.Value + Main.globalSpeedOffset.Value;
|
|
Main.LogDebug("Modified walking speed: " + __result);
|
|
}
|
|
}
|
|
|
|
[HarmonyPatch(typeof(StaffModel), "GetCostToHire")]
|
|
public class StaffModel_GetCostToHire {
|
|
public static void Postfix(ref int __result) {
|
|
Main.LogDebug("Original hiring cost: " + __result);
|
|
__result = (int)(__result * Main.hiringCostMultiplier.Value);
|
|
Main.LogDebug("Modified hiring cost: " + __result);
|
|
}
|
|
}
|
|
|
|
[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");
|
|
if (Main.alwaysEvenly.Value)
|
|
newPerson.SkillAssignmentStrategy = TavernData.SkillAssignmentStrategyType.Balanced;
|
|
}
|
|
}
|
|
|
|
[HarmonyPatch(typeof(HireData), "GetStaffInfo")]
|
|
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");
|
|
if (Main.alwaysChad.Value)
|
|
shouldBeSuperWorker = true;
|
|
}
|
|
}
|
|
}
|