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 Survivor Specific Keybinds v0.1.0
plugins/SurvivorSpecificKeybinds.dll
Decompiled a day agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Threading.Tasks; using System.Xml; using System.Xml.Linq; using BepInEx; using BepInEx.Configuration; using IL.RoR2; using Microsoft.CodeAnalysis; using Mono.Cecil; using Mono.Cecil.Cil; using MonoMod.Cil; using On.RoR2; using Rewired; using RoR2; using RoR2.UI; using RoR2BepInExPack.Utilities; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.UI; using Zio; using Zio.FileSystems; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("SurvivorSpecificKeybinds")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+7733005ddcabba8e8744c0a93ad1e3bbfad1b687")] [assembly: AssemblyProduct("SurvivorSpecificKeybinds")] [assembly: AssemblyTitle("SurvivorSpecificKeybinds")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] [module: UnverifiableCode] 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 SurvivorSpecificKeybinds { public class SurvivorSpecificKeybindsButtonController : MonoBehaviour { public string bodyName; public SurvivorSpecificKeybindsSelectorController survivorSpecificKeybindsSelectorController; public RawImage rawImage; public Color selectedColor; public Color unselectedColor; public void TestCall() { SurvivorSpecificKeybindsUtils.EnsureUserProfileDefaultMaps(); UserProfile userProfile = SurvivorSpecificKeybindsUtils.GetUserProfile(); if (userProfile != null) { if (bodyName == "DefaultDefaultDefault") { JoystickMap val = default(JoystickMap); userProfile.joystickMap = (SurvivorSpecificKeybindsUtils.defaultJoystickMaps.TryGetValue(userProfile, ref val) ? val : userProfile.joystickMap); KeyboardMap val2 = default(KeyboardMap); userProfile.keyboardMap = (SurvivorSpecificKeybindsUtils.defaultKeyboardMaps.TryGetValue(userProfile, ref val2) ? val2 : userProfile.keyboardMap); MouseMap val3 = default(MouseMap); userProfile.mouseMap = (SurvivorSpecificKeybindsUtils.defaultMouseMaps.TryGetValue(userProfile, ref val3) ? val3 : userProfile.mouseMap); } else { SurvivorSpecificKeybindsData survivorSpecificKeybindsData = SurvivorSpecificKeybindsUtils.EnsureUserProfileSurvivorSpecificKeybindsData(userProfile, bodyName); userProfile.keyboardMap = survivorSpecificKeybindsData.keyboardMap; userProfile.mouseMap = survivorSpecificKeybindsData.mouseMap; userProfile.joystickMap = survivorSpecificKeybindsData.joystickMap; } LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser(); firstLocalUser.ApplyUserProfileBindingsToRewiredPlayer(); MPEventSystem.RefreshAllControllerGlyphs(); SurvivorSpecificKeybindsPlugin.currentSurvivorBody = bodyName; } } public void Update() { //IL_002c: 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_0055: Unknown result type (might be due to invalid IL or missing references) if (bodyName == "DefaultDefaultDefault" && Utility.IsNullOrWhiteSpace(SurvivorSpecificKeybindsPlugin.currentSurvivorBody)) { ((Graphic)rawImage).color = selectedColor; } else if (bodyName == SurvivorSpecificKeybindsPlugin.currentSurvivorBody) { ((Graphic)rawImage).color = selectedColor; } else { ((Graphic)rawImage).color = unselectedColor; } } } public class SurvivorSpecificKeybindsController : MonoBehaviour { private bool init; public static SurvivorSpecificKeybindsController instance; public string selectedBodyName = "DefaultDefaultDefault"; public Transform kbmHolder; public void Awake() { instance = this; if (init) { return; } init = true; kbmHolder = ((Component)this).transform.Find("SafeArea/SubPanelArea/SettingsSubPanel, Controls (M&KB)/Scroll View/Viewport/VerticalLayout"); if (!Object.op_Implicit((Object)(object)kbmHolder)) { return; } Transform val = kbmHolder.Find("SettingsEntryButton, Bool (Invert X)"); if (Object.op_Implicit((Object)(object)val)) { GameObject val2 = Object.Instantiate<GameObject>(((Component)val).gameObject, val.parent); val2.transform.SetSiblingIndex(6); Transform val3 = val2.transform.Find("CarouselRect"); if (Object.op_Implicit((Object)(object)val3)) { Object.Destroy((Object)(object)((Component)val3).gameObject); } Transform val4 = val2.transform.Find("ButtonText"); if (Object.op_Implicit((Object)(object)val4)) { Object.Destroy((Object)(object)((Component)val4).gameObject); } GameObject val5 = Object.Instantiate<GameObject>(SurvivorSpecificKeybindsPlugin.SurvivorIconsHolder, val2.transform); } } } public class SurvivorSpecificKeybindsData { public string bodyName; public KeyboardMap keyboardMap; public MouseMap mouseMap; public JoystickMap joystickMap; } [Serializable] [BepInPlugin("com.brynzananas.survivorspecifickeybinds", "Survivor Specific Keybinds", "0.1.0")] public class SurvivorSpecificKeybindsPlugin : BaseUnityPlugin { [CompilerGenerated] private static class <>O { public static Manipulator <0>__LocalUser_RebuildControlChain; public static hook_StartSave <1>__SaveSystemSteam_StartSave; public static Manipulator <2>__SaveSystem_LoadUserProfiles; public static hook_LoadUserProfiles <3>__SaveSystem_LoadUserProfiles1; public static Action<UserProfile> <4>__UserProfileOrPvpBoss; public static Action<LocalUser> <5>__OnBodyChanged; } public const string ModGuid = "com.brynzananas.survivorspecifickeybinds"; public const string ModName = "Survivor Specific Keybinds"; public const string ModVer = "0.1.0"; public static AssetBundle assetBundle; public static GameObject SurvivorIconsHolder; public static SurvivorSpecificKeybindsPlugin instance; public static string currentSurvivorBody; public static FixedConditionalWeakTable<UserProfile, SurvivorSpecificKeybindsSave> keyValuePairs = new FixedConditionalWeakTable<UserProfile, SurvivorSpecificKeybindsSave>(); private static bool hooksSet; public void Awake() { //IL_000c: 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) instance = this; Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/UI/SettingsPanelTitle.prefab").WaitForCompletion().AddComponent<SurvivorSpecificKeybindsController>(); assetBundle = AssetBundle.LoadFromFileAsync(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "assetbundles", "survivorspecificsettingsassets")).assetBundle; SurvivorIconsHolder = assetBundle.LoadAsset<GameObject>("Assets/SurvivorSpecificSettings/SurvivorIconsHolder.prefab"); SetHooks(); } private static void SetHooks() { //IL_0025: 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_0030: Expected O, but got Unknown //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Expected O, but got Unknown if (!hooksSet) { hooksSet = true; object obj = <>O.<0>__LocalUser_RebuildControlChain; if (obj == null) { Manipulator val = LocalUser_RebuildControlChain; <>O.<0>__LocalUser_RebuildControlChain = val; obj = (object)val; } LocalUser.RebuildControlChain += (Manipulator)obj; object obj2 = <>O.<1>__SaveSystemSteam_StartSave; if (obj2 == null) { hook_StartSave val2 = SaveSystemSteam_StartSave; <>O.<1>__SaveSystemSteam_StartSave = val2; obj2 = (object)val2; } SaveSystemSteam.StartSave += (hook_StartSave)obj2; object obj3 = <>O.<2>__SaveSystem_LoadUserProfiles; if (obj3 == null) { Manipulator val3 = SaveSystem_LoadUserProfiles; <>O.<2>__SaveSystem_LoadUserProfiles = val3; obj3 = (object)val3; } SaveSystem.LoadUserProfiles += (Manipulator)obj3; object obj4 = <>O.<3>__SaveSystem_LoadUserProfiles1; if (obj4 == null) { hook_LoadUserProfiles val4 = SaveSystem_LoadUserProfiles1; <>O.<3>__SaveSystem_LoadUserProfiles1 = val4; obj4 = (object)val4; } SaveSystem.LoadUserProfiles += (hook_LoadUserProfiles)obj4; } } private static void SaveSystem_LoadUserProfiles1(orig_LoadUserProfiles orig, SaveSystem self) { orig.Invoke(self); foreach (KeyValuePair<UserProfile, SurvivorSpecificKeybindsSave> keyValuePair in keyValuePairs) { SurvivorSpecificKeybindsUtils.inputsByBodyNames[keyValuePair.Key] = keyValuePair.Value.keyValuePairs; } } private static void SaveSystem_LoadUserProfiles(ILContext il) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected O, but got Unknown //IL_008a: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); int locId = 6; if (!val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[2] { (Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref locId), (Instruction x) => ILPatternMatchingExt.MatchCall<SaveSystem>(x, "AddLoadedUserProfile") })) { ((BaseUnityPlugin)instance).Logger.LogError((object)("IL Hook " + ((MemberReference)il.Method).Name + " failed!")); return; } val.Emit(OpCodes.Ldloc, locId); val.EmitDelegate<Action<UserProfile>>((Action<UserProfile>)UserProfileOrPvpBoss); } private static void UserProfileOrPvpBoss(UserProfile userProfile) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) FileSystem cloudStorage = RoR2Application.cloudStorage; string text = "/UserProfiles/" + userProfile.fileName.CleanString(); ((BaseUnityPlugin)instance).Logger.LogInfo((object)("Reading path: " + text)); if (!cloudStorage.DirectoryExists(UPath.op_Implicit(text))) { cloudStorage.CreateDirectory(UPath.op_Implicit(text)); } foreach (UPath item in FileSystemExtensions.EnumeratePaths((IFileSystem)(object)cloudStorage, UPath.op_Implicit(text))) { UPath current = item; if (!cloudStorage.FileExists(current)) { continue; } ((BaseUnityPlugin)instance).Logger.LogInfo((object)("fullpath: " + ((UPath)(ref current)).FullName)); if (!((UPath)(ref current)).FullName.EndsWith("SurvivorSpecificKeybinds.xml")) { continue; } try { Stream stream = cloudStorage.OpenFile(current, FileMode.Open, FileAccess.Read, FileShare.Read); if (stream == null) { continue; } try { TextReader textReader = new StreamReader(stream, Encoding.UTF8); if (textReader == null) { continue; } try { XDocument xDocument = XDocument.Load(textReader); if (xDocument != null) { SurvivorSpecificKeybindsSave survivorSpecificKeybindsSave = SurvivorSpecificKeybindsSave.FromXml(xDocument); keyValuePairs[userProfile] = survivorSpecificKeybindsSave; } } catch (Exception ex) { ((BaseUnityPlugin)instance).Logger.LogError((object)ex); } } catch (Exception ex2) { ((BaseUnityPlugin)instance).Logger.LogError((object)ex2); } } catch (Exception ex3) { ((BaseUnityPlugin)instance).Logger.LogError((object)ex3); } } } private static void SaveSystemSteam_StartSave(orig_StartSave orig, SaveSystemSteam self, UserProfile userProfile, bool blocking) { SurvivorSpecificKeybindsUtils.EnsureUserProfileDefaultMaps(userProfile); KeyboardMap keyboardMap = userProfile.keyboardMap; MouseMap mouseMap = userProfile.mouseMap; JoystickMap joystickMap = userProfile.joystickMap; userProfile.keyboardMap = SurvivorSpecificKeybindsUtils.defaultKeyboardMaps[userProfile]; userProfile.mouseMap = SurvivorSpecificKeybindsUtils.defaultMouseMaps[userProfile]; userProfile.joystickMap = SurvivorSpecificKeybindsUtils.defaultJoystickMaps[userProfile]; orig.Invoke(self, userProfile, blocking); userProfile.keyboardMap = keyboardMap; userProfile.mouseMap = mouseMap; userProfile.joystickMap = joystickMap; SurvivorSpecificKeybindsSave survivorSpecificKeybindsSave = default(SurvivorSpecificKeybindsSave); FileOutput fileOutput; Task task; if (keyValuePairs.TryGetValue(userProfile, ref survivorSpecificKeybindsSave) && survivorSpecificKeybindsSave.keyValuePairs != null && survivorSpecificKeybindsSave.keyValuePairs.Count > 0) { fileOutput = SurvivorSpecificKeybindsUtils.GetFileOutput(userProfile); task = null; task = new Task(PayloadGeneratorAction); ((SaveSystem)self).AddActiveTask(task); task.Start(TaskScheduler.Default); if (blocking) { task.Wait(); ((SaveSystemBase)self).ProcessFileOutputQueue(); } } void PayloadGeneratorAction() { try { FileIoIndicatorManager.IncrementActiveWriteCount(); XDocument xDocument = survivorSpecificKeybindsSave.ToXml(); SurvivorSpecificKeybindsUtils.SaveFileOutput((SaveSystem)(object)self, xDocument, fileOutput); } catch (Exception) { RoR2Application.onNextUpdate += delegate { }; throw; } finally { FileIoIndicatorManager.DecrementActiveWriteCount(); ((SaveSystem)self).RemoveActiveTask(task); } } } private static void LocalUser_RebuildControlChain(ILContext il) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0063: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); int num = 2; ILLabel val2 = null; if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[2] { (Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0), (Instruction x) => ILPatternMatchingExt.MatchLdfld<LocalUser>(x, "onBodyChanged") })) { val.Emit(OpCodes.Ldarg_0); val.EmitDelegate<Action<LocalUser>>((Action<LocalUser>)OnBodyChanged); } else { ((BaseUnityPlugin)instance).Logger.LogError((object)("IL Hook " + ((MemberReference)il.Method).Name + " failed!")); } } private static void OnBodyChanged(LocalUser localUser) { UserProfile userProfile = localUser.userProfile; if (userProfile != null) { SurvivorSpecificKeybindsUtils.EnsureUserProfileDefaultMaps(userProfile); if (!Object.op_Implicit((Object)(object)localUser.cachedBody)) { userProfile.keyboardMap = SurvivorSpecificKeybindsUtils.defaultKeyboardMaps[userProfile]; userProfile.mouseMap = SurvivorSpecificKeybindsUtils.defaultMouseMaps[userProfile]; userProfile.joystickMap = SurvivorSpecificKeybindsUtils.defaultJoystickMaps[userProfile]; localUser.ApplyUserProfileBindingsToRewiredPlayer(); MPEventSystem.RefreshAllControllerGlyphs(); } string bodyName = ((Object)localUser.cachedBody).name.Replace("(Clone)", ""); if (SurvivorSpecificKeybindsUtils.TryGetUserProfileSurvivorSpecificInputsData(userProfile, bodyName, out var survivorSpecificInputsData)) { userProfile.keyboardMap = survivorSpecificInputsData.keyboardMap; userProfile.joystickMap = survivorSpecificInputsData.joystickMap; userProfile.mouseMap = survivorSpecificInputsData.mouseMap; localUser.ApplyUserProfileBindingsToRewiredPlayer(); MPEventSystem.RefreshAllControllerGlyphs(); } else { userProfile.keyboardMap = SurvivorSpecificKeybindsUtils.defaultKeyboardMaps[userProfile]; userProfile.mouseMap = SurvivorSpecificKeybindsUtils.defaultMouseMaps[userProfile]; userProfile.joystickMap = SurvivorSpecificKeybindsUtils.defaultJoystickMaps[userProfile]; localUser.ApplyUserProfileBindingsToRewiredPlayer(); MPEventSystem.RefreshAllControllerGlyphs(); } } } } public class SurvivorSpecificKeybindsSave { public Dictionary<string, SurvivorSpecificKeybindsData> keyValuePairs = new Dictionary<string, SurvivorSpecificKeybindsData>(); public XDocument ToXml() { List<object> list = new List<object>(); XElement xElement = new XElement("SurvivorSpecificKeybinds"); list.Add(xElement); if (keyValuePairs != null) { foreach (KeyValuePair<string, SurvivorSpecificKeybindsData> keyValuePair in keyValuePairs) { XElement xElement2 = new XElement("SurvivorSpecificKeybindsSlot"); xElement.Add(xElement2); XElement content = new XElement("BodyName", keyValuePair.Key); xElement2.Add(content); SurvivorSpecificKeybindsData value = keyValuePair.Value; XElement content2 = new XElement("KeyboardMap", ((ControllerMap)value.keyboardMap).ToXmlString()); xElement2.Add(content2); XElement content3 = new XElement("MouseMap", ((ControllerMap)value.mouseMap).ToXmlString()); xElement2.Add(content3); XElement content4 = new XElement("JoystickMap", ((ControllerMap)value.joystickMap).ToXmlString()); xElement2.Add(content4); } } return new XDocument(list.ToArray()); } public static SurvivorSpecificKeybindsSave FromXml(XDocument xDocument) { try { SurvivorSpecificKeybindsSave survivorSpecificKeybindsSave = new SurvivorSpecificKeybindsSave(); XElement root = xDocument.Root; if (root == null) { return survivorSpecificKeybindsSave; } foreach (XElement item in root.Elements("SurvivorSpecificKeybindsSlot")) { XElement xElement = item.Element("BodyName"); string text = null; SurvivorSpecificKeybindsData survivorSpecificKeybindsData = new SurvivorSpecificKeybindsData(); if (xElement != null) { text = xElement.Value; } survivorSpecificKeybindsData.bodyName = text; XElement xElement2 = item.Element("KeyboardMap"); string text2 = null; if (xElement2 != null) { text2 = xElement2.Value; } ref KeyboardMap keyboardMap = ref survivorSpecificKeybindsData.keyboardMap; ControllerMap obj = ControllerMap.CreateFromXml((ControllerType)0, text2); keyboardMap = (KeyboardMap)(object)((obj is KeyboardMap) ? obj : null); XElement xElement3 = item.Element("MouseMap"); string text3 = null; if (xElement3 != null) { text3 = xElement3.Value; } ref MouseMap mouseMap = ref survivorSpecificKeybindsData.mouseMap; ControllerMap obj2 = ControllerMap.CreateFromXml((ControllerType)1, text3); mouseMap = (MouseMap)(object)((obj2 is MouseMap) ? obj2 : null); XElement xElement4 = item.Element("JoystickMap"); string text4 = null; if (xElement4 != null) { text4 = xElement4.Value; } ref JoystickMap joystickMap = ref survivorSpecificKeybindsData.joystickMap; ControllerMap obj3 = ControllerMap.CreateFromXml((ControllerType)2, text4); joystickMap = (JoystickMap)(object)((obj3 is JoystickMap) ? obj3 : null); survivorSpecificKeybindsSave.keyValuePairs.Add(text, survivorSpecificKeybindsData); } return survivorSpecificKeybindsSave; } catch (Exception ex) { ((BaseUnityPlugin)SurvivorSpecificKeybindsPlugin.instance).Logger.LogError((object)ex); return null; } } } public class SurvivorSpecificKeybindsSelectorController : MonoBehaviour { public SurvivorSpecificKeybindsController survivorSpecificInputsController; public GridLayoutGroup gridLayoutGroup; public Transform survivorIconsHolder; public GameObject survivorIconButtonPrefab; public float extraPadding = 10f; private LayoutElement layoutElement; private bool init; public void Awake() { if (!Object.op_Implicit((Object)(object)survivorSpecificInputsController)) { survivorSpecificInputsController = SurvivorSpecificKeybindsController.instance; } layoutElement = ((Component)((Component)this).transform.parent).GetComponent<LayoutElement>(); if (!Object.op_Implicit((Object)(object)survivorIconButtonPrefab) || !Object.op_Implicit((Object)(object)survivorIconsHolder) || !RoR2Application.loadFinished || init) { return; } init = true; for (int i = 0; i < SurvivorCatalog.survivorCount; i++) { SurvivorDef val = SurvivorCatalog.survivorDefs[i]; if (!Object.op_Implicit((Object)(object)val)) { continue; } GameObject bodyPrefab = val.bodyPrefab; if (!Object.op_Implicit((Object)(object)bodyPrefab)) { continue; } CharacterBody component = bodyPrefab.GetComponent<CharacterBody>(); if (Object.op_Implicit((Object)(object)component)) { GameObject val2 = Object.Instantiate<GameObject>(survivorIconButtonPrefab, survivorIconsHolder); SurvivorSpecificKeybindsButtonController component2 = val2.GetComponent<SurvivorSpecificKeybindsButtonController>(); if (((Object)bodyPrefab).name == "DefaultDefaultDefault") { ((BaseUnityPlugin)SurvivorSpecificKeybindsPlugin.instance).Logger.LogWarning((object)"Some individual decided to name their survivor body `DefaultDefaultDefault`. Expect issues"); } component2.bodyName = ((Object)bodyPrefab).name; if (Object.op_Implicit((Object)(object)component2.rawImage)) { component2.rawImage.texture = component.portraitIcon; } val2.SetActive(true); } } survivorIconButtonPrefab.SetActive(true); if (Object.op_Implicit((Object)(object)Run.instance)) { ((Component)this).gameObject.SetActive(false); } } public void Update() { UpdateHeight(); } public void UpdateHeight() { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Invalid comparison between Unknown and I4 //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Expected O, but got Unknown if (!Object.op_Implicit((Object)(object)layoutElement) || !Object.op_Implicit((Object)(object)gridLayoutGroup)) { return; } int num = 0; foreach (Transform item in ((Component)gridLayoutGroup).transform) { Transform val = item; if (((Component)val).gameObject.activeSelf) { num++; } } if (num != 0) { int num2 = 1; if ((int)gridLayoutGroup.constraint == 1) { num2 = Mathf.Max(1, gridLayoutGroup.constraintCount); } else { Rect rect = ((RectTransform)((Component)gridLayoutGroup).transform).rect; float width = ((Rect)(ref rect)).width; float num3 = gridLayoutGroup.cellSize.x + gridLayoutGroup.spacing.x; num2 = Mathf.Max(1, Mathf.FloorToInt((width - (float)((LayoutGroup)gridLayoutGroup).padding.left - (float)((LayoutGroup)gridLayoutGroup).padding.right + gridLayoutGroup.spacing.x) / num3)); } int num4 = Mathf.CeilToInt((float)num / (float)num2); float num5 = (float)(((LayoutGroup)gridLayoutGroup).padding.top + ((LayoutGroup)gridLayoutGroup).padding.bottom) + (float)num4 * gridLayoutGroup.cellSize.y + (float)(num4 - 1) * gridLayoutGroup.spacing.y + extraPadding; layoutElement.preferredHeight = num5; layoutElement.minHeight = num5; LayoutRebuilder.ForceRebuildLayoutImmediate((RectTransform)((Component)this).transform); } } } public static class SurvivorSpecificKeybindsUtils { public static FixedConditionalWeakTable<UserProfile, KeyboardMap> defaultKeyboardMaps = new FixedConditionalWeakTable<UserProfile, KeyboardMap>(); public static FixedConditionalWeakTable<UserProfile, MouseMap> defaultMouseMaps = new FixedConditionalWeakTable<UserProfile, MouseMap>(); public static FixedConditionalWeakTable<UserProfile, JoystickMap> defaultJoystickMaps = new FixedConditionalWeakTable<UserProfile, JoystickMap>(); public static FixedConditionalWeakTable<UserProfile, Dictionary<string, SurvivorSpecificKeybindsData>> inputsByBodyNames = new FixedConditionalWeakTable<UserProfile, Dictionary<string, SurvivorSpecificKeybindsData>>(); public static void EnsureUserProfileDefaultMaps() { EnsureUserProfileDefaultMaps(GetUserProfile()); } public static void EnsureUserProfileDefaultMaps(UserProfile userProfile) { EnsureUserProfileDefaultKeyboardMap(userProfile); EnsureUserProfileDefaultMouseMap(userProfile); EnsureUserProfileDefaultJoystickMap(userProfile); } public static KeyboardMap EnsureUserProfileDefaultKeyboardMap() { return EnsureUserProfileDefaultKeyboardMap(GetUserProfile()); } public static KeyboardMap EnsureUserProfileDefaultKeyboardMap(UserProfile userProfile) { if (userProfile == null) { return null; } KeyboardMap keyboardMap = default(KeyboardMap); if (!defaultKeyboardMaps.TryGetValue(userProfile, ref keyboardMap)) { keyboardMap = userProfile.keyboardMap; defaultKeyboardMaps.Add(userProfile, keyboardMap); } return keyboardMap; } public static MouseMap EnsureUserProfileDefaultMouseMap() { return EnsureUserProfileDefaultMouseMap(GetUserProfile()); } public static MouseMap EnsureUserProfileDefaultMouseMap(UserProfile userProfile) { if (userProfile == null) { return null; } MouseMap mouseMap = default(MouseMap); if (!defaultMouseMaps.TryGetValue(userProfile, ref mouseMap)) { mouseMap = userProfile.mouseMap; defaultMouseMaps.Add(userProfile, mouseMap); } return mouseMap; } public static JoystickMap EnsureUserProfileDefaultJoystickMap() { return EnsureUserProfileDefaultJoystickMap(GetUserProfile()); } public static JoystickMap EnsureUserProfileDefaultJoystickMap(UserProfile userProfile) { if (userProfile == null) { return null; } JoystickMap joystickMap = default(JoystickMap); if (!defaultJoystickMaps.TryGetValue(userProfile, ref joystickMap)) { joystickMap = userProfile.joystickMap; defaultJoystickMaps.Add(userProfile, joystickMap); } return joystickMap; } public static SurvivorSpecificKeybindsData EnsureUserProfileSurvivorSpecificKeybindsData(string bodyName) { return EnsureUserProfileSurvivorSpecificKeybindsData(GetUserProfile(), bodyName); } public static SurvivorSpecificKeybindsData EnsureUserProfileSurvivorSpecificKeybindsData(UserProfile userProfile, string bodyName) { if (userProfile == null) { return null; } Dictionary<string, SurvivorSpecificKeybindsData> dictionary = default(Dictionary<string, SurvivorSpecificKeybindsData>); if (!inputsByBodyNames.TryGetValue(userProfile, ref dictionary)) { dictionary = new Dictionary<string, SurvivorSpecificKeybindsData>(); JoystickMap sourceMap = default(JoystickMap); KeyboardMap sourceMap2 = default(KeyboardMap); MouseMap sourceMap3 = default(MouseMap); dictionary[bodyName] = new SurvivorSpecificKeybindsData { bodyName = bodyName, joystickMap = (defaultJoystickMaps.TryGetValue(userProfile, ref sourceMap) ? sourceMap.Clone() : userProfile.joystickMap.Clone()), keyboardMap = (defaultKeyboardMaps.TryGetValue(userProfile, ref sourceMap2) ? sourceMap2.Clone() : userProfile.keyboardMap.Clone()), mouseMap = (defaultMouseMaps.TryGetValue(userProfile, ref sourceMap3) ? sourceMap3.Clone() : userProfile.mouseMap.Clone()) }; inputsByBodyNames[userProfile] = dictionary; } if (!dictionary.TryGetValue(bodyName, out var value)) { JoystickMap sourceMap4 = default(JoystickMap); KeyboardMap sourceMap5 = default(KeyboardMap); MouseMap sourceMap6 = default(MouseMap); SurvivorSpecificKeybindsData obj = new SurvivorSpecificKeybindsData { bodyName = bodyName, joystickMap = (defaultJoystickMaps.TryGetValue(userProfile, ref sourceMap4) ? sourceMap4.Clone() : userProfile.joystickMap.Clone()), keyboardMap = (defaultKeyboardMaps.TryGetValue(userProfile, ref sourceMap5) ? sourceMap5.Clone() : userProfile.keyboardMap.Clone()), mouseMap = (defaultMouseMaps.TryGetValue(userProfile, ref sourceMap6) ? sourceMap6.Clone() : userProfile.mouseMap.Clone()) }; value = (dictionary[bodyName] = obj); } SurvivorSpecificKeybindsSave survivorSpecificKeybindsSave = default(SurvivorSpecificKeybindsSave); if (SurvivorSpecificKeybindsPlugin.keyValuePairs.TryGetValue(userProfile, ref survivorSpecificKeybindsSave)) { survivorSpecificKeybindsSave.keyValuePairs = dictionary; } else { SurvivorSpecificKeybindsPlugin.keyValuePairs[userProfile] = new SurvivorSpecificKeybindsSave { keyValuePairs = dictionary }; } return value; } public static bool TryGetUserProfileSurvivorSpecificInputsData(UserProfile userProfile, string bodyName, out SurvivorSpecificKeybindsData survivorSpecificInputsData) { Dictionary<string, SurvivorSpecificKeybindsData> dictionary = default(Dictionary<string, SurvivorSpecificKeybindsData>); if (inputsByBodyNames.TryGetValue(userProfile, ref dictionary) && dictionary.TryGetValue(bodyName, out survivorSpecificInputsData)) { return true; } survivorSpecificInputsData = null; return false; } public static FileOutput GetFileOutput(UserProfile userProfile) { //IL_001c: 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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown string text = ((UPath)(ref userProfile.filePath)).FullName.CleanString() + "/SurvivorSpecificKeybinds.xml"; return new FileOutput { fileReference = new FileReference { path = UPath.op_Implicit(text), fileSystem = userProfile.fileSystem }, requestTime = DateTime.UtcNow, contents = Array.Empty<byte>() }; } public static void SaveFileOutput(SaveSystem saveSystem, XDocument xDocument, FileOutput fileOutput) { using (MemoryStream memoryStream = new MemoryStream()) { using XmlTextWriter xmlTextWriter = new XmlTextWriter(memoryStream, new UTF8Encoding(encoderShouldEmitUTF8Identifier: false)); xDocument.Save(xmlTextWriter); xmlTextWriter.Flush(); fileOutput.contents = new byte[memoryStream.Length]; memoryStream.Seek(0L, SeekOrigin.Begin); memoryStream.Read(fileOutput.contents, 0, fileOutput.contents.Length); } saveSystem.EnqueueFileOutput(fileOutput); } public static string CleanString(this string str) { return str.Replace(".xml", "").Replace(".cfg", ""); } public static UserProfile GetUserProfile() { LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser(); if (firstLocalUser == null) { return null; } return firstLocalUser.userProfile; } public static KeyboardMap Clone(this KeyboardMap sourceMap) { if (sourceMap == null) { return null; } string text = ((ControllerMap)sourceMap).ToXmlString(); ControllerMap obj = ControllerMap.CreateFromXml((ControllerType)0, text); return (KeyboardMap)(object)((obj is KeyboardMap) ? obj : null); } public static MouseMap Clone(this MouseMap sourceMap) { if (sourceMap == null) { return null; } string text = ((ControllerMap)sourceMap).ToXmlString(); ControllerMap obj = ControllerMap.CreateFromXml((ControllerType)1, text); return (MouseMap)(object)((obj is MouseMap) ? obj : null); } public static JoystickMap Clone(this JoystickMap sourceMap) { if (sourceMap == null) { return null; } string text = ((ControllerMap)sourceMap).ToXmlString(); ControllerMap obj = ControllerMap.CreateFromXml((ControllerType)2, text); return (JoystickMap)(object)((obj is JoystickMap) ? obj : null); } public static void AddLanguageToken(string token, string text) { AddLanguageToken(token, text, "en"); } public static void AddLanguageToken(string token, string text, string lang) { Language orCreateLanguage = Language.GetOrCreateLanguage(lang); if (orCreateLanguage != null) { if (orCreateLanguage.stringsByToken.ContainsKey(token)) { orCreateLanguage.stringsByToken[token] = text; } else { orCreateLanguage.stringsByToken.Add(token, text); } } } public static ConfigEntry<T> CreateConfig<T>(string sectionName, string configName, T defaultValue, string description) { return ((BaseUnityPlugin)SurvivorSpecificKeybindsPlugin.instance).Config.Bind<T>(sectionName, configName, defaultValue, description); } public static string RemoveUpToAndIncluding(string source, string target, StringComparison comparison = StringComparison.Ordinal) { if (string.IsNullOrEmpty(source) || string.IsNullOrEmpty(target)) { return source ?? string.Empty; } int num = source.IndexOf(target, comparison); if (num == -1) { return source; } return source.Substring(num + target.Length); } } }