Skip to content

Commit

Permalink
Fix vehicles rotating camera position when entered at a nonzero angle…
Browse files Browse the repository at this point in the history
… and exited out
  • Loading branch information
RedBigz committed Nov 17, 2024
1 parent 5f29430 commit db077e7
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions TABGVR/Patches/CameraMovementPatch.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using HarmonyLib;

namespace TABGVR.Patches;

[HarmonyPatch(typeof(CameraMovement))]
public class CameraMovementPatch
{
[HarmonyPatch(nameof(CameraMovement.LateUpdate))]
[HarmonyTranspiler]
public static IEnumerable<CodeInstruction> LateUpdate(IEnumerable<CodeInstruction> instructions)
{
foreach (var instruction in instructions.Select((value, i) => new { i, value }))
{
// instruction.value.opcode == OpCodes.Ldarg_0 &&
// instructionsList[instruction.i + 1].operand is FieldInfo fieldInfo &&
// fieldInfo == typeof(CameraMovement).GetField(nameof(CameraMovement.sitting))

if (instruction.i is >= 144 and <= 196)
{
instruction.value.opcode = OpCodes.Nop;
instruction.value.operand = null;
}

yield return instruction.value;
}
}

[HarmonyPatch(nameof(CameraMovement.ResetVehicleCamera))]
[HarmonyPrefix]
public static bool ResetVehicleCameraPatch() => false;
}

0 comments on commit db077e7

Please sign in to comment.