mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 14:29:25 +00:00
[PlaySpaceScaleFix] Initial Commit
This commit is contained in:
parent
84fe655eb5
commit
df8bbf279f
5 changed files with 128 additions and 0 deletions
41
PlaySpaceScaleFix/HarmonyPatches.cs
Normal file
41
PlaySpaceScaleFix/HarmonyPatches.cs
Normal file
|
@ -0,0 +1,41 @@
|
|||
using ABI_RC.Core.Player;
|
||||
using ABI_RC.Systems.IK;
|
||||
using HarmonyLib;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NAK.PlaySpaceScaleFix.HarmonyPatches;
|
||||
|
||||
class PlayerSetupPatches
|
||||
{
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(PlayerSetup), nameof(PlayerSetup.SetPlaySpaceScale))]
|
||||
private static void Prefix_PlayerSetup_SetPlaySpaceScale(ref PlayerSetup __instance, ref Vector3 __state)
|
||||
{
|
||||
__state = __instance.vrCamera.transform.position;
|
||||
__state.y = __instance.transform.position.y;
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(PlayerSetup), nameof(PlayerSetup.SetPlaySpaceScale))]
|
||||
private static void Postfix_PlayerSetup_SetPlaySpaceScale(ref PlayerSetup __instance, ref Vector3 __state)
|
||||
{
|
||||
if (!PlaySpaceScaleFix.EntryEnabled.Value)
|
||||
return;
|
||||
|
||||
Vector3 newPosition = __instance.vrCamera.transform.position;
|
||||
newPosition.y = __instance.transform.position.y;
|
||||
|
||||
Vector3 offset = __state + newPosition;
|
||||
|
||||
// Offset _PlayerLocal to keep player in place
|
||||
__instance.transform.position += offset;
|
||||
|
||||
// TODO: Figure out why VRIK is wonky still
|
||||
if (IKSystem.vrik != null)
|
||||
{
|
||||
IKSystem.vrik.solver.locomotion.AddDeltaPosition(offset);
|
||||
IKSystem.vrik.solver.raycastOriginPelvis += offset;
|
||||
IKSystem.vrik.transform.position += offset;
|
||||
}
|
||||
}
|
||||
}
|
30
PlaySpaceScaleFix/Main.cs
Normal file
30
PlaySpaceScaleFix/Main.cs
Normal file
|
@ -0,0 +1,30 @@
|
|||
using MelonLoader;
|
||||
|
||||
namespace NAK.PlaySpaceScaleFix;
|
||||
|
||||
public class PlaySpaceScaleFix : MelonMod
|
||||
{
|
||||
public static readonly MelonPreferences_Category Category =
|
||||
MelonPreferences.CreateCategory(nameof(PlaySpaceScaleFix));
|
||||
|
||||
public static readonly MelonPreferences_Entry<bool> EntryEnabled =
|
||||
Category.CreateEntry("Enabled", true, description: "Toggle PlaySpaceScaleFix 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);
|
||||
}
|
||||
}
|
||||
}
|
2
PlaySpaceScaleFix/PlaySpaceScaleFix.csproj
Normal file
2
PlaySpaceScaleFix/PlaySpaceScaleFix.csproj
Normal file
|
@ -0,0 +1,2 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project Sdk="Microsoft.NET.Sdk"/>
|
32
PlaySpaceScaleFix/Properties/AssemblyInfo.cs
Normal file
32
PlaySpaceScaleFix/Properties/AssemblyInfo.cs
Normal file
|
@ -0,0 +1,32 @@
|
|||
using MelonLoader;
|
||||
using NAK.PlaySpaceScaleFix.Properties;
|
||||
using System.Reflection;
|
||||
|
||||
[assembly: AssemblyVersion(AssemblyInfoParams.Version)]
|
||||
[assembly: AssemblyFileVersion(AssemblyInfoParams.Version)]
|
||||
[assembly: AssemblyInformationalVersion(AssemblyInfoParams.Version)]
|
||||
[assembly: AssemblyTitle(nameof(NAK.PlaySpaceScaleFix))]
|
||||
[assembly: AssemblyCompany(AssemblyInfoParams.Author)]
|
||||
[assembly: AssemblyProduct(nameof(NAK.PlaySpaceScaleFix))]
|
||||
|
||||
[assembly: MelonInfo(
|
||||
typeof(NAK.PlaySpaceScaleFix.PlaySpaceScaleFix),
|
||||
nameof(NAK.PlaySpaceScaleFix),
|
||||
AssemblyInfoParams.Version,
|
||||
AssemblyInfoParams.Author,
|
||||
downloadLink: "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/tree/main/PlaySpaceScaleFix"
|
||||
)]
|
||||
|
||||
[assembly: MelonGame("Alpha Blend Interactive", "ChilloutVR")]
|
||||
[assembly: MelonPlatform(MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)]
|
||||
[assembly: MelonPlatformDomain(MelonPlatformDomainAttribute.CompatibleDomains.MONO)]
|
||||
[assembly: MelonColor(255, 241, 200, 82)]
|
||||
[assembly: MelonAuthorColor(255, 114, 17, 25)]
|
||||
[assembly: HarmonyDontPatchAll]
|
||||
|
||||
namespace NAK.PlaySpaceScaleFix.Properties;
|
||||
internal static class AssemblyInfoParams
|
||||
{
|
||||
public const string Version = "1.0.0";
|
||||
public const string Author = "NotAKidoS";
|
||||
}
|
23
PlaySpaceScaleFix/format.json
Normal file
23
PlaySpaceScaleFix/format.json
Normal file
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"_id": -1,
|
||||
"name": "PlaySpaceScaleFix",
|
||||
"modversion": "1.0.0",
|
||||
"gameversion": "2022r170p1",
|
||||
"loaderversion": "0.6.1",
|
||||
"modtype": "Mod",
|
||||
"author": "NotAKidoS",
|
||||
"description": "Fixes the issue where the player in VR is incorrectly positioned relative to the center of the playspace when adjusting playspace scales.\n\nEnsures that scaling and switching avatars no longer result in unusual offsets.",
|
||||
"searchtags": [
|
||||
"scale",
|
||||
"play",
|
||||
"space",
|
||||
"offset"
|
||||
],
|
||||
"requirements": [
|
||||
"None"
|
||||
],
|
||||
"downloadlink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/releases/download/r4/PlaySpaceScaleFix.dll",
|
||||
"sourcelink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/tree/main/PlaySpaceScaleFix/",
|
||||
"changelog": "- Initial Release",
|
||||
"embedcolor": "#e56597"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue