mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 14:29:25 +00:00
[ScrollFlight] Cleanup
This commit is contained in:
parent
691d5a1723
commit
ce6582ae18
3 changed files with 85 additions and 23 deletions
|
@ -1,27 +1,87 @@
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
using System.Reflection;
|
||||||
using ABI_RC.Core.UI;
|
using ABI_RC.Core.UI;
|
||||||
|
using ABI_RC.Systems.IK.VRIKHandlers;
|
||||||
using ABI_RC.Systems.Movement;
|
using ABI_RC.Systems.Movement;
|
||||||
|
using ABI.CCK.Components;
|
||||||
|
using HarmonyLib;
|
||||||
using MelonLoader;
|
using MelonLoader;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace NAK.ScrollFlight;
|
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()
|
public override void OnUpdate()
|
||||||
{
|
{
|
||||||
if (BetterBetterCharacterController.Instance == null
|
if (!EntryUseScrollFlight.Value)
|
||||||
|| !BetterBetterCharacterController.Instance.IsFlying()
|
return;
|
||||||
|| Input.GetKey(KeyCode.Mouse2)
|
|
||||||
|| Cursor.lockState != CursorLockMode.Locked)
|
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;
|
return;
|
||||||
|
|
||||||
BetterBetterCharacterController.Instance.worldFlightSpeedMultiplier = Math.Max(0f,
|
|
||||||
BetterBetterCharacterController.Instance.worldFlightSpeedMultiplier + Input.mouseScrollDelta.y);
|
|
||||||
if (Input.mouseScrollDelta.y != 0f)
|
if (Input.mouseScrollDelta.y != 0f)
|
||||||
CohtmlHud.Instance.ViewDropTextImmediate("(Local) ScrollFlight",
|
AdjustFlightModifier(Input.mouseScrollDelta.y);
|
||||||
BetterBetterCharacterController.Instance.worldFlightSpeedMultiplier.ToString(CultureInfo
|
|
||||||
.InvariantCulture), "Speed multiplier");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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",
|
||||||
|
"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
|
||||||
}
|
}
|
|
@ -10,7 +10,7 @@ using System.Reflection;
|
||||||
[assembly: AssemblyProduct(nameof(NAK.ScrollFlight))]
|
[assembly: AssemblyProduct(nameof(NAK.ScrollFlight))]
|
||||||
|
|
||||||
[assembly: MelonInfo(
|
[assembly: MelonInfo(
|
||||||
typeof(NAK.ScrollFlight.ScrollFlight),
|
typeof(NAK.ScrollFlight.ScrollFlightMod),
|
||||||
nameof(NAK.ScrollFlight),
|
nameof(NAK.ScrollFlight),
|
||||||
AssemblyInfoParams.Version,
|
AssemblyInfoParams.Version,
|
||||||
AssemblyInfoParams.Author,
|
AssemblyInfoParams.Author,
|
||||||
|
@ -20,6 +20,8 @@ using System.Reflection;
|
||||||
[assembly: MelonGame("Alpha Blend Interactive", "ChilloutVR")]
|
[assembly: MelonGame("Alpha Blend Interactive", "ChilloutVR")]
|
||||||
[assembly: MelonPlatform(MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)]
|
[assembly: MelonPlatform(MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)]
|
||||||
[assembly: MelonPlatformDomain(MelonPlatformDomainAttribute.CompatibleDomains.MONO)]
|
[assembly: MelonPlatformDomain(MelonPlatformDomainAttribute.CompatibleDomains.MONO)]
|
||||||
|
[assembly: MelonColor(255, 246, 25, 99)] // red-pink
|
||||||
|
[assembly: MelonAuthorColor(255, 158, 21, 32)] // red
|
||||||
[assembly: HarmonyDontPatchAll]
|
[assembly: HarmonyDontPatchAll]
|
||||||
|
|
||||||
namespace NAK.ScrollFlight.Properties;
|
namespace NAK.ScrollFlight.Properties;
|
||||||
|
|
|
@ -1,23 +1,23 @@
|
||||||
{
|
{
|
||||||
"_id": 147,
|
"_id": -1,
|
||||||
"name": "PropUndoButton",
|
"name": "ScrollFlight",
|
||||||
"modversion": "1.0.2",
|
"modversion": "1.0.0",
|
||||||
"gameversion": "2024r175",
|
"gameversion": "2024r175",
|
||||||
"loaderversion": "0.6.1",
|
"loaderversion": "0.6.1",
|
||||||
"modtype": "Mod",
|
"modtype": "Mod",
|
||||||
"author": "NotAKidoS",
|
"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": [
|
"searchtags": [
|
||||||
"prop",
|
"flight",
|
||||||
"undo",
|
"scroll",
|
||||||
"bind",
|
"speed",
|
||||||
"button"
|
"modifier"
|
||||||
],
|
],
|
||||||
"requirements": [
|
"requirements": [
|
||||||
"None"
|
"None"
|
||||||
],
|
],
|
||||||
"downloadlink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/releases/download/r25/PropUndoButton.dll",
|
"downloadlink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/releases/download/r34/ScrollFlight.dll",
|
||||||
"sourcelink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/tree/main/PropUndoButton/",
|
"sourcelink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/tree/main/ScrollFlight/",
|
||||||
"changelog": "- Recompiled for 2024r175",
|
"changelog": "- Initial release",
|
||||||
"embedcolor": "#00FFFF"
|
"embedcolor": "#f61963"
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue