Decompiled source of LethalCompany InputUtils v0.7.10
plugins/LethalCompanyInputUtils/LethalCompanyInputUtils.dll
Decompiled a month ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using LethalCompanyInputUtils.Api; using LethalCompanyInputUtils.BindingPathEnums; using LethalCompanyInputUtils.Components; using LethalCompanyInputUtils.Components.Section; using LethalCompanyInputUtils.Components.Switch; using LethalCompanyInputUtils.Config; using LethalCompanyInputUtils.Data; using LethalCompanyInputUtils.Glyphs; using LethalCompanyInputUtils.Localization; using LethalCompanyInputUtils.Utils; using LethalCompanyInputUtils.Utils.Anim; using LethalCompanyInputUtils.Utils.Anim.TweenValues; using LethalConfig; using LethalConfig.ConfigItems; using LethalConfig.ConfigItems.Options; using LobbyCompatibility.Enums; using LobbyCompatibility.Features; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Layouts; using UnityEngine.InputSystem.Utilities; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("ClientNetworkTransform")] [assembly: IgnoresAccessChecksTo("DissonanceVoip")] [assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")] [assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")] [assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")] [assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")] [assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")] [assembly: IgnoresAccessChecksTo("Unity.Burst")] [assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")] [assembly: IgnoresAccessChecksTo("Unity.Collections")] [assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")] [assembly: IgnoresAccessChecksTo("Unity.Jobs")] [assembly: IgnoresAccessChecksTo("Unity.Mathematics")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")] [assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")] [assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")] [assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")] [assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")] [assembly: IgnoresAccessChecksTo("Unity.Services.QoS")] [assembly: IgnoresAccessChecksTo("Unity.Services.Relay")] [assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")] [assembly: IgnoresAccessChecksTo("Unity.Timeline")] [assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")] [assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.UI")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Rune580")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.7.10.0")] [assembly: AssemblyInformationalVersion("0.7.10+512d2283abb5ce4a27209bd5ba0b0f525354df99")] [assembly: AssemblyProduct("LethalCompanyInputUtils")] [assembly: AssemblyTitle("LethalCompanyInputUtils")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/Rune580/LethalCompanyInputUtils")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.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] [Microsoft.CodeAnalysis.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] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace LethalCompanyInputUtils { public static class LcInputActionApi { private static readonly Dictionary<string, LcInputActions> InputActionsMap = new Dictionary<string, LcInputActions>(); internal static bool PrefabLoaded; internal static RemapContainerController? ContainerInstance; internal static IReadOnlyCollection<LcInputActions> InputActions => InputActionsMap.Values; internal static void LoadIntoUI(KepRemapPanel panel) { //IL_002a: 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_0113: Unknown result type (might be due to invalid IL or missing references) AdjustSizeAndPos(panel); LayoutElement val = EnsureLayoutElement(panel); panel.LoadKeybindsUI(); float horizontalOffset = panel.horizontalOffset; Rect rect = ((Component)((Transform)panel.keyRemapContainer).parent).GetComponent<RectTransform>().rect; float num = Mathf.Floor(((Rect)(ref rect)).width / horizontalOffset); int count = panel.keySlots.Count; int num2 = NumberOfActualKeys(panel.keySlots); int num3 = count - num2; panel.maxVertical = (float)num2 / num + (float)num3; if (ContainerInstance != null && ContainerInstance.legacyButton != null) { ((TMP_Text)((Component)ContainerInstance.legacyButton).GetComponentInChildren<TextMeshProUGUI>()).SetText("> " + string.Format(LocaleManager.GetString("LegacyControls.Button.Label"), num2), true); } if (count == 0) { return; } val.minHeight = (panel.maxVertical + 1f) * panel.verticalOffset; int num4 = 0; int num5 = 0; foreach (GameObject keySlot in panel.keySlots) { if ((float)num5 > num) { num4++; num5 = 0; } keySlot.GetComponent<RectTransform>().anchoredPosition = new Vector2((float)num5 * panel.horizontalOffset, (float)num4 * (0f - panel.verticalOffset)); if (keySlot.GetComponentInChildren<SettingsOption>() == null) { num5 = 0; num4++; } else { num5++; } } } public static bool RemapContainerVisible() { if (ContainerInstance == null) { return false; } return ContainerInstance.LayerShown > 0; } private static int NumberOfActualKeys(List<GameObject> keySlots) { int num = 0; foreach (GameObject keySlot in keySlots) { if (keySlot.GetComponentInChildren<SettingsOption>() != null) { num++; } } return num; } internal static void CloseContainerLayer() { if (ContainerInstance != null) { ContainerInstance.HideHighestLayer(); } } private static void AdjustSizeAndPos(KepRemapPanel panel) { GameObject gameObject = ((Component)((Transform)panel.keyRemapContainer).parent).gameObject; if (gameObject.GetComponent<ContentSizeFitter>() == null) { panel.keyRemapContainer.SetPivotY(1f); panel.keyRemapContainer.SetAnchorMinY(1f); panel.keyRemapContainer.SetAnchorMaxY(1f); panel.keyRemapContainer.SetAnchoredPosY(0f); panel.keyRemapContainer.SetLocalPosY(0f); ContentSizeFitter obj = gameObject.AddComponent<ContentSizeFitter>(); obj.horizontalFit = (FitMode)0; obj.verticalFit = (FitMode)1; } } private static LayoutElement EnsureLayoutElement(KepRemapPanel panel) { GameObject gameObject = ((Component)((Transform)panel.keyRemapContainer).parent).gameObject; LayoutElement component = gameObject.GetComponent<LayoutElement>(); if (component != null) { return component; } return gameObject.AddComponent<LayoutElement>(); } internal static void CalculateVerticalMaxForGamepad(KepRemapPanel panel) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) int num = panel.remappableKeys.Count((RemappableKey key) => key.gamepadOnly); float horizontalOffset = panel.horizontalOffset; Rect rect = ((Component)((Transform)panel.keyRemapContainer).parent).GetComponent<RectTransform>().rect; float num2 = Mathf.Floor(((Rect)(ref rect)).width / horizontalOffset); panel.maxVertical = (float)num / num2; LayoutElement obj = EnsureLayoutElement(panel); obj.minHeight += (panel.maxVertical + 3f) * panel.verticalOffset; } internal static void ResetLoadedInputActions() { PrefabLoaded = false; foreach (LcInputActions inputAction in InputActions) { inputAction.Loaded = false; } } internal static void RegisterInputActions(LcInputActions lcInputActions, InputActionMapBuilder builder) { if (!InputActionsMap.TryAdd(lcInputActions.Id, lcInputActions)) { Logging.Warn("The mod [" + lcInputActions.Plugin.GUID + "] instantiated an Actions class [" + lcInputActions.GetType().Name + "] more than once!\n\t These classes should be treated as singletons!, do not instantiate more than once!"); } else { lcInputActions.CreateInputActions(in builder); InputActionSetupExtensions.AddActionMap(lcInputActions.GetAsset(), builder.Build()); lcInputActions.GetAsset().Enable(); lcInputActions.OnAssetLoaded(); lcInputActions.Load(); lcInputActions.BuildActionRefs(); } } internal static void DisableForRebind() { foreach (LcInputActions inputAction in InputActions) { if (inputAction.Enabled) { inputAction.Disable(); } } } internal static void ReEnableFromRebind() { foreach (LcInputActions inputAction in InputActions) { if (inputAction.WasEnabled) { inputAction.Enable(); } } } internal static void SaveOverrides() { if (ContainerInstance != null) { ContainerInstance.SaveOverrides(); } } internal static void DiscardOverrides() { if (ContainerInstance != null) { ContainerInstance.DiscardOverrides(); } } } [BepInPlugin("com.rune580.LethalCompanyInputUtils", "Lethal Company Input Utils", "0.7.10")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class LethalCompanyInputUtilsPlugin : BaseUnityPlugin { private Harmony? _harmony; private void Awake() { Logging.SetLogSource(((BaseUnityPlugin)this).Logger); _harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "com.rune580.LethalCompanyInputUtils"); SceneManager.activeSceneChanged += OnSceneChanged; InputSystem.onDeviceChange += OnDeviceChanged; LoadAssetBundles(); ControllerGlyph.LoadGlyphs(); FsUtils.EnsureRequiredDirs(); InputUtilsConfig.Init((BaseUnityPlugin)(object)this); LocaleManager.LoadLocaleData(); RegisterExtendedMouseLayout(); ModCompat.Init((BaseUnityPlugin)(object)this); Logging.Info("InputUtils 0.7.10 has finished loading!"); SceneManager.activeSceneChanged += TryExportLayoutsOnLoad; } private static void LoadAssetBundles() { Assets.AddBundle("ui-assets"); } private static void OnSceneChanged(Scene current, Scene next) { LcInputActionApi.ResetLoadedInputActions(); CameraUtils.ClearUiCameraReference(); BindsListController.OffsetCompensation = ((((Scene)(ref next)).name != "MainMenu") ? 20 : 0); } private static void OnDeviceChanged(InputDevice device, InputDeviceChange state) { RebindButton.ReloadGlyphs(); } private static void RegisterExtendedMouseLayout() { InputSystem.RegisterLayoutOverride("{\n \"name\": \"InputUtilsExtendedMouse\",\n \"extend\": \"Mouse\",\n \"controls\": [\n {\n \"name\": \"scroll/up\",\n \"layout\": \"Button\",\n \"useStateFrom\": \"scroll/up\",\n \"format\": \"BIT\",\n \"synthetic\": true\n },\n {\n \"name\": \"scroll/down\",\n \"layout\": \"Button\",\n \"useStateFrom\": \"scroll/down\",\n \"format\": \"BIT\",\n \"synthetic\": true\n },\n {\n \"name\": \"scroll/left\",\n \"layout\": \"Button\",\n \"useStateFrom\": \"scroll/left\",\n \"format\": \"BIT\",\n \"synthetic\": true\n },\n {\n \"name\": \"scroll/right\",\n \"layout\": \"Button\",\n \"useStateFrom\": \"scroll/right\",\n \"format\": \"BIT\",\n \"synthetic\": true\n }\n ]\n}", (string)null); Logging.Info("Registered InputUtilsExtendedMouse Layout Override!"); } private static void TryExportLayoutsOnLoad(Scene arg0, Scene arg1) { SceneManager.activeSceneChanged -= TryExportLayoutsOnLoad; LayoutExporter.TryExportLayouts(); } } internal static class ModCompat { public static void Init(BaseUnityPlugin plugin) { if (Chainloader.PluginInfos.ContainsKey("BMX.LobbyCompatibility")) { LoadLobbyCompatibilityCompat(plugin.Info.Metadata); } } private static void LoadLobbyCompatibilityCompat(BepInPlugin plugin) { PluginHelper.RegisterPlugin(plugin.GUID, plugin.Version, (CompatibilityLevel)0, (VersionStrictness)0); } } public static class PluginInfo { public const string PLUGIN_GUID = "com.rune580.LethalCompanyInputUtils"; public const string PLUGIN_NAME = "Lethal Company Input Utils"; public const string PLUGIN_VERSION = "0.7.10"; } } namespace LethalCompanyInputUtils.BindingPathEnums { public enum KeyboardControl { None = 0, Unbound = 0, AnyKey = 1, Escape = 2, Space = 3, Enter = 4, Tab = 5, Backquote = 6, Quote = 7, Semicolon = 8, Comma = 9, Period = 10, Slash = 11, Backslash = 12, LeftBracket = 13, RightBracket = 14, Minus = 15, Equals = 16, UpArrow = 17, DownArrow = 18, LeftArrow = 19, RightArrow = 20, A = 21, B = 22, C = 23, D = 24, E = 25, F = 26, G = 27, H = 28, I = 29, J = 30, K = 31, L = 32, M = 33, N = 34, O = 35, P = 36, Q = 37, R = 38, S = 39, T = 40, U = 41, V = 42, W = 43, X = 44, Y = 45, Z = 46, Num1 = 47, Num2 = 48, Num3 = 49, Num4 = 50, Num5 = 51, Num6 = 52, Num7 = 53, Num8 = 54, Num9 = 55, Num0 = 56, LeftShift = 57, RightShift = 58, Shift = 59, LeftAlt = 60, RightAlt = 61, Alt = 62, LeftCtrl = 63, RightCtrl = 64, Ctrl = 65, LeftMeta = 66, RightMeta = 67, ContextMenu = 68, Backspace = 69, PageDown = 70, PageUp = 71, Home = 72, End = 73, Insert = 74, Delete = 75, CapsLock = 76, NumLock = 77, PrintScreen = 78, ScrollLock = 79, Pause = 80, NumpadEnter = 81, NumpadDivide = 82, NumpadMultiply = 83, NumpadPlus = 84, NumpadMinus = 85, NumpadPeriod = 86, NumpadEquals = 87, Numpad1 = 88, Numpad2 = 89, Numpad3 = 90, Numpad4 = 91, Numpad5 = 92, Numpad6 = 93, Numpad7 = 94, Numpad8 = 95, Numpad9 = 96, Numpad0 = 97, F1 = 98, F2 = 99, F3 = 100, F4 = 101, F5 = 102, F6 = 103, F7 = 104, F8 = 105, F9 = 106, F10 = 107, F11 = 108, F12 = 109, OEM1 = 110, OEM2 = 111, OEM3 = 112, OEM4 = 113, OEM5 = 114, IMESelected = 115 } public static class KeyboardControlExtensions { public static string ToPath(this KeyboardControl keyboardControl) { return keyboardControl switch { KeyboardControl.None => "", KeyboardControl.AnyKey => "<Keyboard>/anyKey", KeyboardControl.Escape => "<Keyboard>/escape", KeyboardControl.Space => "<Keyboard>/space", KeyboardControl.Enter => "<Keyboard>/enter", KeyboardControl.Tab => "<Keyboard>/tab", KeyboardControl.Backquote => "<Keyboard>/backquote", KeyboardControl.Quote => "<Keyboard>/quote", KeyboardControl.Semicolon => "<Keyboard>/semicolon", KeyboardControl.Comma => "<Keyboard>/comma", KeyboardControl.Period => "<Keyboard>/period", KeyboardControl.Slash => "<Keyboard>/slash", KeyboardControl.Backslash => "<Keyboard>/backslash", KeyboardControl.LeftBracket => "<Keyboard>/leftBracket", KeyboardControl.RightBracket => "<Keyboard>/rightBracket", KeyboardControl.Minus => "<Keyboard>/minus", KeyboardControl.Equals => "<Keyboard>/equals", KeyboardControl.UpArrow => "<Keyboard>/upArrow", KeyboardControl.DownArrow => "<Keyboard>/downArrow", KeyboardControl.LeftArrow => "<Keyboard>/leftArrow", KeyboardControl.RightArrow => "<Keyboard>/rightArrow", KeyboardControl.A => "<Keyboard>/a", KeyboardControl.B => "<Keyboard>/b", KeyboardControl.C => "<Keyboard>/c", KeyboardControl.D => "<Keyboard>/d", KeyboardControl.E => "<Keyboard>/e", KeyboardControl.F => "<Keyboard>/f", KeyboardControl.G => "<Keyboard>/g", KeyboardControl.H => "<Keyboard>/h", KeyboardControl.I => "<Keyboard>/i", KeyboardControl.J => "<Keyboard>/j", KeyboardControl.K => "<Keyboard>/k", KeyboardControl.L => "<Keyboard>/l", KeyboardControl.M => "<Keyboard>/m", KeyboardControl.N => "<Keyboard>/n", KeyboardControl.O => "<Keyboard>/o", KeyboardControl.P => "<Keyboard>/p", KeyboardControl.Q => "<Keyboard>/q", KeyboardControl.R => "<Keyboard>/r", KeyboardControl.S => "<Keyboard>/s", KeyboardControl.T => "<Keyboard>/t", KeyboardControl.U => "<Keyboard>/u", KeyboardControl.V => "<Keyboard>/v", KeyboardControl.W => "<Keyboard>/w", KeyboardControl.X => "<Keyboard>/x", KeyboardControl.Y => "<Keyboard>/y", KeyboardControl.Z => "<Keyboard>/z", KeyboardControl.Num1 => "<Keyboard>/1", KeyboardControl.Num2 => "<Keyboard>/2", KeyboardControl.Num3 => "<Keyboard>/3", KeyboardControl.Num4 => "<Keyboard>/4", KeyboardControl.Num5 => "<Keyboard>/5", KeyboardControl.Num6 => "<Keyboard>/6", KeyboardControl.Num7 => "<Keyboard>/7", KeyboardControl.Num8 => "<Keyboard>/8", KeyboardControl.Num9 => "<Keyboard>/9", KeyboardControl.Num0 => "<Keyboard>/0", KeyboardControl.LeftShift => "<Keyboard>/leftShift", KeyboardControl.RightShift => "<Keyboard>/rightShift", KeyboardControl.Shift => "<Keyboard>/shift", KeyboardControl.LeftAlt => "<Keyboard>/leftAlt", KeyboardControl.RightAlt => "<Keyboard>/rightAlt", KeyboardControl.Alt => "<Keyboard>/alt", KeyboardControl.LeftCtrl => "<Keyboard>/leftCtrl", KeyboardControl.RightCtrl => "<Keyboard>/rightCtrl", KeyboardControl.Ctrl => "<Keyboard>/ctrl", KeyboardControl.LeftMeta => "<Keyboard>/leftMeta", KeyboardControl.RightMeta => "<Keyboard>/rightMeta", KeyboardControl.ContextMenu => "<Keyboard>/contextMenu", KeyboardControl.Backspace => "<Keyboard>/backspace", KeyboardControl.PageDown => "<Keyboard>/pageDown", KeyboardControl.PageUp => "<Keyboard>/pageUp", KeyboardControl.Home => "<Keyboard>/home", KeyboardControl.End => "<Keyboard>/end", KeyboardControl.Insert => "<Keyboard>/insert", KeyboardControl.Delete => "<Keyboard>/delete", KeyboardControl.CapsLock => "<Keyboard>/capsLock", KeyboardControl.NumLock => "<Keyboard>/numLock", KeyboardControl.PrintScreen => "<Keyboard>/printScreen", KeyboardControl.ScrollLock => "<Keyboard>/scrollLock", KeyboardControl.Pause => "<Keyboard>/pause", KeyboardControl.NumpadEnter => "<Keyboard>/numpadEnter", KeyboardControl.NumpadDivide => "<Keyboard>/numpadDivide", KeyboardControl.NumpadMultiply => "<Keyboard>/numpadMultiply", KeyboardControl.NumpadPlus => "<Keyboard>/numpadPlus", KeyboardControl.NumpadMinus => "<Keyboard>/numpadMinus", KeyboardControl.NumpadPeriod => "<Keyboard>/numpadPeriod", KeyboardControl.NumpadEquals => "<Keyboard>/numpadEquals", KeyboardControl.Numpad1 => "<Keyboard>/numpad1", KeyboardControl.Numpad2 => "<Keyboard>/numpad2", KeyboardControl.Numpad3 => "<Keyboard>/numpad3", KeyboardControl.Numpad4 => "<Keyboard>/numpad4", KeyboardControl.Numpad5 => "<Keyboard>/numpad5", KeyboardControl.Numpad6 => "<Keyboard>/numpad6", KeyboardControl.Numpad7 => "<Keyboard>/numpad7", KeyboardControl.Numpad8 => "<Keyboard>/numpad8", KeyboardControl.Numpad9 => "<Keyboard>/numpad9", KeyboardControl.Numpad0 => "<Keyboard>/numpad0", KeyboardControl.F1 => "<Keyboard>/f1", KeyboardControl.F2 => "<Keyboard>/f2", KeyboardControl.F3 => "<Keyboard>/f3", KeyboardControl.F4 => "<Keyboard>/f4", KeyboardControl.F5 => "<Keyboard>/f5", KeyboardControl.F6 => "<Keyboard>/f6", KeyboardControl.F7 => "<Keyboard>/f7", KeyboardControl.F8 => "<Keyboard>/f8", KeyboardControl.F9 => "<Keyboard>/f9", KeyboardControl.F10 => "<Keyboard>/f10", KeyboardControl.F11 => "<Keyboard>/f11", KeyboardControl.F12 => "<Keyboard>/f12", KeyboardControl.OEM1 => "<Keyboard>/OEM1", KeyboardControl.OEM2 => "<Keyboard>/OEM2", KeyboardControl.OEM3 => "<Keyboard>/OEM3", KeyboardControl.OEM4 => "<Keyboard>/OEM4", KeyboardControl.OEM5 => "<Keyboard>/OEM5", KeyboardControl.IMESelected => "<Keyboard>/IMESelected", _ => throw new ArgumentOutOfRangeException("keyboardControl", keyboardControl, null), }; } } public enum MouseControl { None = 0, Unbound = 0, ScrollUp = 1, ScrollDown = 2, ScrollLeft = 3, ScrollRight = 4, Position = 5, Delta = 6, Scroll = 7, ScrollX = 8, ScrollY = 9, Press = 10, LeftButton = 11, RightButton = 12, MiddleButton = 13, ForwardButton = 14, BackButton = 15, Pressure = 16, Radius = 17, PointerId = 18, DisplayIndex = 19, ClickCount = 20 } public static class MouseControlExtensions { public static string ToPath(this MouseControl mouseControl) { return mouseControl switch { MouseControl.None => "", MouseControl.ScrollUp => "<Mouse>/scroll/up", MouseControl.ScrollDown => "<Mouse>/scroll/down", MouseControl.ScrollLeft => "<Mouse>/scroll/left", MouseControl.ScrollRight => "<Mouse>/scroll/right", MouseControl.Position => "<Mouse>/position", MouseControl.Delta => "<Mouse>/delta", MouseControl.Scroll => "<Mouse>/scroll", MouseControl.ScrollX => "<Mouse>/scroll/x", MouseControl.ScrollY => "<Mouse>/scroll/y", MouseControl.Press => "<Mouse>/press", MouseControl.LeftButton => "<Mouse>/leftButton", MouseControl.RightButton => "<Mouse>/rightButton", MouseControl.MiddleButton => "<Mouse>/middleButton", MouseControl.ForwardButton => "<Mouse>/forwardButton", MouseControl.BackButton => "<Mouse>/backButton", MouseControl.Pressure => "<Mouse>/pressure", MouseControl.Radius => "<Mouse>/radius", MouseControl.PointerId => "<Mouse>/pointerId", MouseControl.DisplayIndex => "<Mouse>/displayIndex", MouseControl.ClickCount => "<Mouse>/clickCount", _ => throw new ArgumentOutOfRangeException("mouseControl", mouseControl, null), }; } } public enum GamepadControl { None = 0, Unbound = 0, Dpad = 1, ButtonSouth = 2, ButtonWest = 3, ButtonNorth = 4, ButtonEast = 5, LeftStickPress = 6, RightStickPress = 7, LeftShoulder = 8, RightShoulder = 9, Start = 10, Select = 11, LeftStick = 12, RightStick = 13, LeftTrigger = 14, RightTrigger = 15 } public static class GamepadControlExtensions { public static string ToPath(this GamepadControl gamepadControl) { return gamepadControl switch { GamepadControl.None => "", GamepadControl.Dpad => "<Gamepad>/dpad", GamepadControl.ButtonSouth => "<Gamepad>/buttonSouth", GamepadControl.ButtonWest => "<Gamepad>/buttonWest", GamepadControl.ButtonNorth => "<Gamepad>/buttonNorth", GamepadControl.ButtonEast => "<Gamepad>/buttonEast", GamepadControl.LeftStickPress => "<Gamepad>/leftStickPress", GamepadControl.RightStickPress => "<Gamepad>/rightStickPress", GamepadControl.LeftShoulder => "<Gamepad>/leftShoulder", GamepadControl.RightShoulder => "<Gamepad>/rightShoulder", GamepadControl.Start => "<Gamepad>/start", GamepadControl.Select => "<Gamepad>/select", GamepadControl.LeftStick => "<Gamepad>/leftStick", GamepadControl.RightStick => "<Gamepad>/rightStick", GamepadControl.LeftTrigger => "<Gamepad>/leftTrigger", GamepadControl.RightTrigger => "<Gamepad>/rightTrigger", _ => throw new ArgumentOutOfRangeException("gamepadControl", gamepadControl, null), }; } } } namespace LethalCompanyInputUtils.Utils { internal static class AssemblyUtils { public static BepInPlugin? GetBepInPlugin(this Assembly assembly) { foreach (Type validType in assembly.GetValidTypes()) { BepInPlugin customAttribute = ((MemberInfo)validType).GetCustomAttribute<BepInPlugin>(); if (customAttribute != null) { return customAttribute; } } return null; } public static IEnumerable<Type> GetValidTypes(this Assembly assembly) { try { return assembly.GetTypes(); } catch (ReflectionTypeLoadException ex) { return ex.Types.Where((Type type) => (object)type != null); } } } internal static class Assets { private static readonly List<AssetBundle> AssetBundles = new List<AssetBundle>(); private static readonly Dictionary<string, int> AssetIndices = new Dictionary<string, int>(); public static void AddBundle(string bundleName) { AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(FsUtils.AssetBundlesDir, bundleName)); int count = AssetBundles.Count; AssetBundles.Add(val); string[] allAssetNames = val.GetAllAssetNames(); for (int i = 0; i < allAssetNames.Length; i++) { string text = allAssetNames[i].ToLowerInvariant(); if (text.StartsWith("assets/")) { string text2 = text; int length = "assets/".Length; text = text2.Substring(length, text2.Length - length); } AssetIndices[text] = count; } } public static T? Load<T>(string assetName) where T : Object { try { assetName = assetName.ToLowerInvariant(); if (assetName.StartsWith("assets/")) { string text = assetName; int length = "assets/".Length; assetName = text.Substring(length, text.Length - length); } int index = AssetIndices[assetName]; return AssetBundles[index].LoadAsset<T>("assets/" + assetName); } catch (Exception arg) { Logging.Error($"Couldn't load asset [{assetName}] exception: {arg}"); return default(T); } } } internal static class CameraUtils { private static Camera? _uiCamera; public static Camera GetBestUiCamera() { //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) if (_uiCamera != null && Object.op_Implicit((Object)(object)_uiCamera)) { return _uiCamera; } _uiCamera = null; Scene activeScene = SceneManager.GetActiveScene(); if (((Scene)(ref activeScene)).name == "MainMenu") { GameObject val = ((IEnumerable<GameObject>)((Scene)(ref activeScene)).GetRootGameObjects()).FirstOrDefault((Func<GameObject, bool>)((GameObject go) => ((Object)go).name == "UICamera")); if (val == null) { Logging.Warn("Failed to find UICamera at MainMenu, falling back to Camera.current!"); return Camera.current; } Camera component = val.GetComponent<Camera>(); if (component == null) { Logging.Warn("Failed to find Camera component on UICamera, falling back to Camera.current!"); return Camera.current; } _uiCamera = component; } else { GameObject val2 = ((IEnumerable<GameObject>)((Scene)(ref activeScene)).GetRootGameObjects()).FirstOrDefault((Func<GameObject, bool>)((GameObject go) => ((Object)go).name == "Systems")); if (val2 == null) { Logging.Warn("Failed to find UICamera in active scene, falling back to Camera.current!"); return Camera.current; } Transform val3 = val2.transform.Find("UI/UICamera"); if (val3 == null) { Logging.Warn("Failed to find UICamera at MainMenu, falling back to Camera.current!"); return Camera.current; } Camera component2 = ((Component)val3).GetComponent<Camera>(); if (component2 == null) { Logging.Warn("Failed to find Camera component on UICamera, falling back to Camera.current!"); return Camera.current; } _uiCamera = component2; } return _uiCamera; } public static void ClearUiCameraReference() { _uiCamera = null; } } internal static class DebugUtils { public static string ToPrettyString<TKey, TValue>(this IDictionary<TKey, TValue> dictionary) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("{"); using (IEnumerator<KeyValuePair<TKey, TValue>> enumerator = dictionary.GetEnumerator()) { string[] obj; object obj3; for (; enumerator.MoveNext(); obj[3] = (string)obj3, obj[4] = "\",", stringBuilder.AppendLine(string.Concat(obj))) { enumerator.Current.Deconstruct(out var key, out var value); TKey val = key; TValue val2 = value; obj = new string[5] { "\t\"", null, null, null, null }; ref TKey reference = ref val; key = default(TKey); object obj2; if (key == null) { key = reference; reference = ref key; if (key == null) { obj2 = null; goto IL_007c; } } obj2 = reference.ToString(); goto IL_007c; IL_007c: obj[1] = (string)obj2; obj[2] = "\": \""; ref TValue reference2 = ref val2; value = default(TValue); if (value == null) { value = reference2; reference2 = ref value; if (value == null) { obj3 = null; continue; } } obj3 = reference2.ToString(); } } stringBuilder.Remove(stringBuilder.Length - 1, 1); stringBuilder.AppendLine("}"); return stringBuilder.ToString(); } public static void DrawGizmoUiRectWorld(this RectTransform rectTransform) { //IL_0001: 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_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0093: 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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: 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) float z = ((Transform)rectTransform).position.z; Rect val = rectTransform.UiBoundsWorld(); Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(((Rect)(ref val)).min.x, ((Rect)(ref val)).min.y, z); Vector3 val3 = default(Vector3); ((Vector3)(ref val3))..ctor(((Rect)(ref val)).min.x, ((Rect)(ref val)).max.y, z); Vector3 val4 = default(Vector3); ((Vector3)(ref val4))..ctor(((Rect)(ref val)).max.x, ((Rect)(ref val)).max.y, z); Vector3 val5 = default(Vector3); ((Vector3)(ref val5))..ctor(((Rect)(ref val)).max.x, ((Rect)(ref val)).min.y, z); Gizmos.DrawLine(val2, val3); Gizmos.DrawLine(val3, val4); Gizmos.DrawLine(val4, val5); Gizmos.DrawLine(val5, val2); } public static void DrawGizmoUiRect(this RectTransform rectTransform, Vector3 position) { //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_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0053: 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_0073: 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_008f: 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_0096: 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_009e: 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_00a7: 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 z = position.z; Rect val = rectTransform.UiBounds(position); Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(((Rect)(ref val)).min.x, ((Rect)(ref val)).min.y, z); Vector3 val3 = default(Vector3); ((Vector3)(ref val3))..ctor(((Rect)(ref val)).min.x, ((Rect)(ref val)).max.y, z); Vector3 val4 = default(Vector3); ((Vector3)(ref val4))..ctor(((Rect)(ref val)).max.x, ((Rect)(ref val)).max.y, z); Vector3 val5 = default(Vector3); ((Vector3)(ref val5))..ctor(((Rect)(ref val)).max.x, ((Rect)(ref val)).min.y, z); Gizmos.DrawLine(val2, val3); Gizmos.DrawLine(val3, val4); Gizmos.DrawLine(val4, val5); Gizmos.DrawLine(val5, val2); } public static void DrawGizmoRect(this Rect rect, Vector3 position) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0095: 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_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: 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_00c6: 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_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: 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) float z = position.z; Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(((Rect)(ref rect)).min.x + position.x, ((Rect)(ref rect)).min.y + position.y, z); Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(((Rect)(ref rect)).min.x + position.x, ((Rect)(ref rect)).max.y + position.y, z); Vector3 val3 = default(Vector3); ((Vector3)(ref val3))..ctor(((Rect)(ref rect)).max.x + position.x, ((Rect)(ref rect)).max.y + position.y, z); Vector3 val4 = default(Vector3); ((Vector3)(ref val4))..ctor(((Rect)(ref rect)).max.x + position.x, ((Rect)(ref rect)).min.y + position.y, z); Gizmos.DrawLine(val, val2); Gizmos.DrawLine(val2, val3); Gizmos.DrawLine(val3, val4); Gizmos.DrawLine(val4, val); } } internal static class DeconstructUtils { public static void Deconstruct(this Rect rect, out Vector2 min, out Vector2 max) { //IL_000f: 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_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) min = new Vector2(((Rect)(ref rect)).xMin, ((Rect)(ref rect)).yMin); max = new Vector2(((Rect)(ref rect)).xMax, ((Rect)(ref rect)).yMax); } public static void Deconstruct(this Vector3 vector, out float x, out float y, out float z) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0009: 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) x = vector.x; y = vector.y; z = vector.z; } } public static class DeviceGroups { public const string KeyboardAndMouse = "KeyboardAndMouse"; public const string Gamepad = "Gamepad"; } internal static class FsUtils { private static string? _assetBundlesDir; private static string? _localeDir; public static string SaveDir { get; } = GetSaveDir(); public static string PersistentDir { get; } = Path.Combine(SaveDir, "InputUtils"); public static string PersistentConfigPath { get; } = Path.Combine(PersistentDir, "Settings.cfg"); public static string Pre041ControlsDir { get; } = Path.Combine(Paths.BepInExRootPath, "controls"); public static string ControlsDir { get; } = Path.Combine(Paths.ConfigPath, "controls"); public static string PersistentControlsDir { get; } = Path.Combine(PersistentDir, "controls"); public static string AssetBundlesDir { get { if (_assetBundlesDir == null) { _assetBundlesDir = GetAssetBundlesDir(); } if (string.IsNullOrEmpty(_assetBundlesDir)) { string text = Chainloader.PluginInfos.ToPrettyString(); Logging.Warn("InputUtils is loading in an invalid state!\n\tOne of the following mods may be the culprit:\n" + text); return ""; } return _assetBundlesDir; } } public static string LocaleDir { get { if (_localeDir == null) { _localeDir = GetLocaleDir(); } if (string.IsNullOrEmpty(_localeDir)) { string text = Chainloader.PluginInfos.ToPrettyString(); Logging.Warn("InputUtils is loading in an invalid state!\n\tOne of the following mods may be the culprit:\n" + text); return ""; } return _localeDir; } } private static string GetSaveDir() { string folderPath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); return Path.Combine(folderPath, "AppData", "LocalLow", "ZeekerssRBLX", "Lethal Company"); } private static string? GetAssetBundlesDir() { if (!Chainloader.PluginInfos.TryGetValue("com.rune580.LethalCompanyInputUtils", out var value)) { return null; } string text = Path.Combine((Directory.GetParent(value.Location) ?? throw new NotSupportedException(BadInstallError())).FullName, "AssetBundles"); if (!Directory.Exists(text)) { throw new NotSupportedException(BadInstallError()); } return text; static string BadInstallError() { Logging.Error("InputUtils can't find it's required AssetBundles! This will cause many issues!\nThis either means your mod manager incorrectly installed InputUtilsor if you've manually installed InputUtils, you've done so incorrectly. If you manually installed don't bother reporting the issue, I only provide support to people who use mod managers."); return "InputUtils can't find it's required AssetBundles! This will cause many issues!\nThis either means your mod manager incorrectly installed InputUtilsor if you've manually installed InputUtils, you've done so incorrectly. If you manually installed don't bother reporting the issue, I only provide support to people who use mod managers."; } } private static string? GetLocaleDir() { if (!Chainloader.PluginInfos.TryGetValue("com.rune580.LethalCompanyInputUtils", out var value)) { return null; } string text = Path.Combine((Directory.GetParent(value.Location) ?? throw new NotSupportedException(BadInstallError())).FullName, "Locale"); if (!Directory.Exists(text)) { throw new NotSupportedException(BadInstallError()); } return text; static string BadInstallError() { Logging.Error("InputUtils can't find it's required AssetBundles! This will cause many issues!\nThis either means your mod manager incorrectly installed InputUtilsor if you've manually installed InputUtils, you've done so incorrectly. If you manually installed don't bother reporting the issue, I only provide support to people who use mod managers."); return "InputUtils can't find it's required AssetBundles! This will cause many issues!\nThis either means your mod manager incorrectly installed InputUtilsor if you've manually installed InputUtils, you've done so incorrectly. If you manually installed don't bother reporting the issue, I only provide support to people who use mod managers."; } } public static void EnsureRequiredDirs() { if (!Directory.Exists(ControlsDir)) { Directory.CreateDirectory(ControlsDir); } if (!Directory.Exists(SaveDir)) { Logging.Warn("LethalCompany save directory doesn't exist!\n Persistent settings will fail!"); } else if (!Directory.Exists(PersistentControlsDir)) { Directory.CreateDirectory(PersistentControlsDir); } } } internal static class InputSystemUtils { public static bool IsGamepadOnly(this InputAction action) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return ((IEnumerable<InputBinding>)(object)action.bindings).All((InputBinding binding) => !binding.IsKbmBind()); } public static bool IsKbmBind(this InputBinding binding) { return string.Equals(((InputBinding)(ref binding)).groups, "KeyboardAndMouse"); } public static bool IsGamepadBind(this InputBinding binding) { return string.Equals(((InputBinding)(ref binding)).groups, "Gamepad"); } public static RemappableKey? GetKbmKey(this InputActionReference actionRef) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: 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_003a: 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_0049: Expected O, but got Unknown ReadOnlyArray<InputBinding> bindings = actionRef.action.bindings; for (int i = 0; i < bindings.Count; i++) { InputBinding binding = bindings[i]; if (binding.IsKbmBind()) { return new RemappableKey { ControlName = ((InputBinding)(ref binding)).name, currentInput = actionRef, rebindingIndex = i, gamepadOnly = false }; } } return null; } public static RemappableKey? GetGamepadKey(this InputActionReference actionRef) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: 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_003a: 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_0049: Expected O, but got Unknown ReadOnlyArray<InputBinding> bindings = actionRef.action.bindings; for (int i = 0; i < bindings.Count; i++) { InputBinding binding = bindings[i]; if (binding.IsGamepadBind()) { return new RemappableKey { ControlName = ((InputBinding)(ref binding)).name, currentInput = actionRef, rebindingIndex = i, gamepadOnly = true }; } } return null; } public static int GetRebindingIndex(this RemappableKey? key) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_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) if (key == null) { return -1; } InputAction action = key.currentInput.action; if (action.controls.Count == 0) { if (action.bindings.Count == 0) { return -1; } if (key.gamepadOnly && action.bindings.Count > 1) { return 1; } return 0; } if (key.rebindingIndex >= 0) { return key.rebindingIndex; } return InputActionRebindingExtensions.GetBindingIndexForControl(action, action.controls[0]); } public static void LoadOverridesFromControls(this InputActionAsset asset, string fileName) { BindingOverridePriority value = InputUtilsConfig.bindingOverridePriority.Value; switch (value) { case BindingOverridePriority.GlobalThenLocal: asset.LoadOverridesFromControls(fileName, BindingOverrideType.Local, removeExistingOverrides: true); asset.LoadOverridesFromControls(fileName, BindingOverrideType.Global, removeExistingOverrides: false); break; case BindingOverridePriority.LocalThenGlobal: asset.LoadOverridesFromControls(fileName, BindingOverrideType.Global, removeExistingOverrides: true); asset.LoadOverridesFromControls(fileName, BindingOverrideType.Local, removeExistingOverrides: false); break; case BindingOverridePriority.GlobalOnly: asset.LoadOverridesFromControls(fileName, BindingOverrideType.Global, removeExistingOverrides: true); break; case BindingOverridePriority.LocalOnly: asset.LoadOverridesFromControls(fileName, BindingOverrideType.Local, removeExistingOverrides: true); break; default: throw new ArgumentOutOfRangeException("overridePriority", value, null); } } public static void LoadOverridesFromControls(this InputActionAsset asset, string fileName, BindingOverrideType overrideType, bool removeExistingOverrides) { try { ApplyMigrations(fileName); } catch (Exception data) { Logging.Error("Got error when applying migrations, skipping..."); Logging.Error(data); } string jsonPath = overrideType.GetJsonPath(fileName); if (!File.Exists(jsonPath)) { return; } try { BindingOverrides bindingOverrides = BindingOverrides.FromJson(File.ReadAllText(jsonPath)); if (removeExistingOverrides) { InputActionRebindingExtensions.RemoveAllBindingOverrides((IInputActionCollection2)(object)asset); } bindingOverrides.LoadInto(asset); } catch (Exception data2) { Logging.Error(data2); } } public static void ApplyMigrations(string fileName) { string jsonPath = BindingOverrideType.Local.GetJsonPath(fileName); string text = Path.Combine(FsUtils.Pre041ControlsDir, fileName + ".json"); if (File.Exists(text) && !File.Exists(jsonPath)) { File.Move(text, jsonPath); } if (!File.Exists(jsonPath)) { return; } if (File.ReadAllText(jsonPath).Replace(" ", "").Contains("\"origPath\":\"\"")) { BindingOverrides bindingOverrides = BindingOverrides.FromJson(File.ReadAllText(jsonPath)); for (int i = 0; i < bindingOverrides.overrides.Count; i++) { BindingOverride value = bindingOverrides.overrides[i]; if (string.IsNullOrEmpty(value.origPath) && value.path != null) { if (value.path.StartsWith("<Keyboard>", StringComparison.InvariantCultureIgnoreCase) || value.path.StartsWith("<Mouse>", StringComparison.InvariantCultureIgnoreCase)) { value.origPath = "<InputUtils-Kbm-Not-Bound>"; } else { value.origPath = "<InputUtils-Gamepad-Not-Bound>"; } bindingOverrides.overrides[i] = value; } } File.WriteAllText(jsonPath, JsonConvert.SerializeObject((object)bindingOverrides)); } if (File.ReadAllText(jsonPath).Replace(" ", "").Contains("\"groups\":")) { return; } BindingOverrides bindingOverrides2 = BindingOverrides.FromJson(File.ReadAllText(jsonPath)); for (int j = 0; j < bindingOverrides2.overrides.Count; j++) { BindingOverride value2 = bindingOverrides2.overrides[j]; if (!string.IsNullOrEmpty(value2.origPath)) { if (value2.origPath.StartsWith("<Keyboard>", StringComparison.InvariantCultureIgnoreCase) || value2.origPath.StartsWith("<Mouse>", StringComparison.InvariantCultureIgnoreCase) || string.Equals(value2.origPath, "<InputUtils-Kbm-Not-Bound>")) { value2.groups = "KeyboardAndMouse"; } else { value2.groups = "Gamepad"; } bindingOverrides2.overrides[j] = value2; } } File.WriteAllText(jsonPath, JsonConvert.SerializeObject((object)bindingOverrides2)); } } internal static class LayoutExporter { private static readonly InputControlLayout[] Layouts = (InputControlLayout[])(object)new InputControlLayout[3] { InputSystem.LoadLayout<Keyboard>(), InputSystem.LoadLayout<Mouse>(), InputSystem.LoadLayout<Gamepad>() }; public static void TryExportLayouts() { string[] commandLineArgs = Environment.GetCommandLineArgs(); string text = null; bool flag = false; string[] array = commandLineArgs; foreach (string text2 in array) { if (text2.StartsWith("--inputUtilsExportAllLayouts")) { flag = true; } else if (text2.StartsWith("--inputUtilsExportLayoutsToDir=")) { string[] array2 = text2.Split('='); if (array2.Length == 2) { text = array2[1]; } } } if (text == null) { return; } InputControlLayout[] layouts = (InputControlLayout[])(flag ? ((Array)InputSystem.ListLayouts().Select((Func<string, InputControlLayout>)InputSystem.LoadLayout).ToArray()) : ((Array)Layouts)); try { ExportLayouts(layouts, Path.Combine(text, "device_layouts.json")); Application.Quit(); } catch (Exception data) { Logging.Error(data); } } public static void ExportLayouts(InputControlLayout[] layouts, string filePath) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("{"); stringBuilder.AppendLine("\t\"layouts\": ["); for (int i = 0; i < layouts.Length; i++) { string[] array = layouts[i].ToJson().Split("\n"); foreach (string text in array) { stringBuilder.AppendLine("\t\t" + text); } stringBuilder.Remove(stringBuilder.Length - 2, 2); stringBuilder.AppendLine(","); } stringBuilder.Remove(stringBuilder.Length - 3, 1); stringBuilder.AppendLine("\t]"); stringBuilder.AppendLine("}"); File.WriteAllText(filePath, stringBuilder.ToString()); } } internal static class Logging { private static ManualLogSource? _logSource; internal static void SetLogSource(ManualLogSource logSource) { _logSource = logSource; } public static void Error(object data) { Error(data.ToString()); } public static void Warn(object data) { Warn(data.ToString()); } public static void Info(object data) { Info(data.ToString()); } public static void Error(string msg) { if (_logSource == null) { Debug.LogError((object)("[Lethal Company Input Utils] [Error] " + msg)); } else { _logSource.LogError((object)msg); } } public static void Warn(string msg) { if (_logSource == null) { Debug.LogWarning((object)("[Lethal Company Input Utils] [Warning] " + msg)); } else { _logSource.LogWarning((object)msg); } } public static void Info(string msg) { if (_logSource == null) { Debug.Log((object)("[Lethal Company Input Utils] [Info] " + msg)); } else { _logSource.LogInfo((object)msg); } } } internal static class RectTransformExtensions { public static void SetLocalPosX(this RectTransform rectTransform, float x) { //IL_0001: 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_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000f: 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) Vector3 localPosition = ((Transform)rectTransform).localPosition; ((Transform)rectTransform).localPosition = new Vector3(x, localPosition.y, localPosition.z); } public static void SetLocalPosY(this RectTransform rectTransform, float y) { //IL_0001: 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_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000f: 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) Vector3 localPosition = ((Transform)rectTransform).localPosition; ((Transform)rectTransform).localPosition = new Vector3(localPosition.x, y, localPosition.z); } public static void SetPivotY(this RectTransform rectTransform, float y) { //IL_0002: 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) rectTransform.pivot = new Vector2(rectTransform.pivot.x, y); } public static void SetAnchorMinY(this RectTransform rectTransform, float y) { //IL_0002: 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) rectTransform.anchorMin = new Vector2(rectTransform.anchorMin.x, y); } public static void SetAnchorMaxY(this RectTransform rectTransform, float y) { //IL_0002: 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) rectTransform.anchorMax = new Vector2(rectTransform.anchorMax.x, y); } public static void SetAnchoredPosX(this RectTransform rectTransform, float x) { //IL_0003: 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) rectTransform.anchoredPosition = new Vector2(x, rectTransform.anchoredPosition.y); } public static void SetAnchoredPosY(this RectTransform rectTransform, float y) { //IL_0002: 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) rectTransform.anchoredPosition = new Vector2(rectTransform.anchoredPosition.x, y); } public static void SetSizeDeltaX(this RectTransform rectTransform, float x) { //IL_0003: 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) rectTransform.sizeDelta = new Vector2(x, rectTransform.sizeDelta.y); } public static Rect UiBoundsWorld(this RectTransform rectTransform) { //IL_0001: 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_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000f: 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_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0031: 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_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0054: 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) Vector3 position = ((Transform)rectTransform).position; Rect rect = rectTransform.rect; Vector3 lossyScale = ((Transform)rectTransform).lossyScale; return new Rect(((Rect)(ref rect)).x * lossyScale.x + position.x, ((Rect)(ref rect)).y * lossyScale.y + position.y, ((Rect)(ref rect)).width * lossyScale.x, ((Rect)(ref rect)).height * lossyScale.y); } [Obsolete("Use GetRelativeRect")] public static Rect UiBounds(this RectTransform rectTransform, Vector3 position) { //IL_0001: 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_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) Rect rect = rectTransform.rect; Vector3 lossyScale = ((Transform)rectTransform).lossyScale; return new Rect(((Rect)(ref rect)).x * lossyScale.x + position.x, ((Rect)(ref rect)).y * lossyScale.y + position.y, ((Rect)(ref rect)).width * lossyScale.x, ((Rect)(ref rect)).height * lossyScale.y); } public static Rect GetRelativeRect(this RectTransform rectTransform, RectTransform worldRectTransform) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0053: 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_007b: 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_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: 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_00a8: 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_00bd: 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_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: 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_00cf: 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_00dd: 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) Camera bestUiCamera = CameraUtils.GetBestUiCamera(); Vector3[] array = (Vector3[])(object)new Vector3[4]; worldRectTransform.GetWorldCorners(array); Vector2[] array2 = (Vector2[])(object)new Vector2[4]; for (int i = 0; i < array.Length; i++) { array2[i] = RectTransformUtility.WorldToScreenPoint(bestUiCamera, array[i]); } Vector2[] array3 = (Vector2[])(object)new Vector2[4]; for (int j = 0; j < array2.Length; j++) { RectTransformUtility.ScreenPointToLocalPointInRectangle(rectTransform, array2[j], bestUiCamera, ref array3[j]); } Vector2 val = array3[0]; Vector2 val2 = array3[0]; Vector2[] array4 = array3; foreach (Vector2 val3 in array4) { val = Vector2.Min(val, val3); val2 = Vector2.Max(val2, val3); } Vector2 val4 = val2 - val; return new Rect(val.x, val.y, val4.x, val4.y); } public static Vector2 WorldToLocalPoint(this RectTransform rectTransform, Vector3 worldPoint) { //IL_0007: 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_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000f: 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) Camera bestUiCamera = CameraUtils.GetBestUiCamera(); Vector2 val = RectTransformUtility.WorldToScreenPoint(bestUiCamera, worldPoint); Vector2 result = default(Vector2); RectTransformUtility.ScreenPointToLocalPointInRectangle(rectTransform, val, bestUiCamera, ref result); return result; } public static Vector2 WorldToLocalPoint(this RectTransform rectTransform, RectTransform other) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) return rectTransform.WorldToLocalPoint(((Transform)other).position); } public static float WorldMaxY(this RectTransform rectTransform) { //IL_0001: 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_0009: Unknown result type (might be due to invalid IL or missing references) Rect val = rectTransform.UiBoundsWorld(); return ((Rect)(ref val)).max.y; } public static float WorldMinY(this RectTransform rectTransform) { //IL_0001: 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_0009: Unknown result type (might be due to invalid IL or missing references) Rect val = rectTransform.UiBoundsWorld(); return ((Rect)(ref val)).min.y; } } internal static class RectUtils { public static Vector2 CenteredPos(this Rect rect) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0009: 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_0018: Unknown result type (might be due to invalid IL or missing references) return ((Rect)(ref rect)).min + ((Rect)(ref rect)).size / 2f; } } internal static class RuntimeHelper { public static Vector3 LocalPositionRelativeTo(this Transform transform, Transform parent) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //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_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: 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_0025: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Vector3.zero; Transform val2 = transform; do { val += transform.localPosition; val2 = val2.parent; } while ((Object)(object)val2 != (Object)(object)parent); return val; } public static void DisableKeys(this IEnumerable<RemappableKey> keys) { foreach (RemappableKey key in keys) { key.currentInput.action.Disable(); } } public static void EnableKeys(this IEnumerable<RemappableKey> keys) { foreach (RemappableKey key in keys) { key.currentInput.action.Enable(); } } } internal static class VectorUtils { public static Vector3 Mul(this Vector3 left, Vector3 right) { //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(left.x * right.x, left.y * right.y, left.z * right.z); } } } namespace LethalCompanyInputUtils.Utils.Anim { public interface ITweenValue { bool IgnoreTimeScale { get; } float Duration { get; } void TweenValue(float percentage); bool ValidTarget(); } public class TweenRunner<T> where T : struct, ITweenValue { [CompilerGenerated] private sealed class <Start>d__2 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public T tweenValue; private float <elapsedTime>5__2; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <Start>d__2(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; if (!tweenValue.ValidTarget()) { return false; } <elapsedTime>5__2 = 0f; break; case 1: <>1__state = -1; break; } if (<elapsedTime>5__2 < tweenValue.Duration) { <elapsedTime>5__2 += (tweenValue.IgnoreTimeScale ? Time.unscaledDeltaTime : Time.deltaTime); float percentage = Mathf.Clamp01(<elapsedTime>5__2 / tweenValue.Duration); tweenValue.TweenValue(percentage); <>2__current = null; <>1__state = 1; return true; } tweenValue.TweenValue(1f); return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } protected MonoBehaviour? CoroutineContainer; protected IEnumerator? Tween; [IteratorStateMachine(typeof(TweenRunner<>.<Start>d__2))] private static IEnumerator Start(T tweenValue) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <Start>d__2(0) { tweenValue = tweenValue }; } public void Init(MonoBehaviour coroutineContainer) { CoroutineContainer = coroutineContainer; } public void StartTween(T tweenValue) { if (CoroutineContainer != null) { if (Tween != null) { CoroutineContainer.StopCoroutine(Tween); Tween = null; } if (!((Component)CoroutineContainer).gameObject.activeInHierarchy) { tweenValue.TweenValue(1f); return; } Tween = Start(tweenValue); CoroutineContainer.StartCoroutine(Tween); } } public void StopTween() { if (Tween != null && CoroutineContainer != null) { CoroutineContainer.StopCoroutine(Tween); Tween = null; } } } } namespace LethalCompanyInputUtils.Utils.Anim.TweenValues { public struct Vector2Tween : ITweenValue { private class Vector2TweenCallback : UnityEvent<Vector2> { } private Vector2TweenCallback? _target; public float Duration { get; set; } public Vector2 StartValue { get; set; } public Vector2 TargetValue { get; set; } public bool IgnoreTimeScale { get; set; } public void TweenValue(float percentage) { //IL_000a: 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_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_0022: Unknown result type (might be due to invalid IL or missing references) if (ValidTarget()) { Vector2 val = Vector2.Lerp(StartValue, TargetValue, percentage); ((UnityEvent<Vector2>)_target).Invoke(val); } } public void AddOnChangedCallback(UnityAction<Vector2> callback) { if (_target == null) { _target = new Vector2TweenCallback(); } ((UnityEvent<Vector2>)_target).AddListener(callback); } public bool ValidTarget() { return _target != null; } } public struct Vector3Tween : ITweenValue { private class Vector3TweenCallback : UnityEvent<Vector3> { } private Vector3TweenCallback? _target; public float Duration { get; set; } public Vector3 StartValue { get; set; } public Vector3 TargetValue { get; set; } public bool IgnoreTimeScale { get; set; } public void TweenValue(float percentage) { //IL_000a: 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_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_0022: Unknown result type (might be due to invalid IL or missing references) if (ValidTarget()) { Vector3 val = Vector3.Lerp(StartValue, TargetValue, percentage); ((UnityEvent<Vector3>)_target).Invoke(val); } } public void AddOnChangedCallback(UnityAction<Vector3> callback) { if (_target == null) { _target = new Vector3TweenCallback(); } ((UnityEvent<Vector3>)_target).AddListener(callback); } public bool ValidTarget() { return _target != null; } } public struct Vector4Tween : ITweenValue { private class Vector4TweenCallback : UnityEvent<Vector4> { } private Vector4TweenCallback? _target; public float Duration { get; set; } public Vector4 StartValue { get; set; } public Vector4 TargetValue { get; set; } public bool IgnoreTimeScale { get; set; } public void TweenValue(float percentage) { //IL_000a: 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_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_0022: Unknown result type (might be due to invalid IL or missing references) if (ValidTarget()) { Vector4 val = Vector4.Lerp(StartValue, TargetValue, percentage); ((UnityEvent<Vector4>)_target).Invoke(val); } } public void AddOnChangedCallback(UnityAction<Vector4> callback) { if (_target == null) { _target = new Vector4TweenCallback(); } ((UnityEvent<Vector4>)_target).AddListener(callback); } public bool ValidTarget() { return _target != null; } } } namespace LethalCompanyInputUtils.Patches { public static class InGamePlayerSettingsPatches { [HarmonyPatch(typeof(IngamePlayerSettings), "UpdateGameToMatchSettings")] public static class UpdateGameToMatchSettingsPatch { public static void Prefix() { VanillaInputActions.Instance.Load(); } } [HarmonyPatch(typeof(IngamePlayerSettings), "SaveChangedSettings")] public static class SaveChangedSettingsPatch { public static void Prefix() { LcInputActionApi.SaveOverrides(); } public static void Postfix() { VanillaInputActions.Instance.Load(); } } [HarmonyPatch(typeof(IngamePlayerSettings), "DiscardChangedSettings")] public static class DiscardChangedSettingsPatch { public static void Prefix() { LcInputActionApi.DiscardOverrides(); } } } public static class InputControlPathPatches { [HarmonyPatch] public static class ToHumanReadableStringPatch { public static IEnumerable<MethodBase> TargetMethods() { return from method in AccessTools.GetDeclaredMethods(typeof(InputControlPath)) where method.Name == "ToHumanReadableString" && method.ReturnType == typeof(string) select method; } public static void Postfix(ref string __result) { string text = __result; if ((text == "<InputUtils-Gamepad-Not-Bound>" || text == "<InputUtils-Kbm-Not-Bound>") ? true : false) { __result = ""; } } } } public static class KeyRemapPanelPatches { [HarmonyPatch(typeof(KepRemapPanel), "OnEnable")] public static class LoadKeybindsUIPatch { [CompilerGenerated] private static class <>O { public static UnityAction <0>__CloseContainerLayer; } public static void Prefix(KepRemapPanel __instance) { //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Expected O, but got Unknown //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Expected O, but got Unknown //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_018c: 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_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Expected O, but got Unknown //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Expected O, but got Unknown //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Expected O, but got Unknown LcInputActionApi.DisableForRebind(); if (LcInputActionApi.PrefabLoaded && LcInputActionApi.ContainerInstance != null) { LcInputActionApi.ContainerInstance.baseGameKeys.DisableKeys(); return; } GameObject val = Object.Instantiate<GameObject>(Assets.Load<GameObject>("Prefabs/InputUtilsRemapContainer.prefab"), ((Component)__instance).transform); GameObject val2 = Object.Instantiate<GameObject>(Assets.Load<GameObject>("Prefabs/Legacy Holder.prefab"), ((Component)__instance).transform); if (val == null || val2 == null) { return; } Transform val3 = ((Component)__instance).transform.Find("Scroll View"); if (val3 != null) { val3.SetParent(val2.transform); List<RemappableKey> remappableKeys = __instance.remappableKeys; __instance.remappableKeys = new List<RemappableKey>(); val2.SetActive(false); GameObject gameObject = ((Component)((Component)__instance).transform.Find("Back")).gameObject; Button component = gameObject.GetComponent<Button>(); GameObject obj = Object.Instantiate<GameObject>(gameObject, val2.transform, true); Object.DestroyImmediate((Object)(object)obj.GetComponentInChildren<SettingsOption>()); Button component2 = obj.GetComponent<Button>(); component2.onClick = new ButtonClickedEvent(); ButtonClickedEvent onClick = component2.onClick; object obj2 = <>O.<0>__CloseContainerLayer; if (obj2 == null) { UnityAction val4 = LcInputActionApi.CloseContainerLayer; <>O.<0>__CloseContainerLayer = val4; obj2 = (object)val4; } ((UnityEvent)onClick).AddListener((UnityAction)obj2); GameObject obj3 = Object.Instantiate<GameObject>(gameObject, gameObject.transform.parent); Object.DestroyImmediate((Object)(object)obj3.GetComponentInChildren<SettingsOption>()); Button component3 = obj3.GetComponent<Button>(); component3.onClick = new ButtonClickedEvent(); RectTransform component4 = obj3.GetComponent<RectTransform>(); component4.SetAnchoredPosY(component4.anchoredPosition.y + 25f); component4.SetSizeDeltaX(component4.sizeDelta.x + 180f); RectTransform component5 = ((Component)((Transform)component4).Find("SelectionHighlight")).GetComponent<RectTransform>(); component5.SetSizeDeltaX(410f); component5.offsetMax = new Vector2(410f, component5.offsetMax.y); component5.offsetMin = new Vector2(0f, component5.offsetMin.y); RemapContainerController component6 = val.GetComponent<RemapContainerController>(); component6.baseGameKeys = remappableKeys; component6.backButton = component; component6.legacyButton = component3; component6.legacyHolder = val2; component6.baseGameKeys.DisableKeys(); ((UnityEvent)component3.onClick).AddListener(new UnityAction(component6.ShowLegacyUi)); component6.LoadUi(); Button component7 = ((Component)((Component)__instance).transform.Find("SetDefault")).gameObject.GetComponent<Button>(); ((UnityEventBase)component7.onClick).RemoveAllListeners(); ((UnityEvent)component7.onClick).AddListener(new UnityAction(component6.OnSetToDefault)); val2.transform.SetAsLastSibling(); LcInputActionApi.PrefabLoaded = true; } } public static void Postfix(KepRemapPanel __instance) { LcInputActionApi.LoadIntoUI(__instance); } } [HarmonyPatch(typeof(KepRemapPanel), "OnDisable")] public static class UnloadKeybindsUIPatch { public static void Prefix() { if (LcInputActionApi.ContainerInstance != null) { LcInputActionApi.ContainerInstance.baseGameKeys.EnableKeys(); } } } } public static class MenuManagerPatches { [HarmonyPatch(typeof(MenuManager), "Awake")] public static class AwakePatch { public static void Prefix(MenuManager __instance) { if (__instance.menuAnimator != null) { Transform transform = ((Component)__instance.menuAnimator).gameObject.transform; Object.Instantiate<GameObject>(Assets.Load<GameObject>("Prefabs/PopOver Layer.prefab"), transform); } } } } public static class QuickMenuManagerPatches { [HarmonyPatch(typeof(QuickMenuManager), "Start")] public static class StartPatch { public static void Prefix(QuickMenuManager __instance) { Object.Instantiate<GameObject>(Assets.Load<GameObject>("Prefabs/PopOver Layer.prefab"), __instance.menuContainer.transform); } } [HarmonyPatch(typeof(QuickMenuManager), "CloseQuickMenu")] public static class CloseQuickMenuPatch { public static bool Prefix(QuickMenuManager __instance) { if (LcInputActionApi.RemapContainerVisible() && __instance.isMenuOpen) { LcInputActionApi.CloseContainerLayer(); return false; } return true; } public static void Postfix() { VanillaInputActions.Instance.Load(); } } } public static class SettingsOptionPatches { [HarmonyPatch(typeof(SettingsOption), "SetBindingToCurrentSetting")] public static class SetBindingToCurrentSettingPatch { public static bool Prefix(SettingsOption __instance) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 //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_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //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) if ((int)__instance.optionType != 6) { return true; } Enumerator<InputBinding> enumerator = __instance.rebindableAction.action.bindings.GetEnumerator(); try { while (enumerator.MoveNext()) { InputBinding current = enumerator.Current; if (__instance.gamepadOnlyRebinding) { if (!string.Equals(((InputBinding)(ref current)).effectivePath, "<InputUtils-Gamepad-Not-Bound>")) { continue; } } else if (!string.Equals(((InputBinding)(ref current)).effectivePath, "<InputUtils-Kbm-Not-Bound>")) { continue; } ((TMP_Text)__instance.currentlyUsedKeyText).SetText("", true); return false; } } finally { ((IDisposable)enumerator).Dispose(); } return true; } } } } namespace LethalCompanyInputUtils.Localization { public static class LangTokens { public const string ResetToDefaultPopOver = "RebindButton.ResetToDefault.PopOver"; public const string RemoveBindPopOver = "RebindButton.RemoveBind.PopOver"; public const string UnsupportedDeviceBindPopOver = "RebindButton.NotSupportedDeviceBind.PopOver"; public const string BindingOverrideContextSwitchInfoPopOver = "BindingOverrideContextSwitch.Info.PopOver"; public const string BindingOverridePriorityDropdownInfoPopOver = "BindingOverridePriorityDropdown.Info.PopOver"; } [Serializable] internal class Locale { public string? fallback; public Dictionary<string, string> entries = new Dictionary<string, string>(); public static Locale LoadFrom(string jsonPath) { return JsonConvert.DeserializeObject<Locale>(File.ReadAllText(jsonPath)) ?? throw new NullReferenceException(); } } internal static class LocaleManager { private static readonly Dictionary<string, Func<string>> Keywords = new Dictionary<string, Func<string>>(); private static readonly Dictionary<string, string> LocaleEntries = new Dictionary<string, string>(); internal static void LoadLocaleData() { if (Keywords.Count == 0) { InitKeywords(); } Stack<Locale> stack = new Stack<Locale>(); string text = InputUtilsConfig.localeKey.Value; string text2 = Path.Combine(FsUtils.LocaleDir, text + ".json"); if (!File.Exists(text2)) { Logging.Warn("Could not find Locale " + text + " at `" + text2 + "`!\nFalling back to `en_US`"); text = "en_US"; text2 = Path.Combine(FsUtils.LocaleDir, text + ".json"); } while (File.Exists(text2)) { Locale locale = Locale.LoadFrom(text2); stack.Push(locale); text = ((!(text != "en_US") || locale.fallback != null) ? locale.fallback : "en_US"); text2 = Path.Combine(FsUtils.LocaleDir, text + ".json"); if (text == null) { break; } } Locale result; while (stack.TryPop(out result)) { foreach (var (key, value) in result.entries) { LocaleEntries[key] = value; } } } private static void InitKeywords() { Keywords.Add("CurrentContext", () => GetString($"Context.{BindingOverrideContextSwitch.currentContext}")); Keywords.Add("OppositeContext", () => GetString($"Context.{((BindingOverrideContextSwitch.currentContext == BindingOverrideType.Global) ? BindingOverrideType.Local : BindingOverrideType.Global)}")); Keywords.Add("BindingOverridePriorityConfigValue", () => InputUtilsConfig.bindingOverridePriority.Value switch { BindingOverridePriority.GlobalThenLocal => GetString("OverridePriority.PreferGlobal"), BindingOverridePriority.LocalThenGlobal => GetString("OverridePriority.PreferLocal"), BindingOverridePriority.GlobalOnly => GetString("OverridePriority.GlobalOnly"), BindingOverridePriority.LocalOnly => GetString("OverridePriority.LocalOnly"), _ => throw new ArgumentOutOfRangeException(), }); Keywords.Add("OptionalPreferPriority", delegate { BindingOverrideType currentContext = BindingOverrideContextSwitch.currentContext; BindingOverridePriority value = InputUtilsConfig.bindingOverridePriority.Value; bool flag = (uint)(value - 2) <= 1u; return (flag || (value == BindingOverridePriority.GlobalThenLocal && currentContext == BindingOverrideType.Local) || (value == BindingOverridePriority.LocalThenGlobal && currentContext == BindingOverrideType.Global)) ? "" : GetString("RebindButton.DisabledByOverride.PopOver.Optional"); }); } internal static string[] GetAllLocales() { return Directory.GetFiles(FsUtils.LocaleDir, "*.json").Select(Path.GetFileNameWithoutExtension).ToArray(); } public static bool ContainsToken(string token) { return LocaleEntries.ContainsKey(token); } public static string GetString(string token) { if (!LocaleEntries.TryGetValue(token, out string value)) { Logging.Error("Could not find LocalizedString for '" + token + "'!"); return token; } foreach (KeyValuePair<string, Func<string>> keyword in Keywords) { keyword.Deconstruct(out var key, out var value2); string value3 = key; Func<string> func = value2; int num = value.IndexOf(value3, StringComparison.InvariantCulture); int num2 = -1; while (num >= 0) { int num3 = num - 1; if (num2 < 0) { if (num3 < 0) { num = value.IndexOf(value3, num + 1, StringComparison.InvariantCulture); } else if (value[num3] == '[' && (num3 - 1 < 0 || value[num3 - 1] != '\\')) { num2 = num3; } else { num = value.IndexOf(value3, num + 1, StringComparison.InvariantCulture); } continue; } int num4 = value.IndexOf(']', num2); if (num4 < 0) { break; } num3 = num4 - 1; if (value[num3] == '\\') { break; } try { string text = func(); int num5 = num4 - num2 + 1; int num6 = text.Length - num5; value = value.Remove(num2, num5).Insert(num2, text); num4 += num6; } catch (Exception arg) { Logging.Error($"Error caught during keyword replacement:\n{arg}"); } if (num4 >= value.Length) { break; } num = value.IndexOf(value3, num4, StringComparison.InvariantCulture); num2 = -1; } } return value.Replace("\\[", "[").Replace("\\]", "]"); } } } namespace LethalCompanyInputUtils.Glyphs { [CreateAssetMenu] public class ControllerGlyph : ScriptableObject { public List<string> validGamepadTypes = new List<string>(); public List<GlyphDef> glyphSet = new List<GlyphDef>(); private readonly Dictionary<string, Sprite?> _glyphLut = new Dictionary<string, Sprite>(); private static readonly List<ControllerGlyph> Instances = new List<ControllerGlyph>(); private static bool _loaded; public static ControllerGlyph? MouseGlyphs { get; private set; } public bool IsCurrent { get { Gamepad current = Gamepad.current; if (current == null) { return false; } return validGamepadTypes.Any((string gamepadTypeName) => string.Equals(gamepadTypeName, ((object)current).GetType().Name)); } } public Sprite this[string controlPath] { get { if (_glyphLut.Count == 0) { UpdateLut(); } return _glyphLut.GetValueOrDefault(controlPath, null); } } public static ControllerGlyph? GetBestMatching() { if (Instances.Count == 0) { return null; } foreach (ControllerGlyph instance in Instances) { if (instance.IsCurrent) { return instance; } } return Instances[0]; } internal static void LoadGlyphs() { if (!_loaded) { Assets.Load<ControllerGlyph>("controller glyphs/xbox series x glyphs.asset"); Assets.Load<ControllerGlyph>("controller glyphs/dualsense glyphs.asset"); MouseGlyphs = Assets.Load<ControllerGlyph>("controller glyphs/mouse glyphs.asset"); _loaded = true; } } private void Awake() { if (!Instances.Contains(this)) { Instances.Add(this); } } private void UpdateLut() { foreach (GlyphDef item in glyphSet) { _glyphLut[item.controlPath] = item.glyphSprite; } } private void OnDestroy() { if (Instances.Contains(this)) { Instances.Remove(this); } } } [CreateAssetMenu] public class GlyphDef : ScriptableObject { public string controlPath = ""; public Sprite? glyphSprite; } } namespace LethalCompanyInputUtils.Data { [Serializable] public struct BindingOverride { public string? action; public string? origPath; public string? path; public string? groups; } [Serializable] public class BindingOverrides { public List<BindingOverride> overrides; public BindingOverrides() { overrides = new List<BindingOverride>(); } public BindingOverrides(IEnumerable<InputBinding> bindings) { //IL_001b: 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) overrides = new List<BindingOverride>(); foreach (InputBinding binding in bindings) { InputBinding current = binding; if (((InputBinding)(ref current)).hasOverrides) { BindingOverride item = new BindingOverride { action = ((InputBinding)(ref current)).action, origPath = ((InputBinding)(ref current)).path, path = ((InputBinding)(ref current)).overridePath, groups = ((InputBinding)(ref current)).groups }; overrides.Add(item); } } } public void LoadInto(InputActionAsset asset) { foreach (BindingOverride @override in overrides) { InputAction val = asset.FindAction(@override.action, false); string groups = @override.groups; if (string.IsNullOrEmpty(groups)) { if (val != null) { InputActionRebindingExtensions.ApplyBindingOverride(val, @override.path, (string)null, @override.origPath); } } else if (val != null) { InputActionRebindingExtensions.ApplyBindingOverride(val, @override.path, groups, (string)null); } } } public void LoadInto(IReadOnlyCollection<InputActionReference> actionRefs) { foreach (BindingOverride @override in overrides) { foreach (InputActionReference actionRef in actionRefs) { if (!(actionRef.action.name != @override.action)) { string groups = @override.groups; if (string.IsNullOrEmpty(groups)) { InputActionRebindingExtensions.ApplyBindingOverride(actionRef.action, @override.path, (string)null, @override.origPath); } else { InputActionRebindingExtensions.ApplyBindingOverride(actionRef.action, @override.path, groups, (string)null); } break; } } } } public bool ContainsOverrideFor(RemappableKey key) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_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_0034: 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) InputAction action = key.currentInput.action; int rebindingIndex = key.GetRebindingIndex(); if (rebindingIndex < 0 || rebindingIndex >= action.bindings.Count) { return false; } InputBinding val = action.bindings[rebindingIndex]; foreach (BindingOverride @override in overrides) { if (!(action.name != @override.action)) { string origPath = @override.origPath; string groups = @override.groups; if (!string.IsNullOrEmpty(groups) && ((InputBinding)(ref val)).groups.Contains(groups) && ((InputBinding)(ref val)).path == origPath) { return true; } if (((InputBinding)(ref val)).path == origPath) { return true; } } } return false; } public string AsJson() { return JsonConvert.SerializeObject((object)this); } public static BindingOverrides FromJson(string json) { BindingOverrides bindingOverrides = new BindingOverrides(); JToken value = JsonConvert.DeserializeObject<JObject>(json).GetValue("overrides"); bindingOverrides.overrides = value.ToObject<List<BindingOverride>>(); return bindingOverrides; } public static bool TryFromUnityInputJson(InputActionAsset asset, string json, out BindingOverrides? overrides) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0032: 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_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0044: 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_0082: 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_009b: 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_00a6: Unknown result type (might be due to invalid IL or missing references