Add player count faker
This commit is contained in:
@@ -14,10 +14,10 @@ namespace CykaMod {
|
||||
private const string pluginName = "SupermarketTogether";
|
||||
private const string pluginVersion = "1.0.0";
|
||||
|
||||
// public static ConfigEntry<float> skillCap;
|
||||
public static ConfigEntry<int> playersAdded;
|
||||
|
||||
public void Awake() {
|
||||
// skillCap = Config.Bind("General", "Skill Cap", 100f);
|
||||
playersAdded = Config.Bind("General", "PlayersAdded", 0);
|
||||
|
||||
Logger.LogInfo("Cyka mod loaded");
|
||||
HarmonyFileLog.Enabled = true;
|
||||
@@ -28,6 +28,16 @@ namespace CykaMod {
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(GameData), "UserCode_CmdOpenSupermarket")]
|
||||
public static class Debug {
|
||||
static void Postfix(GameData __instance) {
|
||||
Console.WriteLine("Called UserCode_CmdOpenSupermarket");
|
||||
Console.WriteLine($"timeFactor: {__instance.timeFactor}");
|
||||
Console.WriteLine($"maxProductsCustomersToBuy: {__instance.maxProductsCustomersToBuy}");
|
||||
Console.WriteLine($"maxCustomersNPCs: {__instance.maxCustomersNPCs}");
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(UpgradesManager), "ManageExtraPerks")]
|
||||
public static class ConsoleProductionReductionPatch {
|
||||
static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) {
|
||||
@@ -43,4 +53,32 @@ namespace CykaMod {
|
||||
return codes.AsEnumerable();
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(GameData), "UserCode_CmdOpenSupermarket")]
|
||||
public static class PlayersAddedTranspilePatch {
|
||||
static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) {
|
||||
var codes = new List<CodeInstruction>(instructions);
|
||||
|
||||
// foreach (var codeInstruction in codes) {
|
||||
// Console.WriteLine(codeInstruction);
|
||||
// }
|
||||
|
||||
CodeInstruction previous = codes[0];
|
||||
for (int i = 1; i < codes.Count; i++) {
|
||||
if (previous.opcode == OpCodes.Ldsfld && codes[i].opcode == OpCodes.Callvirt) {
|
||||
Console.WriteLine("Found Ldsfld and Callvirt");
|
||||
codes.Insert(i + 1, new CodeInstruction(OpCodes.Ldc_I4, Main.playersAdded.Value));
|
||||
codes.Insert(i + 2, new CodeInstruction(OpCodes.Add));
|
||||
}
|
||||
|
||||
previous = codes[i];
|
||||
}
|
||||
|
||||
// foreach (var codeInstruction in codes) {
|
||||
// Console.WriteLine(codeInstruction);
|
||||
// }
|
||||
|
||||
return codes.AsEnumerable();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user