SmootherRay: expanded and enhanced

This commit is contained in:
NotAKidoS 2024-09-18 19:53:25 -05:00
parent 59cec7e7d3
commit 70ade663bc
9 changed files with 57 additions and 53 deletions

View file

@ -77,7 +77,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WhereAmIPointing", "WhereAm
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AvatarScaleMod", "AvatarScaleMod\AvatarScaleMod.csproj", "{A38E687F-8B6B-499E-ABC9-BD95C53DD391}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AvatarScaleMod", "AvatarScaleMod\AvatarScaleMod.csproj", "{A38E687F-8B6B-499E-ABC9-BD95C53DD391}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SmoothRay", "SmoothRay\SmoothRay.csproj", "{99F9D60D-9A2D-4DBE-AA52-13D8A0838696}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SmootherRay", "SmootherRay\SmootherRay.csproj", "{99F9D60D-9A2D-4DBE-AA52-13D8A0838696}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LuaNetworkVariables", "LuaNetworkVariables\LuaNetworkVariables.csproj", "{A3D97D1A-3099-49C5-85AD-D8C79CC5FDE3}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LuaNetworkVariables", "LuaNetworkVariables\LuaNetworkVariables.csproj", "{A3D97D1A-3099-49C5-85AD-D8C79CC5FDE3}"
EndProject EndProject

View file

@ -1,2 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk"/>

View file

@ -1,23 +0,0 @@
{
"_id": 162,
"name": "SmoothRay",
"modversion": "1.0.5",
"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\n**Only supports OpenVR, not OpenXR.\n\n **NOTE:** This disables the built-in Smooth Ray setting when the mod is enabled. Compare both & you'll see why.",
"searchtags": [
"vr",
"ray",
"controller",
"smoothing"
],
"requirements": [
"None"
],
"downloadlink": "https://github.com/NotAKidoS/NAK_CVR_Mods/releases/download/r40/SmoothRay.dll",
"sourcelink": "https://github.com/NotAKidoS/NAK_CVR_Mods/tree/main/SmoothRay/",
"changelog": "- Fixed for 2024r176.",
"embedcolor": "#f61963"
}

View file

@ -4,20 +4,20 @@ using ABI_RC.Core.Player;
using HarmonyLib; using HarmonyLib;
using MelonLoader; using MelonLoader;
namespace NAK.SmoothRay; namespace NAK.SmootherRay;
// ChilloutVR adaptation of: // ChilloutVR adaptation of:
// https://github.com/kinsi55/BeatSaber_SmoothedController // https://github.com/kinsi55/BeatSaber_SmoothedController
// https://github.com/kinsi55/BeatSaber_SmoothedController/blob/master/LICENSE // https://github.com/kinsi55/BeatSaber_SmoothedController/blob/master/LICENSE
public class SmoothRayMod : MelonMod public class SmootherRayMod : MelonMod
{ {
internal static MelonLogger.Instance Logger; internal static MelonLogger.Instance Logger;
#region Melon Preferences #region Melon Preferences
public static readonly MelonPreferences_Category Category = public static readonly MelonPreferences_Category Category =
MelonPreferences.CreateCategory(nameof(SmoothRayMod)); MelonPreferences.CreateCategory(nameof(SmootherRayMod));
public static readonly MelonPreferences_Entry<bool> EntryEnabled = public static readonly MelonPreferences_Entry<bool> EntryEnabled =
Category.CreateEntry("Enable Smoothing", true, Category.CreateEntry("Enable Smoothing", true,
@ -73,18 +73,18 @@ public class SmoothRayMod : MelonMod
[HarmonyPatch(typeof(PlayerSetup), nameof(PlayerSetup.Start))] [HarmonyPatch(typeof(PlayerSetup), nameof(PlayerSetup.Start))]
private static void Postfix_PlayerSetup_Start(ref PlayerSetup __instance) private static void Postfix_PlayerSetup_Start(ref PlayerSetup __instance)
{ {
__instance.vrLeftHandTracker.gameObject.AddComponent<SmoothRayer>().ray = __instance.vrRayLeft; __instance.vrLeftHandTracker.gameObject.AddComponent<SmootherRayer>().ray = __instance.vrRayLeft;
__instance.vrRightHandTracker.gameObject.AddComponent<SmoothRayer>().ray = __instance.vrRayRight; __instance.vrRightHandTracker.gameObject.AddComponent<SmootherRayer>().ray = __instance.vrRayRight;
} }
} }
internal static class ControllerRay_Patches internal static class ControllerRay_Patches
{ {
// SmoothRay // SmootherRay
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPatch(typeof(ControllerRay), nameof(ControllerRay.SmoothRay))] [HarmonyPatch(typeof(ControllerRay), nameof(ControllerRay.SmoothRay))]
private static bool Prefix_ControllerRay_SmoothRay(ref ControllerRay __instance) private static bool Prefix_ControllerRay_SmoothRay(ref ControllerRay __instance)
=> !EntryEnabled.Value; // SmoothRay method enforces identity local pos when disabled, so we skip it => !EntryEnabled.Value; // SmootherRay method enforces identity local pos when disabled, so we skip it
} }
#endregion Harmony Patches #endregion Harmony Patches

View file

@ -1,20 +1,20 @@
using MelonLoader; using MelonLoader;
using NAK.SmoothRay.Properties; using NAK.SmootherRay.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.SmoothRay))] [assembly: AssemblyTitle(nameof(NAK.SmootherRay))]
[assembly: AssemblyCompany(AssemblyInfoParams.Author)] [assembly: AssemblyCompany(AssemblyInfoParams.Author)]
[assembly: AssemblyProduct(nameof(NAK.SmoothRay))] [assembly: AssemblyProduct(nameof(NAK.SmootherRay))]
[assembly: MelonInfo( [assembly: MelonInfo(
typeof(NAK.SmoothRay.SmoothRayMod), typeof(NAK.SmootherRay.SmootherRayMod),
nameof(NAK.SmoothRay), nameof(NAK.SmootherRay),
AssemblyInfoParams.Version, AssemblyInfoParams.Version,
AssemblyInfoParams.Author, AssemblyInfoParams.Author,
downloadLink: "https://github.com/NotAKidoS/NAK_CVR_Mods/tree/main/SmoothRay" downloadLink: "https://github.com/NotAKidoS/NAK_CVR_Mods/tree/main/SmootherRay"
)] )]
[assembly: MelonGame("Alpha Blend Interactive", "ChilloutVR")] [assembly: MelonGame("Alpha Blend Interactive", "ChilloutVR")]
@ -24,7 +24,7 @@ using System.Reflection;
[assembly: MelonAuthorColor(255, 158, 21, 32)] // red [assembly: MelonAuthorColor(255, 158, 21, 32)] // red
[assembly: HarmonyDontPatchAll] [assembly: HarmonyDontPatchAll]
namespace NAK.SmoothRay.Properties; namespace NAK.SmootherRay.Properties;
internal static class AssemblyInfoParams internal static class AssemblyInfoParams
{ {

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<RootNamespace>SmoothRay</RootNamespace>
</PropertyGroup>
</Project>

View file

@ -30,9 +30,9 @@ using MelonLoader;
using UnityEngine; using UnityEngine;
using Valve.VR; using Valve.VR;
namespace NAK.SmoothRay; namespace NAK.SmootherRay;
public class SmoothRayer : MonoBehaviour public class SmootherRayer : MonoBehaviour
{ {
#region Variables #region Variables
@ -72,7 +72,7 @@ public class SmoothRayer : MonoBehaviour
UpdatePosesAction(true); UpdatePosesAction(true);
} }
foreach (MelonPreferences_Entry setting in SmoothRayMod.Category.Entries) foreach (MelonPreferences_Entry setting in SmootherRayMod.Category.Entries)
setting.OnEntryValueChangedUntyped.Subscribe(OnUpdateSettings); setting.OnEntryValueChangedUntyped.Subscribe(OnUpdateSettings);
MetaPort.Instance.settings.settingBoolChanged.AddListener(OnSettingsBoolChanged); MetaPort.Instance.settings.settingBoolChanged.AddListener(OnSettingsBoolChanged);
@ -131,13 +131,13 @@ public class SmoothRayer : MonoBehaviour
private void OnUpdateSettings(object arg1, object arg2) private void OnUpdateSettings(object arg1, object arg2)
{ {
_isEnabled = SmoothRayMod.EntryEnabled.Value; _isEnabled = SmootherRayMod.EntryEnabled.Value;
_menuOnly = SmoothRayMod.EntryMenuOnly.Value; _menuOnly = SmootherRayMod.EntryMenuOnly.Value;
_smallMovementThresholdAngle = SmoothRayMod.EntrySmallMovementThresholdAngle.Value; _smallMovementThresholdAngle = SmootherRayMod.EntrySmallMovementThresholdAngle.Value;
// dont let value hit 0, itll freeze controllers // dont let value hit 0, itll freeze controllers
_positionSmoothingValue = Mathf.Max(20f - Mathf.Clamp(SmoothRayMod.EntryPositionSmoothing.Value, 0f, 20f), 0.1f); _positionSmoothingValue = Mathf.Max(20f - Mathf.Clamp(SmootherRayMod.EntryPositionSmoothing.Value, 0f, 20f), 0.1f);
_rotationSmoothingValue = Mathf.Max(20f - Mathf.Clamp(SmoothRayMod.EntryRotationSmoothing.Value, 0f, 20f), 0.1f); _rotationSmoothingValue = Mathf.Max(20f - Mathf.Clamp(SmootherRayMod.EntryRotationSmoothing.Value, 0f, 20f), 0.1f);
if (!_isEnabled) if (!_isEnabled)
return; // only care about setting being enabled return; // only care about setting being enabled
@ -147,7 +147,7 @@ public class SmoothRayer : MonoBehaviour
if (MetaPort.Instance.settings.GetSettingsBool("ControlSmoothRaycast")) if (MetaPort.Instance.settings.GetSettingsBool("ControlSmoothRaycast"))
return; // disable saved setting once return; // disable saved setting once
SmoothRayMod.Logger.Msg("Built-in SmoothRay setting found to be enabled. Disabling built-in SmoothRay implementation in favor of modded implementation."); SmootherRayMod.Logger.Msg("Built-in SmootherRay setting found to be enabled. Disabling built-in SmootherRay implementation in favor of modded implementation.");
MetaPort.Instance.settings.SetSettingsBool("ControlSmoothRaycast", false); MetaPort.Instance.settings.SetSettingsBool("ControlSmoothRaycast", false);
ViewManager.SetGameSettingBool("ControlSmoothRaycast", false); ViewManager.SetGameSettingBool("ControlSmoothRaycast", false);
// ^ did you know the game doesn't even use this method native... // ^ did you know the game doesn't even use this method native...
@ -161,11 +161,11 @@ public class SmoothRayer : MonoBehaviour
if (!value) if (!value)
return; // only care about setting being enabled return; // only care about setting being enabled
_isEnabled = false; // ensure modded SmoothRay is disabled _isEnabled = false; // ensure modded SmootherRay is disabled
if (!SmoothRayMod.EntryEnabled.Value) return; // disable saved setting once if (!SmootherRayMod.EntryEnabled.Value) return; // disable saved setting once
SmoothRayMod.Logger.Msg("Modded SmoothRay found to be enabled. Disabling modded SmoothRay implementation in favor of built-in implementation."); SmootherRayMod.Logger.Msg("Modded SmootherRay found to be enabled. Disabling modded SmootherRay implementation in favor of built-in implementation.");
SmoothRayMod.EntryEnabled.Value = false; SmootherRayMod.EntryEnabled.Value = false;
} }
private void OnAppliedPoses() private void OnAppliedPoses()

23
SmootherRay/format.json Normal file
View file

@ -0,0 +1,23 @@
{
"_id": 162,
"name": "SmootherRay",
"modversion": "1.0.5",
"gameversion": "2024r176",
"loaderversion": "0.6.1",
"modtype": "Mod",
"author": "NotAKidoS",
"description": "Smoothes your controller while the raycast lines are visible.\nThis is a CVR adaptation of a Beat Saber mod: [BeatSaber_SmoothedController](https://github.com/kinsi55/BeatSaber_SmoothedController)\n\n- An option is provided to only smooth when aiming at menus.\n- Smoothing characteristics are completely configurable, but the defaults are basically perfect.\n- Pairs well with the [WhereAmIPointing](https://discord.com/channels/1001388809184870441/1002058238545641542/1282798820073406556) mod.\n\n**Only supports OpenVR, not OpenXR.**\n\n-# NOTE: This disables the shitty built-in Smooth Ray setting when the mod is enabled. Compare both & you'll see why.",
"searchtags": [
"vr",
"ray",
"controller",
"smoothing"
],
"requirements": [
"None"
],
"downloadlink": "https://github.com/NotAKidoS/NAK_CVR_Mods/releases/download/r40/SmootherRay.dll",
"sourcelink": "https://github.com/NotAKidoS/NAK_CVR_Mods/tree/main/SmootherRay/",
"changelog": "- Fixed for 2024r176.",
"embedcolor": "#f61963"
}