using System; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using FishNet.Object; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("HTFSlide")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.3.2.0")] [assembly: AssemblyInformationalVersion("1.3.2")] [assembly: AssemblyProduct("HTFSlide")] [assembly: AssemblyTitle("HTFSlide")] [assembly: AssemblyVersion("1.3.2.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 HTFSlide { [BepInPlugin("com.hatsuneexo.htfslide", "HTF Slide", "1.3.2")] [BepInProcess("How to Fish.exe")] public class Plugin : BaseUnityPlugin { public const string Guid = "com.hatsuneexo.htfslide"; internal static ManualLogSource Log; internal static ConfigEntry SlideKey; internal static ConfigEntry Duration; internal static ConfigEntry StartSpeed; internal static ConfigEntry EndSpeed; internal static ConfigEntry Cooldown; internal static ConfigEntry RequireSprint; internal static ConfigEntry SteerControl; internal static ConfigEntry SlideJumpBoost; internal static ConfigEntry RampLaunchBoost; internal static ConfigEntry KeepSpeedInAir; internal static ConfigEntry FullSpeedTime; internal static ConfigEntry AirGravityMultiplier; internal static ConfigEntry SprintToggle; internal static ConfigEntry SprintKey; internal static ConfigEntry StopSprintWhenIdle; internal static bool SprintLatched; private static float _slideRequestedAt = -99f; private const float SlideRequestWindow = 0.25f; private void Awake() { //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Expected O, but got Unknown //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Expected O, but got Unknown //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Expected O, but got Unknown //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Expected O, but got Unknown //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Expected O, but got Unknown //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Expected O, but got Unknown //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Expected O, but got Unknown //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Expected O, but got Unknown //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Expected O, but got Unknown //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; SlideKey = ((BaseUnityPlugin)this).Config.Bind("Slide", "SlideKey", (Key)55, "Tecla de deslizamiento. Es la misma de agacharse por defecto."); RequireSprint = ((BaseUnityPlugin)this).Config.Bind("Slide", "RequireSprint", true, "Exige estar esprintando para deslizarse. Si lo apagas, te deslizas desde caminar."); Duration = ((BaseUnityPlugin)this).Config.Bind("Slide", "Duration", 1.5f, new ConfigDescription("Cuánto dura el deslizamiento, en segundos.", (AcceptableValueBase)(object)new AcceptableValueRange(0.2f, 3f), Array.Empty())); StartSpeed = ((BaseUnityPlugin)this).Config.Bind("Slide", "StartSpeed", 11f, new ConfigDescription("Velocidad al iniciar el deslizamiento.", (AcceptableValueBase)(object)new AcceptableValueRange(3f, 30f), Array.Empty())); EndSpeed = ((BaseUnityPlugin)this).Config.Bind("Slide", "EndSpeed", 4f, new ConfigDescription("Velocidad al terminar, antes de devolverte el control.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 15f), Array.Empty())); Cooldown = ((BaseUnityPlugin)this).Config.Bind("Slide", "Cooldown", 0.6f, new ConfigDescription("Segundos de espera entre deslizamientos.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 5f), Array.Empty())); SteerControl = ((BaseUnityPlugin)this).Config.Bind("Slide", "SteerControl", 0.25f, new ConfigDescription("Cuánto puedes girar mientras te deslizas. 0 = en línea recta, 1 = control total.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), Array.Empty())); SlideJumpBoost = ((BaseUnityPlugin)this).Config.Bind("SlideJump", "SlideJumpBoost", 3.5f, new ConfigDescription("Impulso vertical extra al saltar mientras te deslizas. 0 lo desactiva.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 12f), Array.Empty())); RampLaunchBoost = ((BaseUnityPlugin)this).Config.Bind("SlideJump", "RampLaunchBoost", 2f, new ConfigDescription("Impulso vertical extra al despegar de un borde o rampa deslizándote, sin pulsar salto. 0 lo desactiva.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 12f), Array.Empty())); KeepSpeedInAir = ((BaseUnityPlugin)this).Config.Bind("SlideJump", "KeepSpeedInAir", true, "Conserva la velocidad horizontal del deslizamiento durante todo el vuelo, en vez de frenarte en cuanto despegas. Puedes seguir girando: solo impide que pierdas impulso."); AirGravityMultiplier = ((BaseUnityPlugin)this).Config.Bind("SlideJump", "AirGravityMultiplier", 0.45f, new ConfigDescription("Multiplica la gravedad extra del juego mientras vuelas con impulso. 1 = gravedad original, 0.45 = vuelo más largo y flotado, 0 = solo gravedad normal.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), Array.Empty())); FullSpeedTime = ((BaseUnityPlugin)this).Config.Bind("Slide", "FullSpeedTime", 0.25f, new ConfigDescription("Segundos a velocidad máxima antes de empezar a frenar. El resto de la duración es la deceleración. 0 = empieza a frenar desde el primer instante.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 2f), Array.Empty())); SprintToggle = ((BaseUnityPlugin)this).Config.Bind("Sprint", "SprintToggle", true, "Correr con interruptor: pulsas una vez y sigues corriendo, en vez de mantener la tecla."); SprintKey = ((BaseUnityPlugin)this).Config.Bind("Sprint", "SprintKey", (Key)51, "Tecla de correr. Cámbiala si reasignaste los controles."); StopSprintWhenIdle = ((BaseUnityPlugin)this).Config.Bind("Sprint", "StopSprintWhenIdle", true, "Deja de correr solo al soltar el movimiento. Si lo apagas, sigues corriendo hasta que vuelvas a pulsar la tecla."); Harmony val = new Harmony("com.hatsuneexo.htfslide"); val.PatchAll(Assembly.GetExecutingAssembly()); string[] array = (from m in val.GetPatchedMethods() select m.Name).Distinct().ToArray(); Log.LogInfo((object)((array.Length != 0) ? ("Enganchado a " + string.Join(", ", array) + ".") : "AVISO: no encuentro PlayerMovement. El mod no hará nada.")); } internal static bool ConsumeSlideRequest() { if (Time.time - _slideRequestedAt > 0.25f) { return false; } _slideRequestedAt = -99f; return true; } private void Update() { //IL_0045: 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) Keyboard current = Keyboard.current; if (current == null) { return; } if (SprintToggle.Value) { KeyControl val = current[SprintKey.Value]; if (val != null && ((ButtonControl)val).wasPressedThisFrame) { SprintLatched = !SprintLatched; } } KeyControl val2 = current[SlideKey.Value]; if (val2 != null && ((ButtonControl)val2).wasPressedThisFrame) { _slideRequestedAt = Time.time; } } internal static bool KeyHeld(Key key) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) Keyboard current = Keyboard.current; if (current == null) { return false; } KeyControl val = current[key]; if (val != null) { return ((ButtonControl)val).isPressed; } return false; } internal static bool KeyPressedThisFrame(Key key) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) Keyboard current = Keyboard.current; if (current == null) { return false; } KeyControl val = current[key]; if (val != null) { return ((ButtonControl)val).wasPressedThisFrame; } return false; } } internal static class Movement { internal static PropertyInfo Velocity; internal static PropertyInfo Grounded; internal static PropertyInfo Sprinting; internal static FieldInfo CrouchInput; internal static FieldInfo SprintInput; internal static FieldInfo MoveInputField; internal static FieldInfo Rig; internal static FieldInfo CurMoveSpeed; internal static FieldInfo TargetMoveSpeed; internal static FieldInfo ExtraGravity; internal static Type Type; internal static bool Resolve() { if (Type != null) { if (Velocity != null) { return Grounded != null; } return false; } Type = AccessTools.TypeByName("PlayerMovement"); if (Type == null) { return false; } Velocity = AccessTools.Property(Type, "Velocity"); Grounded = AccessTools.Property(Type, "Grounded"); Sprinting = AccessTools.Property(Type, "Sprinting"); CrouchInput = AccessTools.Field(Type, "_crouchInput"); SprintInput = AccessTools.Field(Type, "_sprintInput"); MoveInputField = AccessTools.Field(Type, "_moveInput"); Rig = AccessTools.Field(Type, "_rig"); CurMoveSpeed = AccessTools.Field(Type, "_curMoveSpeed"); TargetMoveSpeed = AccessTools.Field(Type, "_targetMoveSpeed"); ExtraGravity = AccessTools.Field(Type, "_extraGravityForce"); if (Velocity != null && Grounded != null) { return Velocity.CanWrite; } return false; } internal static bool IsLocal(object instance) { NetworkBehaviour val = (NetworkBehaviour)((instance is NetworkBehaviour) ? instance : null); if (val != null) { return val.IsOwner; } return true; } private static Rigidbody GetRig(object m) { object? obj = Rig?.GetValue(m); return (Rigidbody)((obj is Rigidbody) ? obj : null); } internal static Vector3 GetVelocity(object m) { //IL_0022: 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) Rigidbody rig = GetRig(m); if ((Object)(object)rig != (Object)null) { return rig.linearVelocity; } return (Vector3)Velocity.GetValue(m); } internal static void SetVelocity(object m, Vector3 v) { //IL_0048: 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_0036: Unknown result type (might be due to invalid IL or missing references) Rigidbody rig = GetRig(m); if ((Object)(object)rig != (Object)null) { rig.linearVelocity = v; if (Velocity != null && Velocity.CanWrite) { Velocity.SetValue(m, v); } } else { Velocity.SetValue(m, v); } } internal static bool IsGrounded(object m) { return (bool)Grounded.GetValue(m); } internal static void SetMoveSpeed(object m, float speed) { CurMoveSpeed?.SetValue(m, speed); } } [HarmonyPatch] internal static class SprintTogglePatch { private static MethodBase TargetMethod() { Type type = AccessTools.TypeByName("PlayerMovement"); if (!(type == null)) { return AccessTools.Method(type, "FixedUpdate", (Type[])null, (Type[])null); } return null; } private static bool Prepare() { if (!Movement.Resolve() || TargetMethod() == null) { return false; } if (Movement.SprintInput == null) { Plugin.Log.LogWarning((object)"No encuentro _sprintInput: el interruptor de correr queda desactivado."); return false; } return true; } private static void Prefix(object __instance) { //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) if (!Plugin.SprintToggle.Value || __instance == null || !Movement.IsLocal(__instance) || SlidePatch.IsSliding || !Plugin.SprintLatched) { return; } try { if (Plugin.StopSprintWhenIdle.Value && Movement.MoveInputField != null) { Vector2 val = (Vector2)Movement.MoveInputField.GetValue(__instance); if (((Vector2)(ref val)).sqrMagnitude < 0.01f) { Plugin.SprintLatched = false; return; } } Movement.SprintInput.SetValue(__instance, true); } catch (Exception ex) { Plugin.Log.LogError((object)("Interruptor de correr desactivado: " + ex.Message)); Plugin.SprintToggle.Value = false; } } } [HarmonyPatch] internal static class SlidePatch { private static bool _sliding; private static float _elapsed; private static float _lastEnd = -99f; private static Vector3 _direction; private static float _currentSpeed; private static bool _airborne; private static float _airSpeed; private static Vector3 _airDirection; private static float _airStarted; private static float _originalGravity; private static bool _gravityChanged; private const float MaxAirMomentum = 4f; internal static bool IsSliding => _sliding; internal static Vector3 Direction => _direction; internal static float CurrentSpeed => _currentSpeed; private static MethodBase TargetMethod() { Type type = AccessTools.TypeByName("PlayerMovement"); if (!(type == null)) { return AccessTools.Method(type, "FixedUpdate", (Type[])null, (Type[])null); } return null; } private static bool Prepare() { if (!Movement.Resolve()) { Plugin.Log.LogWarning((object)"PlayerMovement cambió: Velocity o Grounded no están donde esperaba."); return false; } return TargetMethod() != null; } internal static void EndSlide(object movement) { _sliding = false; _lastEnd = Time.time; if (movement != null) { Movement.SetMoveSpeed(movement, _currentSpeed); } } private static void Postfix(object __instance) { if (__instance == null || !Movement.IsLocal(__instance)) { return; } try { Tick(__instance); } catch (Exception ex) { Plugin.Log.LogError((object)("Deslizamiento desactivado: " + ex.Message)); _sliding = false; } } internal static void BeginAirMomentum(object movement, float speed, Vector3 direction) { //IL_0030: 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_0035: Unknown result type (might be due to invalid IL or missing references) if (Plugin.KeepSpeedInAir.Value) { _airborne = true; _airSpeed = speed; _airDirection = ((((Vector3)(ref direction)).sqrMagnitude > 0.01f) ? ((Vector3)(ref direction)).normalized : Vector3.forward); _airStarted = Time.time; float value = Plugin.AirGravityMultiplier.Value; if (!(Movement.ExtraGravity == null) && !_gravityChanged && !(value >= 0.999f)) { _originalGravity = (float)Movement.ExtraGravity.GetValue(movement); Movement.ExtraGravity.SetValue(movement, _originalGravity * value); _gravityChanged = true; } } } private static void EndAirMomentum(object movement) { _airborne = false; if (_gravityChanged && !(Movement.ExtraGravity == null)) { Movement.ExtraGravity.SetValue(movement, _originalGravity); _gravityChanged = false; } } private static void Tick(object movement) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: 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_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0058: 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_0077: 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_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_014b: 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_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: 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_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0227: 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) bool flag = Movement.IsGrounded(movement); Vector3 velocity = Movement.GetVelocity(movement); Vector3 horizontal = default(Vector3); ((Vector3)(ref horizontal))..ctor(velocity.x, 0f, velocity.z); if (_airborne) { if (flag || Time.time - _airStarted > 4f) { EndAirMomentum(movement); } else { Vector3 val = ((((Vector3)(ref horizontal)).sqrMagnitude > 0.01f) ? ((Vector3)(ref horizontal)).normalized : _airDirection); if (((Vector3)(ref horizontal)).magnitude < _airSpeed) { Movement.SetVelocity(movement, val * _airSpeed + Vector3.up * velocity.y); } Movement.SetMoveSpeed(movement, _airSpeed); } } if (!_sliding) { if (ShouldStart(movement, flag, horizontal)) { _sliding = true; _elapsed = 0f; _direction = ((Vector3)(ref horizontal)).normalized; _currentSpeed = Plugin.StartSpeed.Value; } return; } if (!flag) { Launch(movement, velocity); return; } _elapsed += Time.fixedDeltaTime; if (!Plugin.KeyHeld(Plugin.SlideKey.Value) || _elapsed >= Plugin.Duration.Value) { EndSlide(movement); return; } float value = Plugin.SteerControl.Value; if (value > 0f && ((Vector3)(ref horizontal)).sqrMagnitude > 0.01f) { Vector3 val2 = Vector3.Slerp(_direction, ((Vector3)(ref horizontal)).normalized, value); _direction = ((Vector3)(ref val2)).normalized; } float num = Mathf.Clamp01(_elapsed / Plugin.Duration.Value); float num2 = Mathf.Clamp01(Plugin.FullSpeedTime.Value / Mathf.Max(0.01f, Plugin.Duration.Value)); num2 = Mathf.Min(num2, 0.9f); float num3 = ((num <= num2) ? 0f : Mathf.InverseLerp(num2, 1f, num)); float num4 = 1f - (1f - num3) * (1f - num3); _currentSpeed = Mathf.Lerp(Plugin.StartSpeed.Value, Plugin.EndSpeed.Value, num4); Movement.SetVelocity(movement, _direction * _currentSpeed + Vector3.up * velocity.y); Movement.SetMoveSpeed(movement, _currentSpeed); Movement.CrouchInput?.SetValue(movement, true); } private static void Launch(object movement, Vector3 velocity) { //IL_002f: 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_0017: 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_0028: 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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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_0062: 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_0077: Unknown result type (might be due to invalid IL or missing references) float value = Plugin.RampLaunchBoost.Value; Vector3 val = (Vector3)(Plugin.KeepSpeedInAir.Value ? (_direction * _currentSpeed) : new Vector3(velocity.x, 0f, velocity.z)); float num = velocity.y; if (value > 0f && num > -1f) { num += value; } Movement.SetVelocity(movement, val + Vector3.up * num); BeginAirMomentum(movement, _currentSpeed, _direction); EndSlide(movement); } private static bool ShouldStart(object movement, bool grounded, Vector3 horizontal) { if (!grounded) { return false; } if (Time.time - _lastEnd < Plugin.Cooldown.Value) { return false; } if (((Vector3)(ref horizontal)).sqrMagnitude < 0.5f) { return false; } if (Plugin.RequireSprint.Value && Movement.Sprinting != null && !(bool)Movement.Sprinting.GetValue(movement)) { return false; } return Plugin.ConsumeSlideRequest(); } } [HarmonyPatch] internal static class SlideJumpPatch { private static MethodBase TargetMethod() { Type type = AccessTools.TypeByName("PlayerMovement"); if (!(type == null)) { return AccessTools.Method(type, "Jump", (Type[])null, (Type[])null); } return null; } private static bool Prepare() { if (Movement.Resolve()) { return TargetMethod() != null; } return false; } private static void Postfix(object __instance) { //IL_0016: 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_0040: 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_0028: 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_0039: 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) //IL_0051: 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_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_007d: Unknown result type (might be due to invalid IL or missing references) if (!SlidePatch.IsSliding || __instance == null || !Movement.IsLocal(__instance)) { return; } try { Vector3 velocity = Movement.GetVelocity(__instance); Vector3 val = (Vector3)(Plugin.KeepSpeedInAir.Value ? (SlidePatch.Direction * SlidePatch.CurrentSpeed) : new Vector3(velocity.x, 0f, velocity.z)); Movement.SetVelocity(__instance, val + Vector3.up * (velocity.y + Plugin.SlideJumpBoost.Value)); SlidePatch.BeginAirMomentum(__instance, SlidePatch.CurrentSpeed, SlidePatch.Direction); SlidePatch.EndSlide(__instance); } catch (Exception ex) { Plugin.Log.LogError((object)("Salto con impulso desactivado: " + ex.Message)); } } } }