using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Mirror;
using RewiredConsts;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("BigWalkSourceMovement")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BigWalkSourceMovement")]
[assembly: AssemblyTitle("BigWalkSourceMovement")]
[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 BigWalkSourceMovement
{
[BepInPlugin("codex.bigwalk.sourcemovement", "Big Walk Source Movement", "4.1.1")]
public sealed class Plugin : BasePlugin
{
public const string Guid = "codex.bigwalk.sourcemovement";
public const string Name = "Big Walk Source Movement";
public const string Version = "4.1.1";
internal static ManualLogSource Logger;
internal static ConfigEntry<bool> AutoBhop;
internal static ConfigEntry<float> AirAccelerate;
internal static ConfigEntry<float> AirSpeedCapRatio;
internal static ConfigEntry<float> MaxVelocityRatio;
public override void Load()
{
Logger = ((BasePlugin)this).Log;
AutoBhop = ((BasePlugin)this).Config.Bind<bool>("Source SDK", "Auto bunny hop", true, "Hold the game's normal jump action. Works with keyboard and gamepad bindings.");
AirAccelerate = ((BasePlugin)this).Config.Bind<float>("Source SDK", "sv_airaccelerate", 10f, "Source air acceleration coefficient.");
AirSpeedCapRatio = ((BasePlugin)this).Config.Bind<float>("Source SDK", "Air speed cap ratio", 3f / 32f, "Source air-control cap divided by maximum movement speed (30/320).");
MaxVelocityRatio = ((BasePlugin)this).Config.Bind<float>("Source SDK", "sv_maxvelocity ratio", 10.9375f, "Maximum horizontal velocity divided by maximum movement speed (3500/320).");
Harmony.CreateAndPatchAll(typeof(Plugin).Assembly, "codex.bigwalk.sourcemovement");
((BasePlugin)this).Log.LogInfo((object)"Source motor 4.1 active: native terrain traversal, Source air acceleration, momentum-preserving bhop.");
}
}
internal static class SourceMotor
{
[HarmonyPatch(typeof(PlayerMover), "FixedUpdate")]
private static class PlayerMoverFixedUpdatePatch
{
private static void Prefix(PlayerMover __instance)
{
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
PlayerCharacter val = ((__instance != null) ? __instance.pc : null);
_captured = (Object)(object)val != (Object)null && ((NetworkBehaviour)val).isLocalPlayer && (Object)(object)val.rb != (Object)null && val.inputPlayer != null;
if (_captured)
{
_velocityBeforeNative = val.rb.linearVelocity;
}
}
private static void Postfix(PlayerMover __instance)
{
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: 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_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: 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_00fc: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
//IL_0109: 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_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_0136: Unknown result type (might be due to invalid IL or missing references)
//IL_013a: Unknown result type (might be due to invalid IL or missing references)
//IL_012f: Unknown result type (might be due to invalid IL or missing references)
//IL_013f: Unknown result type (might be due to invalid IL or missing references)
//IL_015b: Unknown result type (might be due to invalid IL or missing references)
//IL_0160: Unknown result type (might be due to invalid IL or missing references)
//IL_0162: Unknown result type (might be due to invalid IL or missing references)
//IL_0167: Unknown result type (might be due to invalid IL or missing references)
//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
//IL_0246: Unknown result type (might be due to invalid IL or missing references)
//IL_024d: Unknown result type (might be due to invalid IL or missing references)
//IL_0254: Unknown result type (might be due to invalid IL or missing references)
//IL_025b: Unknown result type (might be due to invalid IL or missing references)
//IL_0232: Unknown result type (might be due to invalid IL or missing references)
//IL_0239: Unknown result type (might be due to invalid IL or missing references)
//IL_023e: Unknown result type (might be due to invalid IL or missing references)
PlayerCharacter val = ((__instance != null) ? __instance.pc : null);
if (!_captured || (Object)(object)val == (Object)null || !((NetworkBehaviour)val).isLocalPlayer || (Object)(object)val.rb == (Object)null || val.inputPlayer == null)
{
return;
}
float axis = val.inputPlayer.GetAxis(Action.moveX);
float axis2 = val.inputPlayer.GetAxis(Action.moveY);
Vector2 val2 = Vector2.ClampMagnitude(new Vector2(axis, axis2), 1f);
float magnitude = ((Vector2)(ref val2)).magnitude;
Vector3 localControlsVelocity = __instance.localControlsVelocity;
float magnitude2 = ((Vector3)(ref localControlsVelocity)).magnitude;
if (magnitude > 0.25f && magnitude2 > 0.5f)
{
_knownMaxSpeed = Mathf.Max(0.5f, magnitude2 / magnitude);
}
Transform obj = (((Object)(object)val.kernal != (Object)null) ? val.kernal : ((Component)val).transform);
Vector3 forward = obj.forward;
Vector3 right = obj.right;
forward.y = 0f;
right.y = 0f;
((Vector3)(ref forward)).Normalize();
((Vector3)(ref right)).Normalize();
Vector3 val3 = right * val2.x + forward * val2.y;
float magnitude3 = ((Vector3)(ref val3)).magnitude;
Vector3 wishDirection = ((magnitude3 > 0.0001f) ? (val3 / magnitude3) : Vector3.zero);
float wishSpeed = _knownMaxSpeed * Mathf.Min(1f, magnitude3);
Vector3 linearVelocity = val.rb.linearVelocity;
Vector3 velocity = _velocityBeforeNative;
bool flag = val.jumper != null && val.jumper.justJumped;
bool button = val.inputPlayer.GetButton(Action.jump);
bool flag2 = val.ground != null && val.ground.isOnJumpableGround;
bool flag3 = Plugin.AutoBhop.Value && button && flag2;
bool num = val.ground != null && val.ground.isGrounded && !flag && !flag3;
float fixedDeltaTime = Time.fixedDeltaTime;
if (!num)
{
velocity.y = 0f;
AirAccelerate(ref velocity, wishDirection, wishSpeed, _knownMaxSpeed, fixedDeltaTime);
float num2 = _knownMaxSpeed * Mathf.Max(1f, Plugin.MaxVelocityRatio.Value);
if (((Vector3)(ref velocity)).sqrMagnitude > num2 * num2)
{
velocity = ((Vector3)(ref velocity)).normalized * num2;
}
val.rb.linearVelocity = new Vector3(velocity.x, linearVelocity.y, velocity.z);
}
}
}
[HarmonyPatch(typeof(PlayerJumper), "Update")]
private static class HeldJumpQueuePatch
{
private static bool _jumpConsumed;
private static bool _airborneObserved;
private static void Postfix(PlayerJumper __instance)
{
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
if (!Plugin.AutoBhop.Value)
{
return;
}
PlayerCharacter val = ((__instance != null) ? __instance.playerCharacter : null);
if ((Object)(object)val == (Object)null || !((NetworkBehaviour)val).isLocalPlayer || val.inputPlayer == null)
{
return;
}
if (!val.inputPlayer.GetButton(Action.jump))
{
_jumpConsumed = false;
_airborneObserved = false;
return;
}
if (val.ground == null || !val.ground.isGrounded)
{
_airborneObserved = true;
return;
}
float num = (((Object)(object)val.rb != (Object)null) ? val.rb.linearVelocity.y : 0f);
bool num2 = !_jumpConsumed;
bool airborneObserved = _airborneObserved;
if ((num2 || airborneObserved) && num <= 0.1f)
{
__instance.jumpInQueue = true;
_jumpConsumed = true;
_airborneObserved = false;
}
}
}
private static Vector3 _velocityBeforeNative;
private static float _knownMaxSpeed = 3.5f;
private static bool _captured;
private static void AirAccelerate(ref Vector3 velocity, Vector3 wishDirection, float wishSpeed, float maxSpeed, float dt)
{
//IL_0026: 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_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: 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)
if (!(wishSpeed <= 0f))
{
float num = Mathf.Min(wishSpeed, maxSpeed * Mathf.Max(0f, Plugin.AirSpeedCapRatio.Value));
float num2 = Vector3.Dot(velocity, wishDirection);
float num3 = num - num2;
if (!(num3 <= 0f))
{
float num4 = Mathf.Min(num3, Mathf.Max(0f, Plugin.AirAccelerate.Value) * wishSpeed * dt);
velocity += wishDirection * num4;
}
}
}
}
}