diff --git a/MechaDronesTweaks/MechaDronesTweaks.cs b/MechaDronesTweaks/MechaDronesTweaks.cs index 2778f3d..1a9271d 100644 --- a/MechaDronesTweaks/MechaDronesTweaks.cs +++ b/MechaDronesTweaks/MechaDronesTweaks.cs @@ -73,11 +73,13 @@ public static class MechaDronesTweaks public static float EnergyMultiplier = 0.1f; [HarmonyTranspiler, HarmonyPatch(typeof(UITechTree), "RefreshDataValueText")] - private static IEnumerable UITechTreeRefreshDataValueText_Transpiler(IEnumerable instructions) + private static IEnumerable UITechTreeRefreshDataValueText_Transpiler( + IEnumerable instructions) { foreach (var instr in instructions) { - if (instr.opcode == OpCodes.Callvirt && instr.OperandIs(AccessTools.Method(typeof(Mecha), "get_droneSpeed"))) + if (instr.opcode == OpCodes.Callvirt && + instr.OperandIs(AccessTools.Method(typeof(Mecha), "get_droneSpeed"))) { if (UseFixedSpeed) { @@ -116,6 +118,7 @@ public static class MechaDronesTweaks instr.opcode = OpCodes.Ldc_I4_2; } } + yield return instr; } } @@ -180,9 +183,11 @@ public static class MechaDronesTweaks yield return new CodeInstruction(OpCodes.Ldc_R4, SpeedMultiplier); yield return new CodeInstruction(OpCodes.Mul); } + i++; continue; } + if (instrNext.opcode == OpCodes.Ldc_R4) { if (instrNext.OperandIs(0f)) @@ -218,7 +223,10 @@ public static class MechaDronesTweaks { if (UseFixedSpeed) { - if (FixedSpeed > 75f) { instr.operand = 0.5f * FixedSpeed / 75f; } + if (FixedSpeed > 75f) + { + instr.operand = 0.5f * FixedSpeed / 75f; + } } else { @@ -233,10 +241,122 @@ public static class MechaDronesTweaks } } } + yield return instr; } } + [HarmonyTranspiler] + [HarmonyPatch(typeof(BuildTool_Dismantle), nameof(BuildTool_Dismantle.DeterminePreviews))] + [HarmonyPatch(typeof(BuildTool_Upgrade), nameof(BuildTool_Upgrade.DeterminePreviews))] + private static IEnumerable BuildTools_CursorSizePatch_Transpiler( + IEnumerable instructions) + { + foreach (var instr in instructions) + { + if (instr.opcode == OpCodes.Ldc_I4_S && instr.OperandIs(11)) + { + yield return new CodeInstruction(OpCodes.Ldc_I4_S, 31); + } + else + { + yield return instr; + } + } + } + + [HarmonyTranspiler, HarmonyPatch(typeof(BuildTool_Reform), nameof(BuildTool_Reform.ReformAction))] + private static IEnumerable BuildTool_Reform_ReformAction_Transpiler( + IEnumerable instructions) + { + var ilist = instructions.ToList(); + for (var i = 0; i < ilist.Count; i++) + { + var instr = ilist[i]; + if (instr.opcode == OpCodes.Ldc_I4_S && instr.OperandIs(10) && + (ilist[i - 1].opcode == OpCodes.Ldfld && + ilist[i - 1].OperandIs(AccessTools.Field(typeof(BuildTool_Reform), "brushSize")) + || + ilist[i + 1].opcode == OpCodes.Stfld && + ilist[i + 1].OperandIs(AccessTools.Field(typeof(BuildTool_Reform), "brushSize"))) + ) + { + yield return new CodeInstruction(OpCodes.Ldc_I4_S, 30); + } + else + { + yield return instr; + } + } + } + + + [HarmonyTranspiler, HarmonyPatch(typeof(ConnGizmoGraph), MethodType.Constructor)] + private static IEnumerable ConnGizmoGraph_Constructor_Transpiler( + IEnumerable instructions) + { + foreach (var instr in instructions) + { + if (instr.opcode == OpCodes.Ldc_I4 && instr.OperandIs(256)) + { + yield return new CodeInstruction(OpCodes.Ldc_I4, 2048); + } + else + { + yield return instr; + } + } + } + + [HarmonyTranspiler, HarmonyPatch(typeof(ConnGizmoGraph), nameof(ConnGizmoGraph.SetPointCount))] + private static IEnumerable ConnGizmoGraph_SetPointCount_Transpiler( + IEnumerable instructions) + { + foreach (var instr in instructions) + { + if (instr.opcode == OpCodes.Ldc_I4 && instr.OperandIs(256)) + { + yield return new CodeInstruction(OpCodes.Ldc_I4, 2048); + } + else + { + yield return instr; + } + } + } + + [HarmonyTranspiler, HarmonyPatch(typeof(BuildTool_Path), nameof(BuildTool_Path._OnInit))] + private static IEnumerable BuildTool_Path__OnInit_Transpiler( + IEnumerable instructions) + { + foreach (var instr in instructions) + { + if (instr.opcode == OpCodes.Ldc_I4 && instr.OperandIs(160)) + { + instr.operand = 2048; + } + + yield return instr; + } + } + + [HarmonyTranspiler, HarmonyPatch(typeof(BuildTool_Click), nameof(BuildTool_Click._OnInit))] + private static IEnumerable BuildTool_Click__OnInit_Transpiler( + IEnumerable instructions) + { + foreach (var instr in instructions) + { + if (instr.opcode == OpCodes.Ldc_I4_S && instr.OperandIs(15)) + { + yield return new CodeInstruction(OpCodes.Ldc_I4, 512); + } + else + { + yield return instr; + } + } + } + [HarmonyTranspiler] [HarmonyPatch(typeof(BuildTool_Addon), nameof(BuildTool_Addon.CheckBuildConditions))] [HarmonyPatch(typeof(BuildTool_Click), nameof(BuildTool_Click.CheckBuildConditions))] @@ -247,8 +367,10 @@ public static class MechaDronesTweaks [HarmonyPatch(typeof(BuildTool_Reform), nameof(BuildTool_Reform.ReformAction))] [HarmonyPatch(typeof(BuildTool_Upgrade), nameof(BuildTool_Upgrade.DetermineMoreChainTargets))] [HarmonyPatch(typeof(BuildTool_Upgrade), nameof(BuildTool_Upgrade.DeterminePreviews))] - private static IEnumerable BuildAreaElimination_Transpiler(IEnumerable instructions) + private static IEnumerable BuildAreaElimination_Transpiler( + IEnumerable instructions) { + /* Patch (player.mecha.buildArea * player.mecha.buildArea) to 100000000 */ var ilist = instructions.ToList(); var count = ilist.Count - 8; int i;