From d0e20b0a83c3eaa9844b9662494d368919ffcac9 Mon Sep 17 00:00:00 2001 From: Soar Qin Date: Thu, 13 Jul 2023 19:16:28 +0800 Subject: [PATCH] WIP --- CheatEnabler/CheatEnabler.cs | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/CheatEnabler/CheatEnabler.cs b/CheatEnabler/CheatEnabler.cs index cfff9b1..863a482 100644 --- a/CheatEnabler/CheatEnabler.cs +++ b/CheatEnabler/CheatEnabler.cs @@ -169,34 +169,47 @@ public class CheatEnabler : BaseUnityPlugin private class AlwaysInfiniteResource { - [HarmonyTranspiler] - [HarmonyPatch(typeof(GameDesc), "isInfiniteResource", MethodType.Getter)] - private static IEnumerable ForceInfiniteResource(IEnumerable instructions) - { - yield return new CodeInstruction(OpCodes.Ldc_I4, 1); - yield return new CodeInstruction(OpCodes.Ret); - } - [HarmonyTranspiler] [HarmonyPatch(typeof(FactorySystem), "GameTick", typeof(long), typeof(bool))] [HarmonyPatch(typeof(FactorySystem), "GameTick", typeof(long), typeof(bool), typeof(int), typeof(int), typeof(int))] + [HarmonyPatch(typeof(ItemProto), "GetPropValue")] + [HarmonyPatch(typeof(PlanetTransport), "GameTick")] [HarmonyPatch(typeof(UIMinerWindow), "_OnUpdate")] + [HarmonyPatch(typeof(UIMiningUpgradeLabel), "Update")] + [HarmonyPatch(typeof(UIPlanetDetail), "OnPlanetDataSet")] + [HarmonyPatch(typeof(UIPlanetDetail), "RefreshDynamicProperties")] + [HarmonyPatch(typeof(UIStarDetail), "OnStarDataSet")] + [HarmonyPatch(typeof(UIStarDetail), "RefreshDynamicProperties")] + [HarmonyPatch(typeof(UIStationStorage), "RefreshValues")] [HarmonyPatch(typeof(UIVeinCollectorPanel), "_OnUpdate")] private static IEnumerable Transpiler(IEnumerable instructions) { foreach (var instruction in instructions) { - if (instruction.opcode == OpCodes.Ldc_R4 && instruction.OperandIs(99.5f)) + if (instruction.opcode == OpCodes.Ldfld && instruction.OperandIs(AccessTools.Field(typeof(GameHistoryData), "miningCostRate"))) { + yield return new CodeInstruction(OpCodes.Pop); yield return new CodeInstruction(OpCodes.Ldc_R4, 0f); } + else if (instruction.opcode == OpCodes.Ldfld && instruction.OperandIs(AccessTools.Field(typeof(GameHistoryData), "miningSpeedScale"))) + { + yield return new CodeInstruction(OpCodes.Pop); + yield return new CodeInstruction(OpCodes.Ldc_R4, 720f); + } else { yield return instruction; } } } + + [HarmonyPrefix, HarmonyPatch(typeof(BuildTool_BlueprintPaste), "get_bMeetTech")] + private static bool BuildTool_BlueprintPaste_get_bMeetTech_Prefix(ref bool __result) + { + __result = true; + return false; + } } private class UnlockTechOnGameStart