static IEnumerable <CodeInstruction> Transpiler(IEnumerable <CodeInstruction> instructions) { ManeuverD.Log("Patching PatchedConicSolver.CheckNextManeuver"); int state = 0; foreach (CodeInstruction instruction in instructions) { //ManeuverD.Log("state=" + state + " " + instruction.opcode + " \"" + instruction.operand as string + "\""); // We remove the first Vector3d to Vector3 cast if (state == 0 && instruction.opcode == OpCodes.Call && instruction.operand.ToString() == "UnityEngine.Vector3 op_Implicit(Vector3d)") { state++; continue; } // We remove the second Vector3d to Vector3 cast if (state == 1 && instruction.opcode == OpCodes.Call && instruction.operand.ToString() == "UnityEngine.Vector3 op_Implicit(Vector3d)") { state++; continue; } // We replace Quaternion.LookRotation with our QuaternionD.LookRotation if (state == 2 && instruction.opcode == OpCodes.Call && instruction.operand.ToString() == "UnityEngine.Quaternion LookRotation(UnityEngine.Vector3, UnityEngine.Vector3)") { state++; CodeInstruction codeInstruction = new CodeInstruction(OpCodes.Call, SymbolExtensions.GetMethodInfo(() => LookRotation(Vector3d.zero, Vector3d.zero))); //ManeuverD.Log("N state=" + state + " " + codeInstruction.opcode + " \"" + codeInstruction.operand as string + "\""); yield return(codeInstruction); continue; } // We remove the Quaternion to QuaternionD cast if (state == 3 && instruction.opcode == OpCodes.Call && instruction.operand.ToString() == "UnityEngine.QuaternionD op_Implicit(UnityEngine.Quaternion)") { state++; continue; } //ManeuverD.Log("state=" + state + " " + instruction.opcode + " \"" + instruction.operand as string + "\""); yield return(instruction); } }
static IEnumerable <CodeInstruction> Transpiler(IEnumerable <CodeInstruction> instructions) { ManeuverD.Log("Patching ManeuverNode.GetPartialDv"); int state = 0; foreach (var instruction in instructions) { // We remove the first Vector3d to Vector3 cast if (state == 0 && instruction.opcode == OpCodes.Call && instruction.operand.ToString() == "UnityEngine.Vector3 op_Implicit(Vector3d)") { state++; continue; } // We remove the second Vector3d to Vector3 cast if (state == 1 && instruction.opcode == OpCodes.Call && instruction.operand.ToString() == "UnityEngine.Vector3 op_Implicit(Vector3d)") { state++; continue; } // We replace Quaternion.LookRotation with QuaternionD.LookRotation if (state == 2 && instruction.opcode == OpCodes.Call && instruction.operand.ToString() == "UnityEngine.Quaternion LookRotation(UnityEngine.Vector3, UnityEngine.Vector3)") { state++; yield return(new CodeInstruction(OpCodes.Call, SymbolExtensions.GetMethodInfo(() => PatchedConicSolver_CheckNextManeuver_Patch.LookRotation(Vector3d.zero, Vector3d.zero)))); continue; //yield return new CodeInstruction(OpCodes.Call, SymbolExtensions.GetMethodInfo(() => QuaternionD.LookRotation(Vector3d.zero, Vector3d.zero))); } // We remove the Quaternion to QuaternionD cast if (state == 3 && instruction.opcode == OpCodes.Call && instruction.operand.ToString() == "UnityEngine.QuaternionD op_Implicit(UnityEngine.Quaternion)") { state++; continue; } yield return(instruction); } }