using System;
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 Microsoft.CodeAnalysis;
using Mirror;
using Nessie.ATLYSS.EasySettings;
using UnityEngine;
using UnityEngine.Events;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ControlTweaks")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.1.1.0")]
[assembly: AssemblyInformationalVersion("1.1.1+769baf665e592da9c92cc2bd9c76c769883347a2")]
[assembly: AssemblyProduct("Control Tweaks")]
[assembly: AssemblyTitle("ControlTweaks")]
[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 Nessie.ATLYSS.ControlTweaks
{
public struct BufferedInput<T> where T : struct
{
private TimestampedValue<T> _input;
public T Value => _input.Value;
public bool Consumed { get; private set; }
public float TimeSinceChanged => _input.TimeSinceChanged;
private bool IsDefaultInputValue => _input.Value.Equals(default(T));
public bool PressedWithin(float interval)
{
return !IsDefaultInputValue && !Consumed && _input.ChangedWithin(interval);
}
public bool PressedWithinUnscaled(float interval)
{
return !IsDefaultInputValue && !Consumed && _input.ChangedWithinUnscaled(interval);
}
public void UpdateState(T state)
{
if (!state.Equals(Value))
{
_input.UpdateState(state);
Consumed = false;
}
}
public void Consume()
{
Consumed = true;
}
}
[BepInPlugin("ControlTweaks", "Control Tweaks", "1.1.1")]
public class ControlTweaksPlugin : BaseUnityPlugin
{
internal static ManualLogSource Logger;
internal static ConfigEntry<float> ConfigJumpBufferDuration;
internal static ConfigEntry<bool> ConfigSoftHeadBump;
internal static ConfigEntry<KeyCode> ConfigWalkKey;
internal static ConfigEntry<bool> ConfigWalkToggle;
internal static ConfigEntry<float> ConfigWalkSpeed;
internal static float JumpBufferDuration => Mathf.Max(0f, ConfigJumpBufferDuration.Value);
internal static KeyCode WalkKey => ConfigWalkKey.Value;
internal static bool WalkToggle => ConfigWalkToggle.Value;
internal static float WalkSpeed => Mathf.Clamp01(ConfigWalkSpeed.Value);
private void Awake()
{
//IL_0011: 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_0039: Expected O, but got Unknown
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Expected O, but got Unknown
Logger = ((BaseUnityPlugin)this).Logger;
new Harmony("ControlTweaks").PatchAll();
InitConfig();
Settings.OnInitialized.AddListener(new UnityAction(AddSettings));
Settings.OnApplySettings.AddListener((UnityAction)delegate
{
((BaseUnityPlugin)this).Config.Save();
});
}
private void InitConfig()
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Expected O, but got Unknown
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Expected O, but got Unknown
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Expected O, but got Unknown
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Expected O, but got Unknown
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Expected O, but got Unknown
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Expected O, but got Unknown
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: Expected O, but got Unknown
//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Expected O, but got Unknown
//IL_0119: Unknown result type (might be due to invalid IL or missing references)
//IL_0120: Expected O, but got Unknown
ConfigDefinition val = new ConfigDefinition("Jumping", "JumpBufferDuration");
ConfigDescription val2 = new ConfigDescription("How long a regular jump and ledge jump is buffered for. Limited between 0 and 5.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), Array.Empty<object>());
ConfigJumpBufferDuration = ((BaseUnityPlugin)this).Config.Bind<float>(val, 0.25f, val2);
ConfigDefinition val3 = new ConfigDefinition("Jumping", "SoftHeadBump");
ConfigDescription val4 = new ConfigDescription("If the head bumping should be softened instead of instantly falling down.", (AcceptableValueBase)null, Array.Empty<object>());
ConfigSoftHeadBump = ((BaseUnityPlugin)this).Config.Bind<bool>(val3, true, val4);
ConfigDefinition val5 = new ConfigDefinition("Walking", "WalkKeyBind");
ConfigDescription val6 = new ConfigDescription("The key that needs to be held down in order to walk.", (AcceptableValueBase)null, Array.Empty<object>());
ConfigWalkKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>(val5, (KeyCode)306, val6);
ConfigDefinition val7 = new ConfigDefinition("Walking", "WalkToggle");
ConfigDescription val8 = new ConfigDescription("If pressing the walk key should toggle walking.", (AcceptableValueBase)null, Array.Empty<object>());
ConfigWalkToggle = ((BaseUnityPlugin)this).Config.Bind<bool>(val7, false, val8);
ConfigDefinition val9 = new ConfigDefinition("Walking", "WalkSpeedMultiplier");
ConfigDescription val10 = new ConfigDescription("The speed multiplier that's applied when walking. Limited between 0.1 and 0.9.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 0.9f), Array.Empty<object>());
ConfigWalkSpeed = ((BaseUnityPlugin)this).Config.Bind<float>(val9, 0.4f, val10);
}
private void AddSettings()
{
SettingsTab modTab = Settings.ModTab;
modTab.AddHeader("Control Tweaks");
modTab.AddAdvancedSlider("Jump Buffer Duration", ConfigJumpBufferDuration, false);
modTab.AddToggle("Soft Head Bump", ConfigSoftHeadBump);
modTab.AddKeyButton("Walk Key", ConfigWalkKey);
modTab.AddToggle("Walk Toggle", ConfigWalkToggle);
modTab.AddAdvancedSlider("Walk Speed", ConfigWalkSpeed, false);
}
}
public struct TimestampedValue<T> where T : struct
{
private float _timeStamp;
private float _unscaledTimeStamp;
public T Value { get; private set; }
public float TimeSinceChanged => Time.time - _timeStamp;
public float UnscaledTimeSinceChanged => Time.unscaledTime - _unscaledTimeStamp;
public bool ChangedWithin(float interval)
{
return TimeSinceChanged <= interval;
}
public bool ChangedWithinUnscaled(float interval)
{
return UnscaledTimeSinceChanged <= interval;
}
public void UpdateState(T state)
{
if (!state.Equals(Value))
{
OnChanged(state);
}
}
private void OnChanged(T newValue)
{
Value = newValue;
_timeStamp = Time.time;
_unscaledTimeStamp = Time.unscaledTime;
}
}
public struct ValueChange<T>
{
private T _value;
public bool Changed { get; private set; }
public ValueChange(T value = default(T))
{
Changed = false;
_value = value;
}
public void SetValue(T value)
{
Changed = !_value.Equals(value);
_value = value;
}
public static implicit operator T(ValueChange<T> value)
{
return value._value;
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "ControlTweaks";
public const string PLUGIN_NAME = "Control Tweaks";
public const string PLUGIN_VERSION = "1.1.1";
}
}
namespace Nessie.ATLYSS.ControlTweaks.Patches
{
public static class JumpBufferPatches
{
[HarmonyPatch(typeof(PlayerMove), "Handle_JumpControl")]
private static class JumpBufferPatch
{
private static bool _inputJumpDown;
private static bool _canJump;
private static BufferedInput<bool> _inputJump;
[HarmonyPrefix]
private static void RecordInputPressed(PlayerMove __instance)
{
//IL_0006: 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)
_inputJumpDown = Input.GetKeyDown(InputControlManager.current._jump);
_canJump = CanJumpInput(__instance);
if (_inputJumpDown)
{
_inputJump.UpdateState(state: true);
}
else if (Input.GetKeyUp(InputControlManager.current._jump))
{
_inputJump.UpdateState(state: false);
}
}
[HarmonyPostfix]
private static void HandleBufferedJump(PlayerMove __instance)
{
if (_canJump && NetworkClient.active && !(__instance._freezeMovementBuffer > 0f))
{
if (_inputJumpDown)
{
_inputJump.Consume();
}
else if (_inputJump.PressedWithinUnscaled(ControlTweaksPlugin.JumpBufferDuration))
{
InputJump(__instance);
_inputJump.Consume();
}
}
}
private static bool CanJumpInput(PlayerMove instance)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Invalid comparison between Unknown and I4
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
return (int)instance._player._currentPlayerCondition == 2 && !instance._player._inChat && (int)instance._movementLockType == 0 && instance._lockControlBuffer <= 0f && !instance.IsSlidingOnSlope && (instance._pWater._isInWater || instance._currentJumps < instance._maxJumps) && instance._attackMovementSpeedModifier > -80f && !instance._lockControlMidair && !instance._lockControl && !instance._jumpToLandBuffer && !instance.initJumpPress;
}
private static void InputJump(PlayerMove instance)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Invalid comparison between Unknown and I4
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Invalid comparison between Unknown and I4
//IL_0079: 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_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Invalid comparison between Unknown and I4
float num = instance._standardJumpForce;
if (!instance._pWater._isInWater || instance._pWater._canSwimUp || (int)instance._currentMovementAction != 2)
{
if (instance._pWater._isInWater && instance._airTime > 1.5f && ((int)instance._currentMovementAction == 2 || (int)instance._currentMovementAction == 5))
{
num = instance._underwaterJumpForce;
}
instance.Init_Jump(num, (instance._worldSpaceInput == Vector3.zero) ? 0f : 1.65f, 0f);
instance._isJumpInput = true;
instance._pCombat._airAttackLock = 0f;
}
}
}
[HarmonyPatch(typeof(PlayerMove), "Reset_PlayerControllerParams")]
private static class SoftHeadBump
{
[HarmonyPrefix]
private static bool ApplySoftHeadBump(PlayerMove __instance)
{
if (!NetworkClient.active)
{
return true;
}
if (!ControlTweaksPlugin.ConfigSoftHeadBump.Value)
{
return true;
}
if (!DetectHeadBump.IsHandleJumpParams)
{
return true;
}
__instance._airTime += 32f * Time.deltaTime;
return false;
}
}
[HarmonyPatch(typeof(PlayerMove), "Handle_JumpParams")]
private static class DetectHeadBump
{
internal static bool IsHandleJumpParams;
[HarmonyPrefix]
private static void HandleBufferedJump(PlayerMove __instance)
{
IsHandleJumpParams = true;
}
[HarmonyPostfix]
private static void HandleBufferedJumpEnd(PlayerMove __instance)
{
IsHandleJumpParams = false;
}
}
[HarmonyPatch(typeof(PlayerClimbing), "Handle_LedgeClimbControl")]
private static class LedgeJumpBufferPatch
{
private static BufferedInput<bool> _inputJump;
[HarmonyPrefix]
private static bool RecordInputPressed(PlayerClimbing __instance)
{
//IL_0006: 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_0055: Unknown result type (might be due to invalid IL or missing references)
if (Input.GetKeyDown(InputControlManager.current._jump))
{
_inputJump.UpdateState(state: true);
}
else if (Input.GetKeyUp(InputControlManager.current._jump))
{
_inputJump.UpdateState(state: false);
}
if (!NetworkClient.active || (int)__instance._player._currentPlayerAction != 0 || (double)__instance._climbAttachBuffer > 0.0 || Object.op_Implicit((Object)(object)__instance._ropeParent) || __instance._pCombat._isAirAttacked || __instance._pCombat._localAirAttackInput || __instance._pCombat._isChargingWeapon || __instance._pCombat._isBlocking || __instance._pCombat._localBlockingInput || __instance._pMove._lockControlMidair || (double)__instance._pMove._lockControlBuffer > 0.0)
{
return true;
}
if (__instance._onLedge)
{
HandleOnLedge(__instance);
return false;
}
return true;
}
private static void HandleOnLedge(PlayerClimbing instance)
{
//IL_005c: 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)
//IL_0080: 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)
if (!Object.op_Implicit((Object)(object)instance._parentGroundTypeObject))
{
instance._onLedge = false;
instance._isClimbing = false;
instance._climbAttachBuffer = instance._climbInitBuffer;
return;
}
instance._pCombat._blockControlBuffer = 0f;
instance._ledgeGrabBuffer = 0.12f;
Transform transform = ((Component)instance).transform;
Vector3 val = ((RaycastHit)(ref instance._hit)).point - ((Component)instance).transform.position;
val.y = 0f;
transform.rotation = Quaternion.LookRotation(((Vector3)(ref val)).normalized);
if (!instance._parentGroundTypeObject._canLedgeClimb)
{
instance.Init_JumpOffLedgeGrab(20f, -25.5f, 45.5f);
}
if (_inputJump.PressedWithinUnscaled(ControlTweaksPlugin.JumpBufferDuration))
{
float num = (instance._parentGroundTypeObject._noForwardForceOnLedgeJump ? instance._ledgeJumpUpForce : 0f);
instance.Init_JumpOffLedgeGrab(instance._ledgeJumpUpForce, num, 65f);
_inputJump.Consume();
}
}
}
}
public static class WalkPatches
{
[HarmonyPatch(typeof(PlayerMove))]
private static class WalkPatch
{
[HarmonyTargetMethod]
public static MethodBase FindApplyMovementParams()
{
return AccessTools.FirstMethod(typeof(PlayerMove), (Func<MethodInfo, bool>)((MethodInfo method) => method.Name.Contains("Apply_MovementParams")));
}
[HarmonyPrefix]
private static void ApplyWalkModifier(PlayerMove __instance, out Vector3 __state)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: 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)
__state = __instance._worldSpaceInput;
if (IsWalking())
{
__instance._worldSpaceInput *= ControlTweaksPlugin.WalkSpeed;
}
}
[HarmonyPostfix]
private static void RevertWalkModifier(PlayerMove __instance, Vector3 __state)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
__instance._worldSpaceInput = __state;
}
}
[HarmonyPatch(typeof(PlayerVisual), "Iterate_AnimationCondition")]
private static class AnimationPatches
{
[HarmonyPostfix]
private static void PatchWalkAnimation(PlayerVisual __instance)
{
if (NetworkClient.active && Object.op_Implicit((Object)(object)__instance._playerRaceModel) && Object.op_Implicit((Object)(object)__instance._visualAnimator))
{
float num = __instance._playerRaceModel._baseMovementMultiplier * __instance._movementAnimSpeedMod;
if (IsWalking())
{
num *= ControlTweaksPlugin.WalkSpeed;
}
__instance._visualAnimator.SetFloat("_movAnimSpd", Mathf.Max(0.75f, num));
}
}
}
private static ValueChange<bool> _walkToggleState;
private static bool _isWalkingToggled;
private static bool IsWalking()
{
//IL_0032: 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)
if (!ControlTweaksPlugin.WalkToggle)
{
_walkToggleState.SetValue(value: false);
_isWalkingToggled = false;
return Input.GetKey(ControlTweaksPlugin.WalkKey);
}
_walkToggleState.SetValue(Input.GetKey(ControlTweaksPlugin.WalkKey));
if ((bool)_walkToggleState && _walkToggleState.Changed)
{
_isWalkingToggled = !_isWalkingToggled;
}
return _isWalkingToggled;
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}