mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 06:19:22 +00:00
CVRMG Submission *attempt*..?
This commit is contained in:
parent
d4391433d6
commit
0f8a23e0e8
2 changed files with 79 additions and 25 deletions
|
@ -1,17 +1,17 @@
|
||||||
using ABI_RC.Core.InteractionSystem;
|
using ABI_RC.Core;
|
||||||
|
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 ABI_RC.Core.UI;
|
using ABI_RC.Core.UI;
|
||||||
using ABI_RC.Core;
|
|
||||||
using ABI_RC.Core.Util.Object_Behaviour;
|
using ABI_RC.Core.Util.Object_Behaviour;
|
||||||
using ABI_RC.Systems.MovementSystem;
|
using ABI_RC.Systems.MovementSystem;
|
||||||
using MelonLoader;
|
using MelonLoader;
|
||||||
using RootMotion.FinalIK;
|
using RootMotion.FinalIK;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using Object = UnityEngine.Object;
|
|
||||||
using UnityEngine.XR;
|
using UnityEngine.XR;
|
||||||
using Valve.VR;
|
using Valve.VR;
|
||||||
|
using Object = UnityEngine.Object;
|
||||||
|
|
||||||
namespace DesktopVRSwitch;
|
namespace DesktopVRSwitch;
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ public class DesktopVRSwitch : MelonMod
|
||||||
{
|
{
|
||||||
//start attempt
|
//start attempt
|
||||||
isAttemptingSwitch = true;
|
isAttemptingSwitch = true;
|
||||||
MelonCoroutines.Start( AttemptPlatformSwitch() );
|
MelonCoroutines.Start(AttemptPlatformSwitch());
|
||||||
|
|
||||||
//how long we wait until we assume an error occured
|
//how long we wait until we assume an error occured
|
||||||
timedSwitch = Time.time + 10f;
|
timedSwitch = Time.time + 10f;
|
||||||
|
@ -38,26 +38,28 @@ public class DesktopVRSwitch : MelonMod
|
||||||
if (isAttemptingSwitch && Time.time > timedSwitch)
|
if (isAttemptingSwitch && Time.time > timedSwitch)
|
||||||
{
|
{
|
||||||
MelonLogger.Error("Timer exceeded. Something is wrong and coroutine failed partway.");
|
MelonLogger.Error("Timer exceeded. Something is wrong and coroutine failed partway.");
|
||||||
MelonCoroutines.Start( AttemptPlatformSwitch(true) );
|
MelonCoroutines.Start(AttemptPlatformSwitch(true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IEnumerator AttemptPlatformSwitch(bool forceMode = false)
|
private static IEnumerator AttemptPlatformSwitch(bool forceMode = false)
|
||||||
{
|
{
|
||||||
//forceMode will attempt to backtrack to last working mode
|
//forceMode will attempt to backtrack to last working mode (if you dont like the mess, fix it yourself thx)
|
||||||
CurrentMode = forceMode ? CurrentMode : MetaPort.Instance.isUsingVr;
|
CurrentMode = forceMode ? CurrentMode : MetaPort.Instance.isUsingVr;
|
||||||
bool VRMode = forceMode ? CurrentMode : !CurrentMode;
|
bool VRMode = forceMode ? CurrentMode : !CurrentMode;
|
||||||
|
|
||||||
//load or unload SteamVR
|
//load or unload SteamVR
|
||||||
InitializeSteamVR(VRMode);
|
InitializeSteamVR(VRMode);
|
||||||
|
|
||||||
CloseMenuElements(VRMode);
|
CloseMenuElements(VRMode);
|
||||||
|
|
||||||
yield return new WaitForEndOfFrame();
|
yield
|
||||||
|
return new WaitForEndOfFrame();
|
||||||
|
|
||||||
SetMetaPort(VRMode);
|
SetMetaPort(VRMode);
|
||||||
|
|
||||||
yield return new WaitForEndOfFrame();
|
yield
|
||||||
|
return new WaitForEndOfFrame();
|
||||||
|
|
||||||
SetPlayerSetup(VRMode);
|
SetPlayerSetup(VRMode);
|
||||||
SwitchActiveCameraRigs(VRMode);
|
SwitchActiveCameraRigs(VRMode);
|
||||||
|
@ -67,21 +69,33 @@ public class DesktopVRSwitch : MelonMod
|
||||||
RepositionCohtmlHud(VRMode);
|
RepositionCohtmlHud(VRMode);
|
||||||
UpdateHudOperations(VRMode);
|
UpdateHudOperations(VRMode);
|
||||||
|
|
||||||
yield return new WaitForEndOfFrame();
|
yield
|
||||||
|
return new WaitForEndOfFrame();
|
||||||
|
|
||||||
SetMovementSystem(VRMode);
|
SetMovementSystem(VRMode);
|
||||||
|
|
||||||
yield return new WaitForEndOfFrame();
|
yield
|
||||||
|
return new WaitForEndOfFrame();
|
||||||
|
|
||||||
|
//needs to come after SetMovementSystem
|
||||||
|
//UpdateGestureReconizerCam();
|
||||||
|
|
||||||
//right here is the fucker most likely to break
|
//right here is the fucker most likely to break
|
||||||
ReloadCVRInputManager();
|
ReloadCVRInputManager();
|
||||||
|
|
||||||
//some menus have 0.5s wait(), so to be safe
|
//some menus have 0.5s wait(), so to be safe
|
||||||
yield return new WaitForSeconds(1f);
|
yield
|
||||||
|
return new WaitForSeconds(1f);
|
||||||
|
|
||||||
Recalibrate();
|
Recalibrate();
|
||||||
|
|
||||||
yield return null;
|
//tell the game to change VRMode/DesktopMode for Steam/Discord presence
|
||||||
|
//RichPresence.PopulatePresence();
|
||||||
|
|
||||||
|
//nvm that resets the RichPresence clock- i want people to know how long ive wasted staring at mirror
|
||||||
|
|
||||||
|
yield
|
||||||
|
return null;
|
||||||
isAttemptingSwitch = false;
|
isAttemptingSwitch = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,7 +136,6 @@ public class DesktopVRSwitch : MelonMod
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// shouldn't be that important, right?
|
// shouldn't be that important, right?
|
||||||
private static void CloseMenuElements(bool isVR)
|
private static void CloseMenuElements(bool isVR)
|
||||||
{
|
{
|
||||||
|
@ -244,7 +257,7 @@ public class DesktopVRSwitch : MelonMod
|
||||||
{
|
{
|
||||||
MelonLogger.Msg("Parented CohtmlHud to active camera.");
|
MelonLogger.Msg("Parented CohtmlHud to active camera.");
|
||||||
CohtmlHud.Instance.gameObject.transform.parent = isVR ? PlayerSetup.Instance.vrCamera.transform : PlayerSetup.Instance.desktopCamera.transform;
|
CohtmlHud.Instance.gameObject.transform.parent = isVR ? PlayerSetup.Instance.vrCamera.transform : PlayerSetup.Instance.desktopCamera.transform;
|
||||||
|
|
||||||
//sets hud position, rotation, and scale based on MetaPort isUsingVr
|
//sets hud position, rotation, and scale based on MetaPort isUsingVr
|
||||||
CVRTools.ConfigureHudAffinity();
|
CVRTools.ConfigureHudAffinity();
|
||||||
}
|
}
|
||||||
|
@ -318,6 +331,7 @@ public class DesktopVRSwitch : MelonMod
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
MelonLogger.Msg("Updating all CameraFacingObject scripts to face new camera. (this fixes nameplates)");
|
||||||
CameraFacingObject[] camfaceobjs = Object.FindObjectsOfType<CameraFacingObject>();
|
CameraFacingObject[] camfaceobjs = Object.FindObjectsOfType<CameraFacingObject>();
|
||||||
|
|
||||||
for (int i = 0; i < camfaceobjs.Count(); i++)
|
for (int i = 0; i < camfaceobjs.Count(); i++)
|
||||||
|
@ -332,10 +346,34 @@ public class DesktopVRSwitch : MelonMod
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//cant fix unless i log the original VR gripOrigins with a patch...
|
||||||
|
//private static void SetPickupObjectOrigins()
|
||||||
|
//{
|
||||||
|
// try
|
||||||
|
// {
|
||||||
|
// CVRPickupObject[] pickups = Object.FindObjectsOfType<CVRPickupObject>();
|
||||||
|
|
||||||
|
// if (pickups.gripOrigin != null)
|
||||||
|
// {
|
||||||
|
// Transform x = this.gripOrigin.Find("[Desktop]");
|
||||||
|
// if (x != null)
|
||||||
|
// {
|
||||||
|
// this.gripOrigin = x;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// catch (Exception)
|
||||||
|
// {
|
||||||
|
// MelonLogger.Error("Error updating CameraFacingObject objects! Nameplates will be wonk...");
|
||||||
|
// throw;
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
private static void UpdateHudOperations(bool isVR)
|
private static void UpdateHudOperations(bool isVR)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
MelonLogger.Msg("Set HudOperations worldLoadingItem and worldLoadStatus to their respective Desktop/Vr parent.");
|
||||||
HudOperations.Instance.worldLoadingItem = isVR ? HudOperations.Instance.worldLoadingItemVr : HudOperations.Instance.worldLoadingItemDesktop;
|
HudOperations.Instance.worldLoadingItem = isVR ? HudOperations.Instance.worldLoadingItemVr : HudOperations.Instance.worldLoadingItemDesktop;
|
||||||
HudOperations.Instance.worldLoadStatus = isVR ? HudOperations.Instance.worldLoadStatusVr : HudOperations.Instance.worldLoadStatusDesktop;
|
HudOperations.Instance.worldLoadStatus = isVR ? HudOperations.Instance.worldLoadStatusVr : HudOperations.Instance.worldLoadStatusDesktop;
|
||||||
}
|
}
|
||||||
|
@ -345,4 +383,20 @@ public class DesktopVRSwitch : MelonMod
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//i suck at traverse
|
||||||
|
//private static void UpdateGestureReconizerCam()
|
||||||
|
//{
|
||||||
|
// try
|
||||||
|
// {
|
||||||
|
// MelonLogger.Msg("Set GestureReconizerCam camera to Camera.main.");
|
||||||
|
// Camera _camera = Traverse.Create(CVRGestureRecognizer.Instance).Field("_camera").GetValue<Camera>();
|
||||||
|
// _camera = Camera.main;
|
||||||
|
// }
|
||||||
|
// catch (Exception)
|
||||||
|
// {
|
||||||
|
// MelonLogger.Error("Error updating CVRGestureRecognizer camera!");
|
||||||
|
// throw;
|
||||||
|
// }
|
||||||
|
//}
|
||||||
}
|
}
|
|
@ -1,23 +1,23 @@
|
||||||
{
|
{
|
||||||
"_id": 95,
|
"_id": -1,
|
||||||
"name": "DesktopVRSwitch",
|
"name": "DesktopVRSwitch",
|
||||||
"modversion": "1.1.0",
|
"modversion": "1.0.0",
|
||||||
"gameversion": "2022r168",
|
"gameversion": "2022r168",
|
||||||
"loaderversion": "0.5.4",
|
"loaderversion": "0.5.4",
|
||||||
"modtype": "Mod",
|
"modtype": "Mod",
|
||||||
"author": "NotAKidoS",
|
"author": "NotAKidoS",
|
||||||
"description": "Corrects MM and QM position when avatar is scaled.\nAdditional option to scale player collision.",
|
"description": "Allows you to switch between Desktop and VR with a keybind.\n**Press Control + F6 to switch.**\n\nWhile this mod is a nice convienence feature to have access to, not every chillout system or mod is built to support it. I cannot possibly cover every edge case or mitigate issues with every mod. **Use at your own discretion.**",
|
||||||
"searchtags": [
|
"searchtags": [
|
||||||
"menu",
|
"desktop",
|
||||||
"scale",
|
"vr",
|
||||||
"avatarscale",
|
"switch",
|
||||||
"slider"
|
"hotswap"
|
||||||
],
|
],
|
||||||
"requirements": [
|
"requirements": [
|
||||||
"None"
|
"None"
|
||||||
],
|
],
|
||||||
"downloadlink": "https://github.com/NotAKidOnSteam/DesktopVRSwitch/releases/download/r2/DesktopVRSwitch.dll",
|
"downloadlink": "https://github.com/NotAKidOnSteam/DesktopVRSwitch/releases/download/r1/DesktopVRSwitch.dll",
|
||||||
"sourcelink": "https://github.com/NotAKidOnSteam/DesktopVRSwitch/",
|
"sourcelink": "https://github.com/NotAKidOnSteam/DesktopVRSwitch/",
|
||||||
"changelog": "Added option to scale player collision. Fixed some VR specific issues.",
|
"changelog": "Initial Release",
|
||||||
"embedcolor": "804221"
|
"embedcolor": "3498db"
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue