mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 14:29:25 +00:00
[DesktopCameraFix] initial test
This commit is contained in:
parent
a98b9e32d7
commit
6ee3d80ef8
6 changed files with 137 additions and 0 deletions
2
DesktopCameraFix/DesktopCameraFix.csproj
Normal file
2
DesktopCameraFix/DesktopCameraFix.csproj
Normal file
|
@ -0,0 +1,2 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project Sdk="Microsoft.NET.Sdk"/>
|
42
DesktopCameraFix/HarmonyPatches.cs
Normal file
42
DesktopCameraFix/HarmonyPatches.cs
Normal file
|
@ -0,0 +1,42 @@
|
|||
using ABI_RC.Core.Player;
|
||||
using ABI_RC.Systems.MovementSystem;
|
||||
using HarmonyLib;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NAK.DesktopCameraFix.HarmonyPatches;
|
||||
|
||||
class PlayerSetupPatches
|
||||
{
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(PlayerSetup), nameof(PlayerSetup.HandleDesktopCameraPosition))]
|
||||
public static void Postfix_PlayerSetup_HandleDesktopCameraPosition(bool ignore, ref PlayerSetup __instance, ref MovementSystem ____movementSystem, ref int ___headBobbingLevel)
|
||||
{
|
||||
if (!DesktopCameraFix.EntryEnabled.Value)
|
||||
return;
|
||||
|
||||
if (____movementSystem.disableCameraControl && !ignore)
|
||||
return;
|
||||
|
||||
if (___headBobbingLevel != 2)
|
||||
return;
|
||||
|
||||
Transform viewpointTransform = __instance._viewPoint.pointer.transform;
|
||||
if (viewpointTransform != null)
|
||||
{
|
||||
__instance.desktopCamera.transform.position = viewpointTransform.position;
|
||||
}
|
||||
|
||||
/**
|
||||
desktopCameraRig -> desktopCamera
|
||||
desktopCameraRig is parent of desktopCamera.
|
||||
|
||||
desktopCamera rotates, so it pivots in place.
|
||||
desktopCameraRig is moved to head bone, local position of camera is viewpoint offset when standing
|
||||
|
||||
if rig was moving position & rotation, this would work
|
||||
but because rig handles position and camera handles rotation, camera pivots in place instead of at correct point
|
||||
which is gross
|
||||
|
||||
**/
|
||||
}
|
||||
}
|
34
DesktopCameraFix/Main.cs
Normal file
34
DesktopCameraFix/Main.cs
Normal file
|
@ -0,0 +1,34 @@
|
|||
using ABI_RC.Core.IO;
|
||||
using MelonLoader;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NAK.DesktopCameraFix;
|
||||
|
||||
public class DesktopCameraFix : MelonMod
|
||||
{
|
||||
internal const string SettingsCategory = nameof(DesktopCameraFix);
|
||||
|
||||
public static readonly MelonPreferences_Category Category =
|
||||
MelonPreferences.CreateCategory(SettingsCategory);
|
||||
|
||||
public static readonly MelonPreferences_Entry<bool> EntryEnabled =
|
||||
Category.CreateEntry("Enabled", true, description: "Toggle DesktopCameraFix entirely.");
|
||||
|
||||
public override void OnInitializeMelon()
|
||||
{
|
||||
ApplyPatches(typeof(HarmonyPatches.PlayerSetupPatches));
|
||||
}
|
||||
|
||||
void ApplyPatches(Type type)
|
||||
{
|
||||
try
|
||||
{
|
||||
HarmonyInstance.PatchAll(type);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LoggerInstance.Msg($"Failed while patching {type.Name}!");
|
||||
LoggerInstance.Error(e);
|
||||
}
|
||||
}
|
||||
}
|
30
DesktopCameraFix/Properties/AssemblyInfo.cs
Normal file
30
DesktopCameraFix/Properties/AssemblyInfo.cs
Normal file
|
@ -0,0 +1,30 @@
|
|||
using CameraFixes.Properties;
|
||||
using MelonLoader;
|
||||
using System.Reflection;
|
||||
|
||||
[assembly: AssemblyVersion(AssemblyInfoParams.Version)]
|
||||
[assembly: AssemblyFileVersion(AssemblyInfoParams.Version)]
|
||||
[assembly: AssemblyInformationalVersion(AssemblyInfoParams.Version)]
|
||||
[assembly: AssemblyTitle(nameof(NAK.DesktopCameraFix))]
|
||||
[assembly: AssemblyCompany(AssemblyInfoParams.Author)]
|
||||
[assembly: AssemblyProduct(nameof(NAK.DesktopCameraFix))]
|
||||
|
||||
[assembly: MelonInfo(
|
||||
typeof(NAK.DesktopCameraFix.DesktopCameraFix),
|
||||
nameof(NAK.DesktopCameraFix),
|
||||
AssemblyInfoParams.Version,
|
||||
AssemblyInfoParams.Author,
|
||||
downloadLink: "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/tree/main/DesktopCameraFix"
|
||||
)]
|
||||
|
||||
[assembly: MelonGame("Alpha Blend Interactive", "ChilloutVR")]
|
||||
[assembly: MelonPlatform(MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)]
|
||||
[assembly: MelonPlatformDomain(MelonPlatformDomainAttribute.CompatibleDomains.MONO)]
|
||||
[assembly: HarmonyDontPatchAll]
|
||||
|
||||
namespace CameraFixes.Properties;
|
||||
internal static class AssemblyInfoParams
|
||||
{
|
||||
public const string Version = "1.0.0";
|
||||
public const string Author = "NotAKidoS";
|
||||
}
|
23
DesktopCameraFix/format.json
Normal file
23
DesktopCameraFix/format.json
Normal file
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"_id": 129,
|
||||
"name": "CameraFixes",
|
||||
"modversion": "1.0.0",
|
||||
"gameversion": "2022r170",
|
||||
"loaderversion": "0.5.7",
|
||||
"modtype": "Mod",
|
||||
"author": "NotAKidoS",
|
||||
"description": "Prevents VRIK from using toe bones in VR & optionaly FBT.\n\nVRIK calculates weird center of mass when toes are mapped, so it is sometimes desired to unmap toes to prevent an avatars feet from resting far back.\n\nPlease see the README for relevant imagery detailing the problem.",
|
||||
"searchtags": [
|
||||
"toes",
|
||||
"vrik",
|
||||
"ik",
|
||||
"feet"
|
||||
],
|
||||
"requirements": [
|
||||
"None"
|
||||
],
|
||||
"downloadlink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/releases/download/r3/CameraFixes.dll",
|
||||
"sourcelink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/tree/main/CameraFixes/",
|
||||
"changelog": "- Initial Release\n- No double patching. Bad. Stinky. Dont do it.",
|
||||
"embedcolor": "#ffc700"
|
||||
}
|
|
@ -59,6 +59,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SmoothRay", "SmoothRay\Smoo
|
|||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TrackedPointFix", "TrackedPointFix\TrackedPointFix.csproj", "{0A6788A8-89E9-4FC4-B4FE-27FE8B39926C}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DesktopCameraFix", "DesktopCameraFix\DesktopCameraFix.csproj", "{E17F78BF-90FB-44F7-A919-EDDF0BC1AF01}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
@ -177,6 +179,10 @@ Global
|
|||
{0A6788A8-89E9-4FC4-B4FE-27FE8B39926C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{0A6788A8-89E9-4FC4-B4FE-27FE8B39926C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{0A6788A8-89E9-4FC4-B4FE-27FE8B39926C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{E17F78BF-90FB-44F7-A919-EDDF0BC1AF01}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E17F78BF-90FB-44F7-A919-EDDF0BC1AF01}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E17F78BF-90FB-44F7-A919-EDDF0BC1AF01}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E17F78BF-90FB-44F7-A919-EDDF0BC1AF01}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue