Skip to content

Commit

Permalink
Change visor object hierarchy
Browse files Browse the repository at this point in the history
  • Loading branch information
DaXcess committed Feb 2, 2024
1 parent d7c49db commit 25d42c0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions LCVR/EntryPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ private static IEnumerator Start()
// Toggle helmet visor visibility
helmetModel.SetActive(Plugin.Config.EnableHelmetVisor.Value);

// Move helmet model to child of target point
var helmetTarget = StartOfRound.Instance.localPlayerController.gameObject.Find("ScavengerModel/metarig/CameraContainer/MainCamera/HUDHelmetPosition").transform;
helmetContainer.transform.SetParent(helmetTarget, false);

helmetContainer.transform.localPosition = Vector3.zero;
helmetContainer.transform.localEulerAngles = Vector3.zero;

helmetTarget.transform.localPosition = new Vector3(0.01f, -0.068f, -0.073f);
helmetTarget.transform.localScale = Vector3.one;

// Disable ui camera and promote main camera
mainCamera.targetTexture = null;
uiCamera.GetComponent<HDAdditionalCameraData>().xrRendering = false;
Expand Down
10 changes: 10 additions & 0 deletions Patches/PlayerControllerPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,16 @@ static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> inst
codes[index + 2].operand = 0.025f;
codes[index + 5].operand = 0.025f;

// Remove local visor updating (this will be done using hierarchy instead)
var startIndex = codes.FindIndex(x => x.opcode == OpCodes.Ldfld && x.operand == (object)Field(typeof(PlayerControllerB), nameof(PlayerControllerB.localVisor))) - 1;
var endIndex = startIndex + 21;

for (int i = startIndex; i <= endIndex; i++)
{
codes[i].opcode = OpCodes.Nop;
codes[i].operand = null;
}

return codes.AsEnumerable();
}
}
Expand Down

0 comments on commit 25d42c0

Please sign in to comment.