Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of LethalKeys v0.1.1
LethalKeys.dll
Decompiled 12 minutes agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; 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 GameNetcodeStuff; using HarmonyLib; using LethalConfig; using LethalConfig.ConfigItems; using LethalConfig.ConfigItems.Options; using LethalKeys.Compat; using Microsoft.CodeAnalysis; using Steamworks.Data; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Utilities; [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("com.olegknyazev.softmask")] [assembly: IgnoresAccessChecksTo("DissonanceVoip")] [assembly: IgnoresAccessChecksTo("DunGen")] [assembly: IgnoresAccessChecksTo("DunGen.Integration.ASPP")] [assembly: IgnoresAccessChecksTo("DunGen.Integration.UnityNav")] [assembly: IgnoresAccessChecksTo("EasyTextEffects")] [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.Components")] [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("Unity.XR.CoreUtils")] [assembly: IgnoresAccessChecksTo("Unity.XR.Management")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.ConformanceAutomation")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.MetaQuestSupport")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.MockRuntime")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.OculusQuestSupport")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.RuntimeDebugger")] [assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.SpatialTracking")] [assembly: IgnoresAccessChecksTo("UnityEngine.UI")] [assembly: IgnoresAccessChecksTo("UnityEngine.XR.LegacyInputHelpers")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("LethalKeys")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.1.1.0")] [assembly: AssemblyInformationalVersion("0.1.1+d77de33693a1dd92356a27387acf4f94f16aadf5")] [assembly: AssemblyProduct("LethalKeys")] [assembly: AssemblyTitle("LethalKeys")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.1.1.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace LethalKeys { internal static class Hud { private const float QuietDelay = 1.5f; private const float GameAnnouncementDuration = 8f; private const int MaxLines = 4; private const float PageInterval = 6f; private static int _pageNumber; private static float _nextPageAt; private static readonly List<string> QueuedLines = new List<string>(); private static string _queuedHeader; private static float _busyUntil; private static float _readySince = -1f; internal static void Tip(string header, string body, bool warning = false) { if (!((Object)(object)HUDManager.Instance == (Object)null)) { HUDManager.Instance.DisplayTip(StripAccents(header), StripAccents(body), warning, false, "LC_Tip1"); } } internal static void Enqueue(string header, string line) { _queuedHeader = header; QueuedLines.Add(line); Plugin.Log.LogInfo((object)("Message en attente : " + StripAccents(line))); } internal static void ClearQueue() { QueuedLines.Clear(); _readySince = -1f; _pageNumber = 0; _nextPageAt = 0f; } internal static void MarkBusy(string reason) { _busyUntil = Time.time + 8f; _readySince = -1f; if (QueuedLines.Count > 0) { Plugin.Log.LogInfo((object)("ATH occupé (" + reason + "), message reporté.")); } } internal static void Tick(PlayerControllerB local) { if (QueuedLines.Count == 0) { return; } if (!IsHudFree(local)) { _readySince = -1f; return; } if (_readySince < 0f) { _readySince = Time.time; } if (!(Time.time - _readySince < 1.5f) && !(Time.time < _nextPageAt)) { List<string> list = QueuedLines.Take(4).ToList(); QueuedLines.RemoveRange(0, list.Count); string text = _queuedHeader ?? "LethalKeys"; if (_pageNumber > 0 || QueuedLines.Count > 0) { text += $" {_pageNumber + 1}/{_pageNumber + 1 + (QueuedLines.Count + 4 - 1) / 4}"; } string text2 = string.Join("\n", list); Tip(text, text2, warning: true); Plugin.Log.LogInfo((object)("Message affiché : " + StripAccents(text) + " - " + StripAccents(text2).Replace("\n", " | "))); if (QueuedLines.Count > 0) { _pageNumber++; _nextPageAt = Time.time + 6f; } else { ClearQueue(); } } } private static bool IsHudFree(PlayerControllerB local) { HUDManager instance = HUDManager.Instance; if ((Object)(object)instance == (Object)null || (Object)(object)local == (Object)null) { return false; } if (local.isPlayerDead || !local.isPlayerControlled) { return false; } if (instance.hudHidden || instance.displayingNewQuota) { return false; } if (Time.time < _busyUntil) { return false; } return true; } internal static string StripAccents(string text) { if (string.IsNullOrEmpty(text)) { return text; } string text2 = text.Normalize(NormalizationForm.FormD); StringBuilder stringBuilder = new StringBuilder(text2.Length); string text3 = text2; foreach (char c in text3) { if (CharUnicodeInfo.GetUnicodeCategory(c) != UnicodeCategory.NonSpacingMark) { stringBuilder.Append(c); } } return stringBuilder.ToString().Normalize(NormalizationForm.FormC); } } internal static class KeyPool { internal const string KeyboardPrefix = "<keyboard>/"; internal const string MousePrefix = "<mouse>/"; internal static readonly string[] MouseButtons = new string[5] { "<mouse>/leftbutton", "<mouse>/rightbutton", "<mouse>/middlebutton", "<mouse>/forwardbutton", "<mouse>/backbutton" }; internal static readonly (string Group, string[] Keys)[] DefaultKeyGroups = new(string, string[])[4] { ("Touches - Lettres", "abcdefghijklmnopqrstuvwxyz".Select((char c) => c.ToString()).ToArray()), ("Touches - Chiffres", "0123456789".Select((char c) => c.ToString()).ToArray()), ("Touches - Speciales", new string[12] { "space", "shift", "ctrl", "tab", "comma", "period", "semicolon", "quote", "leftBracket", "rightBracket", "minus", "equals" }), ("Touches - Souris", new string[5] { "mouse/leftButton", "mouse/rightButton", "mouse/middleButton", "mouse/forwardButton", "mouse/backButton" }) }; private static readonly HashSet<string> LockedActions = new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "OpenMenu", "EnableChat", "SubmitChat" }; internal static string ToPath(string name) { string text = name.Trim(); if (text.StartsWith("<")) { return Normalize(text); } if (text.StartsWith("mouse/", StringComparison.OrdinalIgnoreCase)) { return "<mouse>/" + text.Substring(6).ToLowerInvariant(); } return "<keyboard>/" + text.ToLowerInvariant(); } internal static string Normalize(string path) { if (!string.IsNullOrEmpty(path)) { return path.Trim().ToLowerInvariant(); } return ""; } internal static bool IsKeyboard(string path) { return Normalize(path).StartsWith("<keyboard>/", StringComparison.Ordinal); } internal static bool IsMouseButton(string path) { return Array.IndexOf(MouseButtons, Normalize(path)) >= 0; } internal static bool IsBindable(string path) { if (!IsKeyboard(path)) { return IsMouseButton(path); } return true; } internal static HashSet<string> OccupiedKeys() { HashSet<string> occupied = new HashSet<string>(); if ((Object)(object)InputSystem.actions != (Object)null) { foreach (InputAction action in InputSystem.actions) { Collect(action); } } foreach (InputAction item in InputSystem.ListEnabledActions()) { Collect(item); } return occupied; void Collect(InputAction action) { //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_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_0018: Unknown result type (might be due to invalid IL or missing references) Enumerator<InputBinding> enumerator3 = action.bindings.GetEnumerator(); try { while (enumerator3.MoveNext()) { InputBinding current = enumerator3.Current; if (!((InputBinding)(ref current)).isComposite && IsBindable(((InputBinding)(ref current)).effectivePath)) { occupied.Add(Normalize(((InputBinding)(ref current)).effectivePath)); } } } finally { ((IDisposable)enumerator3/*cast due to .constrained prefix*/).Dispose(); } } } internal static List<string> SourceKeys(ICollection<string> eligibleActions) { //IL_005d: 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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0071: 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) HashSet<string> hashSet = new HashSet<string>(); HashSet<string> hashSet2 = new HashSet<string>(); InputActionAsset actions = InputSystem.actions; if ((Object)(object)actions == (Object)null) { return new List<string>(); } foreach (InputAction item2 in actions) { bool num = eligibleActions.Contains(item2.name); bool flag = LockedActions.Contains(item2.name); if (!num && !flag) { continue; } Enumerator<InputBinding> enumerator2 = item2.bindings.GetEnumerator(); try { while (enumerator2.MoveNext()) { InputBinding current2 = enumerator2.Current; if (!((InputBinding)(ref current2)).isComposite && IsBindable(((InputBinding)(ref current2)).effectivePath)) { string item = Normalize(((InputBinding)(ref current2)).effectivePath); if (flag) { hashSet2.Add(item); } else { hashSet.Add(item); } } } } finally { ((IDisposable)enumerator2/*cast due to .constrained prefix*/).Dispose(); } } hashSet.ExceptWith(hashSet2); return hashSet.ToList(); } internal static List<string> FreeKeys(IEnumerable<string> allowedKeys) { HashSet<string> occupied = OccupiedKeys(); return (from k in allowedKeys.Where(IsBindable) where !occupied.Contains(k) where IsHudFriendly(KeyScrambler.Describe(k)) select k).ToList(); } private static bool IsHudFriendly(string name) { if (!string.IsNullOrEmpty(name)) { return name.All((char c) => c >= ' ' && c < '\u007f'); } return false; } internal static List<string> ParseKeyList(string csv) { List<string> list = new List<string>(); string[] array = (csv ?? "").Split(new char[3] { ',', ';', ' ' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < array.Length; i++) { string text = array[i].Trim(); string text2 = ToPath(text); bool flag = IsKeyboard(text2) && Keyboard.current != null && InputControlPath.TryFindControl((InputControl)(object)Keyboard.current, text2, 0) == null; if (!IsBindable(text2) || flag) { Plugin.Log.LogWarning((object)("ExtraKeys : '" + text + "' ignorée (ni une touche clavier, ni un bouton de souris).")); } else if (!list.Contains(text2)) { list.Add(text2); } } return list; } internal static HashSet<string> ParseNameList(string csv) { return new HashSet<string>(from s in (csv ?? "").Split(new char[3] { ',', ';', ' ' }, StringSplitOptions.RemoveEmptyEntries) select s.Trim(), StringComparer.OrdinalIgnoreCase); } } internal sealed class ScrambleResult { public string FromPath; public string ToPath; public List<string> Actions = new List<string>(); public string Describe() { return string.Join(", ", Actions) + " : " + KeyScrambler.Describe(FromPath) + " -> " + KeyScrambler.Describe(ToPath); } } internal readonly struct StoredBinding { public readonly string ActionName; public readonly int BindingIndex; public readonly string ToPath; public StoredBinding(string actionName, int bindingIndex, string toPath) { ActionName = actionName; BindingIndex = bindingIndex; ToPath = toPath; } } internal static class KeyScrambler { private sealed class Change { public InputAction Action; public int BindingIndex; public string PreviousOverride; public string ToPath; public string CurrentOverride { get { //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_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) InputBinding val = Action.bindings[BindingIndex]; return ((InputBinding)(ref val)).overridePath; } } } private static readonly List<Change> Changes = new List<Change>(); private static readonly Random Rng = new Random(); private static bool _suspended; private static readonly Dictionary<string, string> DisplayNames = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase) { ["Move"] = "Deplacements", ["Move/up"] = "Avancer", ["Move/down"] = "Reculer", ["Move/left"] = "Gauche", ["Move/right"] = "Droite", ["Jump"] = "Sauter", ["Sprint"] = "Courir", ["Crouch"] = "S'accroupir", ["Interact"] = "Interagir", ["Discard"] = "Lacher", ["ItemSecondaryUse"] = "Objet (secondaire)", ["ReloadBatteries"] = "Recharger", ["InspectItem"] = "Inspecter", ["VoiceButton"] = "Parler", ["Emote1"] = "Emote 1", ["Emote2"] = "Emote 2", ["BuildMode"] = "Construction", ["ConfirmBuildMode"] = "Placer", ["Delete"] = "Ranger meuble", ["UseUtilitySlot"] = "Slot utilitaire", ["PingScan"] = "Scanner", ["ActivateItem"] = "Utiliser objet", ["Use"] = "Utiliser" }; private static readonly Dictionary<string, string> MouseNames = new Dictionary<string, string> { ["<mouse>/leftbutton"] = "Clic gauche", ["<mouse>/rightbutton"] = "Clic droit", ["<mouse>/middlebutton"] = "Clic molette", ["<mouse>/forwardbutton"] = "Souris avant", ["<mouse>/backbutton"] = "Souris arriere" }; internal static IEnumerable<InputActionAsset> Assets { get { InputActionAsset global = InputSystem.actions; if ((Object)(object)global != (Object)null) { yield return global; } InputActionAsset val = (((Object)(object)IngamePlayerSettings.Instance != (Object)null && (Object)(object)IngamePlayerSettings.Instance.playerInput != (Object)null) ? IngamePlayerSettings.Instance.playerInput.actions : null); if ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)global) { yield return val; } } } internal static bool HasChanges => Changes.Count > 0; internal static ScrambleResult Scramble(ICollection<string> eligibleActions, IEnumerable<string> allowedKeys) { List<string> list = KeyPool.SourceKeys(eligibleActions); List<string> list2 = KeyPool.FreeKeys(allowedKeys); if (list.Count == 0) { Plugin.Log.LogWarning((object)"Scramble : aucune touche source (aucune action éligible sur le clavier ?)."); return null; } if (list2.Count == 0) { Plugin.Log.LogWarning((object)"Scramble : aucune touche libre, rien n'est changé."); return null; } string fromPath = list[Rng.Next(list.Count)]; string toPath = list2[Rng.Next(list2.Count)]; Plugin.Log.LogInfo((object)string.Format("Scramble : {0} source(s) [{1}], {2} cible(s) libre(s).", list.Count, string.Join(" ", list), list2.Count)); List<string> source = RemapKey(fromPath, toPath); ScrambleResult scrambleResult = new ScrambleResult { FromPath = fromPath, ToPath = toPath, Actions = source.Where((string n) => eligibleActions.Contains(n.Split('/')[0])).Select(DisplayName).Distinct() .ToList() }; Plugin.Log.LogInfo((object)("Scramble : " + scrambleResult.Describe())); return scrambleResult; } internal static List<string> RemapKey(string fromPath, string toPath) { //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) List<string> list = new List<string>(); int num = 0; foreach (InputActionAsset asset in Assets) { num++; foreach (InputAction item2 in asset) { for (int i = 0; i < item2.bindings.Count; i++) { InputBinding val = item2.bindings[i]; if (!((InputBinding)(ref val)).isComposite && string.Equals(((InputBinding)(ref val)).effectivePath, fromPath, StringComparison.OrdinalIgnoreCase)) { Apply(item2, i, toPath); string item = BindingName(item2, i); if (!list.Contains(item)) { list.Add(item); } Plugin.Log.LogInfo((object)$" [{((Object)asset).name}] {item2.name}#{i} ({((InputBinding)(ref val)).name}) : {fromPath} -> {toPath}"); } } } } if (num == 0) { Plugin.Log.LogWarning((object)"RemapKey : aucun asset d'actions trouvé."); } Plugin.Log.LogInfo((object)$"RemapKey {Describe(fromPath)} -> {Describe(toPath)} : {list.Count} action(s) modifiée(s)."); return list; } private static void Apply(InputAction action, int index, string toPath) { //IL_001a: 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_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) List<Change> changes = Changes; Change obj = new Change { Action = action, BindingIndex = index }; InputBinding val = action.bindings[index]; obj.PreviousOverride = ((InputBinding)(ref val)).overridePath; obj.ToPath = toPath; changes.Add(obj); InputActionRebindingExtensions.ApplyBindingOverride(action, index, toPath); } internal static void ResetAll() { if (!_suspended) { RestorePrevious(dropIfChangedByPlayer: false); } Plugin.Log.LogInfo((object)$"ResetAll : {Changes.Count} binding(s) restauré(s)."); Changes.Clear(); _suspended = false; } internal static void Suspend(bool dropIfChangedByPlayer) { if (!_suspended && Changes.Count != 0) { RestorePrevious(dropIfChangedByPlayer); _suspended = true; } } internal static void Resume() { if (!_suspended) { return; } _suspended = false; foreach (Change change in Changes) { change.PreviousOverride = change.CurrentOverride; InputActionRebindingExtensions.ApplyBindingOverride(change.Action, change.BindingIndex, change.ToPath); } } internal static void Reapply(string reason) { if (Changes.Count != 0) { Suspend(dropIfChangedByPlayer: false); Resume(); Plugin.Log.LogInfo((object)$"Reapply ({reason}) : {Changes.Count} binding(s) réappliqué(s)."); } } private static void RestorePrevious(bool dropIfChangedByPlayer) { for (int num = Changes.Count - 1; num >= 0; num--) { Change change = Changes[num]; try { if (!string.Equals(change.CurrentOverride, change.ToPath, StringComparison.OrdinalIgnoreCase)) { if (dropIfChangedByPlayer) { Plugin.Log.LogInfo((object)$"{change.Action.name}#{change.BindingIndex} réassigné par le joueur : abandonné par le mod."); Changes.RemoveAt(num); } } else if (string.IsNullOrEmpty(change.PreviousOverride)) { InputActionRebindingExtensions.RemoveBindingOverride(change.Action, change.BindingIndex); } else { InputActionRebindingExtensions.ApplyBindingOverride(change.Action, change.BindingIndex, change.PreviousOverride); } } catch (Exception ex) { ManualLogSource log = Plugin.Log; InputAction action = change.Action; log.LogWarning((object)$"Restauration impossible de {((action != null) ? action.name : null)}#{change.BindingIndex} : {ex.Message}"); } } } internal static List<StoredBinding> Export() { InputActionAsset actions = InputSystem.actions; List<StoredBinding> list = new List<StoredBinding>(); HashSet<string> hashSet = new HashSet<string>(); for (int num = Changes.Count - 1; num >= 0; num--) { Change change = Changes[num]; InputActionMap actionMap = change.Action.actionMap; if (!((Object)(object)((actionMap != null) ? actionMap.asset : null) != (Object)(object)actions)) { string item = $"{change.Action.name}#{change.BindingIndex}"; if (hashSet.Add(item)) { list.Add(new StoredBinding(change.Action.name, change.BindingIndex, change.ToPath)); } } } list.Reverse(); return list; } internal static int Import(IEnumerable<StoredBinding> stored) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) int num = 0; foreach (StoredBinding item in stored) { foreach (InputActionAsset asset in Assets) { InputAction val = asset.FindAction(item.ActionName, false); if (val == null || item.BindingIndex < 0 || item.BindingIndex >= val.bindings.Count) { Plugin.Log.LogWarning((object)$"Import : {item.ActionName}#{item.BindingIndex} introuvable dans {((Object)asset).name}, ignoré."); continue; } Apply(val, item.BindingIndex, item.ToPath); if ((Object)(object)asset == (Object)(object)InputSystem.actions) { num++; } } } Plugin.Log.LogInfo((object)$"Import : {num} binding(s) restauré(s) depuis la sauvegarde."); return num; } internal static List<string> Summary(ICollection<string> eligibleActions) { //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_00ad: 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) InputActionAsset actions = InputSystem.actions; List<string> list = new List<string>(); HashSet<string> hashSet = new HashSet<string>(); foreach (Change change in Changes) { InputActionMap actionMap = change.Action.actionMap; if ((Object)(object)((actionMap != null) ? actionMap.asset : null) != (Object)(object)actions || !eligibleActions.Contains(change.Action.name)) { continue; } string item = $"{change.Action.name}#{change.BindingIndex}"; if (hashSet.Add(item)) { InputBinding val = change.Action.bindings[change.BindingIndex]; string text = (string.IsNullOrEmpty(change.PreviousOverride) ? ((InputBinding)(ref val)).path : change.PreviousOverride); string effectivePath = ((InputBinding)(ref val)).effectivePath; if (!string.Equals(text, effectivePath, StringComparison.OrdinalIgnoreCase)) { list.Add(DisplayName(BindingName(change.Action, change.BindingIndex)) + " : " + Describe(text) + " -> " + Describe(effectivePath)); } } } return list; } private static string BindingName(InputAction action, int index) { //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_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) InputBinding val = action.bindings[index]; string name = ((InputBinding)(ref val)).name; if (!string.IsNullOrEmpty(name)) { return action.name + "/" + name; } return action.name; } internal static string DisplayName(string bindingName) { if (!DisplayNames.TryGetValue(bindingName, out var value)) { return bindingName; } return value; } internal static string Describe(string path) { if (string.IsNullOrEmpty(path)) { return "?"; } string text = KeyPool.Normalize(path); if (MouseNames.TryGetValue(text, out var value)) { return value; } if (text.Length == "<keyboard>/".Length + 1 && text.StartsWith("<keyboard>/") && char.IsDigit(text[text.Length - 1])) { return "Touche " + text[text.Length - 1]; } try { InputControl val = ((Keyboard.current != null && KeyPool.IsKeyboard(path)) ? InputControlPath.TryFindControl((InputControl)(object)Keyboard.current, path, 0) : null); if (val != null && !string.IsNullOrEmpty(val.displayName)) { return val.displayName; } return InputControlPath.ToHumanReadableString(path, (HumanReadableStringOptions)2, (InputControl)null); } catch { return path; } } } internal static class Persistence { private const string Es3Key = "LethalKeys_Bindings"; private static string ClientDir => Path.Combine(Paths.ConfigPath, "LethalKeys"); internal static void Save(List<StoredBinding> bindings) { string text = Serialize(bindings); try { if (IsHost(out var saveFile)) { ES3.Save<string>("LethalKeys_Bindings", text, saveFile); Plugin.Log.LogInfo((object)$"Sauvegarde (hôte, {saveFile}) : {bindings.Count} binding(s)."); return; } string path = ClientFile(); Directory.CreateDirectory(ClientDir); File.WriteAllText(path, text); Plugin.Log.LogInfo((object)$"Sauvegarde (client, {Path.GetFileName(path)}) : {bindings.Count} binding(s)."); } catch (Exception arg) { Plugin.Log.LogError((object)$"Sauvegarde impossible : {arg}"); } } internal static List<StoredBinding> Load() { try { string text; if (IsHost(out var saveFile)) { text = (ES3.KeyExists("LethalKeys_Bindings", saveFile) ? ES3.Load<string>("LethalKeys_Bindings", saveFile, "") : ""); Plugin.Log.LogInfo((object)("Chargement (hôte, " + saveFile + ") : " + (string.IsNullOrEmpty(text) ? "rien" : "données trouvées") + ".")); } else { string path = ClientFile(); text = (File.Exists(path) ? File.ReadAllText(path) : ""); Plugin.Log.LogInfo((object)("Chargement (client, " + Path.GetFileName(path) + ") : " + (string.IsNullOrEmpty(text) ? "rien" : "données trouvées") + ".")); } return Deserialize(text); } catch (Exception arg) { Plugin.Log.LogError((object)$"Chargement impossible : {arg}"); return new List<StoredBinding>(); } } internal static void Clear() { try { if (IsHost(out var saveFile)) { if (ES3.KeyExists("LethalKeys_Bindings", saveFile)) { ES3.DeleteKey("LethalKeys_Bindings", saveFile); } Plugin.Log.LogInfo((object)("Données effacées (hôte, " + saveFile + ").")); return; } string path = ClientFile(); if (File.Exists(path)) { File.Delete(path); } Plugin.Log.LogInfo((object)("Données effacées (client, " + Path.GetFileName(path) + ").")); } catch (Exception arg) { Plugin.Log.LogError((object)$"Effacement impossible : {arg}"); } } private static bool IsHost(out string saveFile) { GameNetworkManager instance = GameNetworkManager.Instance; saveFile = (((Object)(object)instance != (Object)null) ? instance.currentSaveFileName : null); if ((Object)(object)instance != (Object)null && instance.isHostingGame) { return !string.IsNullOrEmpty(saveFile); } return false; } private static string ClientFile() { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003e: 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) string text = "lan"; GameNetworkManager instance = GameNetworkManager.Instance; if ((Object)(object)instance != (Object)null && !instance.disableSteam && instance.currentLobby.HasValue) { Lobby value = instance.currentLobby.Value; text = ((Lobby)(ref value)).Owner.Id.Value.ToString(); } return Path.Combine(ClientDir, "host_" + text + ".txt"); } private static string Serialize(IEnumerable<StoredBinding> bindings) { return string.Join("\n", bindings.Select((StoredBinding b) => $"{b.ActionName}|{b.BindingIndex}|{b.ToPath}")); } private static List<StoredBinding> Deserialize(string data) { List<StoredBinding> list = new List<StoredBinding>(); if (string.IsNullOrWhiteSpace(data)) { return list; } string[] array = data.Split(new char[2] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries); foreach (string text in array) { string[] array2 = text.Split('|'); if (array2.Length == 3 && int.TryParse(array2[1], out var result)) { list.Add(new StoredBinding(array2[0], result, array2[2])); } else { Plugin.Log.LogWarning((object)("Ligne de sauvegarde ignorée : '" + text + "'")); } } return list; } } [BepInPlugin("lethalkeys", "LethalKeys", "0.1.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string Guid = "lethalkeys"; public const string Name = "LethalKeys"; public const string Version = "0.1.1"; internal const string ActionsSection = "Actions"; internal static readonly string[] DefaultActions = new string[19] { "Move", "Jump", "Sprint", "Crouch", "Interact", "Discard", "ItemSecondaryUse", "ReloadBatteries", "InspectItem", "VoiceButton", "Emote1", "Emote2", "BuildMode", "ConfirmBuildMode", "Delete", "UseUtilitySlot", "PingScan", "Use", "ActivateItem" }; internal static ManualLogSource Log; internal static ConfigEntry<bool> ShowTip; internal static ConfigEntry<string> ExtraKeys; internal static ConfigEntry<bool> DumpBindings; internal static readonly Dictionary<string, ConfigEntry<bool>> ActionToggles = new Dictionary<string, ConfigEntry<bool>>(); internal static readonly Dictionary<string, (string Name, ConfigEntry<bool> Entry)> KeyToggles = new Dictionary<string, (string, ConfigEntry<bool>)>(); internal static HashSet<string> EligibleActionSet = new HashSet<string>(); internal static List<string> AllowedKeyList = new List<string>(); private readonly Harmony _harmony = new Harmony("lethalkeys"); private void Awake() { Log = ((BaseUnityPlugin)this).Logger; ShowTip = ((BaseUnityPlugin)this).Config.Bind<bool>("Gameplay", "ShowTip", true, "Afficher un message a l'ecran quand une touche change, et un resume au chargement d'une partie."); string[] defaultActions = DefaultActions; foreach (string text in defaultActions) { ActionToggles[text] = ((BaseUnityPlugin)this).Config.Bind<bool>("Actions", text, true, KeyScrambler.DisplayName(text) + " : sa touche peut etre tiree au sort a la mort."); ActionToggles[text].SettingChanged += delegate { RefreshSets(); }; } (string, string[])[] defaultKeyGroups = KeyPool.DefaultKeyGroups; for (int i = 0; i < defaultKeyGroups.Length; i++) { (string, string[]) tuple = defaultKeyGroups[i]; string item = tuple.Item1; defaultActions = tuple.Item2; foreach (string text2 in defaultActions) { string text3 = KeyPool.ToPath(text2); ConfigEntry<bool> val = ((BaseUnityPlugin)this).Config.Bind<bool>(item, text2.Replace('/', ' '), true, "La touche " + Hud.StripAccents(KeyScrambler.Describe(text3)) + " peut etre attribuee a une action."); val.SettingChanged += delegate { RefreshSets(); }; KeyToggles[text3] = (text2, val); } } ExtraKeys = ((BaseUnityPlugin)this).Config.Bind<string>("Touches - Autres", "ExtraKeys", "", "Touches supplementaires, separees par des virgules (noms Unity Input System, position QWERTY) : ex. numpad5, leftAlt, f1. Une touche deja utilisee n'est jamais attribuee, et Echap, Entree et / ne bougent jamais."); ExtraKeys.SettingChanged += delegate { RefreshSets(); }; DumpBindings = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "DumpBindings", false, "Liste toutes les actions et leurs touches dans le log en rejoignant une partie."); RemoveObsoleteEntries(); RefreshSets(); if (LethalConfigCompat.IsAvailable) { LethalConfigCompat.Register(); } _harmony.PatchAll(typeof(Plugin).Assembly); Log.LogInfo((object)string.Format("{0} {1} chargé : {2} action(s), {3} touche(s) autorisée(s).", "LethalKeys", "0.1.1", EligibleActionSet.Count, AllowedKeyList.Count)); } private static void RefreshSets() { EligibleActionSet = new HashSet<string>(from kv in ActionToggles where kv.Value.Value select kv.Key, StringComparer.OrdinalIgnoreCase); List<string> list = (from kv in KeyToggles where kv.Value.Entry.Value select kv.Key).ToList(); foreach (string item in KeyPool.ParseKeyList(ExtraKeys.Value)) { if (!list.Contains(item)) { list.Add(item); } } AllowedKeyList = list; } private void RemoveObsoleteEntries() { Dictionary<ConfigDefinition, string> value = Traverse.Create((object)((BaseUnityPlugin)this).Config).Property("OrphanedEntries", (object[])null).GetValue<Dictionary<ConfigDefinition, string>>(); if (value == null) { return; } int num = 0; foreach (ConfigDefinition item in value.Keys.Where((ConfigDefinition d) => d.Section == "Gameplay" && (d.Key == "EligibleActions" || d.Key == "AllowedKeys")).ToList()) { value.Remove(item); num++; } if (num > 0) { ((BaseUnityPlugin)this).Config.Save(); Log.LogInfo((object)$"{num} ancienne(s) option(s) retirée(s) de la config."); } } } internal static class BuildInfo { public const string Version = "0.1.1"; } } namespace LethalKeys.Patches { [HarmonyPatch(typeof(PlayerControllerB), "Update")] internal static class HudTickPatch { [HarmonyPostfix] private static void Postfix(PlayerControllerB __instance) { if (!((Object)(object)GameNetworkManager.Instance == (Object)null) && !((Object)(object)__instance != (Object)(object)GameNetworkManager.Instance.localPlayerController)) { Hud.Tick(__instance); } } } [HarmonyPatch] internal static class HudBusyPatches { [HarmonyPostfix] [HarmonyPatch(typeof(HUDManager), "FillEndGameStats")] private static void EndGameStats() { Hud.MarkBusy("stats de fin de journée"); } [HarmonyPostfix] [HarmonyPatch(typeof(HUDManager), "DisplayDaysLeft")] private static void DaysLeft() { Hud.MarkBusy("jours restants"); } [HarmonyPostfix] [HarmonyPatch(typeof(HUDManager), "DisplayNewDeadline")] private static void NewDeadline() { Hud.MarkBusy("nouveau quota"); } [HarmonyPostfix] [HarmonyPatch(typeof(HUDManager), "ApplyPenalty")] private static void Penalty() { Hud.MarkBusy("pénalité"); } [HarmonyPostfix] [HarmonyPatch(typeof(HUDManager), "ShowPlayersFiredScreen")] private static void Fired() { Hud.MarkBusy("équipage renvoyé"); } } [HarmonyPatch(typeof(PlayerControllerB), "KillPlayer")] internal static class DeathPatch { [HarmonyPrefix] private static void Prefix(PlayerControllerB __instance, out bool __state) { __state = __instance.isPlayerDead; } [HarmonyPostfix] private static void Postfix(PlayerControllerB __instance, bool __state) { if (!__state && __instance.isPlayerDead && !((Object)(object)GameNetworkManager.Instance == (Object)null) && !((Object)(object)__instance != (Object)(object)GameNetworkManager.Instance.localPlayerController)) { OnLocalPlayerDeath(); } } internal static void OnLocalPlayerDeath() { ScrambleResult scrambleResult = KeyScrambler.Scramble(Plugin.EligibleActionSet, Plugin.AllowedKeyList); if (scrambleResult != null && Plugin.ShowTip.Value) { Hud.Enqueue("Touches modifiees !", scrambleResult.Describe()); } } } [HarmonyPatch] internal static class LifecyclePatches { [HarmonyPostfix] [HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")] private static void OnJoined() { if (KeyScrambler.HasChanges) { KeyScrambler.ResetAll(); } Hud.ClearQueue(); List<StoredBinding> list = Persistence.Load(); if (list.Count == 0) { return; } KeyScrambler.Import(list); List<string> list2 = KeyScrambler.Summary(Plugin.EligibleActionSet); if (!Plugin.ShowTip.Value || list2.Count <= 0) { return; } foreach (string item in list2) { Hud.Enqueue($"Touches modifiees ({list2.Count})", item); } } [HarmonyPostfix] [HarmonyPatch(typeof(StartOfRound), "AutoSaveShipData")] private static void OnAutoSave() { Persistence.Save(KeyScrambler.Export()); } [HarmonyPostfix] [HarmonyPatch(typeof(StartOfRound), "playersFiredGameOver")] private static void OnPlayersFired() { Plugin.Log.LogInfo((object)"Équipage renvoyé : remise à zéro des touches."); bool hasChanges = KeyScrambler.HasChanges; KeyScrambler.ResetAll(); Persistence.Clear(); Hud.ClearQueue(); if (hasChanges && Plugin.ShowTip.Value) { Hud.Enqueue("Equipage renvoye", "Toutes tes touches sont revenues a la normale."); } } [HarmonyPostfix] [HarmonyPatch(typeof(GameNetworkManager), "Disconnect")] private static void OnDisconnect() { if (KeyScrambler.HasChanges) { Plugin.Log.LogInfo((object)"Sortie du lobby : remise à zéro des touches (la sauvegarde est conservée)."); KeyScrambler.ResetAll(); Hud.ClearQueue(); } } } [HarmonyPatch] internal static class SettingsPatches { [HarmonyPrefix] [HarmonyPatch(typeof(IngamePlayerSettings), "CompleteRebind")] private static void BeforeCompleteRebind() { KeyScrambler.Suspend(dropIfChangedByPlayer: true); } [HarmonyFinalizer] [HarmonyPatch(typeof(IngamePlayerSettings), "CompleteRebind")] private static void AfterCompleteRebind() { KeyScrambler.Resume(); } [HarmonyPostfix] [HarmonyPatch(typeof(IngamePlayerSettings), "DiscardChangedSettings")] private static void AfterDiscard() { KeyScrambler.Reapply("annulation des réglages"); } [HarmonyPostfix] [HarmonyPatch(typeof(IngamePlayerSettings), "ResetAllKeybinds")] private static void AfterResetAll() { KeyScrambler.Reapply("réinitialisation des touches"); } [HarmonyPostfix] [HarmonyPatch(typeof(IngamePlayerSettings), "LoadSettingsFromPrefs")] private static void AfterLoad() { KeyScrambler.Reapply("chargement des réglages"); } } } namespace LethalKeys.Debug { [HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")] internal static class BindingDumper { [HarmonyPostfix] private static void Postfix() { if (Plugin.DumpBindings.Value) { Dump(); } } internal static void Dump() { foreach (InputActionAsset asset in KeyScrambler.Assets) { Dump(asset); } } private static void Dump(InputActionAsset asset) { //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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0071: 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_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: 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_00cb: Unknown result type (might be due to invalid IL or missing references) StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine(); stringBuilder.AppendLine("===== LethalKeys : dump des actions (" + ((Object)asset).name + ") ====="); Enumerator<InputActionMap> enumerator = asset.actionMaps.GetEnumerator(); try { while (enumerator.MoveNext()) { InputActionMap current = enumerator.Current; stringBuilder.AppendLine($"[Map] {current.name} (activée : {current.enabled})"); Enumerator<InputAction> enumerator2 = current.actions.GetEnumerator(); try { while (enumerator2.MoveNext()) { InputAction current2 = enumerator2.Current; stringBuilder.AppendLine($" [Action] {current2.name} type={current2.type} control={current2.expectedControlType}"); for (int i = 0; i < current2.bindings.Count; i++) { InputBinding val = current2.bindings[i]; string text = (((InputBinding)(ref val)).isComposite ? "COMPOSITE" : (((InputBinding)(ref val)).isPartOfComposite ? " partie" : "binding")); string text2 = (string.IsNullOrEmpty(((InputBinding)(ref val)).overridePath) ? "" : (" override=" + ((InputBinding)(ref val)).overridePath)); stringBuilder.AppendLine($" #{i} {text,-9} name='{((InputBinding)(ref val)).name}' path='{((InputBinding)(ref val)).path}' effectif='{((InputBinding)(ref val)).effectivePath}' groupes='{((InputBinding)(ref val)).groups}'{text2}"); } } } finally { ((IDisposable)enumerator2/*cast due to .constrained prefix*/).Dispose(); } } } finally { ((IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } stringBuilder.AppendLine("----- Overrides enregistrés (JSON) -----"); stringBuilder.AppendLine(InputActionRebindingExtensions.SaveBindingOverridesAsJson((IInputActionCollection2)(object)asset)); stringBuilder.AppendLine("===== fin du dump ====="); Plugin.Log.LogInfo((object)stringBuilder.ToString()); } } } namespace LethalKeys.Compat { internal static class LethalConfigCompat { internal const string Guid = "ainavt.lc.lethalconfig"; internal static bool IsAvailable => Chainloader.PluginInfos.ContainsKey("ainavt.lc.lethalconfig"); [MethodImpl(MethodImplOptions.NoInlining)] internal static void Register() { //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Expected O, but got Unknown //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Expected O, but got Unknown LethalConfigManager.SkipAutoGen(); LethalConfigManager.SetModDescription("Chaque mort reassigne une de tes touches au hasard. Les changements durent jusqu'au renvoi de l'equipage."); AddCheckBox(Plugin.ShowTip, "Afficher les messages"); foreach (KeyValuePair<string, ConfigEntry<bool>> actionToggle in Plugin.ActionToggles) { AddCheckBox(actionToggle.Value, KeyScrambler.DisplayName(actionToggle.Key)); } AddGroupButtons("Actions", Plugin.ActionToggles.Values.ToList()); (string, string[])[] defaultKeyGroups = KeyPool.DefaultKeyGroups; for (int i = 0; i < defaultKeyGroups.Length; i++) { string item = defaultKeyGroups[i].Item1; List<ConfigEntry<bool>> list = new List<ConfigEntry<bool>>(); foreach (KeyValuePair<string, (string, ConfigEntry<bool>)> keyToggle in Plugin.KeyToggles) { if (!(((ConfigEntryBase)keyToggle.Value.Item2).Definition.Section != item)) { AddCheckBox(keyToggle.Value.Item2, KeyLabel(keyToggle.Key, keyToggle.Value.Item1)); list.Add(keyToggle.Value.Item2); } } AddGroupButtons(item, list); } LethalConfigManager.AddConfigItem((BaseConfigItem)new TextInputFieldConfigItem(Plugin.ExtraKeys, new TextInputFieldOptions { Name = "Touches supplementaires", NumberOfLines = 2, TrimText = true, RequiresRestart = false })); AddCheckBox(Plugin.DumpBindings, "Dump des touches dans le log"); Plugin.Log.LogInfo((object)"Menu LethalConfig enregistré."); } private static void AddCheckBox(ConfigEntry<bool> entry, string label) { //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_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(entry, new BoolCheckBoxOptions { Name = Hud.StripAccents(label), RequiresRestart = false })); } private static void AddGroupButtons(string section, List<ConfigEntry<bool>> entries) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown LethalConfigManager.AddConfigItem((BaseConfigItem)new GenericButtonConfigItem(section, "Tout cocher", "Coche toutes les cases de cette section.", "Tout cocher", (GenericButtonHandler)delegate { entries.ForEach(delegate(ConfigEntry<bool> e) { e.Value = true; }); })); LethalConfigManager.AddConfigItem((BaseConfigItem)new GenericButtonConfigItem(section, "Tout decocher", "Decoche toutes les cases de cette section.", "Tout decocher", (GenericButtonHandler)delegate { entries.ForEach(delegate(ConfigEntry<bool> e) { e.Value = false; }); })); } private static string KeyLabel(string path, string qwertyName) { string text = Hud.StripAccents(KeyScrambler.Describe(path)); if (!KeyPool.IsMouseButton(path) && !string.Equals(text, qwertyName, StringComparison.OrdinalIgnoreCase)) { return text + " (" + qwertyName + ")"; } return text; } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }