mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 06:19:22 +00:00
push
This commit is contained in:
parent
dc577c3a2f
commit
a468487850
24 changed files with 484 additions and 121 deletions
|
@ -183,6 +183,7 @@ internal class DesktopVRIKSystem : MonoBehaviour
|
||||||
// Last Movement Parent Info
|
// Last Movement Parent Info
|
||||||
Vector3 _movementPosition;
|
Vector3 _movementPosition;
|
||||||
Quaternion _movementRotation;
|
Quaternion _movementRotation;
|
||||||
|
CVRMovementParent _currentParent;
|
||||||
|
|
||||||
DesktopVRIKSystem()
|
DesktopVRIKSystem()
|
||||||
{
|
{
|
||||||
|
@ -377,14 +378,19 @@ internal class DesktopVRIKSystem : MonoBehaviour
|
||||||
// desktop pivots from playerlocal transform
|
// desktop pivots from playerlocal transform
|
||||||
var platformPivot = transform.position;
|
var platformPivot = transform.position;
|
||||||
|
|
||||||
// Add platform motion to IK solver
|
// Prevent targeting other parent position
|
||||||
avatarIKSolver.AddPlatformMotion(deltaPosition, deltaRotation, platformPivot);
|
if (_currentParent == currentParent)
|
||||||
|
{
|
||||||
|
// Add platform motion to IK solver
|
||||||
|
avatarIKSolver.AddPlatformMotion(deltaPosition, deltaRotation, platformPivot);
|
||||||
|
ResetDesktopVRIK();
|
||||||
|
}
|
||||||
|
|
||||||
// Store for next frame
|
// Store for next frame
|
||||||
|
_currentParent = currentParent;
|
||||||
_movementPosition = currentPosition;
|
_movementPosition = currentPosition;
|
||||||
_movementRotation = currentRotation;
|
_movementRotation = currentRotation;
|
||||||
|
|
||||||
ResetDesktopVRIK();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using ABI_RC.Core.Player;
|
using ABI_RC.Core.Player;
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using ABI.CCK.Components;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
|
@ -64,4 +65,4 @@ class PlayerSetupPatches
|
||||||
{
|
{
|
||||||
return !(bool)DesktopVRIKSystem.Instance?.OnPlayerSetupResetIk();
|
return !(bool)DesktopVRIKSystem.Instance?.OnPlayerSetupResetIk();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -26,6 +26,6 @@ using System.Reflection;
|
||||||
namespace NAK.Melons.DesktopVRIK.Properties;
|
namespace NAK.Melons.DesktopVRIK.Properties;
|
||||||
internal static class AssemblyInfoParams
|
internal static class AssemblyInfoParams
|
||||||
{
|
{
|
||||||
public const string Version = "4.1.7";
|
public const string Version = "4.1.8";
|
||||||
public const string Author = "NotAKidoS";
|
public const string Author = "NotAKidoS";
|
||||||
}
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"_id": 117,
|
"_id": 117,
|
||||||
"name": "DesktopVRIK",
|
"name": "DesktopVRIK",
|
||||||
"modversion": "4.1.7",
|
"modversion": "4.1.8",
|
||||||
"gameversion": "2022r170",
|
"gameversion": "2022r170",
|
||||||
"loaderversion": "0.5.7",
|
"loaderversion": "0.5.7",
|
||||||
"modtype": "Mod",
|
"modtype": "Mod",
|
||||||
|
@ -17,8 +17,8 @@
|
||||||
"requirements": [
|
"requirements": [
|
||||||
"BTKUILib"
|
"BTKUILib"
|
||||||
],
|
],
|
||||||
"downloadlink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/releases/download/r1/DesktopVRIK.dll",
|
"downloadlink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/releases/download/r2/DesktopVRIK.dll",
|
||||||
"sourcelink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/",
|
"sourcelink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/",
|
||||||
"changelog": "- Enable useAnimatedBendNormal when Locomotion tracking is disabled. This fixes some sitting animations that bend at unnatural angles.\n- Fix avatar root offset not being reset when entering/playing emotes.",
|
"changelog": "- Fixed feet targeting previous movement parent position for a frame.",
|
||||||
"embedcolor": "9b59b6"
|
"embedcolor": "9b59b6"
|
||||||
}
|
}
|
|
@ -7,7 +7,7 @@ using HarmonyLib;
|
||||||
using RootMotion.FinalIK;
|
using RootMotion.FinalIK;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace NAK.Melons.IKFixes.HarmonyPatches;
|
namespace NAK.IKFixes.HarmonyPatches;
|
||||||
|
|
||||||
internal static class BodySystemPatches
|
internal static class BodySystemPatches
|
||||||
{
|
{
|
||||||
|
@ -213,6 +213,7 @@ internal static class VRIKPatches
|
||||||
internal static class PlayerSetupPatches
|
internal static class PlayerSetupPatches
|
||||||
{
|
{
|
||||||
// Last Movement Parent Info
|
// Last Movement Parent Info
|
||||||
|
static CVRMovementParent lastMovementParent;
|
||||||
static Vector3 lastMovementPosition;
|
static Vector3 lastMovementPosition;
|
||||||
static Quaternion lastMovementRotation;
|
static Quaternion lastMovementRotation;
|
||||||
|
|
||||||
|
@ -234,10 +235,15 @@ internal static class PlayerSetupPatches
|
||||||
Vector3 deltaPosition = currentPosition - lastMovementPosition;
|
Vector3 deltaPosition = currentPosition - lastMovementPosition;
|
||||||
Quaternion deltaRotation = Quaternion.Inverse(lastMovementRotation) * currentRotation;
|
Quaternion deltaRotation = Quaternion.Inverse(lastMovementRotation) * currentRotation;
|
||||||
|
|
||||||
// Add platform motion to IK solver
|
// Prevent targeting other parent position
|
||||||
IKSystem.vrik.solver.AddPlatformMotion(deltaPosition, deltaRotation, currentPosition);
|
if (lastMovementParent == currentParent || lastMovementParent == null)
|
||||||
|
{
|
||||||
|
// Add platform motion to IK solver
|
||||||
|
IKSystem.vrik.solver.AddPlatformMotion(deltaPosition, deltaRotation, currentPosition);
|
||||||
|
}
|
||||||
|
|
||||||
// Store for next frame
|
// Store for next frame
|
||||||
|
lastMovementParent = currentParent;
|
||||||
lastMovementPosition = currentPosition;
|
lastMovementPosition = currentPosition;
|
||||||
lastMovementRotation = currentRotation;
|
lastMovementRotation = currentRotation;
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
using MelonLoader;
|
using MelonLoader;
|
||||||
|
|
||||||
namespace NAK.Melons.IKFixes;
|
namespace NAK.IKFixes;
|
||||||
|
|
||||||
public class IKFixes : MelonMod
|
public class IKFixes : MelonMod
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
using MelonLoader;
|
using MelonLoader;
|
||||||
using NAK.Melons.IKFixes.Properties;
|
using NAK.IKFixes.Properties;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
[assembly: AssemblyVersion(AssemblyInfoParams.Version)]
|
[assembly: AssemblyVersion(AssemblyInfoParams.Version)]
|
||||||
[assembly: AssemblyFileVersion(AssemblyInfoParams.Version)]
|
[assembly: AssemblyFileVersion(AssemblyInfoParams.Version)]
|
||||||
[assembly: AssemblyInformationalVersion(AssemblyInfoParams.Version)]
|
[assembly: AssemblyInformationalVersion(AssemblyInfoParams.Version)]
|
||||||
[assembly: AssemblyTitle(nameof(NAK.Melons.IKFixes))]
|
[assembly: AssemblyTitle(nameof(NAK.IKFixes))]
|
||||||
[assembly: AssemblyCompany(AssemblyInfoParams.Author)]
|
[assembly: AssemblyCompany(AssemblyInfoParams.Author)]
|
||||||
[assembly: AssemblyProduct(nameof(NAK.Melons.IKFixes))]
|
[assembly: AssemblyProduct(nameof(NAK.IKFixes))]
|
||||||
|
|
||||||
[assembly: MelonInfo(
|
[assembly: MelonInfo(
|
||||||
typeof(NAK.Melons.IKFixes.IKFixes),
|
typeof(NAK.IKFixes.IKFixes),
|
||||||
nameof(NAK.Melons.IKFixes),
|
nameof(NAK.IKFixes),
|
||||||
AssemblyInfoParams.Version,
|
AssemblyInfoParams.Version,
|
||||||
AssemblyInfoParams.Author,
|
AssemblyInfoParams.Author,
|
||||||
downloadLink: "https://github.com/NotAKidOnSteam/IKFixes"
|
downloadLink: "https://github.com/NotAKidOnSteam/IKFixes"
|
||||||
|
@ -22,9 +22,9 @@ using System.Reflection;
|
||||||
[assembly: MelonPlatformDomain(MelonPlatformDomainAttribute.CompatibleDomains.MONO)]
|
[assembly: MelonPlatformDomain(MelonPlatformDomainAttribute.CompatibleDomains.MONO)]
|
||||||
[assembly: HarmonyDontPatchAll]
|
[assembly: HarmonyDontPatchAll]
|
||||||
|
|
||||||
namespace NAK.Melons.IKFixes.Properties;
|
namespace NAK.IKFixes.Properties;
|
||||||
internal static class AssemblyInfoParams
|
internal static class AssemblyInfoParams
|
||||||
{
|
{
|
||||||
public const string Version = "1.0.2";
|
public const string Version = "1.0.3";
|
||||||
public const string Author = "NotAKidoS";
|
public const string Author = "NotAKidoS";
|
||||||
}
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"_id": 142,
|
"_id": 142,
|
||||||
"name": "IKFixes",
|
"name": "IKFixes",
|
||||||
"modversion": "1.0.2",
|
"modversion": "1.0.3",
|
||||||
"gameversion": "2022r170",
|
"gameversion": "2022r170",
|
||||||
"loaderversion": "0.5.7",
|
"loaderversion": "0.5.7",
|
||||||
"modtype": "Mod",
|
"modtype": "Mod",
|
||||||
|
@ -16,8 +16,8 @@
|
||||||
"requirements": [
|
"requirements": [
|
||||||
"None"
|
"None"
|
||||||
],
|
],
|
||||||
"downloadlink": "https://github.com/NotAKidOnSteam/IKFixes/releases/download/v1.0.2/IKFixes.dll",
|
"downloadlink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/releases/download/r2/IKFixes.dll",
|
||||||
"sourcelink": "https://github.com/NotAKidOnSteam/IKFixes/",
|
"sourcelink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/",
|
||||||
"changelog": "- Initial Release\n- Added FakeRootAngle fix for Halfbody. Feet will no longer only point in the direction of head while looking around/turning. This can be disabled in mod settings.",
|
"changelog": "- Fixed feet targeting previous movement parent position for a frame.",
|
||||||
"embedcolor": "f46e49"
|
"embedcolor": "f46e49"
|
||||||
}
|
}
|
|
@ -1,12 +1,15 @@
|
||||||
using ABI_RC.Core;
|
using ABI.CCK.Components;
|
||||||
|
using ABI_RC.Core;
|
||||||
using ABI_RC.Core.InteractionSystem;
|
using ABI_RC.Core.InteractionSystem;
|
||||||
using ABI_RC.Core.Player;
|
using ABI_RC.Core.Player;
|
||||||
using ABI_RC.Core.Savior;
|
using ABI_RC.Core.Savior;
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using NAK.Melons.MenuScalePatch.Helpers;
|
using NAK.MenuScalePatch.Helpers;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Reflection.Emit;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace NAK.Melons.MenuScalePatch.HarmonyPatches;
|
namespace NAK.MenuScalePatch.HarmonyPatches;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
ViewManager.SetScale runs once a second when it should only run when aspect ratio changes- CVR bug
|
ViewManager.SetScale runs once a second when it should only run when aspect ratio changes- CVR bug
|
||||||
|
@ -21,17 +24,10 @@ internal class HarmonyPatches
|
||||||
[HarmonyPatch(typeof(PlayerSetup), "Start")]
|
[HarmonyPatch(typeof(PlayerSetup), "Start")]
|
||||||
private static void Postfix_PlayerSetup_Start()
|
private static void Postfix_PlayerSetup_Start()
|
||||||
{
|
{
|
||||||
try
|
MSP_MenuInfo.CameraTransform = PlayerSetup.Instance.GetActiveCamera().transform;
|
||||||
{
|
MenuScalePatch.UpdateSettings();
|
||||||
MSP_MenuInfo.CameraTransform = PlayerSetup.Instance.GetActiveCamera().transform;
|
QuickMenuHelper.Instance.CreateWorldAnchors();
|
||||||
MenuScalePatch.UpdateAllSettings();
|
MainMenuHelper.Instance.CreateWorldAnchors();
|
||||||
QuickMenuHelper.Instance.CreateWorldAnchors();
|
|
||||||
MainMenuHelper.Instance.CreateWorldAnchors();
|
|
||||||
}
|
|
||||||
catch (System.Exception e)
|
|
||||||
{
|
|
||||||
MenuScalePatch.Logger.Error(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HarmonyPrefix]
|
[HarmonyPrefix]
|
||||||
|
@ -83,15 +79,8 @@ internal class HarmonyPatches
|
||||||
[HarmonyPatch(typeof(CVR_MenuManager), "Start")]
|
[HarmonyPatch(typeof(CVR_MenuManager), "Start")]
|
||||||
private static void Postfix_CVR_MenuManager_Start(ref CVR_MenuManager __instance, ref GameObject ____leftVrAnchor)
|
private static void Postfix_CVR_MenuManager_Start(ref CVR_MenuManager __instance, ref GameObject ____leftVrAnchor)
|
||||||
{
|
{
|
||||||
try
|
QuickMenuHelper helper = __instance.quickMenu.gameObject.AddComponent<QuickMenuHelper>();
|
||||||
{
|
helper.handAnchor = ____leftVrAnchor.transform;
|
||||||
QuickMenuHelper helper = __instance.quickMenu.gameObject.AddComponent<QuickMenuHelper>();
|
|
||||||
helper.handAnchor = ____leftVrAnchor.transform;
|
|
||||||
}
|
|
||||||
catch (System.Exception e)
|
|
||||||
{
|
|
||||||
MenuScalePatch.Logger.Error(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Set MM stuff
|
//Set MM stuff
|
||||||
|
@ -99,14 +88,7 @@ internal class HarmonyPatches
|
||||||
[HarmonyPatch(typeof(ViewManager), "Start")]
|
[HarmonyPatch(typeof(ViewManager), "Start")]
|
||||||
private static void Postfix_ViewManager_Start(ref ViewManager __instance)
|
private static void Postfix_ViewManager_Start(ref ViewManager __instance)
|
||||||
{
|
{
|
||||||
try
|
__instance.gameObject.AddComponent<MainMenuHelper>();
|
||||||
{
|
|
||||||
__instance.gameObject.AddComponent<MainMenuHelper>();
|
|
||||||
}
|
|
||||||
catch (System.Exception e)
|
|
||||||
{
|
|
||||||
MenuScalePatch.Logger.Error(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//hook quickmenu open/close
|
//hook quickmenu open/close
|
||||||
|
@ -178,13 +160,28 @@ internal class HarmonyPatches
|
||||||
[HarmonyPatch(typeof(CVRTools), "ConfigureHudAffinity")]
|
[HarmonyPatch(typeof(CVRTools), "ConfigureHudAffinity")]
|
||||||
private static void Postfix_CVRTools_ConfigureHudAffinity()
|
private static void Postfix_CVRTools_ConfigureHudAffinity()
|
||||||
{
|
{
|
||||||
try
|
MSP_MenuInfo.CameraTransform = PlayerSetup.Instance.GetActiveCamera().transform;
|
||||||
{
|
}
|
||||||
MSP_MenuInfo.CameraTransform = PlayerSetup.Instance.GetActiveCamera().transform;
|
|
||||||
}
|
// prevents CVRWorld from closing menus when world transitioning, cause cool
|
||||||
catch (System.Exception e)
|
[HarmonyTranspiler]
|
||||||
{
|
[HarmonyPatch(typeof(CVRWorld), nameof(CVRWorld.Start), MethodType.Enumerator)]
|
||||||
MenuScalePatch.Logger.Error(e);
|
private static IEnumerable<CodeInstruction> Transpiler_CVRWorld_Start(IEnumerable<CodeInstruction> instructions, ILGenerator il)
|
||||||
}
|
{
|
||||||
|
var patchedInstructions = new CodeMatcher(instructions).MatchForward(false,
|
||||||
|
new CodeMatch(OpCodes.Ldsfld),
|
||||||
|
new CodeMatch(OpCodes.Ldc_I4_0),
|
||||||
|
new CodeMatch(i => i.opcode == OpCodes.Callvirt && i.operand is MethodInfo { Name: "ForceUiStatus" }))
|
||||||
|
.RemoveInstructions(3)
|
||||||
|
.InstructionEnumeration();
|
||||||
|
|
||||||
|
patchedInstructions = new CodeMatcher(patchedInstructions).MatchForward(false,
|
||||||
|
new CodeMatch(OpCodes.Ldsfld),
|
||||||
|
new CodeMatch(OpCodes.Ldc_I4_0),
|
||||||
|
new CodeMatch(i => i.opcode == OpCodes.Callvirt && i.operand is MethodInfo { Name: "ToggleQuickMenu" }))
|
||||||
|
.RemoveInstructions(3)
|
||||||
|
.InstructionEnumeration();
|
||||||
|
|
||||||
|
return patchedInstructions;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,7 +3,7 @@ using ABI_RC.Core.Savior;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
|
|
||||||
namespace NAK.Melons.MenuScalePatch.Helpers;
|
namespace NAK.MenuScalePatch.Helpers;
|
||||||
|
|
||||||
//TODO: Implement desktop ratio scaling back to MM
|
//TODO: Implement desktop ratio scaling back to MM
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
using ABI_RC.Core.Savior;
|
using ABI_RC.Core.Savior;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace NAK.Melons.MenuScalePatch.Helpers;
|
namespace NAK.MenuScalePatch.Helpers;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
|
|
|
@ -2,10 +2,9 @@
|
||||||
using ABI_RC.Core.InteractionSystem;
|
using ABI_RC.Core.InteractionSystem;
|
||||||
using ABI_RC.Core.Savior;
|
using ABI_RC.Core.Savior;
|
||||||
using ABI_RC.Systems.MovementSystem;
|
using ABI_RC.Systems.MovementSystem;
|
||||||
using System.Reflection;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace NAK.Melons.MenuScalePatch.Helpers;
|
namespace NAK.MenuScalePatch.Helpers;
|
||||||
|
|
||||||
public class MSP_MenuInfo
|
public class MSP_MenuInfo
|
||||||
{
|
{
|
||||||
|
@ -25,21 +24,14 @@ public class MSP_MenuInfo
|
||||||
public static bool DisableMMHelper;
|
public static bool DisableMMHelper;
|
||||||
public static bool DisableMMHelper_VR;
|
public static bool DisableMMHelper_VR;
|
||||||
|
|
||||||
//reflection
|
|
||||||
internal static readonly FieldInfo _desktopMouseModeQM = typeof(ViewManager).GetField("_desktopMouseMode", BindingFlags.NonPublic | BindingFlags.Instance);
|
|
||||||
internal static readonly FieldInfo _desktopMouseModeMM = typeof(CVR_MenuManager).GetField("_desktopMouseMode", BindingFlags.NonPublic | BindingFlags.Instance);
|
|
||||||
internal static readonly FieldInfo ms_followAngleX = typeof(MovementSystem).GetField("_followAngleX", BindingFlags.NonPublic | BindingFlags.Instance);
|
|
||||||
internal static readonly FieldInfo ms_followAngleY = typeof(MovementSystem).GetField("_followAngleY", BindingFlags.NonPublic | BindingFlags.Instance);
|
|
||||||
internal static readonly FieldInfo ms_manualAngleX = typeof(MovementSystem).GetField("_manualAngleX", BindingFlags.NonPublic | BindingFlags.Instance);
|
|
||||||
|
|
||||||
internal static bool isIndependentHeadTurn = false;
|
internal static bool isIndependentHeadTurn = false;
|
||||||
|
|
||||||
internal static void ToggleDesktopInputMethod(bool flag)
|
internal static void ToggleDesktopInputMethod(bool flag)
|
||||||
{
|
{
|
||||||
if (MetaPort.Instance.isUsingVr) return;
|
if (MetaPort.Instance.isUsingVr) return;
|
||||||
|
|
||||||
_desktopMouseModeQM.SetValue(ViewManager.Instance, flag);
|
ViewManager.Instance._desktopMouseMode = flag;
|
||||||
_desktopMouseModeMM.SetValue(CVR_MenuManager.Instance, flag);
|
CVR_MenuManager.Instance._desktopMouseMode = flag;
|
||||||
|
|
||||||
RootLogic.Instance.ToggleMouse(flag);
|
RootLogic.Instance.ToggleMouse(flag);
|
||||||
CVRInputManager.Instance.inputEnabled = !flag;
|
CVRInputManager.Instance.inputEnabled = !flag;
|
||||||
|
@ -59,9 +51,9 @@ public class MSP_MenuInfo
|
||||||
}
|
}
|
||||||
else if (!isPressed && isIndependentHeadTurn)
|
else if (!isPressed && isIndependentHeadTurn)
|
||||||
{
|
{
|
||||||
float angleX = (float)ms_followAngleX.GetValue(MovementSystem.Instance);
|
float angleX = MovementSystem.Instance._followAngleX;
|
||||||
float angleY = (float)ms_followAngleY.GetValue(MovementSystem.Instance);
|
float angleY = MovementSystem.Instance._followAngleY;
|
||||||
float manualAngleX = (float)ms_manualAngleX.GetValue(MovementSystem.Instance);
|
float manualAngleX = MovementSystem.Instance._manualAngleX;
|
||||||
if (angleY == 0f && angleX == manualAngleX)
|
if (angleY == 0f && angleX == manualAngleX)
|
||||||
{
|
{
|
||||||
isIndependentHeadTurn = false;
|
isIndependentHeadTurn = false;
|
||||||
|
|
|
@ -1,35 +1,29 @@
|
||||||
using MelonLoader;
|
using MelonLoader;
|
||||||
using NAK.Melons.MenuScalePatch.Helpers;
|
|
||||||
|
|
||||||
namespace NAK.Melons.MenuScalePatch;
|
namespace NAK.MenuScalePatch;
|
||||||
|
|
||||||
public class MenuScalePatch : MelonMod
|
public class MenuScalePatch : MelonMod
|
||||||
{
|
{
|
||||||
internal static MelonLogger.Instance Logger;
|
internal static MelonPreferences_Category Category = MelonPreferences.CreateCategory(nameof(MenuScalePatch));
|
||||||
internal static MelonPreferences_Category m_categoryMenuScalePatch;
|
|
||||||
internal static MelonPreferences_Entry<bool>
|
internal static MelonPreferences_Entry<bool> EntryUseIndependentHeadTurn =
|
||||||
//m_entryWorldAnchorVRQM,
|
Category.CreateEntry<bool>("Use Independent Head Turn", true, description: "Should you be able to use independent head turn in a menu while in Desktop?");
|
||||||
m_entryUseIndependentHeadTurn,
|
|
||||||
m_entryPlayerAnchorMenus;
|
internal static MelonPreferences_Entry<bool> EntryPlayerAnchorMenus =
|
||||||
|
Category.CreateEntry<bool>("Player Anchor Menus", true, description: "Should the menus be anchored to & constantly follow the player?");
|
||||||
|
|
||||||
public override void OnInitializeMelon()
|
public override void OnInitializeMelon()
|
||||||
{
|
{
|
||||||
m_categoryMenuScalePatch = MelonPreferences.CreateCategory(nameof(MenuScalePatch));
|
foreach (var setting in Category.Entries)
|
||||||
//m_entryWorldAnchorVRQM = m_categoryMenuScalePatch.CreateEntry<bool>("World Anchor VR QM", false, description: "Should place QM in World Space while VR.");
|
|
||||||
m_entryUseIndependentHeadTurn = m_categoryMenuScalePatch.CreateEntry<bool>("Use Independent Head Turn", true, description: "Should you be able to use independent head turn in a menu while in Desktop?");
|
|
||||||
m_entryPlayerAnchorMenus = m_categoryMenuScalePatch.CreateEntry<bool>("Player Anchor Menus", true, description: "Should the menus be anchored to & constantly follow the player?");
|
|
||||||
|
|
||||||
foreach (var setting in m_categoryMenuScalePatch.Entries)
|
|
||||||
{
|
{
|
||||||
setting.OnEntryValueChangedUntyped.Subscribe(OnUpdateSettings);
|
setting.OnEntryValueChangedUntyped.Subscribe(OnUpdateSettings);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Logger = LoggerInstance;
|
internal static void UpdateSettings()
|
||||||
}
|
|
||||||
internal static void UpdateAllSettings()
|
|
||||||
{
|
{
|
||||||
//MSP_MenuInfo.WorldAnchorQM = m_entryWorldAnchorVRQM.Value;
|
Helpers.MSP_MenuInfo.UseIndependentHeadTurn = EntryUseIndependentHeadTurn.Value;
|
||||||
MSP_MenuInfo.UseIndependentHeadTurn = m_entryUseIndependentHeadTurn.Value;
|
Helpers.MSP_MenuInfo.PlayerAnchorMenus = EntryPlayerAnchorMenus.Value;
|
||||||
MSP_MenuInfo.PlayerAnchorMenus = m_entryPlayerAnchorMenus.Value;
|
|
||||||
}
|
}
|
||||||
private static void OnUpdateSettings(object arg1, object arg2) => UpdateAllSettings();
|
private static void OnUpdateSettings(object arg1, object arg2) => UpdateSettings();
|
||||||
}
|
}
|
|
@ -6,29 +6,30 @@
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<LangVersion>latest</LangVersion>
|
<LangVersion>latest</LangVersion>
|
||||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||||
|
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="0Harmony">
|
<Reference Include="0Harmony">
|
||||||
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\MelonLoader\0Harmony.dll</HintPath>
|
<HintPath>..\_ManagedLibs\0Harmony.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Assembly-CSharp">
|
<Reference Include="Assembly-CSharp">
|
||||||
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\Assembly-CSharp.dll</HintPath>
|
<HintPath>..\_ManagedLibs\Assembly-CSharp.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Cohtml.Runtime">
|
<Reference Include="Cohtml.Runtime">
|
||||||
<HintPath>C:\Program Files (x86)\\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\Cohtml.Runtime.dll</HintPath>
|
<HintPath>..\_ManagedLibs\Cohtml.Runtime.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="MelonLoader">
|
<Reference Include="MelonLoader">
|
||||||
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\MelonLoader\MelonLoader.dll</HintPath>
|
<HintPath>..\_ManagedLibs\MelonLoader.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="UnityEngine.AnimationModule">
|
<Reference Include="UnityEngine.AnimationModule">
|
||||||
<HintPath>C:\Program Files (x86)\\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\UnityEngine.AnimationModule.dll</HintPath>
|
<HintPath>..\_ManagedLibs\UnityEngine.AnimationModule.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="UnityEngine.CoreModule">
|
<Reference Include="UnityEngine.CoreModule">
|
||||||
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
|
<HintPath>..\_ManagedLibs\UnityEngine.CoreModule.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="UnityEngine.InputLegacyModule">
|
<Reference Include="UnityEngine.InputLegacyModule">
|
||||||
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\UnityEngine.InputLegacyModule.dll</HintPath>
|
<HintPath>..\_ManagedLibs\UnityEngine.InputLegacyModule.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
|
@ -1,30 +1,30 @@
|
||||||
using MelonLoader;
|
using MelonLoader;
|
||||||
using NAK.Melons.MenuScalePatch.Properties;
|
using NAK.MenuScalePatch.Properties;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
|
|
||||||
[assembly: AssemblyVersion(AssemblyInfoParams.Version)]
|
[assembly: AssemblyVersion(AssemblyInfoParams.Version)]
|
||||||
[assembly: AssemblyFileVersion(AssemblyInfoParams.Version)]
|
[assembly: AssemblyFileVersion(AssemblyInfoParams.Version)]
|
||||||
[assembly: AssemblyInformationalVersion(AssemblyInfoParams.Version)]
|
[assembly: AssemblyInformationalVersion(AssemblyInfoParams.Version)]
|
||||||
[assembly: AssemblyTitle(nameof(NAK.Melons.MenuScalePatch))]
|
[assembly: AssemblyTitle(nameof(NAK.MenuScalePatch))]
|
||||||
[assembly: AssemblyCompany(AssemblyInfoParams.Author)]
|
[assembly: AssemblyCompany(AssemblyInfoParams.Author)]
|
||||||
[assembly: AssemblyProduct(nameof(NAK.Melons.MenuScalePatch))]
|
[assembly: AssemblyProduct(nameof(NAK.MenuScalePatch))]
|
||||||
|
|
||||||
[assembly: MelonInfo(
|
[assembly: MelonInfo(
|
||||||
typeof(NAK.Melons.MenuScalePatch.MenuScalePatch),
|
typeof(NAK.MenuScalePatch.MenuScalePatch),
|
||||||
nameof(NAK.Melons.MenuScalePatch),
|
nameof(NAK.MenuScalePatch),
|
||||||
AssemblyInfoParams.Version,
|
AssemblyInfoParams.Version,
|
||||||
AssemblyInfoParams.Author,
|
AssemblyInfoParams.Author,
|
||||||
downloadLink: "https://github.com/NotAKidOnSteam/MenuScalePatch"
|
downloadLink: "https://github.com/NotAKidOnSteam/NAK_CVR_Mods"
|
||||||
)]
|
)]
|
||||||
|
|
||||||
[assembly: MelonGame("Alpha Blend Interactive", "ChilloutVR")]
|
[assembly: MelonGame("Alpha Blend Interactive", "ChilloutVR")]
|
||||||
[assembly: MelonPlatform(MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)]
|
[assembly: MelonPlatform(MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)]
|
||||||
[assembly: MelonPlatformDomain(MelonPlatformDomainAttribute.CompatibleDomains.MONO)]
|
[assembly: MelonPlatformDomain(MelonPlatformDomainAttribute.CompatibleDomains.MONO)]
|
||||||
|
|
||||||
namespace NAK.Melons.MenuScalePatch.Properties;
|
namespace NAK.MenuScalePatch.Properties;
|
||||||
internal static class AssemblyInfoParams
|
internal static class AssemblyInfoParams
|
||||||
{
|
{
|
||||||
public const string Version = "4.2.6";
|
public const string Version = "4.2.7";
|
||||||
public const string Author = "NotAKidoS";
|
public const string Author = "NotAKidoS";
|
||||||
}
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"_id": 95,
|
"_id": 95,
|
||||||
"name": "MenuScalePatch",
|
"name": "MenuScalePatch",
|
||||||
"modversion": "4.2.6",
|
"modversion": "4.2.7",
|
||||||
"gameversion": "2022r170",
|
"gameversion": "2022r170",
|
||||||
"loaderversion": "0.5.7",
|
"loaderversion": "0.5.7",
|
||||||
"modtype": "Mod",
|
"modtype": "Mod",
|
||||||
|
@ -16,8 +16,8 @@
|
||||||
"requirements": [
|
"requirements": [
|
||||||
"None"
|
"None"
|
||||||
],
|
],
|
||||||
"downloadlink": "https://github.com/NotAKidOnSteam/MenuScalePatch/releases/download/v4.2.6/MenuScalePatch.dll",
|
"downloadlink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/releases/download/r2/MenuScalePatch.dll",
|
||||||
"sourcelink": "https://github.com/NotAKidOnSteam/MenuScalePatch/",
|
"sourcelink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/",
|
||||||
"changelog": "- Fixed hitching & potential crash when opening menu after a long time of it being closed. Don't disable CohtmlView, only enable it.\n- Let game update menu position while its closed.\n- Tweaked independent head turn handling to ensure menu is correctly positioned on recenter if PlayerAnchorMenus is disabled.\n- Undo change to which transform to parent menu anchors.",
|
"changelog": "- Menus are no longer forced closed on world load.",
|
||||||
"embedcolor": "363020"
|
"embedcolor": "363020"
|
||||||
}
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
using ABI.CCK.Components;
|
using ABI.CCK.Components;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using ABI_RC.Core.Player;
|
||||||
|
|
||||||
namespace NAK.CCK.CustomComponents;
|
namespace NAK.CCK.CustomComponents;
|
||||||
|
|
||||||
|
@ -16,6 +17,7 @@ public class NAKPointerTracker : MonoBehaviour
|
||||||
public string parameterName;
|
public string parameterName;
|
||||||
|
|
||||||
// Internal stuff
|
// Internal stuff
|
||||||
|
bool isLocal;
|
||||||
float initialAngle;
|
float initialAngle;
|
||||||
CVRPointer trackedPointer;
|
CVRPointer trackedPointer;
|
||||||
|
|
||||||
|
@ -46,6 +48,7 @@ public class NAKPointerTracker : MonoBehaviour
|
||||||
Vector3 direction = (transform.TransformPoint(offset) - referenceTransform.position);
|
Vector3 direction = (transform.TransformPoint(offset) - referenceTransform.position);
|
||||||
Vector3 projectedDirection = Vector3.ProjectOnPlane(direction, referenceTransform.up);
|
Vector3 projectedDirection = Vector3.ProjectOnPlane(direction, referenceTransform.up);
|
||||||
initialAngle = Vector3.SignedAngle(referenceTransform.forward, projectedDirection, referenceTransform.up);
|
initialAngle = Vector3.SignedAngle(referenceTransform.forward, projectedDirection, referenceTransform.up);
|
||||||
|
isLocal = gameObject.layer == 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnDrawGizmosSelected()
|
void OnDrawGizmosSelected()
|
||||||
|
@ -88,8 +91,13 @@ public class NAKPointerTracker : MonoBehaviour
|
||||||
{
|
{
|
||||||
if (animator != null)
|
if (animator != null)
|
||||||
{
|
{
|
||||||
float angle = GetAngleFromPosition(trackedPointer.transform.position, initialAngle);
|
float angle = GetAngleFromPosition(trackedPointer.transform.position, initialAngle) / 360;
|
||||||
animator.SetFloat(parameterName + "_Angle", angle / 360);
|
if (!isLocal)
|
||||||
|
{
|
||||||
|
animator.SetFloat(parameterName + "_Angle", angle);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
PlayerSetup.Instance.changeAnimatorParam(parameterName + "_Angle", angle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ public class CustomComponents : MelonMod
|
||||||
public override void OnInitializeMelon()
|
public override void OnInitializeMelon()
|
||||||
{
|
{
|
||||||
// Add our CCK component to the prop whitelist
|
// Add our CCK component to the prop whitelist
|
||||||
var propWhitelist = SharedFilter._spawnableWhitelist;
|
var propWhitelist = SharedFilter._avatarWhitelist;
|
||||||
propWhitelist.Add(typeof(NAKPointerTracker));
|
propWhitelist.Add(typeof(NAKPointerTracker));
|
||||||
}
|
}
|
||||||
}
|
}
|
182
ThirdPerson/CameraLogic.cs
Normal file
182
ThirdPerson/CameraLogic.cs
Normal file
|
@ -0,0 +1,182 @@
|
||||||
|
using ABI_RC.Core.Base;
|
||||||
|
using ABI_RC.Core.Player;
|
||||||
|
using ABI_RC.Core.Util.Object_Behaviour;
|
||||||
|
using Aura2API;
|
||||||
|
using BeautifyEffect;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Reflection;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.AzureSky;
|
||||||
|
using UnityEngine.Rendering.PostProcessing;
|
||||||
|
|
||||||
|
namespace ThirdPerson;
|
||||||
|
|
||||||
|
internal static class CameraLogic
|
||||||
|
{
|
||||||
|
private static float _dist;
|
||||||
|
private static GameObject _ourCam;
|
||||||
|
private static GameObject _desktopCam;
|
||||||
|
private static CameraFovClone _cameraFovClone;
|
||||||
|
|
||||||
|
internal static CameraLocation CurrentLocation = CameraLocation.Default;
|
||||||
|
|
||||||
|
internal enum CameraLocation
|
||||||
|
{
|
||||||
|
Default,
|
||||||
|
FrontView,
|
||||||
|
RightSide,
|
||||||
|
LeftSide
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool _state;
|
||||||
|
internal static bool State
|
||||||
|
{
|
||||||
|
get => _state;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_state = value;
|
||||||
|
_ourCam.SetActive(_state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool _setupPostProcessing;
|
||||||
|
private static readonly FieldInfo _ppResourcesFieldInfo = typeof(PostProcessLayer).GetField("m_Resources", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||||
|
private static readonly FieldInfo _ppOldResourcesFieldInfo = typeof(PostProcessLayer).GetField("m_OldResources", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||||
|
|
||||||
|
internal static IEnumerator SetupCamera()
|
||||||
|
{
|
||||||
|
yield return new WaitUntil(() => PlayerSetup.Instance);
|
||||||
|
|
||||||
|
_ourCam = new GameObject("ThirdPersonCameraObj") { };
|
||||||
|
_ourCam.AddComponent<Camera>();
|
||||||
|
|
||||||
|
_cameraFovClone = _ourCam.AddComponent<CameraFovClone>();
|
||||||
|
|
||||||
|
_desktopCam = PlayerSetup.Instance.desktopCamera;
|
||||||
|
_cameraFovClone.targetCamera = _desktopCam.GetComponent<Camera>();
|
||||||
|
|
||||||
|
_ourCam.transform.SetParent(_desktopCam.transform);
|
||||||
|
|
||||||
|
RelocateCam(CameraLocation.Default);
|
||||||
|
|
||||||
|
_ourCam.gameObject.SetActive(false);
|
||||||
|
|
||||||
|
ThirdPerson.Logger.Msg("Finished setting up third person camera.");
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static void CopyFromPlayerCam()
|
||||||
|
{
|
||||||
|
Camera ourCamComponent = _ourCam.GetComponent<Camera>();
|
||||||
|
Camera playerCamComponent = _desktopCam.GetComponent<Camera>();
|
||||||
|
if (ourCamComponent == null || playerCamComponent == null) return;
|
||||||
|
ThirdPerson.Logger.Msg("Copying active camera settings & components.");
|
||||||
|
|
||||||
|
//steal basic settings
|
||||||
|
ourCamComponent.farClipPlane = playerCamComponent.farClipPlane;
|
||||||
|
ourCamComponent.nearClipPlane = playerCamComponent.nearClipPlane;
|
||||||
|
ourCamComponent.cullingMask = playerCamComponent.cullingMask;
|
||||||
|
ourCamComponent.depthTextureMode = playerCamComponent.depthTextureMode;
|
||||||
|
|
||||||
|
//steal post processing if added
|
||||||
|
PostProcessLayer ppLayerPlayerCam = playerCamComponent.GetComponent<PostProcessLayer>();
|
||||||
|
PostProcessLayer ppLayerThirdPerson = ourCamComponent.AddComponentIfMissing<PostProcessLayer>();
|
||||||
|
if (ppLayerPlayerCam != null && ppLayerThirdPerson != null)
|
||||||
|
{
|
||||||
|
ppLayerThirdPerson.enabled = ppLayerPlayerCam.enabled;
|
||||||
|
ppLayerThirdPerson.volumeLayer = ppLayerPlayerCam.volumeLayer;
|
||||||
|
//need to copy these via reflection, otherwise post processing will error
|
||||||
|
if (!_setupPostProcessing)
|
||||||
|
{
|
||||||
|
_setupPostProcessing = true;
|
||||||
|
PostProcessResources resources = (PostProcessResources)_ppResourcesFieldInfo.GetValue(ppLayerPlayerCam);
|
||||||
|
PostProcessResources oldResources = (PostProcessResources)_ppOldResourcesFieldInfo.GetValue(ppLayerPlayerCam);
|
||||||
|
_ppResourcesFieldInfo.SetValue(ppLayerThirdPerson, resources);
|
||||||
|
_ppResourcesFieldInfo.SetValue(ppLayerThirdPerson, oldResources);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//what even is this aura camera stuff
|
||||||
|
AuraCamera auraPlayerCam = playerCamComponent.GetComponent<AuraCamera>();
|
||||||
|
AuraCamera auraThirdPerson = ourCamComponent.AddComponentIfMissing<AuraCamera>();
|
||||||
|
if (auraPlayerCam != null && auraThirdPerson != null)
|
||||||
|
{
|
||||||
|
auraThirdPerson.enabled = auraPlayerCam.enabled;
|
||||||
|
auraThirdPerson.frustumSettings = auraPlayerCam.frustumSettings;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auraThirdPerson.enabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//flare layer thing? the sun :_:_:_:_:_:
|
||||||
|
FlareLayer flarePlayerCam = playerCamComponent.GetComponent<FlareLayer>();
|
||||||
|
FlareLayer flareThirdPerson = ourCamComponent.AddComponentIfMissing<FlareLayer>();
|
||||||
|
if (flarePlayerCam != null && flareThirdPerson != null)
|
||||||
|
{
|
||||||
|
flareThirdPerson.enabled = flarePlayerCam.enabled;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
flareThirdPerson.enabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//and now what the fuck is fog scattering
|
||||||
|
AzureFogScattering azureFogPlayerCam = playerCamComponent.GetComponent<AzureFogScattering>();
|
||||||
|
AzureFogScattering azureFogThirdPerson = ourCamComponent.AddComponentIfMissing<AzureFogScattering>();
|
||||||
|
if (azureFogPlayerCam != null && azureFogThirdPerson != null)
|
||||||
|
{
|
||||||
|
azureFogThirdPerson.fogScatteringMaterial = azureFogPlayerCam.fogScatteringMaterial;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Object.Destroy(ourCamComponent.GetComponent<AzureFogScattering>());
|
||||||
|
}
|
||||||
|
|
||||||
|
//why is there so many thingsssssssss
|
||||||
|
Beautify beautifyPlayerCam = playerCamComponent.GetComponent<Beautify>();
|
||||||
|
Beautify beautifyThirdPerson = ourCamComponent.AddComponentIfMissing<Beautify>();
|
||||||
|
if (beautifyPlayerCam != null && beautifyThirdPerson != null)
|
||||||
|
{
|
||||||
|
beautifyThirdPerson.quality = beautifyPlayerCam.quality;
|
||||||
|
beautifyThirdPerson.profile = beautifyPlayerCam.profile;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Object.Destroy(ourCamComponent.gameObject.GetComponent<Beautify>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static void RelocateCam(CameraLocation location, bool resetDist = false)
|
||||||
|
{
|
||||||
|
_ourCam.transform.rotation = _desktopCam.transform.rotation;
|
||||||
|
if (resetDist) ResetDist();
|
||||||
|
switch (location)
|
||||||
|
{
|
||||||
|
case CameraLocation.FrontView:
|
||||||
|
_ourCam.transform.localPosition = new Vector3(0, 0.015f, 0.55f + _dist);
|
||||||
|
_ourCam.transform.localRotation = new Quaternion(0, 180, 0, 0);
|
||||||
|
CurrentLocation = CameraLocation.FrontView;
|
||||||
|
break;
|
||||||
|
case CameraLocation.RightSide:
|
||||||
|
_ourCam.transform.localPosition = new Vector3(0.3f, 0.015f, -0.55f + _dist);
|
||||||
|
_ourCam.transform.localRotation = new Quaternion(0, 0, 0, 0);
|
||||||
|
CurrentLocation = CameraLocation.RightSide;
|
||||||
|
break;
|
||||||
|
case CameraLocation.LeftSide:
|
||||||
|
_ourCam.transform.localPosition = new Vector3(-0.3f, 0.015f, -0.55f + _dist);
|
||||||
|
_ourCam.transform.localRotation = new Quaternion(0, 0, 0, 0);
|
||||||
|
CurrentLocation = CameraLocation.LeftSide;
|
||||||
|
break;
|
||||||
|
case CameraLocation.Default:
|
||||||
|
default:
|
||||||
|
_ourCam.transform.localPosition = new Vector3(0, 0.015f, -0.55f + _dist);
|
||||||
|
_ourCam.transform.localRotation = new Quaternion(0, 0, 0, 0);
|
||||||
|
CurrentLocation = CameraLocation.Default;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void ResetDist() => _dist = 0;
|
||||||
|
internal static void IncrementDist() { _dist += 0.25f; RelocateCam(CurrentLocation); }
|
||||||
|
internal static void DecrementDist() { _dist -= 0.25f; RelocateCam(CurrentLocation); }
|
||||||
|
}
|
27
ThirdPerson/Patches.cs
Normal file
27
ThirdPerson/Patches.cs
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
using ABI.CCK.Components;
|
||||||
|
using ABI_RC.Core.InteractionSystem;
|
||||||
|
using ABI_RC.Core.Player;
|
||||||
|
using MelonLoader;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using static ThirdPerson.CameraLogic;
|
||||||
|
|
||||||
|
namespace ThirdPerson;
|
||||||
|
|
||||||
|
internal static class Patches
|
||||||
|
{
|
||||||
|
internal static void Apply(HarmonyLib.Harmony harmony)
|
||||||
|
{
|
||||||
|
harmony.Patch(
|
||||||
|
typeof(CVRWorld).GetMethod("SetDefaultCamValues", BindingFlags.NonPublic | BindingFlags.Instance),
|
||||||
|
postfix: typeof(Patches).GetMethod(nameof(OnWorldStart), BindingFlags.NonPublic | BindingFlags.Static).ToNewHarmonyMethod()
|
||||||
|
);
|
||||||
|
harmony.Patch(
|
||||||
|
typeof(CVRWorld).GetMethod("CopyRefCamValues", BindingFlags.NonPublic | BindingFlags.Instance),
|
||||||
|
postfix: typeof(Patches).GetMethod(nameof(OnWorldStart), BindingFlags.NonPublic | BindingFlags.Static).ToNewHarmonyMethod()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Copy camera settings & postprocessing components
|
||||||
|
private static void OnWorldStart() => CopyFromPlayerCam();
|
||||||
|
}
|
48
ThirdPerson/ThirdPerson.cs
Normal file
48
ThirdPerson/ThirdPerson.cs
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
using MelonLoader;
|
||||||
|
using System;
|
||||||
|
using System.Reflection;
|
||||||
|
using UnityEngine;
|
||||||
|
using static ThirdPerson.CameraLogic;
|
||||||
|
using BuildInfo = ThirdPerson.BuildInfo;
|
||||||
|
|
||||||
|
[assembly: AssemblyCopyright("Created by " + BuildInfo.Author)]
|
||||||
|
[assembly: MelonInfo(typeof(ThirdPerson.ThirdPerson), BuildInfo.Name, BuildInfo.Version, BuildInfo.Author)]
|
||||||
|
[assembly: MelonGame("Alpha Blend Interactive", "ChilloutVR")]
|
||||||
|
[assembly: MelonColor(ConsoleColor.DarkMagenta)]
|
||||||
|
|
||||||
|
namespace ThirdPerson;
|
||||||
|
|
||||||
|
public static class BuildInfo
|
||||||
|
{
|
||||||
|
public const string Name = "ThirdPerson";
|
||||||
|
public const string Author = "Davi & NotAKidoS";
|
||||||
|
public const string Version = "1.0.1";
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ThirdPerson : MelonMod
|
||||||
|
{
|
||||||
|
internal static MelonLogger.Instance Logger;
|
||||||
|
|
||||||
|
public override void OnInitializeMelon()
|
||||||
|
{
|
||||||
|
Logger = LoggerInstance;
|
||||||
|
|
||||||
|
MelonCoroutines.Start(SetupCamera());
|
||||||
|
|
||||||
|
Patches.Apply(HarmonyInstance);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnUpdate()
|
||||||
|
{
|
||||||
|
if (State)
|
||||||
|
{
|
||||||
|
if (Input.GetAxis("Mouse ScrollWheel") > 0f) IncrementDist();
|
||||||
|
else if (Input.GetAxis("Mouse ScrollWheel") < 0f) DecrementDist();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Input.GetKey(KeyCode.LeftControl)) return;
|
||||||
|
if (Input.GetKeyDown(KeyCode.T)) State = !State;
|
||||||
|
if (!State || !Input.GetKeyDown(KeyCode.Y)) return;
|
||||||
|
RelocateCam((CameraLocation)(((int)CurrentLocation + 1) % Enum.GetValues(typeof(CameraLocation)).Length), true);
|
||||||
|
}
|
||||||
|
}
|
54
ThirdPerson/ThirdPerson.csproj
Normal file
54
ThirdPerson/ThirdPerson.csproj
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net472</TargetFramework>
|
||||||
|
<CVRReferences>true</CVRReferences>
|
||||||
|
<CopyToMods>true</CopyToMods>
|
||||||
|
<LangVersion>latest</LangVersion>
|
||||||
|
<AssemblyVersion>1.0.0.0</AssemblyVersion>
|
||||||
|
<Version>1.0.0</Version>
|
||||||
|
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="0Harmony">
|
||||||
|
<HintPath>..\_ManagedLibs\0Harmony.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Assembly-CSharp">
|
||||||
|
<HintPath>..\_ManagedLibs\Assembly-CSharp.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Assembly-CSharp-firstpass">
|
||||||
|
<HintPath>..\_ManagedLibs\Assembly-CSharp-firstpass.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Aura2_Core">
|
||||||
|
<HintPath>..\_ManagedLibs\Aura2_Core.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Cohtml.Runtime">
|
||||||
|
<HintPath>..\_ManagedLibs\Cohtml.Runtime.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="MelonLoader">
|
||||||
|
<HintPath>..\_ManagedLibs\MelonLoader.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Unity.Postprocessing.Runtime">
|
||||||
|
<HintPath>..\_ManagedLibs\Unity.Postprocessing.Runtime.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.AnimationModule">
|
||||||
|
<HintPath>..\_ManagedLibs\UnityEngine.AnimationModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.AssetBundleModule">
|
||||||
|
<HintPath>..\_ManagedLibs\UnityEngine.AssetBundleModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.CoreModule">
|
||||||
|
<HintPath>..\_ManagedLibs\UnityEngine.CoreModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.InputLegacyModule">
|
||||||
|
<HintPath>..\_ManagedLibs\UnityEngine.InputLegacyModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.PhysicsModule">
|
||||||
|
<HintPath>..\_ManagedLibs\UnityEngine.PhysicsModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<Target Name="Deploy" AfterTargets="Build">
|
||||||
|
<Copy SourceFiles="$(TargetPath)" DestinationFolder="C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\Mods\" />
|
||||||
|
<Message Text="Copied $(TargetPath) to C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\Mods\" Importance="high" />
|
||||||
|
</Target>
|
||||||
|
</Project>
|
25
ThirdPerson/ThirdPerson.sln
Normal file
25
ThirdPerson/ThirdPerson.sln
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 17
|
||||||
|
VisualStudioVersion = 17.2.32630.192
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ThirdPerson", "ThirdPerson.csproj", "{F5DE9D13-231E-4DBD-8294-D0AA1B5A91A1}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{F5DE9D13-231E-4DBD-8294-D0AA1B5A91A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{F5DE9D13-231E-4DBD-8294-D0AA1B5A91A1}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{F5DE9D13-231E-4DBD-8294-D0AA1B5A91A1}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{F5DE9D13-231E-4DBD-8294-D0AA1B5A91A1}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {B44A1184-3AC9-4ABD-8603-6B13ECDA5CA9}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
22
ThirdPerson/format.json
Normal file
22
ThirdPerson/format.json
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"_id": 16,
|
||||||
|
"name": "ThirdPerson",
|
||||||
|
"modversion": "1.0.1",
|
||||||
|
"gameversion": "2022r170",
|
||||||
|
"loaderversion": "0.5.7",
|
||||||
|
"modtype": "Mod",
|
||||||
|
"author": "Davi & NotAKidoS",
|
||||||
|
"description": "Allows you to go into third person view by pressing Ctrl + T to toggle and Ctrl + Y to change the mode",
|
||||||
|
"searchtags": [
|
||||||
|
"third person view",
|
||||||
|
"3rd person",
|
||||||
|
"third person"
|
||||||
|
],
|
||||||
|
"requirements": [],
|
||||||
|
"downloadlink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/releases/tag/r2/ThirdPerson.dll",
|
||||||
|
"sourcelink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/",
|
||||||
|
"changelog": "- Made thirdperson camera parent to Desktop camera instead of active camera.\n- Copy postprocessing settings from player camera on world start.\n - This fixed HUD rendering twice in thirdperson due to game update.\n- Added CameraFovClone component to copy zoom from desktop camera.\n- Removed logic that disabled thirdperson when opening a menu, as Game UI renders on top anyways.",
|
||||||
|
"embedcolor": "F61961"
|
||||||
|
}
|
||||||
|
]
|
Loading…
Add table
Add a link
Reference in a new issue