using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using HarmonyLib.Tools;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("UltraStrafe")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.1.1.0")]
[assembly: AssemblyInformationalVersion("1.1.1+1dceb115566da61a89a3dd11afccfb9577c6eab6")]
[assembly: AssemblyProduct("UltraStrafe")]
[assembly: AssemblyTitle("UltraStrafe")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.1.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 UltraStrafe
{
internal class ConfigManager
{
internal ConfigFile Config;
public Dictionary<string, object> Cvars;
internal static ConfigEntry<float> sv_accelerate;
internal static ConfigEntry<float> sv_maxspeed;
internal static ConfigEntry<byte> sv_maxfrictionlessframes;
internal static ConfigEntry<bool> sv_acceltweak;
internal static ConfigEntry<float> sv_switchspeed;
internal static ConfigEntry<bool> sv_autobhop;
internal static ConfigEntry<float> sv_jumppower;
public ConfigManager(ConfigFile config)
{
Config = config;
Cvars = new Dictionary<string, object>
{
{ "sv_accelerate", sv_accelerate },
{ "sv_maxspeed", sv_maxspeed },
{ "sv_maxfrictionlessframes", sv_maxfrictionlessframes },
{ "sv_acceltweak", sv_acceltweak },
{ "sv_switchspeed", sv_switchspeed },
{ "sv_autobhop", sv_autobhop },
{ "sv_jumppower", sv_jumppower }
};
base..ctor();
}
public void Reload()
{
sv_accelerate = Config.Bind<float>("Cvars", "sv_accelerate", 70f, "The (base) acceleration value for the strafe movement, affecting the turn radius.");
sv_maxspeed = Config.Bind<float>("Cvars", "sv_maxspeed", 0f, "The maximum speed value for the strafe movement. Set to 0 for no maximum");
sv_jumppower = Config.Bind<float>("Cvars", "sv_jumppower", 90f, "The jump power for jumping (note that this affects all jumps, not just bhops.");
sv_maxfrictionlessframes = Config.Bind<byte>("Cvars", "sv_maxfrictionlessframes", (byte)2, "The maximum number of frames that friction is disabled for when landing. A value from 2-4 is recommended depending on your specs with lower framerates having a higher value.");
sv_acceltweak = Config.Bind<bool>("Cvars", "sv_acceltweak", true, "Enable this to make sv_accelerate increase based on your speed");
sv_switchspeed = Config.Bind<float>("Cvars", "sv_switchspeed", 16.5f, "The speed at which it switches from ultrakill physics (low speeds) to quake (high speeds). I don't recommend changing unless you know what you're doing.");
sv_autobhop = Config.Bind<bool>("Cvars", "sv_autobhop", false, "Enable this to make the game automatically jump while holding jump, without any need to release the jump key");
}
}
internal static class JumpBuffer
{
private static bool jumpBuffer = false;
private static readonly FieldRef<NewMovement, WallCheck> wcRef = AccessTools.FieldRefAccess<NewMovement, WallCheck>("wc");
private static readonly FieldRef<NewMovement, float> clingFadeRef = AccessTools.FieldRefAccess<NewMovement, float>("clingFade");
private static readonly FieldRef<NewMovement, bool> jumpCooldownRef = AccessTools.FieldRefAccess<NewMovement, bool>("jumpCooldown");
private static readonly FieldRef<NewMovement, bool> fallingRef = AccessTools.FieldRefAccess<NewMovement, bool>("falling");
public static void JumpBufferCheck(NewMovement __instance)
{
if (MonoSingleton<InputManager>.Instance.InputSource.Jump.WasPerformedThisFrame)
{
jumpBuffer = true;
}
if (!GameStateManager.Instance.PlayerInputLocked && jumpBuffer && MonoSingleton<InputManager>.Instance.InputSource.Jump.IsPressed && !jumpCooldownRef.Invoke(__instance) && (!fallingRef.Invoke(__instance) || __instance.gc.canJump || wcRef.Invoke(__instance).CheckForEnemyCols()))
{
if (__instance.gc.canJump || wcRef.Invoke(__instance).CheckForEnemyCols())
{
__instance.currentWallJumps = 0;
__instance.rocketJumps = 0;
__instance.hammerJumps = 0;
clingFadeRef.Invoke(__instance) = 0f;
__instance.rocketRides = 0;
}
jumpBuffer = ConfigManager.sv_autobhop.Value;
__instance.Jump();
}
}
}
[HarmonyPatch(typeof(NewMovement))]
public class MovementPatcher
{
[HarmonyPatch(typeof(NewMovement), "Move")]
[HarmonyPrefix]
private static bool MovePrefix(NewMovement __instance)
{
new QuakeMovement(__instance).NewMove();
return false;
}
[HarmonyPatch(typeof(NewMovement), "Update")]
[HarmonyPrefix]
private static bool UpdatePrefix(NewMovement __instance)
{
JumpBuffer.JumpBufferCheck(__instance);
return true;
}
[HarmonyPatch(typeof(NewMovement), "Jump")]
[HarmonyPrefix]
private static bool JumpPrefix(NewMovement __instance)
{
__instance.jumpPower = ConfigManager.sv_jumppower.Value;
return true;
}
}
[BepInPlugin("com.10-days-till-xmas.ultrastrafe", "UltraStrafe", "1.1.1")]
public class Plugin : BaseUnityPlugin
{
internal static ManualLogSource Logger;
internal static ConfigManager ConfigManager;
internal void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
Logger.LogInfo((object)"Plugin UltraStrafe is loaded! :3");
ConfigManager = new ConfigManager(((BaseUnityPlugin)this).Config);
ConfigManager.Reload();
DoPatching();
}
private void DoPatching()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
Harmony val = new Harmony("com.10-days-till-xmas.ultrastrafe");
HarmonyFileLog.Enabled = true;
val.PatchAll();
Logger.LogInfo((object)"Patches applied!");
}
[HarmonyPostfix]
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
private static void ScoresSubmission(ref bool __result)
{
__result = false;
}
}
internal class QuakeMovement
{
private readonly NewMovement __instance;
private float wishspeed;
private static int frictionlessFrames = 0;
private static readonly FieldRef<NewMovement, bool> slideEndingRef = AccessTools.FieldRefAccess<NewMovement, bool>("slideEnding");
private static readonly FieldRef<NewMovement, bool> hurtingRef = AccessTools.FieldRefAccess<NewMovement, bool>("hurting");
private static readonly FieldRef<NewMovement, Vector3> movementDirectionRef = AccessTools.FieldRefAccess<NewMovement, Vector3>("movementDirection");
private static readonly FieldRef<NewMovement, Vector3> movementDirection2Ref = AccessTools.FieldRefAccess<NewMovement, Vector3>("movementDirection2");
private static readonly FieldRef<NewMovement, Vector3> airDirectionRef = AccessTools.FieldRefAccess<NewMovement, Vector3>("airDirection");
private static readonly FieldRef<NewMovement, float> frictionRef = AccessTools.FieldRefAccess<NewMovement, float>("friction");
public static float sv_accelerate = ConfigManager.sv_accelerate.Value;
public static float sv_maxspeed = ConfigManager.sv_maxspeed.Value;
public static int sv_maxfrictionlessframes = ConfigManager.sv_maxfrictionlessframes.Value;
public static float sv_switchspeed = ConfigManager.sv_switchspeed.Value;
public static bool sv_acceltweak = ConfigManager.sv_acceltweak.Value;
public QuakeMovement(NewMovement __instance)
{
this.__instance = __instance;
base..ctor();
}
private void NewGroundMove()
{
//IL_000b: 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_012c: 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)
//IL_01b7: 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_01d1: Unknown result type (might be due to invalid IL or missing references)
//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
//IL_0161: Unknown result type (might be due to invalid IL or missing references)
//IL_0166: Unknown result type (might be due to invalid IL or missing references)
//IL_0198: Unknown result type (might be due to invalid IL or missing references)
//IL_0199: Unknown result type (might be due to invalid IL or missing references)
//IL_019b: Unknown result type (might be due to invalid IL or missing references)
//IL_01a0: 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_018f: Unknown result type (might be due to invalid IL or missing references)
//IL_0191: Unknown result type (might be due to invalid IL or missing references)
//IL_0196: Unknown result type (might be due to invalid IL or missing references)
float num = __instance.rb.velocity.y;
if (__instance.slopeCheck.onGround && movementDirectionRef.Invoke(__instance).x == 0f && movementDirectionRef.Invoke(__instance).z == 0f)
{
num = 0f;
__instance.rb.useGravity = false;
}
else
{
__instance.rb.useGravity = true;
}
float num2 = (__instance.slowMode ? 1.25f : 2.75f);
if (Object.op_Implicit((Object)(object)__instance.groundProperties))
{
num2 *= __instance.groundProperties.speedMultiplier;
}
float num3 = __instance.walkSpeed * Time.deltaTime * num2;
movementDirection2Ref.Invoke(__instance) = new Vector3(movementDirectionRef.Invoke(__instance).x * num3, num, movementDirectionRef.Invoke(__instance).z * num3);
Vector3 val = __instance.pushForce;
if (Object.op_Implicit((Object)(object)__instance.groundProperties) && __instance.groundProperties.push)
{
Vector3 val2 = __instance.groundProperties.pushForce;
if (__instance.groundProperties.pushDirectionRelative)
{
val2 = ((Component)__instance.groundProperties).transform.rotation * val2;
}
val += val2;
}
__instance.rb.velocity = Vector3.Lerp(__instance.rb.velocity, movementDirection2Ref.Invoke(__instance) + val, 0.25f * frictionRef.Invoke(__instance));
__instance.anim.SetBool("Run", false);
}
private float NewAcceleration(float speed)
{
float num = Mathf.Clamp(Mathf.Log(speed - 8.5f, 2f) - 2f, 1f, 10f);
return sv_accelerate * num;
}
private void NewAirMove()
{
//IL_001c: 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_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_00d9: 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_01a9: Unknown result type (might be due to invalid IL or missing references)
//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
//IL_020c: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: 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_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_029e: 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)
//IL_0138: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: Unknown result type (might be due to invalid IL or missing references)
//IL_013e: Unknown result type (might be due to invalid IL or missing references)
//IL_0340: Unknown result type (might be due to invalid IL or missing references)
//IL_0350: Unknown result type (might be due to invalid IL or missing references)
__instance.rb.useGravity = true;
Vector2 val = new Vector2(__instance.rb.velocity.x, __instance.rb.velocity.z);
float magnitude = ((Vector2)(ref val)).magnitude;
if (magnitude > sv_switchspeed)
{
Vector3 val2 = default(Vector3);
((Vector3)(ref val2))..ctor(movementDirectionRef.Invoke(__instance).x, 0f, movementDirectionRef.Invoke(__instance).z);
wishspeed = ((Vector3)(ref val2)).magnitude;
if (wishspeed > sv_maxspeed && sv_maxspeed != 0f)
{
val2 *= sv_maxspeed / wishspeed;
wishspeed = sv_maxspeed;
}
float num = Vector3.Dot(__instance.rb.velocity, val2);
float num2 = wishspeed - num;
if (!(num2 <= 0f))
{
float num3 = Time.deltaTime * wishspeed * (sv_acceltweak ? NewAcceleration(magnitude) : sv_accelerate);
if (num3 > num2)
{
num3 = num2;
}
Rigidbody rb = __instance.rb;
rb.velocity += num3 * val2;
}
}
else
{
float num4 = (__instance.slowMode ? 1.25f : 2.75f);
movementDirection2Ref.Invoke(__instance) = new Vector3(movementDirectionRef.Invoke(__instance).x * __instance.walkSpeed * Time.deltaTime * num4, __instance.rb.velocity.y, movementDirectionRef.Invoke(__instance).z * __instance.walkSpeed * Time.deltaTime * num4);
airDirectionRef.Invoke(__instance).y = 0f;
if (__instance.rb.velocity.x * movementDirection2Ref.Invoke(__instance).x < Mathf.Pow(movementDirection2Ref.Invoke(__instance).x, 2f))
{
airDirectionRef.Invoke(__instance).x = movementDirection2Ref.Invoke(__instance).x;
}
else
{
airDirectionRef.Invoke(__instance).x = 0f;
}
if (__instance.rb.velocity.z * movementDirection2Ref.Invoke(__instance).z < Mathf.Pow(movementDirection2Ref.Invoke(__instance).z, 2f))
{
airDirectionRef.Invoke(__instance).z = movementDirection2Ref.Invoke(__instance).z;
}
else
{
airDirectionRef.Invoke(__instance).z = 0f;
}
__instance.rb.AddForce(((Vector3)(ref airDirectionRef.Invoke(__instance))).normalized * __instance.airAcceleration);
}
}
public void NewMove()
{
slideEndingRef.Invoke(__instance) = false;
if (!hurtingRef.Invoke(__instance) && !__instance.levelOver)
{
((Component)__instance).gameObject.layer = 2;
__instance.exploded = false;
}
if (__instance.gc.onGround && !__instance.jumping)
{
__instance.currentWallJumps = 0;
__instance.rocketJumps = 0;
__instance.hammerJumps = 0;
__instance.rocketRides = 0;
}
if (__instance.gc.onGround && frictionRef.Invoke(__instance) > 0f && !__instance.jumping)
{
if (frictionlessFrames == 0)
{
NewGroundMove();
}
else
{
frictionlessFrames--;
}
}
else
{
NewAirMove();
frictionlessFrames = sv_maxfrictionlessframes;
}
}
}
public static class UltraStrafePluginInfo
{
public const string PLUGIN_GUID = "com.10-days-till-xmas.ultrastrafe";
public const string PLUGIN_NAME = "UltraStrafe";
public const string PLUGIN_VERSION = "1.1.1";
}
}