using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using REPOSourceMovement.Patches;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("REPOSourceMovement")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("REPOSourceMovement")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("532311b0-a104-4feb-b2f2-323e5d61f312")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace REPOSourceMovement
{
[BepInPlugin("BREADFPV.REPOSourceMovement", "REPOSourceMovement", "0.0.1")]
public class SourceMovement : BaseUnityPlugin
{
private const string modGUID = "BREADFPV.REPOSourceMovement";
private const string modName = "REPOSourceMovement";
private const string modVersion = "0.0.1";
private readonly Harmony harmony = new Harmony("BREADFPV.REPOSourceMovement");
private static SourceMovement instance;
internal ManualLogSource mls;
private void Awake()
{
if ((Object)(object)instance == (Object)null)
{
instance = this;
}
mls = Logger.CreateLogSource("BREADFPV.REPOSourceMovement");
mls.LogInfo((object)"REPOSourceMovement loaded!");
harmony.PatchAll(typeof(SourceMovement));
harmony.PatchAll(typeof(PlayerControllerPatch));
}
}
}
namespace REPOSourceMovement.Patches
{
[HarmonyPatch(typeof(PlayerAvatar))]
internal class PlayerAvatarPatch
{
private static Light fullbrightLight;
private static KeyCode toggleKey = (KeyCode)45;
private static bool fullbrightOn = false;
[HarmonyPatch("Awake")]
[HarmonyPostfix]
private static void Fullbright(PlayerAvatar __instance)
{
}
[HarmonyPatch("Update")]
[HarmonyPostfix]
private static void FullbrightToggle()
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
if (Input.GetKeyDown(toggleKey))
{
fullbrightOn = !fullbrightOn;
}
if (fullbrightOn)
{
((Behaviour)fullbrightLight).enabled = true;
}
else
{
((Behaviour)fullbrightLight).enabled = false;
}
}
}
[HarmonyPatch(typeof(PlayerController))]
internal class PlayerControllerPatch
{
private const float BASE_SPEED = 7f;
private const float SPRINT_MULTIPLIER = 1.7f;
private const float AIR_ACCELERATION = 2000f;
private const float MAX_AIR_VELOCITY = 3f;
private const float GROUND_FRICTION = 4f;
private const float BHOP_BONUS = 0.3f;
private const float MAX_VELOCITY = 40f;
private const float JUMP_FORCE = 4f;
private const float INITIAL_PUSH = 3f;
private static bool wasGrounded = true;
private static bool autoBhop = true;
private static float lastJumpTime = 0f;
private static bool useSourceMovement = false;
private static KeyCode toggleKey = (KeyCode)61;
private static readonly FieldInfo isTumblingField = AccessTools.Field(typeof(PlayerAvatar), "isTumbling");
[HarmonyPatch("FixedUpdate")]
[HarmonyPrefix]
private static bool SourceMovementFixedUpdate(PlayerController __instance)
{
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: 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_010c: Unknown result type (might be due to invalid IL or missing references)
//IL_010f: Unknown result type (might be due to invalid IL or missing references)
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: Unknown result type (might be due to invalid IL or missing references)
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
//IL_0121: Unknown result type (might be due to invalid IL or missing references)
//IL_0125: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
//IL_0147: 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_0152: Unknown result type (might be due to invalid IL or missing references)
//IL_015e: 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_016a: Unknown result type (might be due to invalid IL or missing references)
//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
//IL_024f: Unknown result type (might be due to invalid IL or missing references)
//IL_0253: Unknown result type (might be due to invalid IL or missing references)
//IL_025d: Unknown result type (might be due to invalid IL or missing references)
//IL_0262: Unknown result type (might be due to invalid IL or missing references)
//IL_0264: Unknown result type (might be due to invalid IL or missing references)
//IL_0266: Unknown result type (might be due to invalid IL or missing references)
//IL_0268: Unknown result type (might be due to invalid IL or missing references)
//IL_026d: Unknown result type (might be due to invalid IL or missing references)
//IL_0271: Unknown result type (might be due to invalid IL or missing references)
//IL_027d: Unknown result type (might be due to invalid IL or missing references)
//IL_0294: Unknown result type (might be due to invalid IL or missing references)
//IL_0299: Unknown result type (might be due to invalid IL or missing references)
//IL_036c: Unknown result type (might be due to invalid IL or missing references)
//IL_036e: Unknown result type (might be due to invalid IL or missing references)
//IL_0372: Unknown result type (might be due to invalid IL or missing references)
//IL_0377: Unknown result type (might be due to invalid IL or missing references)
//IL_037c: Unknown result type (might be due to invalid IL or missing references)
//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
//IL_02db: Unknown result type (might be due to invalid IL or missing references)
//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
//IL_02df: Unknown result type (might be due to invalid IL or missing references)
//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
//IL_039b: Unknown result type (might be due to invalid IL or missing references)
//IL_039d: Unknown result type (might be due to invalid IL or missing references)
//IL_0426: Unknown result type (might be due to invalid IL or missing references)
//IL_0412: Unknown result type (might be due to invalid IL or missing references)
//IL_041c: Unknown result type (might be due to invalid IL or missing references)
//IL_0421: Unknown result type (might be due to invalid IL or missing references)
//IL_03e7: Unknown result type (might be due to invalid IL or missing references)
//IL_03e9: Unknown result type (might be due to invalid IL or missing references)
//IL_03ed: Unknown result type (might be due to invalid IL or missing references)
//IL_03f2: Unknown result type (might be due to invalid IL or missing references)
//IL_03f7: Unknown result type (might be due to invalid IL or missing references)
//IL_0446: Unknown result type (might be due to invalid IL or missing references)
//IL_044b: Unknown result type (might be due to invalid IL or missing references)
if (!useSourceMovement)
{
return true;
}
bool flag = false;
try
{
if ((Object)(object)__instance.playerAvatarScript != (Object)null)
{
flag = (bool)isTumblingField.GetValue(__instance.playerAvatarScript);
}
}
catch
{
}
if (flag)
{
return true;
}
float axis = Input.GetAxis("Horizontal");
float axis2 = Input.GetAxis("Vertical");
bool key = Input.GetKey((KeyCode)32);
bool key2 = Input.GetKey((KeyCode)304);
Rigidbody rb = __instance.rb;
bool grounded = __instance.CollisionController.Grounded;
Vector3 forward = __instance.cameraGameObject.transform.forward;
Vector3 right = __instance.cameraGameObject.transform.right;
forward.y = 0f;
right.y = 0f;
((Vector3)(ref forward)).Normalize();
((Vector3)(ref right)).Normalize();
Vector3 val = Vector3.zero;
Vector3 val2;
if (axis != 0f || axis2 != 0f)
{
val2 = forward * axis2 + right * axis;
val = ((Vector3)(ref val2)).normalized;
}
bool flag2 = wasGrounded && !grounded;
wasGrounded = grounded;
Vector3 val3 = rb.velocity;
int num;
if (grounded)
{
val2 = new Vector3(val3.x, 0f, val3.z);
num = ((((Vector3)(ref val2)).magnitude < 0.5f) ? 1 : 0);
}
else
{
num = 0;
}
bool flag3 = (byte)num != 0;
if (grounded)
{
if (flag3 && ((Vector3)(ref val)).magnitude > 0.1f)
{
val3 += val * 3f;
}
Vector3 val4 = default(Vector3);
((Vector3)(ref val4))..ctor(val3.x, 0f, val3.z);
float magnitude = ((Vector3)(ref val4)).magnitude;
float num2 = Mathf.Max(0f, 1f - 4f * Time.fixedDeltaTime);
val3.x *= num2;
val3.z *= num2;
float num3 = 7f;
if (key2)
{
num3 *= 1.7f;
}
if (((Vector3)(ref val)).magnitude > 0.1f)
{
float num4 = 10f;
Vector3 val5 = val * num4 * Time.fixedDeltaTime;
val3 += val5;
((Vector3)(ref val4))..ctor(val3.x, 0f, val3.z);
magnitude = ((Vector3)(ref val4)).magnitude;
float num5 = Vector3.Dot(((Vector3)(ref val4)).normalized, val);
if (magnitude > num3 && num5 > 0f)
{
float num6 = (magnitude - num3) * num5 * 0.1f;
Vector3 val6 = ((Vector3)(ref val4)).normalized * num6;
val3 -= val6;
}
}
}
if (grounded && autoBhop && key && Time.time - lastJumpTime > 0.1f)
{
val3.y = 4f;
lastJumpTime = Time.time;
}
if (flag2 && ((Vector3)(ref val3)).magnitude > 0.1f)
{
float num7 = Mathf.Min(((Vector3)(ref val3)).magnitude * 0.3f, 40f - ((Vector3)(ref val3)).magnitude);
val3 += val * num7;
}
if (!grounded && ((Vector3)(ref val)).magnitude > 0.1f)
{
float num8 = Vector3.Dot(val3, val);
float num9 = Mathf.Clamp(3f - num8, 0f, 3f);
if (num9 > 0f)
{
float num10 = 2000f * Time.fixedDeltaTime;
num10 = Mathf.Min(num10, num9);
val3 += val * num10;
}
}
if (((Vector3)(ref val3)).magnitude > 40f)
{
val3 = ((Vector3)(ref val3)).normalized * 40f;
}
rb.velocity = val3;
if (Input.GetKeyDown((KeyCode)282))
{
val2 = rb.velocity;
Debug.Log((object)$"Velocity: {((Vector3)(ref val2)).magnitude}, Grounded: {grounded}, Stationary: {flag3}");
}
return false;
}
[HarmonyPatch("Update")]
[HarmonyPostfix]
private static void HandleInputs(PlayerController __instance)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: 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_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
if (Input.GetKeyDown(toggleKey))
{
useSourceMovement = !useSourceMovement;
Debug.Log((object)("Movement System: " + (useSourceMovement ? "Source Engine" : "Original R.E.P.O.")));
if ((Object)(object)__instance.rb != (Object)null)
{
Vector3 velocity = __instance.rb.velocity;
__instance.rb.velocity = new Vector3(velocity.x * 0.5f, velocity.y * 0.5f, velocity.z * 0.5f);
}
}
}
}
}