Skip to content

Commit

Permalink
Few more offsets, re-enable rigs
Browse files Browse the repository at this point in the history
  • Loading branch information
DaXcess committed Aug 25, 2024
1 parent 34ea0af commit dc35cb9
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 10 deletions.
Binary file modified Resources/lethalcompanyvr
Binary file not shown.
11 changes: 4 additions & 7 deletions Source/Experiments/Experiments.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,7 @@ private static bool DeveloperMode(ref bool __result)
}
#endif

// TODO: Remove yes
// [LCVRPatch]
// This patch will only get added if the --lcvr-item-offset-editor flag is passed
[HarmonyPatch]
internal static class ItemOffsetEditorPatches
{
Expand All @@ -157,11 +156,10 @@ internal static class ItemOffsetEditorPatches
_offset == null ? _offset = new GameObject("VR Item Offset Editor").transform : _offset;

[HarmonyPatch(typeof(GrabbableObject), nameof(GrabbableObject.LateUpdate))]
[HarmonyPriority(Priority.Last)]
[HarmonyPrefix]
private static bool OverrideItemOffset(GrabbableObject __instance)
{
return true;

if (!Offset.gameObject.activeSelf)
return true;

Expand All @@ -182,12 +180,11 @@ private static bool OverrideItemOffset(GrabbableObject __instance)
return false;
}

[HarmonyPatch(typeof(CaveDwellerPhysicsProp), nameof(CaveDwellerPhysicsProp.LateUpdate))]
[HarmonyPatch(typeof(CaveDwellerPhysicsProp), nameof(CaveDwellerPhysicsProp.LateUpdate))]
[HarmonyPriority(Priority.Last)]
[HarmonyPrefix]
private static bool OverrideCaveDwellerItemOffset(CaveDwellerPhysicsProp __instance)
{
return true;

if (!Offset.gameObject.activeSelf)
return true;

Expand Down
7 changes: 7 additions & 0 deletions Source/Patches/HarmonyPatcher.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using HarmonyLib;
using System;
using System.Reflection;
using LCVR.Experiments;

namespace LCVR.Patches;

Expand All @@ -17,6 +18,12 @@ public static void PatchUniversal()
public static void PatchVR()
{
Patch(vrPatcher, LCVRPatchTarget.VROnly);

if (!Plugin.Flags.HasFlag(Flags.ItemOffsetEditor))
return;

Logger.LogWarning("Item offset editor is enabled!");
vrPatcher.CreateClassProcessor(typeof(ItemOffsetEditorPatches)).Patch();
}

private static void Patch(Harmony patcher, LCVRPatchTarget target)
Expand Down
2 changes: 2 additions & 0 deletions Source/Player/Items.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ internal static class Items
{ "Soccer ball", (new Vector3(-0.07f, 0.17f, -0.19f), Vector3.zero) },
{ "Control pad", (new Vector3(0.25f, -0.22f, 0.27f), new Vector3(340, 248, 167)) },
{ "Garbage lid", (new Vector3(0.23f, -0.1f, 0.44f), new Vector3(14, 15, 17)) },
{ "Hive", (new Vector3(0.13f, -0.15f, 0.16f), Vector3.zero) },
{ "Plastic fish", (new Vector3(0, 0.12f, -0.06f), new Vector3(0, 80, 165)) },
{ "Maneater", (new Vector3(0.24f, -0.15f, 0.35f), new Vector3(-6, 167, 14)) }
};
}
5 changes: 3 additions & 2 deletions Source/Player/VRPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,6 @@ private void BuildVRRig()
Bones.Metarig.localPosition = Vector3.zero;

RigTracker ??= fullModel.AddComponent<RigTracker>();
RigTracker.enabled = false;

// Setting up the left arm

Expand Down Expand Up @@ -710,6 +709,8 @@ public void UpdateIKWeights()
PlayerController.cameraLookRig2.weight = 1;
PlayerController.leftArmRigSecondary.weight = 0;
PlayerController.rightArmRigSecondary.weight = 0;
PlayerController.playerBodyAnimator?.SetLayerWeight(
PlayerController.playerBodyAnimator.GetLayerIndex("UpperBodyEmotes"), 0);

// Vanilla Rigs
PlayerController.leftArmRig.weight = 0;
Expand Down Expand Up @@ -783,7 +784,7 @@ private IEnumerator UpdatePlayerPrefs()

private void TurnBodyToCamera(float turnWeight)
{
var newRotation = Quaternion.Euler(transform.rotation.eulerAngles.x, mainCamera.transform.eulerAngles.y, transform.rotation.eulerAngles.z);
var newRotation = Quaternion.Euler(transform.eulerAngles.x, mainCamera.transform.eulerAngles.y, transform.eulerAngles.z);
transform.rotation = Quaternion.Lerp(transform.rotation, newRotation, Time.deltaTime * turnWeight);
}

Expand Down
8 changes: 7 additions & 1 deletion Source/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,14 @@ private void Awake()
}
}

if (Environment.GetCommandLineArgs().Contains("--lcvr-debug-interactables"))
var args = Environment.GetCommandLineArgs();

if (args.Contains("--lcvr-debug-interactables"))
Flags |= Flags.InteractableDebug;

if (args.Contains("--lcvr-item-offset-editor"))
Flags |= Flags.ItemOffsetEditor;

// Verify game assembly to detect compatible version
var allowUnverified = Environment.GetCommandLineArgs().Contains("--lcvr-skip-checksum");

Expand Down Expand Up @@ -335,4 +340,5 @@ public enum Flags
RestartRequired = 1 << 1,
InvalidGameAssembly = 1 << 2,
InteractableDebug = 1 << 3,
ItemOffsetEditor = 1 << 4,
}

0 comments on commit dc35cb9

Please sign in to comment.