using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Nivalis;
using Nivalis.Boat;
using NivalisSettings;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("NivalisJump")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("NivalisJump")]
[assembly: AssemblyTitle("NivalisJump")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace NivalisJump
{
public interface IJumpAddon
{
bool Enabled { get; }
}
public interface IJumpMovementAddon : IJumpAddon
{
bool SuppressLandingDip { get; }
bool WantsAutoJump(PlayerCharacterController pc);
Vector3 GetTakeoffVelocity(Vector3 groundVelocity, Vector3 landingVelocity, bool justLanded);
Vector3 AirAccelerate(PlayerCharacterController pc, Vector3 velocity, Vector3 wishDir, float wishAmount, float dt);
}
public interface IJumpPhysicsAddon : IJumpAddon
{
bool ClaimJump(PlayerCharacterController pc);
bool WantsFall(PlayerCharacterController pc);
bool StepVertical(PlayerCharacterController pc, ref float verticalSpeed, float gravity, Vector3 wishDir, bool blocked, float dt);
}
public static class JumpApi
{
private static readonly List<IJumpAddon> Addons = new List<IJumpAddon>();
public static PlayerCharacterController CurrentPlayer { get; internal set; }
public static bool IsAirborne => JumpPatches.Airborne;
public static Vector3 AirVelocity
{
get
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
return JumpPatches.AirVelocity;
}
set
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
JumpPatches.AirVelocity = new Vector3(value.x, 0f, value.z);
}
}
public static float Gravity => Plugin.Gravity.Value;
public static void Register(IJumpAddon addon)
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Expected O, but got Unknown
if (!Addons.Contains(addon))
{
Addons.Add(addon);
}
ManualLogSource logger = Plugin.Logger;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(23, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Jump addon registered: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(addon.GetType().FullName);
}
logger.LogInfo(val);
}
public static void Unregister(IJumpAddon addon)
{
Addons.Remove(addon);
}
public static T Get<T>() where T : class, IJumpAddon
{
foreach (IJumpAddon addon in Addons)
{
if (addon is T result && addon.Enabled)
{
return result;
}
}
return null;
}
public static bool JumpHeld()
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
Keyboard current = Keyboard.current;
if (current != null)
{
return ((ButtonControl)current[Plugin.GetJumpKey()]).isPressed;
}
return false;
}
public static void GetWishInput(PlayerCharacterController pc, Vector3 gameDesired, out Vector3 wishDir, out float wishAmount)
{
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: Unknown result type (might be due to invalid IL or missing references)
//IL_0123: Unknown result type (might be due to invalid IL or missing references)
//IL_0131: Unknown result type (might be due to invalid IL or missing references)
float num = 0f;
float num2 = 0f;
Keyboard current = Keyboard.current;
if (current != null)
{
if (((ButtonControl)current[(Key)37]).isPressed)
{
num += 1f;
}
if (((ButtonControl)current[(Key)33]).isPressed)
{
num -= 1f;
}
if (((ButtonControl)current[(Key)18]).isPressed)
{
num2 += 1f;
}
if (((ButtonControl)current[(Key)15]).isPressed)
{
num2 -= 1f;
}
}
if (num != 0f || num2 != 0f)
{
Vector3 forward = (((Object)(object)pc.Camera != (Object)null) ? ((Component)pc.Camera).transform : ((Component)pc).transform).forward;
forward.y = 0f;
((Vector3)(ref forward)).Normalize();
Vector3 val = default(Vector3);
((Vector3)(ref val))..ctor(forward.z, 0f, 0f - forward.x);
Vector3 val2 = forward * num + val * num2;
wishDir = ((Vector3)(ref val2)).normalized;
wishAmount = 1f;
}
else
{
gameDesired.y = 0f;
wishAmount = Mathf.Clamp01(((Vector3)(ref gameDesired)).magnitude);
wishDir = ((wishAmount > 0.001f) ? ((Vector3)(ref gameDesired)).normalized : Vector3.zero);
}
}
}
[HarmonyPatch(typeof(PlayerCharacterController))]
internal static class JumpPatches
{
internal static bool Airborne;
internal static Vector3 AirVelocity;
private static bool _physicsJump;
private static float _airY;
private static float _verticalSpeed;
private static float _offset;
private static float _groundY;
private static int _groundedFrames;
private static Vector3 _lastAppliedPos;
private static float _bufferTimer;
private static Vector3 _wishDir;
private static bool _blocked;
private static Vector3 _prevGroundPos;
private static bool _hasPrevGroundPos;
private static Vector3 _groundVelocity;
private static bool _justLanded;
private static Vector3 _landingVelocity;
private static bool _dipActive;
private static float _dipTime;
private static float _dipSpeed;
private static float _dipOmega;
[HarmonyPrefix]
[HarmonyPatch("ManualUpdate")]
private static void ManualUpdatePrefix(PlayerCharacterController __instance, BoatController drivenBoat)
{
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Expected O, but got Unknown
//IL_015e: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_0106: Unknown result type (might be due to invalid IL or missing references)
//IL_010d: Expected O, but got Unknown
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
try
{
JumpApi.CurrentPlayer = __instance;
Transform transform = ((Component)__instance).transform;
float currentOffset = _offset;
if (_offset != 0f || (Airborne && _physicsJump))
{
Vector3 position = transform.position;
Vector3 val = position - _lastAppliedPos;
Vector2 val2 = new Vector2(val.x, val.z);
float magnitude = ((Vector2)(ref val2)).magnitude;
bool flag = default(bool);
if (magnitude > 2f)
{
if (Plugin.DebugLog.Value)
{
ManualLogSource logger = Plugin.Logger;
BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(37, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Reset: player moved ");
((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<float>(magnitude, "F2");
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" m between frames");
}
logger.LogInfo(val3);
}
ResetState();
currentOffset = 0f;
}
else if (_offset != 0f)
{
if (Plugin.DebugLog.Value && Mathf.Abs(val.y) > 0.001f)
{
ManualLogSource logger2 = Plugin.Logger;
BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(39, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("External move between frames: dy ");
((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<float>(val.y, "F3");
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(", dxz ");
((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<float>(magnitude, "F3");
}
logger2.LogInfo(val3);
}
position.y = _groundY;
SetPosition(transform, position);
}
_offset = 0f;
}
if (!CanJump(__instance, drivenBoat))
{
if (Airborne || _dipActive)
{
if (Plugin.DebugLog.Value)
{
Plugin.Logger.LogInfo((object)"Reset: movement disabled by the game");
}
ResetState();
}
_bufferTimer = 0f;
return;
}
float unscaledDeltaTime = Time.unscaledDeltaTime;
if (JumpPressed())
{
_bufferTimer = Plugin.JumpBuffer.Value;
}
else
{
_bufferTimer -= unscaledDeltaTime;
}
IJumpMovementAddon jumpMovementAddon = JumpApi.Get<IJumpMovementAddon>();
bool flag2 = _bufferTimer > 0f || (jumpMovementAddon?.WantsAutoJump(__instance) ?? false);
bool flag3 = !Airborne && (_justLanded || _groundedFrames > 0);
if (flag3 && flag2)
{
StartJump(__instance, jumpMovementAddon, currentOffset);
}
else if (flag3 && _groundedFrames > 0)
{
IJumpPhysicsAddon jumpPhysicsAddon = JumpApi.Get<IJumpPhysicsAddon>();
if (jumpPhysicsAddon != null && jumpPhysicsAddon.WantsFall(__instance))
{
StartFall(__instance, jumpPhysicsAddon);
}
}
_justLanded = false;
}
catch (Exception ex)
{
Plugin.Logger.LogError((object)ex);
}
}
[HarmonyPrefix]
[HarmonyPatch("UpdateMovement")]
private static bool UpdateMovementPrefix(PlayerCharacterController __instance, float deltaTime, Vector3 desiredMoveDirection)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
if (!Airborne)
{
return true;
}
try
{
AirMove(__instance, deltaTime, desiredMoveDirection);
}
catch (Exception ex)
{
Plugin.Logger.LogError((object)ex);
}
return false;
}
[HarmonyPostfix]
[HarmonyPatch("ManualUpdate")]
private static void ManualUpdatePostfix(PlayerCharacterController __instance)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
try
{
Transform transform = ((Component)__instance).transform;
float unscaledDeltaTime = Time.unscaledDeltaTime;
if (!Airborne)
{
Vector3 position = transform.position;
_groundedFrames++;
TrackGroundVelocity(position, unscaledDeltaTime);
if (_dipActive)
{
ApplyOffset(transform, position, UpdateDip(unscaledDeltaTime));
}
}
else if (_physicsJump)
{
PhysicsAirStep(__instance, transform, unscaledDeltaTime);
}
else
{
OffsetAirStep(transform, unscaledDeltaTime);
}
}
catch (Exception ex)
{
Plugin.Logger.LogError((object)ex);
ResetState();
}
}
private static void OffsetAirStep(Transform t, float dt)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Expected O, but got Unknown
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
Vector3 position = t.position;
float y = position.y;
_verticalSpeed -= Plugin.Gravity.Value * dt;
_airY += _verticalSpeed * dt;
if (Plugin.TraceLog.Value)
{
ManualLogSource logger = Plugin.Logger;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(31, 5, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("air dt ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(dt, "F4");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ground ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(y, "F3");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" air ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(_airY, "F3");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" vy ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(_verticalSpeed, "F2");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" speed ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(((Vector3)(ref AirVelocity)).magnitude, "F2");
}
logger.LogInfo(val);
}
if (_airY <= y && _verticalSpeed <= 0f)
{
Land(t, position);
}
else
{
ApplyOffset(t, position, _airY - y);
}
}
private static void PhysicsAirStep(PlayerCharacterController pc, Transform t, float dt)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Expected O, but got Unknown
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
bool num = JumpApi.Get<IJumpPhysicsAddon>()?.StepVertical(pc, ref _verticalSpeed, Plugin.Gravity.Value, _wishDir, _blocked, dt) ?? true;
Vector3 val = (_lastAppliedPos = t.position);
if (Plugin.TraceLog.Value)
{
ManualLogSource logger = Plugin.Logger;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(31, 5, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("phys dt ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(dt, "F4");
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" y ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(val.y, "F3");
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" vy ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(_verticalSpeed, "F2");
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" speed ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(((Vector3)(ref AirVelocity)).magnitude, "F2");
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" blocked ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<bool>(_blocked);
}
logger.LogInfo(val2);
}
if (num)
{
Land(t, val);
}
}
private static void ApplyOffset(Transform t, Vector3 groundPos, float offset)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
_offset = offset;
_groundY = groundPos.y;
groundPos.y += offset;
SetPosition(t, groundPos);
_lastAppliedPos = groundPos;
}
private static void SetPosition(Transform t, Vector3 position)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
t.position = position;
Physics.SyncTransforms();
}
private static bool CanJump(PlayerCharacterController pc, BoatController drivenBoat)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
if (((Behaviour)pc).enabled && pc.CanMove && (int)pc.State == 0 && (Object)(object)drivenBoat == (Object)null && (Object)(object)pc.boardedBoat == (Object)null)
{
return Time.timeScale > 0f;
}
return false;
}
private static void StartJump(PlayerCharacterController pc, IJumpMovementAddon movement, float currentOffset)
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Expected O, but got Unknown
AirVelocity = movement?.GetTakeoffVelocity(_groundVelocity, _landingVelocity, _justLanded) ?? _groundVelocity;
_physicsJump = JumpApi.Get<IJumpPhysicsAddon>()?.ClaimJump(pc) ?? false;
Airborne = true;
_groundedFrames = 0;
_airY = ((Component)pc).transform.position.y + (_dipActive ? currentOffset : 0f);
_dipActive = false;
_verticalSpeed = Mathf.Sqrt(2f * Plugin.Gravity.Value * Plugin.JumpHeight.Value);
_bufferTimer = 0f;
_lastAppliedPos = ((Component)pc).transform.position;
if (Plugin.DebugLog.Value)
{
ManualLogSource logger = Plugin.Logger;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(10, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Jump: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(((Vector3)(ref AirVelocity)).magnitude, "F2");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" m/s");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(_physicsJump ? " (physics)" : "");
}
logger.LogInfo(val);
}
}
private static void StartFall(PlayerCharacterController pc, IJumpPhysicsAddon physics)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Expected O, but got Unknown
AirVelocity = _groundVelocity;
_physicsJump = physics.ClaimJump(pc);
if (!_physicsJump)
{
return;
}
Airborne = true;
_groundedFrames = 0;
_dipActive = false;
_verticalSpeed = 0f;
_lastAppliedPos = ((Component)pc).transform.position;
if (Plugin.DebugLog.Value)
{
ManualLogSource logger = Plugin.Logger;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(10, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Fall: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(((Vector3)(ref AirVelocity)).magnitude, "F2");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" m/s");
}
logger.LogInfo(val);
}
}
private static void Land(Transform t, Vector3 groundPos)
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Expected O, but got Unknown
float verticalSpeed = _verticalSpeed;
Airborne = false;
_physicsJump = false;
_offset = 0f;
_justLanded = true;
_groundedFrames = 0;
_landingVelocity = AirVelocity;
_groundVelocity = AirVelocity;
_verticalSpeed = 0f;
_prevGroundPos = groundPos;
_hasPrevGroundPos = true;
IJumpMovementAddon jumpMovementAddon = JumpApi.Get<IJumpMovementAddon>();
if (jumpMovementAddon == null || !jumpMovementAddon.SuppressLandingDip)
{
StartDip(verticalSpeed);
}
if (_dipActive)
{
ApplyOffset(t, groundPos, UpdateDip(0f));
}
if (Plugin.DebugLog.Value)
{
ManualLogSource logger = Plugin.Logger;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(23, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Land: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(((Vector3)(ref AirVelocity)).magnitude, "F2");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" m/s, impact ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(verticalSpeed, "F2");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" m/s");
}
logger.LogInfo(val);
}
}
private static void StartDip(float impactSpeed)
{
float num = Mathf.Min(Plugin.LandingDip.Value, (0f - impactSpeed) * 0.015f);
if (num < 0.002f)
{
_dipActive = false;
return;
}
_dipSpeed = impactSpeed;
_dipOmega = (0f - impactSpeed) / (num * (float)Math.E);
_dipTime = 0f;
_dipActive = true;
}
private static float UpdateDip(float dt)
{
_dipTime += dt;
if (_dipTime * _dipOmega > 7f)
{
_dipActive = false;
return 0f;
}
return _dipSpeed * _dipTime * Mathf.Exp((0f - _dipOmega) * _dipTime);
}
private static void AirMove(PlayerCharacterController pc, float dt, Vector3 desired)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_0105: Unknown result type (might be due to invalid IL or missing references)
//IL_0106: Unknown result type (might be due to invalid IL or missing references)
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_014c: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
//IL_0165: Unknown result type (might be due to invalid IL or missing references)
//IL_016f: Unknown result type (might be due to invalid IL or missing references)
//IL_0176: Unknown result type (might be due to invalid IL or missing references)
//IL_0185: Unknown result type (might be due to invalid IL or missing references)
//IL_015c: Unknown result type (might be due to invalid IL or missing references)
//IL_018a: Unknown result type (might be due to invalid IL or missing references)
//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
//IL_01af: Expected O, but got Unknown
JumpApi.GetWishInput(pc, desired, out _wishDir, out var wishAmount);
_blocked = false;
IJumpMovementAddon jumpMovementAddon = JumpApi.Get<IJumpMovementAddon>();
if (jumpMovementAddon != null)
{
AirVelocity = jumpMovementAddon.AirAccelerate(pc, AirVelocity, _wishDir, wishAmount, dt);
}
else if (wishAmount > 0.001f)
{
Vector3 val = _wishDir * (pc.MaxSpeed * wishAmount);
if (((Vector3)(ref AirVelocity)).magnitude > ((Vector3)(ref val)).magnitude)
{
val = _wishDir * ((Vector3)(ref AirVelocity)).magnitude;
}
AirVelocity = Vector3.MoveTowards(AirVelocity, val, Plugin.AirControl.Value * dt);
}
if (dt <= 0f)
{
return;
}
Transform transform = ((Component)pc).transform;
Vector3 position = transform.position;
Vector3 val2 = AirVelocity * dt;
CharacterController val3 = ((_physicsJump && (Object)(object)pc.NavMesh == (Object)null) ? pc.CharacterController : null);
if ((Object)(object)val3 != (Object)null && ((Collider)val3).enabled)
{
val3.Move(val2);
}
else
{
pc.Move(val2);
}
Vector3 val4 = transform.position - position;
val4.y = 0f;
float magnitude = ((Vector3)(ref val2)).magnitude;
float magnitude2 = ((Vector3)(ref val4)).magnitude;
if (!(magnitude > 0.0001f) || !(magnitude2 < magnitude * 0.9f))
{
return;
}
_blocked = true;
Vector3 airVelocity = AirVelocity;
AirVelocity = ((magnitude2 > 0.0001f) ? (((Vector3)(ref val4)).normalized * Mathf.Max(0f, Vector3.Dot(AirVelocity, ((Vector3)(ref val4)).normalized))) : Vector3.zero);
if (Plugin.DebugLog.Value)
{
ManualLogSource logger = Plugin.Logger;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val5 = new BepInExInfoLogInterpolatedStringHandler(33, 4, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("Blocked: moved ");
((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<float>(magnitude2, "F3");
((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" of ");
((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<float>(magnitude, "F3");
((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" m, speed ");
((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<float>(((Vector3)(ref airVelocity)).magnitude, "F2");
((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" -> ");
((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<float>(((Vector3)(ref AirVelocity)).magnitude, "F2");
}
logger.LogInfo(val5);
}
}
private static void TrackGroundVelocity(Vector3 p, float dt)
{
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
if (_hasPrevGroundPos && dt > 0f)
{
Vector3 val = (p - _prevGroundPos) / dt;
val.y = 0f;
_groundVelocity = ((((Vector3)(ref val)).sqrMagnitude < 2500f) ? val : Vector3.zero);
}
_prevGroundPos = p;
_hasPrevGroundPos = true;
}
private static void ResetState()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
Airborne = false;
AirVelocity = Vector3.zero;
_physicsJump = false;
_offset = 0f;
_verticalSpeed = 0f;
_groundVelocity = Vector3.zero;
_hasPrevGroundPos = false;
_justLanded = false;
_groundedFrames = 0;
_dipActive = false;
}
private static bool JumpPressed()
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
Keyboard current = Keyboard.current;
if (current != null && ((ButtonControl)current[Plugin.GetJumpKey()]).wasPressedThisFrame)
{
return true;
}
if (Plugin.ScrollWheelJump.Value)
{
Mouse current2 = Mouse.current;
if (current2 != null && Mathf.Abs(((InputControl<Vector2>)(object)current2.scroll).ReadValue().y) > 0.01f)
{
return true;
}
}
return false;
}
}
[BepInPlugin("com.asher.nivalisjump", "Nivalis Jump", "1.0.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BasePlugin
{
public const string Guid = "com.asher.nivalisjump";
public const string Version = "1.0.1";
internal static ManualLogSource Logger;
internal static ConfigEntry<string> JumpKey;
internal static ConfigEntry<bool> ScrollWheelJump;
internal static ConfigEntry<float> JumpHeight;
internal static ConfigEntry<float> Gravity;
internal static ConfigEntry<float> JumpBuffer;
internal static ConfigEntry<float> AirControl;
internal static ConfigEntry<float> LandingDip;
internal static ConfigEntry<bool> DebugLog;
internal static ConfigEntry<bool> TraceLog;
private static Key _cachedKey = (Key)1;
private static string _cachedKeyName;
public override void Load()
{
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Expected O, but got Unknown
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Expected O, but got Unknown
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_0101: Expected O, but got Unknown
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_013e: Expected O, but got Unknown
//IL_0171: Unknown result type (might be due to invalid IL or missing references)
//IL_017b: Expected O, but got Unknown
//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
//IL_01f0: Expected O, but got Unknown
Logger = ((BasePlugin)this).Log;
JumpKey = ((BasePlugin)this).Config.Bind<string>("Jump", "Key", "Space", "Jump key, a UnityEngine.InputSystem.Key name (Space, F, LeftAlt, ...).");
ScrollWheelJump = ((BasePlugin)this).Config.Bind<bool>("Jump", "ScrollWheel", false, "Also jump on mouse wheel scroll, CS-style (bind jump to mwheel).");
JumpHeight = ((BasePlugin)this).Config.Bind<float>("Jump", "Height", 1f, new ConfigDescription("Jump apex height in meters.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 5f), Array.Empty<object>()));
Gravity = ((BasePlugin)this).Config.Bind<float>("Jump", "Gravity", 20f, new ConfigDescription("Gravity while airborne, m/s^2.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 60f), Array.Empty<object>()));
JumpBuffer = ((BasePlugin)this).Config.Bind<float>("Jump", "BufferTime", 0.1f, new ConfigDescription("A jump pressed this many seconds before landing still triggers on touchdown.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 0.5f), Array.Empty<object>()));
AirControl = ((BasePlugin)this).Config.Bind<float>("Jump", "AirControl", 6f, new ConfigDescription("How fast you can steer in the air, m/s^2. Momentum is kept when no key is held.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 30f), Array.Empty<object>()));
LandingDip = ((BasePlugin)this).Config.Bind<float>("Jump", "LandingDip", 0.08f, new ConfigDescription("How deep (m) the view sinks and springs back on landing, so the fall doesn't stop dead. 0 = off.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 0.3f), Array.Empty<object>()));
DebugLog = ((BasePlugin)this).Config.Bind<bool>("Debug", "Log", false, "Log jump/land/reset events.");
TraceLog = ((BasePlugin)this).Config.Bind<bool>("Debug", "Trace", false, "Log every airborne frame (very verbose).");
new Harmony("com.asher.nivalisjump").PatchAll(typeof(JumpPatches));
TryRegisterSettings();
ManualLogSource log = ((BasePlugin)this).Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(20, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Nivalis Jump ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("1.0.1");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" loaded");
}
log.LogInfo(val);
}
private void TryRegisterSettings()
{
if (((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.ContainsKey("com.asher.nivalissettings"))
{
RegisterSettings();
}
}
[MethodImpl(MethodImplOptions.NoInlining)]
private void RegisterSettings()
{
ModSettings.Register((BasePlugin)(object)this, (string)null).Label((ConfigEntryBase)(object)JumpKey, "Jump Key").Label((ConfigEntryBase)(object)ScrollWheelJump, "Jump On Mouse Wheel")
.Label((ConfigEntryBase)(object)JumpHeight, "Jump Height")
.Label((ConfigEntryBase)(object)JumpBuffer, "Jump Buffer")
.HideSection("Debug")
.Order = 0;
}
internal static Key GetJumpKey()
{
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Expected O, but got Unknown
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
string value = JumpKey.Value;
if (value != _cachedKeyName)
{
_cachedKeyName = value;
if (!Enum.TryParse<Key>(value, ignoreCase: true, out _cachedKey))
{
ManualLogSource logger = Logger;
bool flag = default(bool);
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(32, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Unknown jump key '");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(value);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("', using Space");
}
logger.LogWarning(val);
_cachedKey = (Key)1;
}
}
return _cachedKey;
}
}
}