Decompiled source of PadAssist v0.16.1
PadAssist.dll
Decompiled 2 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using AIGraph; using Agents; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Core.Logging.Interpolation; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using CellMenu; using CharacterDestruction; using Enemies; using GameData; using Gear; using HarmonyLib; using Il2CppInterop.Runtime; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSystem; using Il2CppSystem.Collections.Generic; using Il2CppSystem.Reflection; using InControl; using LevelGeneration; using Localization; using Microsoft.CodeAnalysis; using MirrMods; using Player; using StateMachines; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("PadAssist")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+df0c5b38624247da40d44e16a8301e00557f5596")] [assembly: AssemblyProduct("PadAssist")] [assembly: AssemblyTitle("PadAssist")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [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 MirrMods { internal static class ModsTab { public static class Order { public const int CouchCoop = 800; public const int PadAssist = 700; public const int Map3D = 600; public const int LogTracker = 500; public const int Boosters = 400; } [HarmonyPatch(typeof(CM_PageSettings), "CreateKeyMappingSubMenu")] private static class AfterGamepad { [HarmonyPriority(0)] private static void Postfix(CM_PageSettings __instance, eSettingsSubMenuId subMenuId) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown if ((int)subMenuId != 7) { return; } try { Make(__instance); } catch (Exception ex) { if (_errors++ < 5) { bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(20, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("MIRR'S MODS"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": the tab not made: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex); } L.LogError(val); } } } } [HarmonyPatch(typeof(Text), "UpdateAllTexts")] private static class Texts { private static void Postfix() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown try { Named(); } catch (Exception ex) { if (_errors++ < 5) { bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(18, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("MIRR'S MODS"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": the tab's name: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message); } L.LogError(val); } } } } public const string Name = "MIRR'S MODS"; public const eSettingsSubMenuId Id = (eSettingsSubMenuId)98000; private const string Marker = "MirrModsTab"; private const uint GameText = 68u; private static readonly Color Frame = new Color(56f / 85f, 7f / 85f, 0.16862746f, 1f); private static readonly Color Text = new Color(0.8235294f, 0.101960786f, 18f / 85f, 1f); private static readonly ManualLogSource L = Logger.CreateLogSource(typeof(ModsTab).Assembly.GetName().Name + " settings tab"); private static CM_PageSettings _page; private static int _errors; private static void Make(CM_PageSettings page) { //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Expected O, but got Unknown //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Expected O, but got Unknown _page = page; if ((Object)(object)Window() != (Object)null) { return; } HashSet<IntPtr> hashSet = new HashSet<IntPtr>(); foreach (CM_Item componentsInChild in ((Component)page).GetComponentsInChildren<CM_Item>(true)) { hashSet.Add(((Il2CppObjectBase)componentsInChild).Pointer); } page.CreateSubmenu(68u, (eSettingsSubMenuId)98000, new List<iSettingsFieldData>(), true, false); List<CM_ScrollWindow> allSettingsWindows = page.m_allSettingsWindows; CM_ScrollWindow val = ((allSettingsWindows != null && allSettingsWindows.Count > 0) ? allSettingsWindows[allSettingsWindows.Count - 1] : null); CM_Item val2 = null; foreach (CM_Item componentsInChild2 in ((Component)page).GetComponentsInChildren<CM_Item>(true)) { if (!hashSet.Contains(((Il2CppObjectBase)componentsInChild2).Pointer) && !((Object)(object)((Il2CppObjectBase)componentsInChild2).TryCast<CM_ScrollWindow>() != (Object)null) && (!((Object)(object)val != (Object)null) || !((Component)componentsInChild2).transform.IsChildOf(((Component)val).transform))) { val2 = componentsInChild2; break; } } bool flag = default(bool); if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null) { BepInExErrorLogInterpolatedStringHandler val3 = new BepInExErrorLogInterpolatedStringHandler(49, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>("MIRR'S MODS"); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(": the game's new tab not found (window "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<bool>((Object)(object)val != (Object)null); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(", button "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<bool>((Object)(object)val2 != (Object)null); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(")"); } L.LogError(val3); } else { ((Object)((Component)val).gameObject).name = "MirrModsTab"; ((Object)((Component)val2).gameObject).name = "MirrModsTab"; Named(); Tint(val2); BepInExInfoLogInterpolatedStringHandler val4 = new BepInExInfoLogInterpolatedStringHandler(52, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>("MIRR'S MODS"); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(": the tab made in the settings after GAMEPAD MAPPING"); } L.LogInfo(val4); } } public static void Tint(CM_Item tab) { //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Expected O, but got Unknown //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_002d: 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_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_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: 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_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)tab == (Object)null) { return; } try { foreach (TextMeshPro componentsInChild in ((Component)tab).GetComponentsInChildren<TextMeshPro>(true)) { ((Graphic)componentsInChild).color = As(Text, ((Graphic)componentsInChild).color); } foreach (SpriteRenderer componentsInChild2 in ((Component)tab).GetComponentsInChildren<SpriteRenderer>(true)) { componentsInChild2.color = As(Frame, componentsInChild2.color); } if ((Object)(object)tab.m_hoverSprite != (Object)null) { tab.m_hoverSprite.color = As(Frame, tab.m_hoverSprite.color); } tab.m_spriteColorOrg = As(Frame, tab.m_spriteColorOrg); tab.m_spriteColorOut = As(Frame, tab.m_spriteColorOut); tab.m_spriteColorOver = As(Frame, tab.m_spriteColorOver); tab.m_customSpriteDefaultColor = As(Frame, tab.m_customSpriteDefaultColor); tab.m_customSpriteHoverColor = As(Frame, tab.m_customSpriteHoverColor); Each(tab.m_textColorOrg); Each(tab.m_textColorOut); Each(tab.m_textColorOver); } catch (Exception ex) { if (_errors++ < 5) { bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(20, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("MIRR'S MODS"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": a tab not tinted: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message); } L.LogError(val); } } } private static Color As(Color tint, Color was) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: 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_0018: Unknown result type (might be due to invalid IL or missing references) return new Color(tint.r, tint.g, tint.b, was.a); } private static void Each(Il2CppStructArray<Color> colours) { //IL_000a: 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_0016: Unknown result type (might be due to invalid IL or missing references) if (colours != null) { for (int i = 0; i < ((Il2CppArrayBase<Color>)(object)colours).Length; i++) { ((Il2CppArrayBase<Color>)(object)colours)[i] = As(Text, ((Il2CppArrayBase<Color>)(object)colours)[i]); } } } private static CM_ScrollWindow Window() { List<CM_ScrollWindow> val = (((Object)(object)_page != (Object)null && !((Il2CppObjectBase)_page).WasCollected) ? _page.m_allSettingsWindows : null); if (val == null) { return null; } for (int i = 0; i < val.Count; i++) { if ((Object)(object)val[i] != (Object)null && ((Object)((Component)val[i]).gameObject).name == "MirrModsTab") { return val[i]; } } return null; } private static void Named() { CM_ScrollWindow val = Window(); if ((Object)(object)val == (Object)null) { return; } val.SetText("MIRR'S MODS"); foreach (CM_Item componentsInChild in ((Component)_page).GetComponentsInChildren<CM_Item>(true)) { if (((Object)((Component)componentsInChild).gameObject).name == "MirrModsTab" && (Object)(object)((Il2CppObjectBase)componentsInChild).TryCast<CM_ScrollWindow>() == (Object)null) { componentsInChild.SetText("MIRR'S MODS"); break; } } } } } namespace PadAssist { internal static class AimAssist { internal class State { public FPSCamera Cam; public LocalPlayerAgent Owner; public IntPtr OwnerAt; public float Stick; public float YawBefore; public float PitchBefore; public float Slow = 1f; public float PadAt = -100f; public float PickAt; public float SnapUntil; public IntPtr Item; public bool Gun; public bool Shotgun; public MeleeWeaponFirstPerson Melee; public EnemyAgent Enemy; public Dam_EnemyDamageLimb Limb; public Collider Part; public Transform Bone; public string What = ""; public IntPtr Left; public float LeftUntil; public IntPtr SpotOf; public float SpotAt; public Vector3 SpotPos; public int Targets; public int Snaps; public float Angle; public float Distance; public float Turned; public bool Aiming; public float LogFrom = -1f; public float SumSnap; public float SumPull; public float SumFollow; public float SumAll; public float SumAiming; } [HarmonyPatch(typeof(LookCameraController), "GamepadLookUpdate")] private static class Look { private static void Prefix(LookCameraController __instance, float axisHor, float axisVer) { //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Expected O, but got Unknown //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Invalid comparison between Unknown and I4 try { if (!(Settings.AimStrength <= 0f) && !((Object)(object)__instance == (Object)null) && (int)GameStateManager.CurrentStateName == 10) { State state = For(__instance); if (state != null) { float lookSpeedModifier = state.Cam.m_lookSpeedModifier; float num = Mathf.Sqrt(axisHor * axisHor + axisVer * axisVer); state.Stick = Mathf.Clamp01((lookSpeedModifier > 0.01f) ? (num / lookSpeedModifier) : num); state.YawBefore = ((LookCameraController)state.Cam).m_yaw; state.PitchBefore = ((LookCameraController)state.Cam).m_pitch; } } } catch (Exception ex) { if (_errors++ < 5) { ManualLogSource l = Plugin.L; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(23, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("aim assist, the stick: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex); } l.LogError(val); } } } private static void Postfix(LookCameraController __instance) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Invalid comparison between Unknown and I4 try { if (!(Settings.AimStrength <= 0f) && !((Object)(object)__instance == (Object)null) && (int)GameStateManager.CurrentStateName == 10) { State state = For(__instance); if (state != null) { Step(state); } } } catch (Exception ex) { if (_errors++ < 5) { ManualLogSource l = Plugin.L; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(12, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("aim assist: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex); } l.LogError(val); } } } } private const float MeleeReach = 4.5f; private const float EnemyRadius = 0.4f; private const float SnapTime = 0.22f; private const float PullGain = 16f; private const float HipReach = 0.6f; private const float StickTurns = 0.05f; private const float StickRest = 0.15f; private const float StickFree = 0.7f; private const float SlowMost = 0.7f; private const float HeadFavour = 0.5f; private static readonly Dictionary<IntPtr, State> States = new Dictionary<IntPtr, State>(); private static int _errors; private static int _enemyErrors; private static float _tidyAt; public static void Update() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Invalid comparison between Unknown and I4 if (States.Count == 0) { return; } if ((int)GameStateManager.CurrentStateName != 10) { States.Clear(); return; } float unscaledTime = Time.unscaledTime; if (unscaledTime < _tidyAt) { return; } _tidyAt = unscaledTime + 5f; List<IntPtr> list = null; foreach (KeyValuePair<IntPtr, State> state in States) { if (state.Value != null && (Object)(object)state.Value.Cam == (Object)null) { (list ?? (list = new List<IntPtr>())).Add(state.Key); } } if (list == null) { return; } foreach (IntPtr item in list) { States.Remove(item); } } private static State For(LookCameraController look) { if (States.TryGetValue(((Il2CppObjectBase)look).Pointer, out var value)) { return value; } FPSCamera val = ((Il2CppObjectBase)look).TryCast<FPSCamera>(); value = (((Object)(object)val == (Object)null) ? null : new State { Cam = val }); States[((Il2CppObjectBase)look).Pointer] = value; return value; } private static void Drop(State s) { s.Enemy = null; s.Limb = null; s.Part = null; s.Bone = null; s.What = ""; s.SpotOf = IntPtr.Zero; } private static void Rest(State s) { Drop(s); s.Aiming = false; s.SnapUntil = 0f; } private static void Step(State s) { //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Expected O, but got Unknown //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Invalid comparison between Unknown and I4 //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Invalid comparison between Unknown and I4 //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: Invalid comparison between Unknown and I4 //IL_041e: Unknown result type (might be due to invalid IL or missing references) //IL_0423: 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_042b: Unknown result type (might be due to invalid IL or missing references) //IL_042e: Unknown result type (might be due to invalid IL or missing references) //IL_0433: Unknown result type (might be due to invalid IL or missing references) //IL_048f: Unknown result type (might be due to invalid IL or missing references) //IL_0491: Unknown result type (might be due to invalid IL or missing references) //IL_0493: Unknown result type (might be due to invalid IL or missing references) //IL_0525: Unknown result type (might be due to invalid IL or missing references) //IL_052a: Unknown result type (might be due to invalid IL or missing references) //IL_052e: Unknown result type (might be due to invalid IL or missing references) //IL_0518: Unknown result type (might be due to invalid IL or missing references) //IL_0533: Unknown result type (might be due to invalid IL or missing references) //IL_0535: Unknown result type (might be due to invalid IL or missing references) //IL_0537: Unknown result type (might be due to invalid IL or missing references) //IL_0539: Unknown result type (might be due to invalid IL or missing references) //IL_053e: Unknown result type (might be due to invalid IL or missing references) //IL_0540: Unknown result type (might be due to invalid IL or missing references) //IL_0555: Unknown result type (might be due to invalid IL or missing references) //IL_055f: Unknown result type (might be due to invalid IL or missing references) //IL_0569: Unknown result type (might be due to invalid IL or missing references) //IL_0578: Unknown result type (might be due to invalid IL or missing references) //IL_057a: Unknown result type (might be due to invalid IL or missing references) //IL_05ba: Unknown result type (might be due to invalid IL or missing references) //IL_05bc: Unknown result type (might be due to invalid IL or missing references) //IL_05be: Unknown result type (might be due to invalid IL or missing references) //IL_05c3: Unknown result type (might be due to invalid IL or missing references) //IL_05c5: Unknown result type (might be due to invalid IL or missing references) //IL_05c7: Unknown result type (might be due to invalid IL or missing references) //IL_05c9: Unknown result type (might be due to invalid IL or missing references) //IL_05ce: Unknown result type (might be due to invalid IL or missing references) //IL_05d0: Unknown result type (might be due to invalid IL or missing references) //IL_05d7: Unknown result type (might be due to invalid IL or missing references) //IL_05e5: Unknown result type (might be due to invalid IL or missing references) //IL_05ec: Unknown result type (might be due to invalid IL or missing references) //IL_06c4: Unknown result type (might be due to invalid IL or missing references) //IL_06c6: Unknown result type (might be due to invalid IL or missing references) //IL_0643: Unknown result type (might be due to invalid IL or missing references) //IL_0646: 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_064d: Unknown result type (might be due to invalid IL or missing references) //IL_0652: Unknown result type (might be due to invalid IL or missing references) //IL_0657: Unknown result type (might be due to invalid IL or missing references) //IL_0659: Unknown result type (might be due to invalid IL or missing references) //IL_065b: Unknown result type (might be due to invalid IL or missing references) //IL_065d: Unknown result type (might be due to invalid IL or missing references) //IL_0662: Unknown result type (might be due to invalid IL or missing references) //IL_0664: Unknown result type (might be due to invalid IL or missing references) //IL_066b: Unknown result type (might be due to invalid IL or missing references) //IL_0679: 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) s.Slow = 1f; FPSCamera cam = s.Cam; float unscaledTime = Time.unscaledTime; LocalPlayerAgent owner = cam.m_owner; IntPtr intPtr = (((Object)(object)owner != (Object)null) ? ((Il2CppObjectBase)owner).Pointer : IntPtr.Zero); if (intPtr != s.OwnerAt) { Rest(s); s.Owner = owner; s.OwnerAt = intPtr; s.Item = IntPtr.Zero; bool flag = (s.Gun = (s.Shotgun = false)); s.Melee = null; s.Targets = 0; s.LogFrom = -1f; if ((Object)(object)owner != (Object)null) { ManualLogSource l = Plugin.L; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(25, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("aim assist: a camera for "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(Name(s)); } l.LogInfo(val); } } Log(s, unscaledTime); if ((Object)(object)owner == (Object)null || !((Agent)owner).Alive || (int)GameStateManager.CurrentStateName != 10) { Rest(s); return; } bool flag2 = s.Stick > 0.05f; InputDevice val2 = Pad.Of((PlayerAgent)(object)owner); if (val2 != null) { float value = ((OneAxisInputControl)val2.LeftStickX).Value; float value2 = ((OneAxisInputControl)val2.LeftStickY).Value; if ((flag2 | (value * value + value2 * value2 > 0.04f || ((OneAxisInputControl)val2.LeftTrigger).Value > 0.2f || ((OneAxisInputControl)val2.RightTrigger).Value > 0.2f)) || val2.AnyButtonIsPressed || Pad.JustUsed(val2)) { s.PadAt = unscaledTime; } } bool flag3 = unscaledTime - s.PadAt > 2f; if (flag3 && !s.Aiming) { Rest(s); return; } FirstPersonItemHolder fPItemHolder = ((PlayerAgent)owner).FPItemHolder; ItemEquippable val3 = (((Object)(object)fPItemHolder != (Object)null) ? fPItemHolder.WieldedItem : null); IntPtr intPtr2 = (((Object)(object)val3 != (Object)null) ? ((Il2CppObjectBase)val3).Pointer : IntPtr.Zero); if (intPtr2 != s.Item) { s.Item = intPtr2; s.Gun = intPtr2 != IntPtr.Zero && (Object)(object)((Il2CppObjectBase)val3).TryCast<BulletWeapon>() != (Object)null; s.Shotgun = s.Gun && IsShotgun(val3); s.Melee = ((intPtr2 == IntPtr.Zero || s.Gun) ? null : ((Il2CppObjectBase)val3).TryCast<MeleeWeaponFirstPerson>()); } bool flag4 = (Object)(object)s.Melee != (Object)null && Settings.AimMelee; if (!s.Gun && !flag4) { Rest(s); return; } bool flag5; if (s.Gun) { flag5 = fPItemHolder.ItemAimTrigger; } else { eMeleeWeaponState currentStateName = s.Melee.CurrentStateName; flag5 = (int)currentStateName == 7 || (int)currentStateName == 9; } if (flag3 && !flag5) { Rest(s); return; } bool flag6 = flag5 && !s.Aiming; s.Aiming = flag5; if (!flag5) { s.SnapUntil = 0f; } bool flag7 = s.Stick > 0.05f; if (!flag5 && (!Settings.AimHip || !flag7)) { Drop(s); return; } float num = (flag5 ? Settings.AimSnap : 0f); float num2 = (flag5 ? Settings.AimPull : 0f); float aimFollow = Settings.AimFollow; float aimSlowdown = Settings.AimSlowdown; float num3 = (flag4 ? Mathf.Min(30f, Settings.AimReach * 2.5f) : Settings.AimReach); if (!flag5) { num3 *= 0.6f; } else if (!flag4 && (flag6 || unscaledTime < s.SnapUntil)) { num3 *= 1.5f; } float num4 = (flag4 ? 4.5f : Settings.AimRange); float num5 = Mathf.DeltaAngle(s.YawBefore, ((LookCameraController)cam).m_yaw); float num6 = ((LookCameraController)cam).m_pitch - s.PitchBefore; float num7 = Mathf.Sqrt(num5 * num5 + num6 * num6); bool steering = s.Stick > 0.2f && num7 > 0.0001f; float num8 = 0f; float num9 = 0f; if (num7 > 0.0001f) { num8 = num5 / num7; num9 = num6 / num7; } Vector3 position = cam.Position; Vector3 forward = cam.Forward; Quaternion val4 = Frame(cam); if (((Object)(object)s.Enemy != (Object)null && (!((Agent)s.Enemy).Alive || ((Object)(object)s.Limb != (Object)null && s.Limb.IsDestroyed))) || flag6 || unscaledTime >= s.PickAt) { s.PickAt = unscaledTime + 0.08f; Pick(s, (PlayerAgent)(object)owner, position, forward, val4, num3, num4, flag4, steering, num8, num9, unscaledTime); if (flag6 && (Object)(object)s.Enemy != (Object)null && num > 0f) { s.SnapUntil = unscaledTime + 0.22f; s.Snaps++; } } if ((Object)(object)s.Enemy == (Object)null) { return; } if (s.Stick > 0.7f) { s.SnapUntil = 0f; } Vector3 val5; if (!((Object)(object)s.Part != (Object)null)) { val5 = s.Bone.position; } else { Bounds bounds = s.Part.bounds; val5 = ((Bounds)(ref bounds)).center; } Vector3 val6 = val5; Vector3 val7 = Minus(val6, position); float num10 = Length(val7); if (num10 < 0.3f) { return; } Vector3 val8 = default(Vector3); ((Vector3)(ref val8))..ctor(val7.x / num10, val7.y / num10, val7.z / num10); float num11 = (s.Angle = Angle(forward, val8)); s.Distance = num10; if (num11 - Width(num10) > num3 * 1.3f || num10 > num4 * 1.2f) { Drop(s); return; } Vector3 d = In(val4, forward); Vector3 d2 = In(val4, val8); float num12 = Mathf.DeltaAngle(Yaw(d), Yaw(d2)); float num13 = Pitch(d2) - Pitch(d); float deltaTime = Time.deltaTime; float num14 = 0f; float num15 = 0f; IntPtr pointer = ((Il2CppObjectBase)s.Bone).Pointer; if (aimFollow > 0f && pointer == s.SpotOf && unscaledTime - s.SpotAt < 0.1f) { Vector3 d3 = In(val4, Minus(s.SpotPos, position)); Vector3 d4 = In(val4, val7); float num16 = Mathf.DeltaAngle(Yaw(d3), Yaw(d4)); float num17 = Pitch(d4) - Pitch(d3); if (Mathf.Abs(num16) < 8f && Mathf.Abs(num17) < 8f) { num14 = num16 * aimFollow; num15 = num17 * aimFollow; } } s.SpotOf = pointer; s.SpotAt = unscaledTime; s.SpotPos = val6; float num18 = 0f; float num19 = 0f; if (num11 > 0.03f) { float num20 = Mathf.Clamp01((0.7f - s.Stick) / 0.54999995f); num18 = 1f - Mathf.Exp((0f - num2) * 16f * num20 * deltaTime); if (unscaledTime < s.SnapUntil) { num19 = 1f - Mathf.Pow(1f - Mathf.Min(num, 0.98f), deltaTime / 0.22f); } } float num21 = 1f - (1f - num18) * (1f - num19); float num22 = num12 * num21 + num14; float num23 = num13 * num21 + num15; if (s.Stick > 0.1f && num7 > 0.0001f) { float num24 = num22 * num8 + num23 * num9; if (num24 < 0f) { num22 -= num24 * num8; num23 -= num24 * num9; } } float num25 = Mathf.Sqrt(num22 * num22 + num23 * num23); if (num25 > 1E-05f) { s.Turned += num25; s.SumAll += num25; if (flag5) { s.SumAiming += num25; } s.SumSnap += num11 * num19; s.SumPull += num11 * num18 * (1f - num19); s.SumFollow += Mathf.Sqrt(num14 * num14 + num15 * num15); } else { num22 = (num23 = 0f); } float num26 = Width(num10) + 1.5f; if (aimSlowdown > 0f && num11 < num26 && num7 > 0.0001f) { s.Slow = 1f - 0.7f * aimSlowdown * (1f - num11 / num26); num22 -= num5 * (1f - s.Slow); num23 -= num6 * (1f - s.Slow); } if (num22 != 0f || num23 != 0f) { Turn(cam, num22, num23); } } private static void Turn(FPSCamera cam, float yaw, float pitch) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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_0033: 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_003c: Unknown result type (might be due to invalid IL or missing references) ((LookCameraController)cam).m_yaw = ((LookCameraController)cam).m_yaw + yaw; float num = ((LookCameraController)cam).m_pitch + pitch; Vector2 pitchLimit = ((LookCameraController)cam).m_pitchLimit; if (num < 0f - pitchLimit.x) { num = 0f - pitchLimit.x; } else if (num > 0f - pitchLimit.y) { num = 0f - pitchLimit.y; } ((LookCameraController)cam).m_pitch = num; } private static void Log(State s, float now) { //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Expected O, but got Unknown if (s.LogFrom < 0f) { s.LogFrom = now; } else { if (now - s.LogFrom < 1f) { return; } if (s.SumAll >= 1f) { string text = (((Object)(object)s.Enemy != (Object)null) ? $"; now on {((Object)s.Enemy).name}'s {s.What}, {s.Distance:0} m, {s.Angle:0.0} degrees off" : ""); ManualLogSource l = Plugin.L; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(80, 8, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("aim assist: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(Name(s)); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'s view turned "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(s.SumAll, "0.0"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" degrees in "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(now - s.LogFrom, "0.0"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" s "); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(s.SumAiming, "0.0"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" of it aiming): snap "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(s.SumSnap, "0.0"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", pull "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(s.SumPull, "0.0"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", follow "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(s.SumFollow, "0.0"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text); } l.LogInfo(val); } s.LogFrom = now; s.SumSnap = (s.SumPull = (s.SumFollow = (s.SumAll = (s.SumAiming = 0f)))); } } private static Vector3 Minus(Vector3 a, Vector3 b) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_0013: 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_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) return new Vector3(a.x - b.x, a.y - b.y, a.z - b.z); } private static float Length(Vector3 v) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_0013: 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_0021: Unknown result type (might be due to invalid IL or missing references) return Mathf.Sqrt(v.x * v.x + v.y * v.y + v.z * v.z); } private static float Width(float distance) { return Mathf.Atan2(0.4f, distance) * 57.29578f; } private static float Angle(Vector3 a, Vector3 b) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_0013: 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_0021: 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_0035: 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_0042: 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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Sqrt(a.x * a.x + a.y * a.y + a.z * a.z); float num2 = Mathf.Sqrt(b.x * b.x + b.y * b.y + b.z * b.z); if (num < 1E-06f || num2 < 1E-06f) { return 180f; } return Mathf.Acos(Mathf.Clamp((a.x * b.x + a.y * b.y + a.z * b.z) / (num * num2), -1f, 1f)) * 57.29578f; } private static float Yaw(Vector3 d) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) return Mathf.Atan2(d.x, d.z) * 57.29578f; } private static float Pitch(Vector3 d) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_0013: 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_0021: 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) float num = Mathf.Sqrt(d.x * d.x + d.y * d.y + d.z * d.z); if (!(num < 1E-06f)) { return (0f - Mathf.Asin(Mathf.Clamp(d.y / num, -1f, 1f))) * 57.29578f; } return 0f; } private static Quaternion Frame(FPSCamera cam) { //IL_0043: 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) Transform parent = ((Component)cam).transform.parent; Transform val = (((Object)(object)parent != (Object)null) ? parent.parent : null); if (!((Object)(object)val != (Object)null)) { return new Quaternion(0f, 0f, 0f, 1f); } return val.rotation; } private static Vector3 In(Quaternion q, Vector3 v) { //IL_0000: 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_0010: 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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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_0046: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) float num = 0f - q.x; float num2 = 0f - q.y; float num3 = 0f - q.z; float w = q.w; float num4 = 2f * (num2 * v.z - num3 * v.y); float num5 = 2f * (num3 * v.x - num * v.z); float num6 = 2f * (num * v.y - num2 * v.x); return new Vector3(v.x + w * num4 + (num2 * num6 - num3 * num5), v.y + w * num5 + (num3 * num4 - num * num6), v.z + w * num6 + (num * num5 - num2 * num4)); } private static string Name(State s) { try { return ((Object)(object)s.Owner != (Object)null) ? $"{((PlayerAgent)s.Owner).PlayerName ?? "a player"} (slot {((PlayerAgent)s.Owner).PlayerSlotIndex + 1})" : "a player"; } catch { return "a player"; } } private static void Pick(State s, PlayerAgent owner, Vector3 pos, Vector3 forward, Quaternion frame, float cone, float range, bool melee, bool steering, float turnYaw, float turnPitch, float now) { //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Expected O, but got Unknown //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0044: 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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: 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_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: 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_00da: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Unknown result type (might be due to invalid IL or missing references) //IL_0316: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0132: 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_0145: 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_0153: 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_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016d: 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_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_0371: Unknown result type (might be due to invalid IL or missing references) //IL_0378: Expected O, but got Unknown //IL_021b: 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_0223: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) AIG_CourseNode courseNode = ((Agent)owner).CourseNode; List<EnemyAgent> val = ((courseNode != null) ? AIG_CourseGraph.GetReachableEnemiesInNodes(courseNode, 3) : null); if (val == null) { Drop(s); return; } IntPtr intPtr = (((Object)(object)s.Enemy != (Object)null) ? ((Il2CppObjectBase)s.Enemy).Pointer : IntPtr.Zero); bool flag = false; Vector3 d = In(frame, forward); float num = Yaw(d); float num2 = Pitch(d); List<(float, EnemyAgent)> list = new List<(float, EnemyAgent)>(); int count = val.Count; bool flag2 = default(bool); for (int i = 0; i < count; i++) { try { EnemyAgent val2 = val[i]; if ((Object)(object)val2 == (Object)null || !((Agent)val2).Alive) { continue; } Vector3 val3 = Minus(((Agent)val2).AimTargetBody.position, pos); float num3 = Length(val3); if (num3 > range) { continue; } Vector3 val4 = Minus(((Agent)val2).AimTarget.position, pos); float num4 = Angle(forward, val3); float num5 = Angle(forward, val4); float num6 = Width(num3); float num7 = Mathf.Min(num4, num5); if (melee) { Vector3 position = ((Agent)val2).AimTargetBody.position; Vector3 position2 = val2.Position; for (float num8 = 0.35f; num8 < 1f; num8 += 0.3f) { num7 = Mathf.Min(num7, Angle(forward, new Vector3(position.x + (position2.x - position.x) * num8 - pos.x, position.y + (position2.y - position.y) * num8 - pos.y, position.z + (position2.z - position.z) * num8 - pos.z))); } } float num9 = Mathf.Max(0f, num7 - num6); if (num9 > cone) { continue; } float num10 = num9 + num3 * 0.05f; IntPtr pointer = ((Il2CppObjectBase)val2).Pointer; if (pointer == intPtr) { num10 -= cone * 0.25f; } if (pointer == s.Left && now < s.LeftUntil) { num10 += cone; } if (steering) { Vector3 d2 = In(frame, (num5 < num4) ? val4 : val3); if (Mathf.DeltaAngle(num, Yaw(d2)) * turnYaw + (Pitch(d2) - num2) * turnPitch < 0f - (num6 + 1f)) { num10 += cone; if (pointer == intPtr) { flag = true; } } } list.Add((num10, val2)); } catch (Exception ex) { if (_enemyErrors++ < 5) { ManualLogSource l = Plugin.L; BepInExErrorLogInterpolatedStringHandler val5 = new BepInExErrorLogInterpolatedStringHandler(22, 1, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("aim assist, an enemy: "); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(ex.Message); } l.LogError(val5); } } } list.Sort(((float score, EnemyAgent enemy) a, (float score, EnemyAgent enemy) b) => a.score.CompareTo(b.score)); for (int num11 = 0; num11 < list.Count && num11 < 3; num11++) { if (!Choose(s, list[num11].Item2, pos, forward, melee)) { continue; } if (flag && ((Il2CppObjectBase)s.Enemy).Pointer != intPtr) { s.Left = intPtr; s.LeftUntil = now + 1.5f; } if (s.Targets++ == 0) { ManualLogSource l2 = Plugin.L; BepInExInfoLogInterpolatedStringHandler val6 = new BepInExInfoLogInterpolatedStringHandler(57, 5, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val6).AppendLiteral("aim assist: "); ((BepInExLogInterpolatedStringHandler)val6).AppendFormatted<string>(Name(s)); ((BepInExLogInterpolatedStringHandler)val6).AppendLiteral("'s first target: "); ((BepInExLogInterpolatedStringHandler)val6).AppendFormatted<string>(((Object)s.Enemy).name); ((BepInExLogInterpolatedStringHandler)val6).AppendLiteral(", its "); ((BepInExLogInterpolatedStringHandler)val6).AppendFormatted<string>(s.What); ((BepInExLogInterpolatedStringHandler)val6).AppendLiteral(", "); ((BepInExLogInterpolatedStringHandler)val6).AppendFormatted<int>(list.Count); ((BepInExLogInterpolatedStringHandler)val6).AppendLiteral(" in reach of "); ((BepInExLogInterpolatedStringHandler)val6).AppendFormatted<int>(count); ((BepInExLogInterpolatedStringHandler)val6).AppendLiteral(" around"); } l2.LogInfo(val6); } return; } Drop(s); } private static bool Sees(Vector3 from, Vector3 spot) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) return !Physics.Linecast(from, spot, LayerManager.MASK_SENTRYGUN_DETECTION_BLOCKERS); } private static Vector3 Middle(Dam_EnemyDamageLimb limb, out Collider part) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: 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_0018: Unknown result type (might be due to invalid IL or missing references) part = ((Component)limb).GetComponent<Collider>(); if (!((Object)(object)part != (Object)null)) { return ((Component)limb).transform.position; } Bounds bounds = part.bounds; return ((Bounds)(ref bounds)).center; } private static void Hold(State s, EnemyAgent e, Dam_EnemyDamageLimb limb, Collider part, string what) { s.Enemy = e; s.Limb = limb; s.Part = part; s.Bone = ((Component)limb).transform; s.What = what; } private static bool Choose(State s, EnemyAgent e, Vector3 pos, Vector3 forward, bool melee) { //IL_003c: 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_019d: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_0183: 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_0080: Invalid comparison between Unknown and I4 //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: 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_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_0127: 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) AimAt aimAt = Settings.AimAt; Il2CppReferenceArray<Dam_EnemyDamageLimb> val = (((Object)(object)e.Damage != (Object)null) ? e.Damage.DamageLimbs : null); if ((melee || s.Shotgun) && aimAt != AimAt.Body) { if (val != null && Part(s, e, val, pos, forward, aimAt, melee)) { return true; } } else if (aimAt == AimAt.WeakSpot && val != null) { List<(float, Dam_EnemyDamageLimb, Collider, Vector3)> list = new List<(float, Dam_EnemyDamageLimb, Collider, Vector3)>(); for (int i = 0; i < ((Il2CppArrayBase<Dam_EnemyDamageLimb>)(object)val).Length; i++) { Dam_EnemyDamageLimb val2 = ((Il2CppArrayBase<Dam_EnemyDamageLimb>)(object)val)[i]; if (!((Object)(object)val2 == (Object)null) && (int)val2.m_type == 1 && !val2.IsDestroyed) { Collider part; Vector3 val3 = Middle(val2, out part); list.Add((Angle(forward, new Vector3(val3.x - pos.x, val3.y - pos.y, val3.z - pos.z)), val2, part, val3)); } } list.Sort(((float angle, Dam_EnemyDamageLimb limb, Collider part, Vector3 at) a, (float angle, Dam_EnemyDamageLimb limb, Collider part, Vector3 at) b) => a.angle.CompareTo(b.angle)); foreach (var item in list) { if (Sees(pos, item.Item4)) { Hold(s, e, item.Item2, item.Item3, "weak spot"); return true; } } } if (!melee && !s.Shotgun && aimAt != AimAt.Body && Head(s, e, pos)) { return true; } Transform aimTargetBody = ((Agent)e).AimTargetBody; if ((Object)(object)aimTargetBody != (Object)null && Sees(pos, aimTargetBody.position)) { s.Enemy = e; s.Limb = null; s.Part = null; s.Bone = aimTargetBody; s.What = "body"; return true; } if (aimAt == AimAt.Body) { return Head(s, e, pos); } return false; } private static bool Head(State s, EnemyAgent e, Vector3 pos) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Invalid comparison between Unknown and I4 //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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_002d: Unknown result type (might be due to invalid IL or missing references) Dam_EnemyDamageLimb headLimb = e.m_headLimb; if ((Object)(object)headLimb == (Object)null || headLimb.IsDestroyed || (int)headLimb.m_type == 2) { return false; } Collider part; Vector3 spot = Middle(headLimb, out part); if (!Sees(pos, spot)) { return false; } Hold(s, e, headLimb, part, "head"); return true; } private static int ArmOrLeg(Dam_EnemyDamageLimb limb) { //IL_0013: 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_0019: 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_004d: Expected I4, but got Unknown CD_CharacterDestructionCollider destruction = limb.m_destruction; if ((Object)(object)destruction == (Object)null) { return 0; } CD_BodypartType bodyPart = destruction.m_bodyPart; switch (bodyPart - 2) { case 0: case 1: return 1; case 2: case 3: return 2; case 7: case 8: return 3; case 9: case 10: return 4; default: return 0; } } private static bool Part(State s, EnemyAgent e, Il2CppReferenceArray<Dam_EnemyDamageLimb> limbs, Vector3 pos, Vector3 forward, AimAt mode, bool melee) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Invalid comparison between Unknown and I4 //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0167: 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_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0188: 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_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: 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_0086: Invalid comparison between Unknown and I4 //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: 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_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0105: 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_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0203: 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) Dam_EnemyDamageLimb headLimb = e.m_headLimb; IntPtr intPtr = (((Object)(object)headLimb != (Object)null) ? ((Il2CppObjectBase)headLimb).Pointer : IntPtr.Zero); bool[] array = new bool[5]; List<(float, Dam_EnemyDamageLimb, Collider, Vector3, int, string)> list = new List<(float, Dam_EnemyDamageLimb, Collider, Vector3, int, string)>(); for (int i = 0; i < ((Il2CppArrayBase<Dam_EnemyDamageLimb>)(object)limbs).Length; i++) { Dam_EnemyDamageLimb val = ((Il2CppArrayBase<Dam_EnemyDamageLimb>)(object)limbs)[i]; if ((Object)(object)val == (Object)null) { continue; } int num = ArmOrLeg(val); if (val.IsDestroyed) { array[num] = true; } else { if ((int)val.m_type == 2) { continue; } float num2 = 1f; string item; if (mode == AimAt.WeakSpot && (int)val.m_type == 1) { item = "weak spot"; num2 = 0.5f; } else if (((Il2CppObjectBase)val).Pointer == intPtr) { item = "head"; num2 = 0.5f; } else { if (!melee || num == 0 || !val.HasDestruction()) { continue; } item = ((num <= 2) ? "arm" : "leg"); } Collider part; Vector3 val2 = Middle(val, out part); list.Add((Angle(forward, new Vector3(val2.x - pos.x, val2.y - pos.y, val2.z - pos.z)) * num2, val, part, val2, num, item)); } } Transform val3 = (melee ? null : ((Agent)e).AimTargetBody); if ((Object)(object)val3 != (Object)null) { Vector3 position = val3.position; list.Add((Angle(forward, new Vector3(position.x - pos.x, position.y - pos.y, position.z - pos.z)), null, null, position, 0, "body")); } list.Sort(((float score, Dam_EnemyDamageLimb limb, Collider part, Vector3 at, int which, string what) a, (float score, Dam_EnemyDamageLimb limb, Collider part, Vector3 at, int which, string what) b) => a.score.CompareTo(b.score)); foreach (var item2 in list) { if ((item2.Item5 == 0 || !array[item2.Item5]) && Sees(pos, item2.Item4)) { if ((Object)(object)item2.Item2 != (Object)null) { Hold(s, e, item2.Item2, item2.Item3, item2.Item6); } else { s.Enemy = e; s.Limb = null; s.Part = null; s.Bone = val3; s.What = "body"; } return true; } } return false; } private static bool IsShotgun(ItemEquippable item) { if ((Object)(object)((Il2CppObjectBase)item).TryCast<Shotgun>() != (Object)null) { return true; } try { return item.ArchetypeData != null && item.ArchetypeData.ShotgunBulletCount > 1; } catch { return false; } } public static string Describe() { //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: Unknown result type (might be due to invalid IL or missing references) List<string> list = new List<string> { $"aim assist: {Settings.AimText}; cameras {States.Count}" }; foreach (State value2 in States.Values) { if (value2 != null) { string value = (((Object)(object)value2.Enemy != (Object)null) ? $"{((Object)value2.Enemy).name}'s {value2.What}, {value2.Angle:0.0} degrees off, {value2.Distance:0.0} m" : "none"); list.Add($" {Name(value2)}: {(value2.Shotgun ? "shotgun" : (value2.Gun ? "gun" : (((Object)(object)value2.Melee != (Object)null) ? "melee" : "nothing to aim")))}{(value2.Aiming ? ", aiming" : "")}; stick {value2.Stick:0.00}, slowed to {value2.Slow:0.00}; controller used {Time.unscaledTime - value2.PadAt:0.0} s ago; target {value}; targets so far {value2.Targets}, snaps {value2.Snaps}, turned {value2.Turned:0} degrees; its frame turned {(((Object)(object)value2.Cam != (Object)null) ? Quaternion.Angle(Frame(value2.Cam), Quaternion.identity) : 0f):0.0} degrees from the world's"); } } return string.Join("\n", list); } } public static class Buttons { public enum Act { Jump, Crouch, Reload, Use, Flashlight, Aim, Fire, Run, Ping, Map, Main, Special, Melee, Tool, Comms, Next, Previous, NextWeapon, PreviousWeapon } private class State { public int Frame = -1; public IntPtr Pad; public readonly List<InputControlType> Eaten = new List<InputControlType>(); public InputAction Pending; public float PendingUntil; public readonly int[] TFrame = new int[19]; public readonly bool[] TDown = new bool[19]; public readonly bool[] TPrev = new bool[19]; public readonly float[] Peak = new float[19]; public readonly float[] Rest = new float[19]; public readonly bool[] Waits = new bool[2]; public readonly bool[] Uses = new bool[2]; public readonly float[] Since = new float[2]; public readonly InventorySlot[] Of = (InventorySlot[])(object)new InventorySlot[2]; public InventorySlot LastWeapon; public InventorySlot Asked; public float AskedAt = -10f; public bool Fed; public bool FedBefore; } public const int Acts = 19; private static readonly (string Title, InputControlType Default)[] Info = new(string, InputControlType)[19] { ("Jump", (InputControlType)19), ("Crouch", (InputControlType)20), ("Reload", (InputControlType)21), ("Use", (InputControlType)22), ("Flashlight", (InputControlType)13), ("Aim", (InputControlType)15), ("Fire", (InputControlType)16), ("Sprint", (InputControlType)5), ("Ping", (InputControlType)10), ("Map", (InputControlType)14), ("Main weapon", (InputControlType)11), ("Special weapon", (InputControlType)0), ("Melee weapon", (InputControlType)0), ("Tool, pack, consumable", (InputControlType)12), ("Communication", (InputControlType)100), ("Next item", (InputControlType)0), ("Previous item", (InputControlType)0), ("Next weapon", (InputControlType)18), ("Previous weapon", (InputControlType)17) }; public static readonly Act[] Listed = new Act[19] { Act.Jump, Act.Crouch, Act.Reload, Act.Use, Act.Flashlight, Act.Aim, Act.Fire, Act.Run, Act.Ping, Act.Map, Act.NextWeapon, Act.PreviousWeapon, Act.Main, Act.Special, Act.Melee, Act.Tool, Act.Comms, Act.Next, Act.Previous }; public static readonly InputControlType[] Controls; private static readonly string[] Labels; private static readonly string[] Helps; public static readonly string[] Presets; private static readonly ConfigEntry<string>[] Kept; private static readonly InputControlType[,] Table; private static int _errors; private static readonly string[] OldLeftHanded; private static readonly State[] States; private static readonly InventorySlot[] Cycle; private static readonly InputAction[] CycleAction; private static readonly InventorySlot[] Weapons; private static readonly InputAction[] WeaponAction; private static readonly Act[] WeaponAct; public const float HoldTime = 0.25f; private const float AskedFor = 1f; private const float PendFor = 0.8f; public static bool Wanted => Settings.OwnButtons; public static string Short(InputControlType c) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return Short(0, c); } public static string Short(int n, InputControlType c) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Invalid comparison between Unknown and I4 //IL_0005: 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_002e: Expected I4, but got Unknown //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Invalid comparison between Unknown and I4 //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Invalid comparison between Unknown and I4 //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Invalid comparison between Unknown and I4 //IL_00ea: Unknown result type (might be due to invalid IL or missing references) if ((int)c <= 102) { switch (c - 15) { case 4: return Settings.SouthOf(n); case 5: return Settings.EastOf(n); case 6: return Settings.WestOf(n); case 7: return Settings.NorthOf(n); case 2: return Styled(n, "LB", "L", "L1"); case 3: return Styled(n, "RB", "R", "R1"); case 0: return Styled(n, "LT", "ZL", "L2"); case 1: return Styled(n, "RT", "ZR", "R2"); } if ((int)c == 102) { goto IL_00e2; } } else if ((int)c == 107 || (int)c == 109 || (int)c == 113) { goto IL_00e2; } return Canon(c); IL_00e2: return "Back"; } private static string Styled(int n, string xbox, string nintendo, string playStation) { return Settings.NamesOf(n) switch { ButtonNames.Nintendo => nintendo, ButtonNames.PlayStation => playStation, _ => xbox, }; } private unsafe static string Canon(InputControlType c) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected I4, but got Unknown return (int)c switch { 0 => "-", 19 => "A", 20 => "B", 21 => "X", 22 => "Y", 17 => "LB", 18 => "RB", 15 => "LT", 16 => "RT", 5 => "L3", 10 => "R3", 11 => "D-Pad Up", 12 => "D-Pad Down", 13 => "D-Pad Left", 14 => "D-Pad Right", _ => ((object)(*(InputControlType*)(&c))/*cast due to .constrained prefix*/).ToString(), }; } public static string Title(Act a) { return Info[(int)a].Title; } public static string Label(Act a) { return Labels[(int)a]; } public static string Help(Act a) { return Helps[(int)a]; } public static List<Act> ActsOn(int n, InputControlType c) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0013: 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_0019: 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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) List<Act> list = new List<Act>(); if ((int)c == 0 || n < 1 || n > 4) { return list; } c = Plain(c); Act[] listed = Listed; foreach (Act act in listed) { if (Plain(Table[n, (int)act]) == c) { list.Add(act); } } return list; } public static InputControlType Plain(InputControlType c) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Invalid comparison between Unknown and I4 //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Invalid comparison between Unknown and I4 //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Invalid comparison between Unknown and I4 //IL_0024: Unknown result type (might be due to invalid IL or missing references) if ((int)c <= 107) { if ((int)c == 102 || (int)c == 107) { goto IL_001b; } } else if ((int)c == 109 || (int)c == 113) { goto IL_001b; } bool flag = false; goto IL_0021; IL_001b: flag = true; goto IL_0021; IL_0021: if (!flag) { return c; } return (InputControlType)100; } private static InputControlType PresetOf(int preset, int act) { //IL_000b: 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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0015: 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_002e: Expected I4, but got Unknown //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_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_0046: 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_0044: 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) InputControlType val = Info[act].Default; if (preset == 1) { val = (InputControlType)((val - 15) switch { 0 => 16, 1 => 15, 2 => 18, 3 => 17, _ => val, }); } return val; } public static int PresetOf(int n) { //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) if (n < 1 || n > 4) { return 0; } for (int i = 0; i < Presets.Length; i++) { bool flag = true; for (int j = 0; j < 19 && flag; j++) { flag = Table[n, j] == PresetOf(i, j); } if (flag) { return i; } } return -1; } public static void UsePreset(int n, int preset) { //IL_0024: 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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown if (n >= 1 && n <= 4 && preset >= 0 && preset < Presets.Length) { for (int i = 0; i < 19; i++) { Table[n, i] = PresetOf(preset, i); } Save(n); ManualLogSource l = Plugin.L; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(32, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("buttons: player "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(n); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": the layout "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(Presets[preset]); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(Line(n)); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")"); } l.LogInfo(val); } } public static void Clear(int n, InputControlType c) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000c: 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_0012: 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_0024: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown //IL_0034: 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) if (n < 1 || n > 4 || (int)c == 0) { return; } c = Plain(c); for (int i = 0; i < 19; i++) { if (Plain(Table[n, i]) == c) { Table[n, i] = (InputControlType)0; } } Save(n); ManualLogSource l = Plugin.L; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(34, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("buttons: player "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(n); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(Short(n, c)); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" does nothing ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(Line(n)); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")"); } l.LogInfo(val); } internal static ConfigEntry<string> Bind(ConfigFile config, int n) { return Kept[n] = config.Bind<string>("Buttons", $"Player {n}", "", "Player " + n + "'s own buttons on its controller, where they differ from the mod's: Action=Button pairs, e.g. \"Jump=X, Reload=A\" (the Xbox names, whatever names are shown; a button named takes the action that had it the button this one had). Actions: Jump, Crouch, Reload, Use, Flashlight, Aim, Fire, Run, Ping, Map, Main, Special, Melee, Tool, Comms, Next, Previous (item), NextWeapon, PreviousWeapon. Buttons: A, B, X, Y, LB, RB, LT, RT, L3, R3, DPadUp, DPadDown, DPadLeft, DPadRight, Back, None. Empty: the mod's buttons. Changed in the game's settings, CONTROLLERS. Player 1 is the one playing alone; 2-4 are CouchCoop's local players."); } internal static ConfigEntry<string> Entry(int n) { return Kept[n]; } public static void LoadAll() { for (int i = 1; i <= 4; i++) { Load(i); } } private static void Load(int n) { //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_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: 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_00fb: Expected O, but got Unknown //IL_0145: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < 19; i++) { Table[n, i] = Info[i].Default; } string text = Kept[n]?.Value; if (string.IsNullOrWhiteSpace(text)) { return; } if (WasLeftHanded(text)) { for (int j = 0; j < 19; j++) { Table[n, j] = PresetOf(1, j); } return; } string[] array = text.Split(','); bool flag = default(bool); foreach (string text2 in array) { string[] array2 = text2.Split('='); if (array2.Length == 2 && array2[0].Trim().Equals("Objectives", StringComparison.OrdinalIgnoreCase)) { continue; } if (array2.Length != 2 || !Enum.TryParse<Act>(array2[0].Trim(), ignoreCase: true, out var result) || result < Act.Jump || result >= (Act)19 || !Parse(array2[1].Trim(), out var c)) { ManualLogSource l = Plugin.L; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(47, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("buttons: player "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(n); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'s: '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text2.Trim()); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' not understood, left out"); } l.LogWarning(val); } else { Put(n, result, c); } } } private static bool WasLeftHanded(string s) { HashSet<string> hashSet = new HashSet<string>(); string[] array = s.Split(','); foreach (string text in array) { hashSet.Add(text.Replace(" ", "").ToLowerInvariant()); } return hashSet.SetEquals(OldLeftHanded); } private static void Put(int n, Act a, InputControlType c) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: 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_004e: 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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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) InputControlType val = Table[n, (int)a]; if ((int)c != 0) { for (int i = 0; i < 19; i++) { if (i != (int)a && Plain(Table[n, i]) == Plain(c)) { Table[n, i] = val; } } } Table[n, (int)a] = c; } private unsafe static bool Parse(string s, out InputControlType c) { //IL_0048: 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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Expected I4, but got Unknown c = (InputControlType)0; string text = s.Replace("-", "").Replace(" ", ""); if (text.Length == 0 || text.Equals("None", StringComparison.OrdinalIgnoreCase)) { return true; } InputControlType[] controls = Controls; for (int i = 0; i < controls.Length; i++) { InputControlType val = controls[i]; if (Canon(val).Replace("-", "").Replace(" ", "").Equals(text, StringComparison.OrdinalIgnoreCase) || ((object)(*(InputControlType*)(&val))/*cast due to .constrained prefix*/).ToString().Equals(text, StringComparison.OrdinalIgnoreCase)) { c = (InputControlType)(int)val; return true; } } return false; } private static void Save(int n) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_0060: Unknown result type (might be due to invalid IL or missing references) List<string> list = new List<string>(); for (int i = 0; i < 19; i++) { if (Table[n, i] != Info[i].Default) { list.Add($"{i}={(((int)Table[n, i] == 0) ? "None" : Canon(Table[n, i]).Replace("-", "").Replace(" ", ""))}"); } } if (Kept[n] != null) { Kept[n].Value = string.Join(", ", list); } } public static InputControlType Of(int n, Act a) { //IL_0013: 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 (n < 1 || n > 4) { return Info[(int)a].Default; } return Table[n, (int)a]; } public static void Set(int n, Act a, InputControlType c) { //IL_000b: 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: Expected O, but got Unknown //IL_0060: Unknown result type (might be due to invalid IL or missing references) if (n >= 1 && n <= 4) { Put(n, a, c); Save(n); ManualLogSource l = Plugin.L; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(25, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("buttons: player "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(n); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(Title(a)); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" on "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(Short(n, c)); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(Line(n)); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")"); } l.LogInfo(val); } } public static void Reset(int n) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_0048: Expected O, but got Unknown if (n >= 1 && n <= 4) { for (int i = 0; i < 19; i++) { Table[n, i] = Info[i].Default; } Save(n); ManualLogSource l = Plugin.L; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(41, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("buttons: player "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(n); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": the mod's buttons again"); } l.LogInfo(val); } } private static bool ActOf(InputAction action, out Act act) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Expected I4, but got Unknown //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Expected I4, but got Unknown switch (action - 5) { default: switch (action - 58) { case 9: break; case 0: act = Act.Ping; return true; case 5: case 6: act = Act.Comms; return true; case 7: act = Act.Next; return true; case 8: act = Act.Previous; return true; default: goto end_IL_0003; } goto case 1; case 0: act = Act.Jump; return true; case 5: act = Act.Crouch; return true; case 6: act = Act.Reload; return true; case 1: act = Act.Use; return true; case 27: act = Act.Flashlight; return true; case 2: act = Act.Aim; return true; case 3: act = Act.Fire; return true; case 4: act = Act.Run; return true; case 28: act = Act.Map; return true; case 18: act = Act.Main; return true; case 19: act = Act.Special; return true; case 21: act = Act.Melee; return true; case 20: case 22: case 23: act = Act.Tool; return true; case 7: case 8: case 9: case 10: case 11: case 12: case 13: case 14: case 15: case 16: case 17: case 24: case 25: case 26: break; end_IL_0003: break; } act = Act.Jump; return false; } public static bool Answers(InputAction action, int kind, int n, InputDevice pad, out bool result) { //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Expected O, but got Unknown //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Invalid comparison between Unknown and I4 //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Invalid comparison between Unknown and I4 //IL_002a: 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_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) result = false; if (!Wanted || n < 1 || n > 4) { return false; } if (((int)action == 34 || (int)action == 56) ? true : false) { return true; } if (!ActOf(action, out var act)) { return false; } bool flag = default(bool); try { if (pad == null) { return true; } State[] states = States; State state = states[n] ?? (states[n] = new State()); if (act == Act.Comms) { result = kind == 0 && Comms.Held(n); return true; } Tick(n, pad, state); flag = Comms.Active(n); if (flag) { bool flag2 = (((uint)act <= 1u || (uint)(act - 10) <= 3u) ? true : false); flag = flag2; } if (flag) { return true; } switch (act) { case Act.Map: if (kind == 1) { result = Read(n, pad, state, act, 1); } break; case Act.Main: case Act.Special: case Act.Melee: case Act.Tool: if (kind == 1 && state.Pending == action) { result = true; state.Pending = (InputAction)0; } break; default: result = Read(n, pad, state, act, kind) || Fed(state, action, kind); break; } } catch (Exception ex) { if (_errors++ < 5) { ManualLogSource l = Plugin.L; BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(11, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("buttons: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<InputAction>(action); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex); } l.LogError(val); } } return true; } public static bool Axis(InputAction action, int n, InputDevice pad, out float value) { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Invalid comparison between Unknown and I4 //IL_002b: 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_0036: Unknown result type (might be due to invalid IL or missing references) value = 0f; if (!Wanted || n < 1 || n > 4 || (int)action != 47) { return false; } try { InputControlType val = (InputControlType)((pad != null) ? ((int)Table[n, 6]) : 0); if ((int)val != 0) { InputControl control = pad.GetControl(val); value = ((control != null) ? ((OneAxisInputControl)control).Value : 0f); } } catch (Exception ex) { if (_errors++ < 5) { ManualLogSource l = Plugin.L; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(24, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("buttons: the fire axis: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Exception>(ex); } l.LogError(val2); } } return true; } public static bool RunPressed(int n, InputDevice pad) { //IL_0015: 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_001f: Unknown result type (might be due to invalid IL or missing references) if (!Wanted) { return ((OneAxisInputControl)pad.LeftStickButton).WasPressed; } InputControlType val = Of(n, Act.Run); if ((int)val != 0) { InputControl control = pad.GetControl(val); if (control != null) { return ((OneAxisInputControl)control).WasPressed; } } return false; } private static bool Read(int n, InputDevice pad, State st, Act act, int kind) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: 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_0013: 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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Invalid comparison between Unknown and I4 //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Invalid comparison between Unknown and I4 InputControlType val = Table[n, (int)act]; if ((int)val == 0) { return false; } InputControl control = pad.GetControl(val); if (control == null || !Free(st, pad, val)) { return false; } if ((int)val != 15 && (int)val != 16) { return kind switch { 1 => ((OneAxisInputControl)control).WasPressed, 0 => ((OneAxisInputControl)control).IsPressed, _ => ((OneAxisInputControl)control).WasReleased, }; } int frameCount = Time.frameCount; if (st.TFrame[(int)act] != frameCount) { bool flag = st.TFrame[(int)act] != frameCount - 1; st.TFrame[(int)act] = frameCount; float value = ((OneAxisInputControl)control).Value; float num = ((act == Act.Fire) ? 0f : 0.15f); float num2 = ((act == Act.Fire) ? 0.05f : 0.15f); bool flag2 = st.TDown[(int)act]; bool flag3; if (value <= 0f) { st.Peak[(int)act] = 0f; st.Rest[(int)act] = 0f; flag3 = false; } else if (!flag2) { st.Rest[(int)act] = Math.Min(value, st.Rest[(int)act]); flag3 = value > num + st.Rest[(int)act]; if (flag3) { st.Peak[(int)act] = value; } } else { st.Peak[(int)act] = Math.Max(value, st.Peak[(int)act]); flag3 = value > st.Peak[(int)act] - num2; if (!flag3) { st.Rest[(int)act] = value; } } st.TDown[(int)act] = flag3; st.TPrev[(int)act] = (flag ? flag3 : flag2); } switch (kind) { default: if (!st.TDown[(int)act]) { return st.TPrev[(int)act]; } return false; case 1: if (st.TDown[(int)act]) { return !st.TPrev[(int)act]; } return false; case 0: return st.TDown[(int)act]; } } private static void Tick(int n, InputDevice pad, State st) { //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0076: 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_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Invalid comparison between Unknown and I4 //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: 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_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: 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_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: 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_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0245: 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_0254: 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_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_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Invalid comparison between Unknown and I4 //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Invalid comparison between Unknown and I4 //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Expected I4, but got Unknown //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) int frameCount = Time.frameCount; if (st.Frame == frameCount && st.Pad == ((Il2CppObjectBase)pad).Pointer) { return; } st.Frame = frameCount; st.Pad = ((Il2CppObjectBase)pad).Pointer; PlayerAgent val = Players.Now.AgentOf(n) ?? PlayerManager.GetLocalPlayerAgent(); InventorySlot val2 = (InventorySlot)(((Object)(object)val != (Object)null && (Object)(object)val.Inventory != (Object)null) ? ((int)val.Inventory.WieldedSlot) : 0); bool num = Array.IndexOf(Weapons, val2) >= 0; bool flag = !num && (int)val2 > 0; if (num) { st.LastWeapon = val2; } float unscaledTime = Time.unscaledTime; if ((int)st.Pending != 0 && (unscaledTime > st.PendingUntil || Comms.Active(n))) { st.Pending = (InputAction)0; } InventorySlot val3 = From(st, val2); InputAction val4 = (InputAction)0; InputControlType val5 = Table[n, 13]; if ((int)val5 != 0) { InputControl control = pad.GetControl(val5); if (control != null && ((OneAxisInputControl)control).WasPressed && Free(st, pad, val5)) { val4 = NextBelow(val, val3); } } for (int i = 0; i < Weapons.Length; i++) { if (Read(n, pad, st, WeaponAct[i], 1) && (int)val4 == 0) { val4 = WeaponAction[i]; } } for (int j = 0; j < 2; j++) { Act act = ((j == 0) ? Act.NextWeapon : Act.PreviousWeapon); bool num2 = Read(n, pad, st, act, 1); bool flag2 = Read(n, pad, st, act, 0); bool flag3 = false; if (st.Uses[j] && (!flag2 || (int)val2 != (int)st.Of[j])) { st.Uses[j] = false; } if (num2) { if (flag) { st.Waits[j] = true; st.Since[j] = unscaledTime; st.Of[j] = (InventorySlot)(int)val2; } else { flag3 = true; } } else if (st.Waits[j]) { if ((int)val2 != (int)st.Of[j]) { st.Waits[j] = false; } else if (!flag2) { st.Waits[j] = false; flag3 = true; } else if (unscaledTime - st.Since[j] >= 0.25f) { st.Waits[j] = false; st.Uses[j] = true; } } if (flag3 && (int)val4 == 0) { val4 = Ring(val, st, val3, (j == 0) ? 1 : (-1)); } } if ((int)val4 != 0 && !Comms.Active(n)) { st.Pending = val4; st.PendingUntil = unscaledTime + 0.8f; st.Asked = SlotOf(val4); st.AskedAt = unscaledTime; } st.FedBefore = st.Fed; st.Fed = st.Uses[0] || st.Uses[1]; } private static bool Fed(State st, InputAction action, int kind) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 if (((int)action != 6 && (int)action != 67) || 1 == 0) {