Some mods target the Mono version of the game, which is available by opting into the Steam beta branch "alternate"
Decompiled source of ScheduleStrafe v1.0.0
schedule_strafe.dll
Decompiled 3 weeks agousing System; using System.Diagnostics; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using HarmonyLib; using MelonLoader; using MelonLoader.Preferences; using Microsoft.CodeAnalysis; using ScheduleOne; using ScheduleOne.DevUtilities; using ScheduleOne.PlayerScripts; using ScheduleOne.UI; using UnityEngine; using schedule_strafe; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: MelonInfo(typeof(GameMovement), "schedule_strafe", "1.0.0", "Patoke", null)] [assembly: MelonGame("TVGS", "Schedule I")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("schedule_strafe")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+94a439adc5bf8a1ebcbc5bdfc1c06a3153177f6d")] [assembly: AssemblyProduct("schedule_strafe")] [assembly: AssemblyTitle("schedule_strafe")] [assembly: NeutralResourcesLanguage("en-US")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.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 schedule_strafe { public static class CollisionTest { public const float DIST_EPSILON = 1f / 32f; public const float MINIMUM_MOVE_FRACTION = 0.0001f; public const float EFFECTIVELY_HORIZONTAL_NORMAL_Z = 0.0001f; public const int MAX_CLIP_PLANES = 5; public static int ClipVelocity(Vector3 in_velocity, Vector3 plane_normal, out Vector3 velocity, float overbounce) { //IL_0002: 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_0020: 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_0029: 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_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0031: 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_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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) int num = 0; float y = plane_normal.y; if (y > 0f) { num |= 1; } if (y == 0f) { num |= 2; } float num2 = Vector3.Dot(in_velocity, plane_normal); Vector3 val = plane_normal * num2; velocity = in_velocity - val; float num3 = Vector3.Dot(velocity, plane_normal); if (num3 < 0f) { num3 = Math.Min(num3, -1f / 32f); velocity -= plane_normal * num3; } return num; } public static int TryPlayerMove(PlayerMovement __instance, in Vector3 in_velocity, out Vector3 velocity) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: 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_002c: 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) //IL_0034: 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_003c: 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_0063: 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_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0085: 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) //IL_031c: Unknown result type (might be due to invalid IL or missing references) //IL_0321: 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_00ee: 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_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_02e5: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: 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_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_02f9: Unknown result type (might be due to invalid IL or missing references) //IL_02fe: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_0297: 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_029c: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) float num = Time.deltaTime; float num2 = 0f; int num3 = 4; int num4 = 0; int num5 = 0; Vector3[] array = (Vector3[])(object)new Vector3[5]; velocity = in_velocity; Vector3 velocity2 = Vector3.zero; Vector3 in_velocity2 = velocity; Vector3 val = velocity; for (int i = 0; i < num3; i++) { if (((Vector3)(ref velocity)).magnitude == 0f) { break; } Vector3 end = ((Component)__instance).transform.position + num * velocity; Tracer.Trace trace = Tracer.TraceCollider((Collider)(object)__instance.Player.CapCol, ((Component)__instance).transform.position, end, ~(1 << LayerMask.NameToLayer("Trash"))); if (trace.fraction > 0f && trace.fraction < 0.0001f) { trace.fraction = 0f; } num2 += trace.fraction; if (trace.fraction > 0f) { in_velocity2 = velocity; num5 = 0; } if (trace.fraction == 1f) { break; } if (trace.planeNormal.y > Cvars.sv_standable_normal.Value) { num4 |= 1; } if (Math.Abs(trace.planeNormal.y) < 0.0001f) { trace.planeNormal.y = 0f; num4 |= 2; } num -= num * trace.fraction; if (num5 > 5) { velocity = Vector3.zero; break; } array[num5] = trace.planeNormal; num5++; if (num5 == 1) { for (int j = 0; j < num5; j++) { if (array[j].y > Cvars.sv_standable_normal.Value) { ClipVelocity(in_velocity2, array[j], out velocity2, 1f); in_velocity2 = velocity2; } else { ClipVelocity(in_velocity2, array[j], out velocity2, 1f); } } velocity = velocity2; in_velocity2 = velocity2; continue; } int k; for (k = 0; k < num5; k++) { ClipVelocity(in_velocity2, array[k], out velocity, 1f); int l; for (l = 0; l < num5 && (l == k || !(Vector3.Dot(velocity, array[l]) < 0f)); l++) { } if (l == num5) { break; } } if (k == num5) { if (num5 != 2) { velocity = Vector3.zero; break; } Vector3 val2 = Vector3.Cross(array[0], array[1]); Vector3 normalized = ((Vector3)(ref val2)).normalized; float num6 = Vector3.Dot(normalized, velocity); velocity.x *= normalized.x * num6; velocity.y *= normalized.y * num6; velocity.z *= normalized.z * num6; } if (Vector3.Dot(velocity, val) <= 0f) { velocity = Vector3.zero; break; } } if (num2 == 0f) { velocity = Vector3.zero; } return num4; } } public class GameMovement : MelonMod { public override void OnInitializeMelon() { Cvars.SetupCvars(); ((MelonBase)this).LoggerInstance.Msg("Mod initialized."); } public override void OnGUI() { //IL_006a: Unknown result type (might be due to invalid IL or missing references) float num = 150f; float num2 = 25f; float num3 = MathF.Sqrt(MovementPatches.velocity.x * MovementPatches.velocity.x + MovementPatches.velocity.z * MovementPatches.velocity.z); GUI.Label(new Rect((float)Screen.width / 2f - num / 2f, (float)Screen.height / 2f + Cvars.cl_speedcounter_offset.Value, num, num2), "speed: " + num3); } } [HarmonyPatch(typeof(PlayerMovement), "Move")] public static class MovementPatches { public static int groundedFrames = 0; public static bool isGrounded = true; public static Vector3 velocity; public static float fmove; public static float smove; public static void Friction(PlayerMovement __instance) { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) float magnitude = ((Vector3)(ref velocity)).magnitude; if (!(magnitude < 0.0001905f)) { float num = Cvars.sv_friction.Value / __instance.SlipperyMovementMultiplier; float num2 = ((magnitude < Cvars.sv_stopspeed.Value) ? Cvars.sv_stopspeed.Value : magnitude) * num * Time.deltaTime; float num3 = magnitude - num2; if (num3 < 0f) { num3 = 0f; } if (num3 != magnitude) { num3 /= magnitude; velocity *= num3; } } } public static void Accelerate(PlayerMovement __instance, float wishspeed, Vector3 wishdir) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: 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_0040: 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_004c: Unknown result type (might be due to invalid IL or missing references) if (!__instance.canMove) { return; } float num = Vector3.Dot(velocity, wishdir); float num2 = wishspeed - num; if (!(num2 < 0f)) { float num3 = Cvars.sv_accelerate.Value * Time.deltaTime * wishspeed; if (num3 > num2) { num3 = num2; } velocity += wishdir * num3; } } public static void AirAccelerate(PlayerMovement __instance, float wishspeed, Vector3 wishdir) { //IL_0019: 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_004b: 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_0052: 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) if (!__instance.canMove) { return; } float num = wishspeed; if (num > 1f) { num = 1f; } float num2 = Vector3.Dot(velocity, wishdir); float num3 = num - num2; if (!(num3 < 0f)) { float num4 = Cvars.sv_airaccelerate.Value * Time.deltaTime * wishspeed; if (num4 > num3) { num4 = num3; } velocity += wishdir * num4; } } public static bool Prefix(PlayerMovement __instance, float ___timeSinceStaminaDrain, float ___crouchSpeedMultipler, float ___gravityMultiplier, float ___jumpForce, ref bool ___sprintActive, ref bool ___sprintReleased, ref bool ___isJumping, ref float ___timeGrounded) { //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Invalid comparison between Unknown and I4 //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Invalid comparison between Unknown and I4 //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_0516: Unknown result type (might be due to invalid IL or missing references) //IL_051b: Unknown result type (might be due to invalid IL or missing references) //IL_051f: Unknown result type (might be due to invalid IL or missing references) //IL_0524: Unknown result type (might be due to invalid IL or missing references) //IL_0531: Unknown result type (might be due to invalid IL or missing references) //IL_0536: Unknown result type (might be due to invalid IL or missing references) //IL_053a: Unknown result type (might be due to invalid IL or missing references) //IL_053f: Unknown result type (might be due to invalid IL or missing references) //IL_055b: Unknown result type (might be due to invalid IL or missing references) //IL_0568: Unknown result type (might be due to invalid IL or missing references) //IL_057d: Unknown result type (might be due to invalid IL or missing references) //IL_058a: Unknown result type (might be due to invalid IL or missing references) //IL_05a8: Unknown result type (might be due to invalid IL or missing references) //IL_05ad: Unknown result type (might be due to invalid IL or missing references) //IL_0620: Unknown result type (might be due to invalid IL or missing references) //IL_05f9: Unknown result type (might be due to invalid IL or missing references) //IL_0671: Unknown result type (might be due to invalid IL or missing references) //IL_067b: Unknown result type (might be due to invalid IL or missing references) //IL_0680: Unknown result type (might be due to invalid IL or missing references) //IL_064b: Unknown result type (might be due to invalid IL or missing references) //IL_0611: Unknown result type (might be due to invalid IL or missing references) //IL_0616: Unknown result type (might be due to invalid IL or missing references) Traverse val = Traverse.Create((object)__instance).Property("isSprinting", (object[])null); Traverse val2 = Traverse.Create((object)__instance).Property("CurrentSprintMultiplier", (object[])null); val.SetValue((object)false); if (!((Collider)__instance.Controller).enabled) { val2.SetValue((object)Mathf.MoveTowards(__instance.CurrentSprintMultiplier, 1f, Time.deltaTime * 4f)); return false; } if ((Object)(object)__instance.currentVehicle != (Object)null) { return false; } fmove = (smove = 0f); if (GameInput.GetButton((ButtonCode)3)) { fmove += Cvars.cl_forwardspeed.Value; } if (GameInput.GetButton((ButtonCode)4)) { fmove -= Cvars.cl_forwardspeed.Value; } if (GameInput.GetButton((ButtonCode)5)) { smove -= Cvars.cl_sidespeed.Value; } if (GameInput.GetButton((ButtonCode)6)) { smove += Cvars.cl_sidespeed.Value; } if (GameInput.GetButtonDown((ButtonCode)9) && !___sprintActive) { ___sprintActive = true; ___sprintReleased = false; } else if (GameInput.GetButton((ButtonCode)9) && (int)Singleton<Settings>.Instance.SprintMode == 1) { ___sprintActive = true; } else if ((int)Singleton<Settings>.Instance.SprintMode == 1) { ___sprintActive = false; } if (!GameInput.GetButton((ButtonCode)9)) { ___sprintReleased = true; } if (GameInput.GetButtonDown((ButtonCode)9) & ___sprintReleased) { ___sprintActive = !___sprintActive; } isGrounded = ((Enum)__instance.Player.CharacterController.collisionFlags).HasFlag((Enum)(object)(CollisionFlags)4); if (isGrounded) { groundedFrames++; } else { groundedFrames = 0; } if (!isGrounded) { velocity.y += Physics.gravity.y * ___gravityMultiplier * Time.deltaTime * PlayerMovement.GravityMultiplier * 0.5f; } bool flag = (Cvars.sv_autobunnyhopping.Value ? GameInput.GetButton((ButtonCode)7) : GameInput.GetButtonDown((ButtonCode)7)); Vector3 val3; if (__instance.canMove && __instance.canJump && isGrounded && !___isJumping && !GameInput.IsTyping && !Singleton<PauseMenu>.Instance.IsPaused && flag) { ___isJumping = true; if (__instance.onJump != null) { __instance.onJump(); } Player.Local.PlayJumpAnimation(); val3 = __instance.Controller.velocity; ((Vector3)(ref val3)).Set(__instance.Controller.velocity.x, 0f, __instance.Controller.velocity.z); ___timeGrounded = 0f; float num = 1f; float num2 = 2.1f; float num3 = MathF.Sqrt(2f * ___jumpForce * PlayerMovement.JumpMultiplier * num2); velocity.y = num * num3; } MethodInfo method = typeof(PlayerMovement).GetMethod("TryToggleCrouch", BindingFlags.Instance | BindingFlags.NonPublic); if (__instance.canMove && !GameInput.IsTyping && !Singleton<PauseMenu>.Instance.IsPaused && GameInput.GetButtonDown((ButtonCode)8)) { method.Invoke(__instance, Array.Empty<object>()); } if (isGrounded) { ___isJumping = false; if (__instance.onJump != null) { __instance.onLand(); } } if (__instance.isCrouched) { float num4 = 1f / 3f; fmove *= num4; smove *= num4; } if (Player.Local.IsTased) { float num5 = 0.1f; fmove *= num5; smove *= num5; } val.SetValue((object)false); float num6 = 1.25f; if (___sprintActive && __instance.canMove && !__instance.isCrouched && !__instance.Player.IsTased && (fmove != 0f || smove != 0f)) { if (__instance.CurrentStaminaReserve > 0f || !__instance.SprintingRequiresStamina) { val2.SetValue((object)Mathf.MoveTowards(__instance.CurrentSprintMultiplier, num6, Time.deltaTime * 4f)); if (__instance.SprintingRequiresStamina) { __instance.ChangeStamina(-12.5f * Time.deltaTime, true); } val.SetValue((object)true); } else { ___sprintActive = false; val2.SetValue((object)Mathf.MoveTowards(__instance.CurrentSprintMultiplier, 1f, Time.deltaTime * 4f)); } } else { ___sprintActive = false; val2.SetValue((object)Mathf.MoveTowards(__instance.CurrentSprintMultiplier, 1f, Time.deltaTime * 4f)); } if (!__instance.isSprinting && ___timeSinceStaminaDrain > 1f) { val2.SetValue((object)Mathf.MoveTowards(__instance.CurrentSprintMultiplier, 1f, Time.deltaTime * 4f)); } if (__instance.isSprinting) { float currentSprintMultiplier = __instance.CurrentSprintMultiplier; fmove *= currentSprintMultiplier; smove *= currentSprintMultiplier; } Vector3 normalized = default(Vector3); ((Vector3)(ref normalized))..ctor(0f, 0f, 0f); val3 = ((Component)__instance.Player).transform.forward; Vector3 normalized2 = ((Vector3)(ref val3)).normalized; val3 = ((Component)__instance.Player).transform.right; Vector3 normalized3 = ((Vector3)(ref val3)).normalized; normalized2.y = (normalized3.y = 0f); normalized.x = normalized2.x * fmove + normalized3.x * smove; normalized.z = normalized2.z * fmove + normalized3.z * smove; float num7 = ((Vector3)(ref normalized)).magnitude; normalized = ((Vector3)(ref normalized)).normalized; normalized.y = 0f; float num8 = Cvars.sv_maxspeed.Value * __instance.CurrentSprintMultiplier; if (num7 != 0f && num7 > num8) { num7 = num8; } if (isGrounded && groundedFrames > 1) { Friction(__instance); Accelerate(__instance, num7, normalized); if (((Vector3)(ref velocity)).magnitude < 0.001905f) { velocity = Vector3.zero; } } else { AirAccelerate(__instance, num7, normalized); } CollisionTest.TryPlayerMove(__instance, in velocity, out velocity); if (!isGrounded) { velocity.y += Physics.gravity.y * ___gravityMultiplier * Time.deltaTime * PlayerMovement.GravityMultiplier * 0.5f; } __instance.Controller.Move(velocity * Time.deltaTime); return false; } } public static class Cvars { private static MelonPreferences_Category cvars_category; public static MelonPreferences_Entry<float> sv_maxspeed; public static MelonPreferences_Entry<float> sv_stopspeed; public static MelonPreferences_Entry<float> sv_friction; public static MelonPreferences_Entry<float> sv_accelerate; public static MelonPreferences_Entry<float> sv_airaccelerate; public static MelonPreferences_Entry<float> sv_standable_normal; public static MelonPreferences_Entry<float> cl_forwardspeed; public static MelonPreferences_Entry<float> cl_sidespeed; public static MelonPreferences_Entry<float> cl_speedcounter_offset; public static MelonPreferences_Entry<bool> cl_speedcounter; public static MelonPreferences_Entry<bool> sv_autobunnyhopping; public static void SetupCvars() { cvars_category = MelonPreferences.CreateCategory("ScheduleStrafe"); sv_accelerate = cvars_category.CreateEntry<float>("sv_accelerate", 5f, "Ground acceleration value", (string)null, false, false, (ValueValidator)null, (string)null); sv_airaccelerate = cvars_category.CreateEntry<float>("sv_airaccelerate", 12f, "Air acceleration value", (string)null, false, false, (ValueValidator)null, (string)null); sv_friction = cvars_category.CreateEntry<float>("sv_friction", 5.2f, "Ground slippery-ness, the lower, the more slippery the ground is", (string)null, false, false, (ValueValidator)null, (string)null); sv_stopspeed = cvars_category.CreateEntry<float>("sv_stopspeed", 0.01524f, "If ground speed is below this value, stop moving", (string)null, false, false, (ValueValidator)null, (string)null); sv_maxspeed = cvars_category.CreateEntry<float>("sv_maxspeed", 5f, "Max ground speed value", (string)null, false, false, (ValueValidator)null, (string)null); sv_standable_normal = cvars_category.CreateEntry<float>("sv_standable_normal", 0.7f, "Surface angle when we start to \"surf\"", (string)null, false, false, (ValueValidator)null, (string)null); cl_forwardspeed = cvars_category.CreateEntry<float>("cl_forwardspeed", 5f, "How fast we move forwards", (string)null, false, false, (ValueValidator)null, (string)null); cl_sidespeed = cvars_category.CreateEntry<float>("cl_sidespeed", 5f, "How fast we move sideways", (string)null, false, false, (ValueValidator)null, (string)null); cl_speedcounter_offset = cvars_category.CreateEntry<float>("cl_speedcounter_offset", 100f, "Vertical offset of the speed counter to the center of the screen", (string)null, false, false, (ValueValidator)null, (string)null); cl_speedcounter = cvars_category.CreateEntry<bool>("cl_speedcounter", true, "Should display the speed counter", (string)null, false, false, (ValueValidator)null, (string)null); sv_autobunnyhopping = cvars_category.CreateEntry<bool>("sv_autobunnyhopping", true, "Should we automatically bunnyhop", (string)null, false, false, (ValueValidator)null, (string)null); } } public class Tracer { public struct Trace { public Vector3 startPos; public Vector3 endPos; public float fraction; public bool startSolid; public Collider hitCollider; public Vector3 hitPoint; public Vector3 planeNormal; public float distance; } public static void GetCapsulePoints(CapsuleCollider capc, Vector3 origin, out Vector3 p1, out Vector3 p2) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: 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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: 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) //IL_0049: 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_0053: Unknown result type (might be due to invalid IL or missing references) float num = capc.height / 2f - capc.radius; p1 = origin + capc.center + Vector3.up * num; p2 = origin + capc.center - Vector3.up * num; } public static Trace TraceCollider(Collider collider, Vector3 origin, Vector3 end, int layerMask, float colliderScale = 1f) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Expected O, but got Unknown //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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) if (collider is CapsuleCollider) { CapsuleCollider val = (CapsuleCollider)collider; GetCapsulePoints(val, origin, out var p, out var p2); return TraceCapsule(p, p2, val.radius, origin, end, ((Collider)val).contactOffset, layerMask, colliderScale); } throw new NotImplementedException("Trace missing for collider: " + ((object)collider).GetType()); } public static Trace TraceCapsule(Vector3 point1, Vector3 point2, float radius, Vector3 start, Vector3 destination, float contactOffset, int layerMask, float colliderScale = 1f) { //IL_000a: 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_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0014: 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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: 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_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_0056: 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_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_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0073: 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_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: 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_00ff: 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_0111: 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) Trace trace = default(Trace); trace.startPos = start; trace.endPos = destination; Trace result = trace; float num = Mathf.Sqrt(contactOffset * contactOffset + contactOffset * contactOffset); radius *= 1f - contactOffset; Vector3 val = destination - start; Vector3 normalized = ((Vector3)(ref val)).normalized; float num2 = Vector3.Distance(start, destination) + num; RaycastHit val2 = default(RaycastHit); if (Physics.CapsuleCast(point1 - Vector3.up * colliderScale * 0.5f, point2 + Vector3.up * colliderScale * 0.5f, radius * colliderScale, normalized, ref val2, num2, layerMask, (QueryTriggerInteraction)1)) { result.fraction = ((RaycastHit)(ref val2)).distance / num2; result.hitCollider = ((RaycastHit)(ref val2)).collider; result.hitPoint = ((RaycastHit)(ref val2)).point; result.planeNormal = ((RaycastHit)(ref val2)).normal; result.distance = ((RaycastHit)(ref val2)).distance; Ray val3 = default(Ray); ((Ray)(ref val3))..ctor(((RaycastHit)(ref val2)).point - normalized * 0.001f, normalized); RaycastHit val4 = default(RaycastHit); if (((RaycastHit)(ref val2)).collider.Raycast(val3, ref val4, 0.002f)) { result.planeNormal = ((RaycastHit)(ref val4)).normal; } } else { result.fraction = 1f; } return result; } } }