mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 22:39:22 +00:00
[EzCurls] Initial tests
This commit is contained in:
parent
686a06fab1
commit
623df261b0
7 changed files with 294 additions and 0 deletions
79
EzCurls/Main.cs
Normal file
79
EzCurls/Main.cs
Normal file
|
@ -0,0 +1,79 @@
|
|||
using ABI_RC.Core.Savior;
|
||||
using MelonLoader;
|
||||
using System.Reflection;
|
||||
|
||||
namespace NAK.EzCurls;
|
||||
|
||||
public class EzCurls : MelonMod
|
||||
{
|
||||
internal const string SettingsCategory = nameof(EzCurls);
|
||||
|
||||
public static readonly MelonPreferences_Category Category =
|
||||
MelonPreferences.CreateCategory(SettingsCategory);
|
||||
|
||||
public static readonly MelonPreferences_Entry<bool> EntryUseCurlSnapping =
|
||||
Category.CreateEntry("UseCurlSnapping", true,
|
||||
description: "Finger curl snapping to a specified value when in the specified range.");
|
||||
|
||||
public static readonly MelonPreferences_Entry<float> EntrySnappedCurlValue =
|
||||
Category.CreateEntry("SnappedCurlValue", 0.5f,
|
||||
description: "The value to which the finger curl snaps within the range.");
|
||||
|
||||
public static readonly MelonPreferences_Entry<float> EntryRangeStartPercent =
|
||||
Category.CreateEntry("RangeStartPercent", 0.5f,
|
||||
description: "The minimum value for the SnappedCurlValue range.");
|
||||
|
||||
public static readonly MelonPreferences_Entry<float> EntryRangeEndPercent =
|
||||
Category.CreateEntry("RangeEndPercent", 0.8f,
|
||||
description: "The maximum value for the SnappedCurlValue range.");
|
||||
|
||||
public static readonly MelonPreferences_Entry<bool> EntryUseCurlSmoothing =
|
||||
Category.CreateEntry("UseCurlSmoothing", false,
|
||||
description: "Finger curl smoothing to average out similar finger positions.");
|
||||
|
||||
public static readonly MelonPreferences_Entry<bool> EntryDontSmoothExtremes =
|
||||
Category.CreateEntry("DontSmoothExtremes", true,
|
||||
description: "Should the finger curl smoothing be less effective on curls towards 0 or 1?");
|
||||
|
||||
public static readonly MelonPreferences_Entry<float> EntryCurlSimilarityThreshold =
|
||||
Category.CreateEntry("CurlSimilarityThreshold", 0.1f,
|
||||
description: "The threshold for curl similarity during curl smoothing.");
|
||||
|
||||
public static readonly MelonPreferences_Entry<float> EntryCurlSmoothingFactor =
|
||||
Category.CreateEntry("CurlSmoothingFactor", 0.5f,
|
||||
description: "The multiplier for curl smoothing.");
|
||||
|
||||
public override void OnInitializeMelon()
|
||||
{
|
||||
HarmonyInstance.Patch(
|
||||
typeof(InputModuleSteamVR).GetMethod(nameof(InputModuleSteamVR.Start)),
|
||||
prefix: new HarmonyLib.HarmonyMethod(typeof(EzCurls).GetMethod(nameof(OnInputModuleSteamVRStart_Prefix), BindingFlags.NonPublic | BindingFlags.Static))
|
||||
);
|
||||
|
||||
foreach (MelonPreferences_Entry setting in Category.Entries)
|
||||
setting.OnEntryValueChangedUntyped.Subscribe(OnSettingsChanged);
|
||||
}
|
||||
|
||||
public static void OnSettingsChanged(object oldValue = null, object newValue = null)
|
||||
{
|
||||
if (InputModuleCurlAdjuster.Instance == null)
|
||||
return;
|
||||
|
||||
// curl snapping
|
||||
InputModuleCurlAdjuster.Instance.UseCurlSnapping = EntryUseCurlSnapping.Value;
|
||||
InputModuleCurlAdjuster.Instance.SnappedCurlValue = EntrySnappedCurlValue.Value;
|
||||
InputModuleCurlAdjuster.Instance.RangeStartPercent = EntryRangeStartPercent.Value;
|
||||
InputModuleCurlAdjuster.Instance.RangeEndPercent = EntryRangeEndPercent.Value;
|
||||
|
||||
// curl smoothing
|
||||
InputModuleCurlAdjuster.Instance.UseCurlSmoothing = EntryUseCurlSmoothing.Value;
|
||||
InputModuleCurlAdjuster.Instance.DontSmoothExtremes = EntryDontSmoothExtremes.Value;
|
||||
InputModuleCurlAdjuster.Instance.CurlSimilarityThreshold = EntryCurlSimilarityThreshold.Value;
|
||||
InputModuleCurlAdjuster.Instance.CurlSmoothingFactor = EntryCurlSmoothingFactor.Value;
|
||||
}
|
||||
|
||||
private static void OnInputModuleSteamVRStart_Prefix(ref InputModuleSteamVR __instance)
|
||||
{
|
||||
__instance.gameObject.AddComponent<InputModuleCurlAdjuster>();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue