mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-01 22:09:23 +00:00
ScrollFlight: fixed error spam on launch, added reset on exit flight option
This commit is contained in:
parent
7b73452df6
commit
0720ab508d
2 changed files with 23 additions and 4 deletions
|
@ -23,6 +23,10 @@ public class ScrollFlightMod : MelonMod
|
||||||
Category.CreateEntry("use_scroll_flight", true,
|
Category.CreateEntry("use_scroll_flight", true,
|
||||||
"Use Scroll Flight", description: "Toggle Scroll Flight.");
|
"Use Scroll Flight", description: "Toggle Scroll Flight.");
|
||||||
|
|
||||||
|
private static readonly MelonPreferences_Entry<bool> EntryResetOnExitFlight =
|
||||||
|
Category.CreateEntry("reset_on_exit_flight", false,
|
||||||
|
"Reset On Exit Flight", description: "Reset Scroll Flight speed on exit flight.");
|
||||||
|
|
||||||
#endregion Melon Preferences
|
#endregion Melon Preferences
|
||||||
|
|
||||||
#region Private Fields
|
#region Private Fields
|
||||||
|
@ -39,14 +43,29 @@ public class ScrollFlightMod : MelonMod
|
||||||
CVRWorld.GameRulesUpdated += OnApplyMovementSettings; // thank you kafe for using actions
|
CVRWorld.GameRulesUpdated += OnApplyMovementSettings; // thank you kafe for using actions
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool wasFlying = false;
|
||||||
|
|
||||||
// stole from LucMod :3
|
// stole from LucMod :3
|
||||||
public override void OnUpdate()
|
public override void OnUpdate()
|
||||||
{
|
{
|
||||||
if (!EntryUseScrollFlight.Value)
|
if (!EntryUseScrollFlight.Value)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (BetterBetterCharacterController.Instance == null
|
if (BetterBetterCharacterController.Instance == null)
|
||||||
|| !BetterBetterCharacterController.Instance.IsFlying()
|
return;
|
||||||
|
|
||||||
|
bool isFlying = BetterBetterCharacterController.Instance.IsFlying();
|
||||||
|
|
||||||
|
if (EntryResetOnExitFlight.Value
|
||||||
|
&& (wasFlying && !isFlying))
|
||||||
|
{
|
||||||
|
BetterBetterCharacterController.Instance.worldFlightSpeedMultiplier = _originalWorldFlightSpeedMultiplier;
|
||||||
|
_currentWorldFlightSpeedMultiplier = _originalWorldFlightSpeedMultiplier;
|
||||||
|
}
|
||||||
|
|
||||||
|
wasFlying = isFlying;
|
||||||
|
|
||||||
|
if (!isFlying
|
||||||
|| Input.GetKey(KeyCode.Mouse2) // scroll zoom
|
|| Input.GetKey(KeyCode.Mouse2) // scroll zoom
|
||||||
|| Input.GetKey(KeyCode.LeftControl) // third person / better interact desktop
|
|| Input.GetKey(KeyCode.LeftControl) // third person / better interact desktop
|
||||||
|| Cursor.lockState != CursorLockMode.Locked) // unity explorer / in menu
|
|| Cursor.lockState != CursorLockMode.Locked) // unity explorer / in menu
|
||||||
|
@ -58,7 +77,7 @@ public class ScrollFlightMod : MelonMod
|
||||||
|
|
||||||
private static void AdjustFlightModifier(float adjustValue)
|
private static void AdjustFlightModifier(float adjustValue)
|
||||||
{
|
{
|
||||||
_currentWorldFlightSpeedMultiplier = Math.Max(0f, _currentWorldFlightSpeedMultiplier + adjustValue);
|
_currentWorldFlightSpeedMultiplier = Mathf.Max(0f, _currentWorldFlightSpeedMultiplier + adjustValue);
|
||||||
|
|
||||||
if (_currentWorldFlightSpeedMultiplier <= 0f)
|
if (_currentWorldFlightSpeedMultiplier <= 0f)
|
||||||
{
|
{
|
||||||
|
|
|
@ -27,6 +27,6 @@ using System.Reflection;
|
||||||
namespace NAK.ScrollFlight.Properties;
|
namespace NAK.ScrollFlight.Properties;
|
||||||
internal static class AssemblyInfoParams
|
internal static class AssemblyInfoParams
|
||||||
{
|
{
|
||||||
public const string Version = "1.0.0";
|
public const string Version = "1.0.1";
|
||||||
public const string Author = "NotAKidoS";
|
public const string Author = "NotAKidoS";
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue