[ScrollFlight] Cleanup

This commit is contained in:
NotAKidoS 2024-06-24 03:18:16 -05:00
parent 691d5a1723
commit ce6582ae18
3 changed files with 85 additions and 23 deletions

View file

@ -1,27 +1,87 @@
using System.Globalization;
using System.Reflection;
using ABI_RC.Core.UI;
using ABI_RC.Systems.IK.VRIKHandlers;
using ABI_RC.Systems.Movement;
using ABI.CCK.Components;
using HarmonyLib;
using MelonLoader;
using UnityEngine;
namespace NAK.ScrollFlight;
public class ScrollFlight : MelonMod
public class ScrollFlightMod : MelonMod
{
// stole from LucMod lol
#region Melon Preferences
private const string SettingsCategory = nameof(ScrollFlightMod);
private static readonly MelonPreferences_Category Category =
MelonPreferences.CreateCategory(SettingsCategory);
private static readonly MelonPreferences_Entry<bool> EntryUseScrollFlight =
Category.CreateEntry("use_scroll_flight", true,
"Use Scroll Flight", description: "Toggle Scroll Flight.");
#endregion Melon Preferences
#region Private Fields
private static float _currentWorldFlightSpeedMultiplier;
private static float _originalWorldFlightSpeedMultiplier = 5f;
#endregion Private Fields
#region Melon Events
public override void OnInitializeMelon()
{
CVRWorld.GameRulesUpdated += OnApplyMovementSettings; // thank you kafe for using actions
}
// stole from LucMod :3
public override void OnUpdate()
{
if (BetterBetterCharacterController.Instance == null
|| !BetterBetterCharacterController.Instance.IsFlying()
|| Input.GetKey(KeyCode.Mouse2)
|| Cursor.lockState != CursorLockMode.Locked)
if (!EntryUseScrollFlight.Value)
return;
if (BetterBetterCharacterController.Instance == null
|| !BetterBetterCharacterController.Instance.IsFlying()
|| Input.GetKey(KeyCode.Mouse2) // scroll zoom
|| Input.GetKey(KeyCode.LeftControl) // third person / better interact desktop
|| Cursor.lockState != CursorLockMode.Locked) // unity explorer / in menu
return;
BetterBetterCharacterController.Instance.worldFlightSpeedMultiplier = Math.Max(0f,
BetterBetterCharacterController.Instance.worldFlightSpeedMultiplier + Input.mouseScrollDelta.y);
if (Input.mouseScrollDelta.y != 0f)
AdjustFlightModifier(Input.mouseScrollDelta.y);
}
private static void AdjustFlightModifier(float adjustValue)
{
_currentWorldFlightSpeedMultiplier = Math.Max(0f, _currentWorldFlightSpeedMultiplier + adjustValue);
if (_currentWorldFlightSpeedMultiplier <= 0f)
{
// reset to original value
BetterBetterCharacterController.Instance.worldFlightSpeedMultiplier = _originalWorldFlightSpeedMultiplier;
CohtmlHud.Instance.ViewDropTextImmediate("(Local) ScrollFlight",
BetterBetterCharacterController.Instance.worldFlightSpeedMultiplier.ToString(CultureInfo
.InvariantCulture), "Speed multiplier");
"Default", $"World default ({_currentWorldFlightSpeedMultiplier.ToString(CultureInfo.InvariantCulture)})");
return;
}
BetterBetterCharacterController.Instance.worldFlightSpeedMultiplier = _currentWorldFlightSpeedMultiplier;
CohtmlHud.Instance.ViewDropTextImmediate("(Local) ScrollFlight",
_currentWorldFlightSpeedMultiplier.ToString(CultureInfo.InvariantCulture), "Speed multiplier");
}
#endregion Melon Events
#region Harmony Patches
private static void OnApplyMovementSettings()
{
_currentWorldFlightSpeedMultiplier = _originalWorldFlightSpeedMultiplier = BetterBetterCharacterController.Instance.worldFlightSpeedMultiplier;
}
#endregion Harmony Patches
}

View file

@ -10,7 +10,7 @@ using System.Reflection;
[assembly: AssemblyProduct(nameof(NAK.ScrollFlight))]
[assembly: MelonInfo(
typeof(NAK.ScrollFlight.ScrollFlight),
typeof(NAK.ScrollFlight.ScrollFlightMod),
nameof(NAK.ScrollFlight),
AssemblyInfoParams.Version,
AssemblyInfoParams.Author,
@ -20,6 +20,8 @@ using System.Reflection;
[assembly: MelonGame("Alpha Blend Interactive", "ChilloutVR")]
[assembly: MelonPlatform(MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)]
[assembly: MelonPlatformDomain(MelonPlatformDomainAttribute.CompatibleDomains.MONO)]
[assembly: MelonColor(255, 246, 25, 99)] // red-pink
[assembly: MelonAuthorColor(255, 158, 21, 32)] // red
[assembly: HarmonyDontPatchAll]
namespace NAK.ScrollFlight.Properties;

View file

@ -1,23 +1,23 @@
{
"_id": 147,
"name": "PropUndoButton",
"modversion": "1.0.2",
"_id": -1,
"name": "ScrollFlight",
"modversion": "1.0.0",
"gameversion": "2024r175",
"loaderversion": "0.6.1",
"modtype": "Mod",
"author": "NotAKidoS",
"description": "**CTRL+Z** to undo latest spawned prop. **CTRL+SHIFT+Z** to redo deleted prop.\nIncludes optional SFX for prop spawn, undo, redo, warn, and deny, which can be disabled in settings.\n\nYou can replace the sfx in 'ChilloutVR\\ChilloutVR_Data\\StreamingAssets\\Cohtml\\UIResources\\GameUI\\mods\\PropUndo\\audio'.",
"description": "Scroll-wheel to adjust flight speed in Desktop.",
"searchtags": [
"prop",
"undo",
"bind",
"button"
"flight",
"scroll",
"speed",
"modifier"
],
"requirements": [
"None"
],
"downloadlink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/releases/download/r25/PropUndoButton.dll",
"sourcelink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/tree/main/PropUndoButton/",
"changelog": "- Recompiled for 2024r175",
"embedcolor": "#00FFFF"
"downloadlink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/releases/download/r34/ScrollFlight.dll",
"sourcelink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/tree/main/ScrollFlight/",
"changelog": "- Initial release",
"embedcolor": "#f61963"
}