From a168619d19781f7f3577413467830efa7d5ce424 Mon Sep 17 00:00:00 2001 From: NotAKidoS <37721153+NotAKidoS@users.noreply.github.com> Date: Sun, 8 Sep 2024 16:38:06 -0500 Subject: [PATCH] SmoothRay: brought back from the dead --- .DepricatedMods/SmoothRay/HarmonyPatches.cs | 14 ---- .DepricatedMods/SmoothRay/Main.cs | 28 ------- NAK_CVR_Mods.sln | 6 ++ SmoothRay/Main.cs | 76 +++++++++++++++++++ .../Properties/AssemblyInfo.cs | 6 +- .../SmoothRay => SmoothRay}/README.md | 3 + .../SmoothRay => SmoothRay}/SmoothRay.csproj | 0 .../SmoothRay.cs => SmoothRay/SmoothRayer.cs | 4 +- .../SmoothRay => SmoothRay}/format.json | 10 +-- 9 files changed, 95 insertions(+), 52 deletions(-) delete mode 100644 .DepricatedMods/SmoothRay/HarmonyPatches.cs delete mode 100644 .DepricatedMods/SmoothRay/Main.cs create mode 100644 SmoothRay/Main.cs rename {.DepricatedMods/SmoothRay => SmoothRay}/Properties/AssemblyInfo.cs (87%) rename {.DepricatedMods/SmoothRay => SmoothRay}/README.md (78%) rename {.DepricatedMods/SmoothRay => SmoothRay}/SmoothRay.csproj (100%) rename .DepricatedMods/SmoothRay/SmoothRay.cs => SmoothRay/SmoothRayer.cs (96%) rename {.DepricatedMods/SmoothRay => SmoothRay}/format.json (66%) diff --git a/.DepricatedMods/SmoothRay/HarmonyPatches.cs b/.DepricatedMods/SmoothRay/HarmonyPatches.cs deleted file mode 100644 index 590def2..0000000 --- a/.DepricatedMods/SmoothRay/HarmonyPatches.cs +++ /dev/null @@ -1,14 +0,0 @@ -using ABI_RC.Core.Player; -using HarmonyLib; - -namespace NAK.SmoothRay.HarmonyPatches; - -internal class PlayerSetupPatches -{ - [HarmonyPostfix] - [HarmonyPatch(typeof(PlayerSetup), nameof(PlayerSetup.Start))] - private static void Postfix_PlayerSetup_Start(ref PlayerSetup __instance) - { - - } -} \ No newline at end of file diff --git a/.DepricatedMods/SmoothRay/Main.cs b/.DepricatedMods/SmoothRay/Main.cs deleted file mode 100644 index 0a591d6..0000000 --- a/.DepricatedMods/SmoothRay/Main.cs +++ /dev/null @@ -1,28 +0,0 @@ -using MelonLoader; - -namespace NAK.SmoothRay; - -// ChilloutVR adaptation of: -// https://github.com/kinsi55/BeatSaber_SmoothedController -// https://github.com/kinsi55/BeatSaber_SmoothedController/blob/master/LICENSE - -public class SmoothRay : MelonMod -{ - public override void OnInitializeMelon() - { - ApplyPatches(typeof(HarmonyPatches.PlayerSetupPatches)); - } - - private void ApplyPatches(Type type) - { - try - { - HarmonyInstance.PatchAll(type); - } - catch (Exception e) - { - LoggerInstance.Msg($"Failed while patching {type.Name}!"); - LoggerInstance.Error(e); - } - } -} \ No newline at end of file diff --git a/NAK_CVR_Mods.sln b/NAK_CVR_Mods.sln index 7c513e3..391758a 100644 --- a/NAK_CVR_Mods.sln +++ b/NAK_CVR_Mods.sln @@ -77,6 +77,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WhereAmIPointing", "WhereAm EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AvatarScaleMod", "AvatarScaleMod\AvatarScaleMod.csproj", "{A38E687F-8B6B-499E-ABC9-BD95C53DD391}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SmoothRay", "SmoothRay\SmoothRay.csproj", "{99F9D60D-9A2D-4DBE-AA52-13D8A0838696}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -231,6 +233,10 @@ Global {A38E687F-8B6B-499E-ABC9-BD95C53DD391}.Debug|Any CPU.Build.0 = Debug|Any CPU {A38E687F-8B6B-499E-ABC9-BD95C53DD391}.Release|Any CPU.ActiveCfg = Release|Any CPU {A38E687F-8B6B-499E-ABC9-BD95C53DD391}.Release|Any CPU.Build.0 = Release|Any CPU + {99F9D60D-9A2D-4DBE-AA52-13D8A0838696}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {99F9D60D-9A2D-4DBE-AA52-13D8A0838696}.Debug|Any CPU.Build.0 = Debug|Any CPU + {99F9D60D-9A2D-4DBE-AA52-13D8A0838696}.Release|Any CPU.ActiveCfg = Release|Any CPU + {99F9D60D-9A2D-4DBE-AA52-13D8A0838696}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/SmoothRay/Main.cs b/SmoothRay/Main.cs new file mode 100644 index 0000000..e5e2a12 --- /dev/null +++ b/SmoothRay/Main.cs @@ -0,0 +1,76 @@ +using ABI_RC.Core.Player; +using HarmonyLib; +using MelonLoader; + +namespace NAK.SmoothRay; + +// ChilloutVR adaptation of: +// https://github.com/kinsi55/BeatSaber_SmoothedController +// https://github.com/kinsi55/BeatSaber_SmoothedController/blob/master/LICENSE + +public class SmoothRay : MelonMod +{ + #region Melon Preferences + + public static readonly MelonPreferences_Category Category = + MelonPreferences.CreateCategory(nameof(SmoothRay)); + + public static readonly MelonPreferences_Entry EntryEnabled = + Category.CreateEntry("Enable Smoothing", true, + description: "Enable or disable smoothing."); + + public static readonly MelonPreferences_Entry EntryMenuOnly = + Category.CreateEntry("Menu Only", true, + description: "Only use smoothing on Main Menu and Quick Menu. This will be fine for most users, but it may be desired on pickups & Unity UI elements too."); + + public static readonly MelonPreferences_Entry EntryPositionSmoothing = + Category.CreateEntry("Position Smoothing", 3f, + description: "How much to smooth position changes by. Use the slider to adjust the position smoothing factor. Range: 0 to 20."); + + public static readonly MelonPreferences_Entry EntryRotationSmoothing = + Category.CreateEntry("Rotation Smoothing", 12f, + description: "How much to smooth rotation changes by. Use the slider to adjust the rotation smoothing factor. Range: 0 to 20."); + + public static readonly MelonPreferences_Entry EntrySmallMovementThresholdAngle = + Category.CreateEntry("Small Angle Threshold", 6f, + description: "Angle difference to consider a 'small' movement. The less shaky your hands are, the lower you probably want to set this. This is probably the primary value you want to tweak. Use the slider to adjust the threshold angle. Range: 4 to 15."); + + #endregion Melon Preferences + + #region Melon Events + + public override void OnInitializeMelon() + { + ApplyPatches(typeof(PlayerSetup_Patches)); + } + + private void ApplyPatches(Type type) + { + try + { + HarmonyInstance.PatchAll(type); + } + catch (Exception e) + { + LoggerInstance.Msg($"Failed while patching {type.Name}!"); + LoggerInstance.Error(e); + } + } + + #endregion Melon Events + + #region Harmony Patches + + internal static class PlayerSetup_Patches + { + [HarmonyPostfix] + [HarmonyPatch(typeof(PlayerSetup), nameof(PlayerSetup.Start))] + private static void Postfix_PlayerSetup_Start(ref PlayerSetup __instance) + { + __instance.vrLeftHandTracker.gameObject.AddComponent().ray = __instance.vrRayLeft; + __instance.vrRightHandTracker.gameObject.AddComponent().ray = __instance.vrRayRight; + } + } + + #endregion Harmony Patches +} \ No newline at end of file diff --git a/.DepricatedMods/SmoothRay/Properties/AssemblyInfo.cs b/SmoothRay/Properties/AssemblyInfo.cs similarity index 87% rename from .DepricatedMods/SmoothRay/Properties/AssemblyInfo.cs rename to SmoothRay/Properties/AssemblyInfo.cs index 2becd53..a87f25c 100644 --- a/.DepricatedMods/SmoothRay/Properties/AssemblyInfo.cs +++ b/SmoothRay/Properties/AssemblyInfo.cs @@ -20,14 +20,14 @@ using System.Reflection; [assembly: MelonGame("Alpha Blend Interactive", "ChilloutVR")] [assembly: MelonPlatform(MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)] [assembly: MelonPlatformDomain(MelonPlatformDomainAttribute.CompatibleDomains.MONO)] -[assembly: MelonColor(255, 220, 130, 5)] -[assembly: MelonAuthorColor(255, 158, 21, 32)] +[assembly: MelonColor(255, 246, 25, 99)] // red-pink +[assembly: MelonAuthorColor(255, 158, 21, 32)] // red [assembly: HarmonyDontPatchAll] namespace NAK.SmoothRay.Properties; internal static class AssemblyInfoParams { - public const string Version = "1.0.3"; + public const string Version = "1.0.4"; public const string Author = "NotAKidoS"; } \ No newline at end of file diff --git a/.DepricatedMods/SmoothRay/README.md b/SmoothRay/README.md similarity index 78% rename from .DepricatedMods/SmoothRay/README.md rename to SmoothRay/README.md index 7c670d3..72fcbf0 100644 --- a/.DepricatedMods/SmoothRay/README.md +++ b/SmoothRay/README.md @@ -1,6 +1,9 @@ # SmoothRay Smoothes your controller while using the Quick and Main menus to make it easier to navigate. +This is a CVR adaptation of a Beat Saber mod: [BeatSaber_SmoothedController](https://github.com/kinsi55/BeatSaber_SmoothedController) + +**Only supports OpenVR, not OpenXR.** --- diff --git a/.DepricatedMods/SmoothRay/SmoothRay.csproj b/SmoothRay/SmoothRay.csproj similarity index 100% rename from .DepricatedMods/SmoothRay/SmoothRay.csproj rename to SmoothRay/SmoothRay.csproj diff --git a/.DepricatedMods/SmoothRay/SmoothRay.cs b/SmoothRay/SmoothRayer.cs similarity index 96% rename from .DepricatedMods/SmoothRay/SmoothRay.cs rename to SmoothRay/SmoothRayer.cs index ae562af..55797e7 100644 --- a/.DepricatedMods/SmoothRay/SmoothRay.cs +++ b/SmoothRay/SmoothRayer.cs @@ -131,8 +131,8 @@ public class SmoothRayer : MonoBehaviour _menuOnly = SmoothRay.EntryMenuOnly.Value; _smallMovementThresholdAngle = SmoothRay.EntrySmallMovementThresholdAngle.Value; // dont let value hit 0, itll freeze controllers - _positionSmoothingValue = Math.Max(20f - Mathf.Clamp(SmoothRay.EntryPositionSmoothing.Value, 0f, 20f), 0.1f); - _rotationSmoothingValue = Math.Max(20f - Mathf.Clamp(SmoothRay.EntryRotationSmoothing.Value, 0f, 20f), 0.1f); + _positionSmoothingValue = Mathf.Max(20f - Mathf.Clamp(SmoothRay.EntryPositionSmoothing.Value, 0f, 20f), 0.1f); + _rotationSmoothingValue = Mathf.Max(20f - Mathf.Clamp(SmoothRay.EntryRotationSmoothing.Value, 0f, 20f), 0.1f); } private void OnAppliedPoses() diff --git a/.DepricatedMods/SmoothRay/format.json b/SmoothRay/format.json similarity index 66% rename from .DepricatedMods/SmoothRay/format.json rename to SmoothRay/format.json index 2c91941..4fc19ff 100644 --- a/.DepricatedMods/SmoothRay/format.json +++ b/SmoothRay/format.json @@ -1,12 +1,12 @@ { "_id": 162, "name": "SmoothRay", - "modversion": "1.0.3", - "gameversion": "2023r172", + "modversion": "1.0.4", + "gameversion": "2024r176", "loaderversion": "0.6.1", "modtype": "Mod", "author": "NotAKidoS", - "description": "Smoothes your controller while using the Quick and Main menus to make it easier to navigate.\nThis is a CVR adaptation of a Beat Saber mod: [BeatSaber_SmoothedController](https://github.com/kinsi55/BeatSaber_SmoothedController)\n\nSupport for TrackedControllerFix & DesktopVRSwitch.\n**Only supports OpenVR, not OpenXR.**", + "description": "Smoothes your controller while using the Quick and Main menus to make it easier to navigate.\nThis is a CVR adaptation of a Beat Saber mod: [BeatSaber_SmoothedController](https://github.com/kinsi55/BeatSaber_SmoothedController)\n\n**Only supports OpenVR, not OpenXR.**", "searchtags": [ "vr", "ray", @@ -18,6 +18,6 @@ ], "downloadlink": "https://github.com/NotAKidoS/NAK_CVR_Mods/releases/download/r21/SmoothRay.dll", "sourcelink": "https://github.com/NotAKidoS/NAK_CVR_Mods/tree/main/SmoothRay/", - "changelog": "- Fixes for 2023r172. Literally just recompiled.", - "embedcolor": "#dc8105" + "changelog": "- Fixed for 2024r176.", + "embedcolor": "#f61963" } \ No newline at end of file