Decompiled source of Coop KBnM v1.0.6
CoopKBnM.dll
Decompiled 2 weeks 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.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using HarmonyLib; using InControl; using Mono.Cecil.Cil; using MonoMod.Cil; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("CoopKBnM")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("CoopKBnM")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("825bc8e2-2faf-496c-803c-3f3e31eba1a0")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace CoopKBnM; [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("kleirof.etg.coopkbnm", "Coop KB&M", "1.0.6")] public class CoopKBnMModule : BaseUnityPlugin { public const string GUID = "kleirof.etg.coopkbnm"; public const string NAME = "Coop KB&M"; public const string VERSION = "1.0.6"; public const string TEXT_COLOR = "#FFFFCC"; public static bool isCoopViewLoaded; public static bool secondWindowActive; private static GameObject rawInputObject; private Harmony harmony; public void Start() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Expected O, but got Unknown OptionsManager.OnStart(); ETGModMainBehaviour.WaitForGameManagerStart((Action<GameManager>)GMStart); rawInputObject = new GameObject("Raw Input Object"); Object.DontDestroyOnLoad((Object)(object)rawInputObject); rawInputObject.AddComponent<RawInputHandler>(); if (Chainloader.PluginInfos.TryGetValue("kleirof.etg.coopview", out var _)) { isCoopViewLoaded = true; } harmony = new Harmony("kleirof.etg.coopkbnm"); harmony.PatchAll(); DoOptionalPatches(); } private void Update() { if ((Object)(object)OptionsManager.masterControlsOptionsScrollablePanelObject == (Object)null && !OptionsManager.isInitializingOptions) { ((MonoBehaviour)this).StartCoroutine(OptionsManager.InitializeOptions()); } } public static void Log(string text, string color = "FFFFFF") { ETGModConsole.Log((object)("<color=" + color + ">" + text + "</color>"), false); } public void GMStart(GameManager g) { Log("Coop KB&M v1.0.6 started successfully.", "#FFFFCC"); } private void DoOptionalPatches() { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Expected O, but got Unknown //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Expected O, but got Unknown //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Expected O, but got Unknown //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Expected O, but got Unknown //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Expected O, but got Unknown //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Expected O, but got Unknown if (Chainloader.PluginInfos.ContainsKey("kleirof.etg.customcursor")) { Type type = AccessTools.TypeByName("CustomCursor.CursorManager"); MethodInfo methodInfo = AccessTools.Method(type, "SetCustomCursorIsOn", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(CoopKBnMPatches.SetCustomCursorIsOnPatchClass), "SetCustomCursorIsOnPostfix", (Type[])null, (Type[])null); harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); MethodInfo methodInfo3 = AccessTools.Method(type, "SetPlayerOneCursor", (Type[])null, (Type[])null); MethodInfo methodInfo4 = AccessTools.Method(typeof(CoopKBnMPatches.SetPlayerOneCursorPatchClass), "SetPlayerOneCursorPostfix", (Type[])null, (Type[])null); harmony.Patch((MethodBase)methodInfo3, (HarmonyMethod)null, new HarmonyMethod(methodInfo4), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); MethodInfo methodInfo5 = AccessTools.Method(type, "SetPlayerOneCursorModulation", (Type[])null, (Type[])null); MethodInfo methodInfo6 = AccessTools.Method(typeof(CoopKBnMPatches.SetPlayerOneCursorModulationPatchClass), "SetPlayerOneCursorModulationPostfix", (Type[])null, (Type[])null); harmony.Patch((MethodBase)methodInfo5, (HarmonyMethod)null, new HarmonyMethod(methodInfo6), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); MethodInfo methodInfo7 = AccessTools.Method(type, "SetPlayerOneCursorScale", (Type[])null, (Type[])null); MethodInfo methodInfo8 = AccessTools.Method(typeof(CoopKBnMPatches.SetPlayerOneCursorScalePatchClass), "SetPlayerOneCursorScalePostfix", (Type[])null, (Type[])null); harmony.Patch((MethodBase)methodInfo7, (HarmonyMethod)null, new HarmonyMethod(methodInfo8), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); MethodInfo methodInfo9 = AccessTools.Method(type, "SetPlayerTwoCursor", (Type[])null, (Type[])null); MethodInfo methodInfo10 = AccessTools.Method(typeof(CoopKBnMPatches.SetPlayerTwoCursorPatchClass), "SetPlayerTwoCursorPostfix", (Type[])null, (Type[])null); harmony.Patch((MethodBase)methodInfo9, (HarmonyMethod)null, new HarmonyMethod(methodInfo10), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); MethodInfo methodInfo11 = AccessTools.Method(type, "SetPlayerTwoCursorModulation", (Type[])null, (Type[])null); MethodInfo methodInfo12 = AccessTools.Method(typeof(CoopKBnMPatches.SetPlayerTwoCursorModulationPatchClass), "SetPlayerTwoCursorModulationPostfix", (Type[])null, (Type[])null); harmony.Patch((MethodBase)methodInfo11, (HarmonyMethod)null, new HarmonyMethod(methodInfo12), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); MethodInfo methodInfo13 = AccessTools.Method(type, "SetPlayerTwoCursorScale", (Type[])null, (Type[])null); MethodInfo methodInfo14 = AccessTools.Method(typeof(CoopKBnMPatches.SetPlayerTwoCursorScalePatchClass), "SetPlayerTwoCursorScalePostfix", (Type[])null, (Type[])null); harmony.Patch((MethodBase)methodInfo13, (HarmonyMethod)null, new HarmonyMethod(methodInfo14), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } } public static class CoopKBnMPatches { [HarmonyPatch(typeof(FoyerCharacterSelectFlag), "Update")] public class FoyerCharacterSelectFlagUpdatePatchClass { [HarmonyILManipulator] public static void FoyerCharacterSelectFlagUpdatePatch(ILContext ctx) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown ILCursor crs = new ILCursor(ctx); if (TheNthTime(() => crs.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.Match(x, OpCodes.Brfalse) }), 2)) { crs.EmitCall<FoyerCharacterSelectFlagUpdatePatchClass>("FoyerCharacterSelectFlagUpdatePatchCall"); } } private static bool FoyerCharacterSelectFlagUpdatePatchCall(bool orig) { return false; } } [HarmonyPatch(typeof(BraveInput), "AssignActionsDevice")] public class AssignActionsDevicePatchClass { [HarmonyILManipulator] public static void AssignActionsDevicePatch(ILContext ctx) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) ILCursor crs = new ILCursor(ctx); if (TheNthTime(() => crs.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchLdfld<BraveInput>(x, "m_playerID") }), 2)) { crs.Emit(OpCodes.Ldarg_0); crs.EmitCall<AssignActionsDevicePatchClass>("AssignActionsDevicePatchCall"); } } private static bool AssignActionsDevicePatchCall(bool orig, BraveInput self) { return orig && ((PlayerActionSet)self.m_activeGungeonActions).Device != null; } } [HarmonyPatch(typeof(PlayerAction), "UpdateBindings")] public class UpdateBindingsPatchClass { [HarmonyILManipulator] public static void UpdateBindingsPatch(ILContext ctx) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown //IL_0030: 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_0055: 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_0077: 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_00e7: Unknown result type (might be due to invalid IL or missing references) ILCursor crs = new ILCursor(ctx); if (TheNthTime(() => crs.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.Match(x, OpCodes.Brfalse) }), 2)) { crs.Emit(OpCodes.Ldloca_S, (byte)11); crs.Emit(OpCodes.Ldloc_S, (byte)8); crs.Emit(OpCodes.Ldarg_1); crs.Emit(OpCodes.Ldarg_2); crs.Emit(OpCodes.Ldarg_0); crs.EmitCall<UpdateBindingsPatchClass>("UpdateBindingsPatchCall_1"); } if (crs.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCallvirt<BindingSource>(x, "GetValue") })) { crs.Emit(OpCodes.Ldloc_S, (byte)8); crs.Emit(OpCodes.Ldarg_0); crs.EmitCall<UpdateBindingsPatchClass>("UpdateBindingsPatchCall_2"); } } private static bool UpdateBindingsPatchCall_1(bool orig, ref float value, BindingSource bindingSource, ulong updateTick, float deltaTime, PlayerAction self) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Invalid comparison between Unknown and I4 if (orig && GameManager.HasInstance && (int)GameManager.Instance.CurrentGameType == 1 && !BraveInput.GetInstanceForPlayer(0).IsKeyboardAndMouse(false) && BraveInput.GetInstanceForPlayer(1).IsKeyboardAndMouse(false) && bindingSource is KeyBindingSource && OptionsManager.isShareOneKeyboardMode && (self.Name == "Cancel" || self.Name == "Pause" || self.Name == "Menu Select" || self.Name == "Select Left" || self.Name == "Select Right" || self.Name == "Select Up" || self.Name == "Select Down")) { value = bindingSource.GetValue(self.Device); ((OneAxisInputControl)self).UpdateWithValue(value, updateTick, deltaTime); } return orig; } private static float UpdateBindingsPatchCall_2(float orig, BindingSource bindingSource, PlayerAction self) { if (bindingSource is KeyBindingSource && OptionsManager.restrictKeyboardInputPort) { return RawInputHandler.GetValue((KeyBindingSource)(object)((bindingSource is KeyBindingSource) ? bindingSource : null), self.Device, RawInputHandler.IsFirstKeyboard(self)); } if (bindingSource is MouseBindingSource) { if (OptionsManager.restrictMouseInputPort) { return RawInputHandler.GetValue((MouseBindingSource)(object)((bindingSource is MouseBindingSource) ? bindingSource : null), self.Device, RawInputHandler.IsFirstMouse(self)); } return RawInputHandler.GetValue((MouseBindingSource)(object)((bindingSource is MouseBindingSource) ? bindingSource : null), self.Device); } return orig; } } [HarmonyPatch(typeof(BraveOptionsMenuItem), "DetermineAvailableOptions")] public class DetermineAvailableOptionsPatchClass { [HarmonyPrefix] public static bool DetermineAvailableOptionsPrefix(BraveOptionsMenuItem __instance) { //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) //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_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Invalid comparison between Unknown and I4 //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Invalid comparison between Unknown and I4 //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Invalid comparison between Unknown and I4 BraveOptionsOptionType optionType = __instance.optionType; BraveOptionsOptionType val = optionType; if ((int)val != 256) { if ((int)val == 257) { List<string> list = (((int)GameManager.Options.CurrentLanguage == 11) ? new List<string> { "鼠标 1", "鼠标 2" } : new List<string> { "Mouse 1", "Mouse 2" }); __instance.labelOptions = list.ToArray(); } } else { List<string> list2 = (((int)GameManager.Options.CurrentLanguage == 11) ? new List<string> { "键盘 1", "键盘 2" } : new List<string> { "Keyboard 1", "Keyboard 2" }); __instance.labelOptions = list2.ToArray(); } return true; } } [HarmonyPatch(typeof(BraveOptionsMenuItem), "HandleLeftRightArrowValueChanged")] public class HandleLeftRightArrowValueChangedPatchClass { [HarmonyPostfix] public static void HandleLeftRightArrowValueChangedPostfix(BraveOptionsMenuItem __instance) { //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) //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_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Invalid comparison between Unknown and I4 BraveOptionsOptionType optionType = __instance.optionType; BraveOptionsOptionType val = optionType; if ((int)val != 256) { if ((int)val == 257) { OptionsManager.currentPlayerOneMousePort = __instance.m_selectedIndex; ((MonoBehaviour)GameManager.Instance).StartCoroutine(OptionsManager.ReassignKeyboardAndMouseCrt()); Debug.Log((object)$"Coop KBnM: Current player two keyboard port set to {__instance.m_selectedIndex}"); if (!OptionsManager.isInitializingOptions) { float normalizedPlayerOneMouseSensitivity = OptionsManager.normalizedPlayerOneMouseSensitivity; OptionsManager.normalizedPlayerOneMouseSensitivity = OptionsManager.normalizedPlayerTwoMouseSensitivity; OptionsManager.normalizedPlayerTwoMouseSensitivity = normalizedPlayerOneMouseSensitivity; } if ((Object)(object)OptionsManager.playerOneMouseSensitivityPanelObject != (Object)null) { ((Component)OptionsManager.playerOneMouseSensitivityPanelObject.transform.Find("PanelEnsmallenerThatmakesDavesLifeHardandBrentsLifeEasy/MusicVolumeProgressBar")).GetComponent<dfProgressBar>().Value = OptionsManager.normalizedPlayerOneMouseSensitivity; } if ((Object)(object)OptionsManager.playerTwoMouseSensitivityPanelObject != (Object)null) { ((Component)OptionsManager.playerTwoMouseSensitivityPanelObject.transform.Find("PanelEnsmallenerThatmakesDavesLifeHardandBrentsLifeEasy/MusicVolumeProgressBar")).GetComponent<dfProgressBar>().Value = OptionsManager.normalizedPlayerTwoMouseSensitivity; } RawInputHandler.playerOneMouseSensitivity = Mathf.Clamp(4f * OptionsManager.normalizedPlayerOneMouseSensitivity + 0.4f, 0.4f, 4.4f); RawInputHandler.playerTwoMouseSensitivity = Mathf.Clamp(4f * OptionsManager.normalizedPlayerTwoMouseSensitivity + 0.4f, 0.4f, 4.4f); } } else { OptionsManager.currentPlayerOneKeyboardPort = __instance.m_selectedIndex; ((MonoBehaviour)GameManager.Instance).StartCoroutine(OptionsManager.ReassignKeyboardAndMouseCrt()); Debug.Log((object)$"Coop KBnM: Current player one keyboard port set to {__instance.m_selectedIndex}"); } } [HarmonyILManipulator] public static void HandleLeftRightArrowValueChangedPatch(ILContext ctx) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_003d: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(ctx); if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCallvirt<GameOptions>(x, "set_CurrentPreferredFullscreenMode") })) { val.Emit(OpCodes.Ldarg_0); val.EmitCall<HandleLeftRightArrowValueChangedPatchClass>("HandleLeftRightArrowValueChangedPatchCall"); } } private static void HandleLeftRightArrowValueChangedPatchCall(BraveOptionsMenuItem self) { GameManager.Options.CurrentPreferredFullscreenMode = (PreferredFullscreenMode)((self.m_selectedIndex == 0) ? 1 : 2); } } [HarmonyPatch(typeof(BraveOptionsMenuItem), "HandleCheckboxValueChanged")] public class HandleCheckboxValueChangedPatchClass { [HarmonyPrefix] public static bool HandleCheckboxValueChangedPrefix(BraveOptionsMenuItem __instance) { //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) //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_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 BraveOptionsOptionType optionType = __instance.optionType; BraveOptionsOptionType val = optionType; if ((int)val == 258) { bool flag = __instance.m_selectedIndex != 0; if (OptionsManager.isShareOneKeyboardMode != flag) { OptionsManager.isShareOneKeyboardMode = flag; Debug.Log((object)$"Coop KBnM: Is share one keyboard mode set to {flag}"); if (OptionsManager.isShareOneKeyboardMode) { OptionsManager.SaveBindingData(saveSharingBindingData: false); OptionsManager.LoadBindingData(saveSharingBindingData: true); OptionsManager.RemoveDuplicateBindings(); } else { OptionsManager.SaveBindingData(saveSharingBindingData: true); OptionsManager.LoadBindingData(saveSharingBindingData: false); } OptionsManager.SaveBindingInfoToCachedOptions(); BraveInput.SaveBindingInfoToOptions(); GameOptions.Save(); } ((MonoBehaviour)GameManager.Instance).StartCoroutine(OptionsManager.ReassignKeyboardAndMouseCrt()); } return true; } } [HarmonyPatch(typeof(BraveOptionsMenuItem), "HandleFillbarValueChanged")] public class HandleFillbarValueChangedPatchClass { [HarmonyPrefix] public static bool HandleFillbarValueChangedPrefix(BraveOptionsMenuItem __instance) { //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) //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_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Invalid comparison between Unknown and I4 BraveOptionsOptionType optionType = __instance.optionType; BraveOptionsOptionType val = optionType; if ((int)val != 259) { if ((int)val == 260) { RawInputHandler.playerTwoMouseSensitivity = Mathf.Clamp(4f * __instance.m_actualFillbarValue + 0.4f, 0.4f, 4.4f); OptionsManager.normalizedPlayerTwoMouseSensitivity = __instance.m_actualFillbarValue; Debug.Log((object)$"Coop KBnM: Normalized player two mouse sensitivity set to {__instance.m_actualFillbarValue}"); } } else { RawInputHandler.playerOneMouseSensitivity = Mathf.Clamp(4f * __instance.m_actualFillbarValue + 0.4f, 0.4f, 4.4f); OptionsManager.normalizedPlayerOneMouseSensitivity = __instance.m_actualFillbarValue; Debug.Log((object)$"Coop KBnM: Normalized player one mouse sensitivity set to {__instance.m_actualFillbarValue}"); } return true; } } [HarmonyPatch(typeof(BraveOptionsMenuItem), "DoSelectedAction")] public class DoSelectedActionPatchClass { [HarmonyILManipulator] public static void DoSelectedActionPatch(ILContext ctx) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown //IL_0052: Unknown result type (might be due to invalid IL or missing references) ILCursor crs = new ILCursor(ctx); if (crs.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchStsfld<FullOptionsMenuController>(x, "CurrentBindingPlayerTargetIndex") })) { crs.Emit(OpCodes.Ldarg_0); crs.EmitCall<DoSelectedActionPatchClass>("DoSelectedActionPatchCall_1"); } crs.Index = 0; if (TheNthTime(() => crs.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, 0) }), 4)) { crs.EmitCall<DoSelectedActionPatchClass>("DoSelectedActionPatchCall_2"); } } private static int DoSelectedActionPatchCall_1(int orig, BraveOptionsMenuItem self) { return (!(((Object)self).name == "EditKeyboardBindingsButtonPanel")) ? 1 : 0; } private static int DoSelectedActionPatchCall_2(int orig) { return 1; } } [HarmonyPatch(typeof(KeyboardBindingMenuOption), "InitializeKeyboard")] public class InitializeKeyboardPatchClass { [HarmonyILManipulator] public static void InitializeKeyboardPatch(ILContext ctx) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown ILCursor val = new ILCursor(ctx); if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCallvirt<GameManager>(x, "get_CurrentGameType") })) { val.EmitCall<InitializeKeyboardPatchClass>("InitializeKeyboardPatchCall"); } } private static int InitializeKeyboardPatchCall(int orig) { return 0; } } [HarmonyPatch(typeof(KeyboardBindingMenuOption), "EnterAssignmentMode")] public class EnterAssignmentModePatchClass { [HarmonyPostfix] public static void EnterAssignmentModePostfix(KeyboardBindingMenuOption __instance, bool isAlternateKey) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) GungeonActions activeActions = __instance.GetBestInputInstance().ActiveActions; PlayerAction actionFromType = activeActions.GetActionFromType(__instance.ActionType); BindingListenOptions bindingOptions = actionFromType.ListenOptions; bindingOptions.OnBindingFound = delegate(PlayerAction action, BindingSource binding) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected O, but got Unknown //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) if (binding == (BindingSource)new KeyBindingSource((Key[])(object)new Key[1] { (Key)13 })) { action.StopListeningForBinding(); ((Component)GameUIRoot.Instance.PauseMenuPanel).GetComponent<PauseMenuController>().OptionsMenu.ClearModalKeyBindingDialog((dfControl)null, (dfControlEventArgs)null); return false; } if (binding == (BindingSource)new KeyBindingSource((Key[])(object)new Key[1] { (Key)78 })) { action.StopListeningForBinding(); ((Component)GameUIRoot.Instance.PauseMenuPanel).GetComponent<PauseMenuController>().OptionsMenu.ClearModalKeyBindingDialog((dfControl)null, (dfControlEventArgs)null); return false; } if (__instance.IsControllerMode && binding is KeyBindingSource) { return false; } if (binding is KeyBindingSource && OptionsManager.isShareOneKeyboardMode && BraveInput.m_instances.Count > 1 && action.Owner == BraveInput.GetInstanceForPlayer(1).ActiveActions && ((PlayerActionSet)BraveInput.GetInstanceForPlayer(0).ActiveActions).HasBinding(binding)) { return false; } if (binding is KeyBindingSource && OptionsManager.isShareOneKeyboardMode && BraveInput.m_instances.Count > 1 && action.Owner == BraveInput.GetInstanceForPlayer(0).ActiveActions && ((PlayerActionSet)BraveInput.GetInstanceForPlayer(1).ActiveActions).HasBinding(binding)) { int count = ((PlayerActionSet)BraveInput.GetInstanceForPlayer(1).ActiveActions).Actions.Count; for (int i = 0; i < count; i++) { ((PlayerActionSet)BraveInput.GetInstanceForPlayer(1).ActiveActions).Actions[i].HardRemoveBinding(binding); } } action.StopListeningForBinding(); if (!__instance.m_parentOptionsMenu.ActionIsMultibindable(__instance.ActionType, activeActions)) { __instance.m_parentOptionsMenu.ClearBindingFromAllControls(FullOptionsMenuController.CurrentBindingPlayerTargetIndex, binding); } action.SetBindingOfTypeByNumber(binding, binding.BindingSourceType, isAlternateKey ? 1 : 0, bindingOptions.OnBindingAdded); ((Component)GameUIRoot.Instance.PauseMenuPanel).GetComponent<PauseMenuController>().OptionsMenu.ToggleKeyBindingDialogState(binding); __instance.Initialize(); return false; }; } } [HarmonyPatch(typeof(GungeonActions), "ReinitializeDefaults")] public class ReinitializeDefaultsPatchClass { [HarmonyPostfix] public static void ReinitializeDefaultsPostfix() { if (OptionsManager.isShareOneKeyboardMode) { OptionsManager.RemoveDuplicateBindings(); } } } [HarmonyPatch(typeof(GungeonActions), "InitializeSwappedTriggersPreset")] public class InitializeSwappedTriggersPresetPatchClass { [HarmonyPostfix] public static void InitializeSwappedTriggersPresetPostfix() { if (OptionsManager.isShareOneKeyboardMode) { OptionsManager.RemoveDuplicateBindings(); } } } [HarmonyPatch(/*Could not decode attribute arguments.*/)] public class Get_MousePositionPatchClass { [HarmonyPrefix] public static bool Get_MousePositionPrefix(ref Vector3 __result) { //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) //IL_000c: Unknown result type (might be due to invalid IL or missing references) __result = Vector2.op_Implicit(RawInputHandler.firstMousePosition); return false; } } [HarmonyPatch(typeof(MouseBindingSource), "PositiveScrollWheelIsActive")] public class PositiveScrollWheelIsActivePatchClass { [HarmonyPrefix] public static bool PositiveScrollWheelIsActivePrefix(float threshold, ref bool __result) { float num = Mathf.Max(0f, (float)RawInputHandler.GetPublicWheel() * MouseBindingSource.ScaleZ); __result = num > threshold; return false; } } [HarmonyPatch(typeof(MouseBindingSource), "NegativeScrollWheelIsActive")] public class NegativeScrollWheelIsActivePatchClass { [HarmonyPrefix] public static bool NegativeScrollWheelIsActivePrefix(float threshold, ref bool __result) { float num = Mathf.Min((float)RawInputHandler.GetPublicWheel() * MouseBindingSource.ScaleZ, 0f); __result = num < 0f - threshold; return false; } } [HarmonyPatch(typeof(Input), "GetAxis")] public class GetAxisPatchClass { [HarmonyPrefix] public static bool GetAxisPrefix(string axisName, ref float __result) { if (axisName == "Mouse ScrollWheel") { __result = RawInputHandler.GetPublicSmoothWheelValue(); return false; } return true; } } [HarmonyPatch(typeof(GameCursorController), "DrawCursor")] public class DrawCursorPatchClass { [HarmonyILManipulator] public static void DrawCursorPatch(ILContext ctx) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown ILCursor val = new ILCursor(ctx); if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCall<GameCursorController>(x, "get_showMouseCursor") })) { val.EmitCall<DrawCursorPatchClass>("DrawCursorPatchCall_1"); } if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCallvirt<BraveInput>(x, "IsKeyboardAndMouse") })) { val.EmitCall<DrawCursorPatchClass>("DrawCursorPatchCall_2"); } } [HarmonyPostfix] public static void DrawCursorPostfix(GameCursorController __instance) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0693: Unknown result type (might be due to invalid IL or missing references) //IL_0699: Invalid comparison between Unknown and I4 //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Invalid comparison between Unknown and I4 //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_02e2: Unknown result type (might be due to invalid IL or missing references) //IL_04b1: Unknown result type (might be due to invalid IL or missing references) //IL_04b6: Unknown result type (might be due to invalid IL or missing references) //IL_077c: Unknown result type (might be due to invalid IL or missing references) //IL_0782: Invalid comparison between Unknown and I4 //IL_06df: Unknown result type (might be due to invalid IL or missing references) //IL_06e4: Unknown result type (might be due to invalid IL or missing references) //IL_06c6: Unknown result type (might be due to invalid IL or missing references) //IL_06cb: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Invalid comparison between Unknown and I4 //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_0380: Unknown result type (might be due to invalid IL or missing references) //IL_0385: Unknown result type (might be due to invalid IL or missing references) //IL_0921: Unknown result type (might be due to invalid IL or missing references) //IL_0926: Unknown result type (might be due to invalid IL or missing references) //IL_0908: Unknown result type (might be due to invalid IL or missing references) //IL_090d: Unknown result type (might be due to invalid IL or missing references) //IL_0554: Unknown result type (might be due to invalid IL or missing references) //IL_0559: Unknown result type (might be due to invalid IL or missing references) //IL_03a1: Unknown result type (might be due to invalid IL or missing references) //IL_03a6: Unknown result type (might be due to invalid IL or missing references) //IL_0398: Unknown result type (might be due to invalid IL or missing references) //IL_039d: Unknown result type (might be due to invalid IL or missing references) //IL_03b1: Unknown result type (might be due to invalid IL or missing references) //IL_03ce: Unknown result type (might be due to invalid IL or missing references) //IL_07be: Unknown result type (might be due to invalid IL or missing references) //IL_07c3: Unknown result type (might be due to invalid IL or missing references) //IL_07cd: Unknown result type (might be due to invalid IL or missing references) //IL_07ea: Unknown result type (might be due to invalid IL or missing references) //IL_0575: Unknown result type (might be due to invalid IL or missing references) //IL_057a: Unknown result type (might be due to invalid IL or missing references) //IL_056c: Unknown result type (might be due to invalid IL or missing references) //IL_0571: Unknown result type (might be due to invalid IL or missing references) //IL_0585: Unknown result type (might be due to invalid IL or missing references) //IL_05a2: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_03ef: Unknown result type (might be due to invalid IL or missing references) //IL_03f6: Unknown result type (might be due to invalid IL or missing references) //IL_03fb: Unknown result type (might be due to invalid IL or missing references) //IL_03ff: Unknown result type (might be due to invalid IL or missing references) //IL_040c: Unknown result type (might be due to invalid IL or missing references) //IL_041a: Unknown result type (might be due to invalid IL or missing references) //IL_0427: Unknown result type (might be due to invalid IL or missing references) //IL_0435: Unknown result type (might be due to invalid IL or missing references) //IL_043c: Unknown result type (might be due to invalid IL or missing references) //IL_0448: Unknown result type (might be due to invalid IL or missing references) //IL_0460: Unknown result type (might be due to invalid IL or missing references) //IL_0469: Unknown result type (might be due to invalid IL or missing references) //IL_080b: Unknown result type (might be due to invalid IL or missing references) //IL_0812: Unknown result type (might be due to invalid IL or missing references) //IL_0817: Unknown result type (might be due to invalid IL or missing references) //IL_081b: Unknown result type (might be due to invalid IL or missing references) //IL_0828: Unknown result type (might be due to invalid IL or missing references) //IL_0836: Unknown result type (might be due to invalid IL or missing references) //IL_0843: Unknown result type (might be due to invalid IL or missing references) //IL_0851: Unknown result type (might be due to invalid IL or missing references) //IL_0858: Unknown result type (might be due to invalid IL or missing references) //IL_0864: Unknown result type (might be due to invalid IL or missing references) //IL_087c: Unknown result type (might be due to invalid IL or missing references) //IL_0885: Unknown result type (might be due to invalid IL or missing references) //IL_05c3: Unknown result type (might be due to invalid IL or missing references) //IL_05ca: Unknown result type (might be due to invalid IL or missing references) //IL_05cf: Unknown result type (might be due to invalid IL or missing references) //IL_05d3: Unknown result type (might be due to invalid IL or missing references) //IL_05e0: Unknown result type (might be due to invalid IL or missing references) //IL_05ee: Unknown result type (might be due to invalid IL or missing references) //IL_05fb: Unknown result type (might be due to invalid IL or missing references) //IL_0609: Unknown result type (might be due to invalid IL or missing references) //IL_0610: Unknown result type (might be due to invalid IL or missing references) //IL_061c: Unknown result type (might be due to invalid IL or missing references) //IL_0634: Unknown result type (might be due to invalid IL or missing references) //IL_063d: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_09e9: Unknown result type (might be due to invalid IL or missing references) //IL_09ee: Unknown result type (might be due to invalid IL or missing references) //IL_0a33: Unknown result type (might be due to invalid IL or missing references) //IL_0a50: Unknown result type (might be due to invalid IL or missing references) //IL_0a23: Unknown result type (might be due to invalid IL or missing references) //IL_0a1c: Unknown result type (might be due to invalid IL or missing references) //IL_0a0c: Unknown result type (might be due to invalid IL or missing references) //IL_0a05: Unknown result type (might be due to invalid IL or missing references) //IL_0a28: Unknown result type (might be due to invalid IL or missing references) //IL_0a11: Unknown result type (might be due to invalid IL or missing references) //IL_0a71: Unknown result type (might be due to invalid IL or missing references) //IL_0a78: Unknown result type (might be due to invalid IL or missing references) //IL_0a7d: Unknown result type (might be due to invalid IL or missing references) //IL_0a81: Unknown result type (might be due to invalid IL or missing references) //IL_0a8e: Unknown result type (might be due to invalid IL or missing references) //IL_0a9c: Unknown result type (might be due to invalid IL or missing references) //IL_0aa9: Unknown result type (might be due to invalid IL or missing references) //IL_0ab7: Unknown result type (might be due to invalid IL or missing references) //IL_0abe: Unknown result type (might be due to invalid IL or missing references) //IL_0aca: Unknown result type (might be due to invalid IL or missing references) //IL_0ae2: Unknown result type (might be due to invalid IL or missing references) //IL_0aeb: Unknown result type (might be due to invalid IL or missing references) if (!GameManager.HasInstance || !GameCursorController.showMouseCursor || !GameManager.HasInstance || (int)GameManager.Instance.CurrentGameType != 1) { return; } if (!CoopKBnMModule.isCoopViewLoaded || !CoopKBnMModule.secondWindowActive) { if (RawInputHandler.ShowPublicCursor) { Color val = default(Color); ((Color)(ref val))..ctor(0.5f, 0.5f, 0.5f, 0.5f); float num = 1f; Texture2D val2; if (customCursorIsOn) { if ((int)GameManager.Instance.CurrentGameType == 1 && !BraveInput.GetInstanceForPlayer(0).IsKeyboardAndMouse(false) && BraveInput.GetInstanceForPlayer(1).IsKeyboardAndMouse(false)) { val2 = playerTwoCursor; val = CoopKBnMPatches.playerTwoCursorModulation; num = playerTwoCursorScale; } else { val2 = playerOneCursor; val = CoopKBnMPatches.playerOneCursorModulation; num = playerOneCursorScale; } if ((Object)(object)val2 == (Object)null) { val2 = __instance.normalCursor; int currentCursorIndex = GameManager.Options.CurrentCursorIndex; if (currentCursorIndex >= 0 && currentCursorIndex < __instance.cursors.Length) { val2 = __instance.cursors[currentCursorIndex]; } } } else { val2 = __instance.normalCursor; int currentCursorIndex2 = GameManager.Options.CurrentCursorIndex; if (currentCursorIndex2 >= 0 && currentCursorIndex2 < __instance.cursors.Length) { val2 = __instance.cursors[currentCursorIndex2]; } if ((int)GameManager.Instance.CurrentGameType == 1 && !BraveInput.GetInstanceForPlayer(0).IsKeyboardAndMouse(false) && BraveInput.GetInstanceForPlayer(1).IsKeyboardAndMouse(false)) { ((Color)(ref val))..ctor(0.402f, 0.111f, 0.32f); } } Vector2 firstMousePosition = RawInputHandler.firstMousePosition; firstMousePosition.y = (float)Screen.height - firstMousePosition.y; Vector2 val3 = new Vector2((float)((Texture)val2).width, (float)((Texture)val2).height) * (float)((!((Object)(object)Pixelator.Instance != (Object)null)) ? 3 : ((int)Pixelator.Instance.ScaleTileScale)) * num; Rect val4 = default(Rect); ((Rect)(ref val4))..ctor(firstMousePosition.x + 0.5f - val3.x / 2f, firstMousePosition.y + 0.5f - val3.y / 2f, val3.x, val3.y); Graphics.DrawTexture(val4, (Texture)(object)val2, new Rect(0f, 0f, 1f, 1f), 0, 0, 0, 0, val); return; } if (RawInputHandler.ShowPlayerOneMouseCursor) { Color playerOneCursorModulation = default(Color); ((Color)(ref playerOneCursorModulation))..ctor(0.5f, 0.5f, 0.5f, 0.5f); float num2 = 1f; Texture2D val5; if (customCursorIsOn) { val5 = playerOneCursor; playerOneCursorModulation = CoopKBnMPatches.playerOneCursorModulation; num2 = playerOneCursorScale; if ((Object)(object)val5 == (Object)null) { val5 = __instance.normalCursor; int currentCursorIndex3 = GameManager.Options.CurrentCursorIndex; if (currentCursorIndex3 >= 0 && currentCursorIndex3 < __instance.cursors.Length) { val5 = __instance.cursors[currentCursorIndex3]; } } } else { val5 = __instance.normalCursor; int currentCursorIndex4 = GameManager.Options.CurrentCursorIndex; if (currentCursorIndex4 >= 0 && currentCursorIndex4 < __instance.cursors.Length) { val5 = __instance.cursors[currentCursorIndex4]; } } Vector2 val6 = ((!OptionsManager.restrictMouseInputPort) ? RawInputHandler.firstMousePosition : ((OptionsManager.currentPlayerOneMousePort != 1) ? RawInputHandler.firstMousePosition : RawInputHandler.secondMousePosition)); val6.y = (float)Screen.height - val6.y; Vector2 val7 = new Vector2((float)((Texture)val5).width, (float)((Texture)val5).height) * (float)((!((Object)(object)Pixelator.Instance != (Object)null)) ? 3 : ((int)Pixelator.Instance.ScaleTileScale)) * num2; Rect val8 = default(Rect); ((Rect)(ref val8))..ctor(val6.x + 0.5f - val7.x / 2f, val6.y + 0.5f - val7.y / 2f, val7.x, val7.y); Graphics.DrawTexture(val8, (Texture)(object)val5, new Rect(0f, 0f, 1f, 1f), 0, 0, 0, 0, playerOneCursorModulation); } if (!RawInputHandler.ShowPlayerTwoMouseCursor) { return; } Color playerTwoCursorModulation = default(Color); ((Color)(ref playerTwoCursorModulation))..ctor(0.402f, 0.111f, 0.32f); float num3 = 1f; Texture2D val9; if (customCursorIsOn) { val9 = playerTwoCursor; playerTwoCursorModulation = CoopKBnMPatches.playerTwoCursorModulation; num3 = playerTwoCursorScale; if ((Object)(object)val9 == (Object)null) { val9 = __instance.normalCursor; int currentCursorIndex5 = GameManager.Options.CurrentCursorIndex; if (currentCursorIndex5 >= 0 && currentCursorIndex5 < __instance.cursors.Length) { val9 = __instance.cursors[currentCursorIndex5]; } } } else { val9 = __instance.normalCursor; int currentCursorIndex6 = GameManager.Options.CurrentCursorIndex; if (currentCursorIndex6 >= 0 && currentCursorIndex6 < __instance.cursors.Length) { val9 = __instance.cursors[currentCursorIndex6]; } } Vector2 val10 = ((!OptionsManager.restrictMouseInputPort) ? RawInputHandler.firstMousePosition : ((OptionsManager.currentPlayerOneMousePort != 0) ? RawInputHandler.firstMousePosition : RawInputHandler.secondMousePosition)); val10.y = (float)Screen.height - val10.y; Vector2 val11 = new Vector2((float)((Texture)val9).width, (float)((Texture)val9).height) * (float)((!((Object)(object)Pixelator.Instance != (Object)null)) ? 3 : ((int)Pixelator.Instance.ScaleTileScale)) * num3; Rect val12 = default(Rect); ((Rect)(ref val12))..ctor(val10.x + 0.5f - val11.x / 2f, val10.y + 0.5f - val11.y / 2f, val11.x, val11.y); Graphics.DrawTexture(val12, (Texture)(object)val9, new Rect(0f, 0f, 1f, 1f), 0, 0, 0, 0, playerTwoCursorModulation); } else if (RawInputHandler.ShowPublicCursor) { Color val13 = default(Color); ((Color)(ref val13))..ctor(0.5f, 0.5f, 0.5f, 0.5f); float num4 = 1f; Texture2D val14; if (customCursorIsOn) { if ((int)GameManager.Instance.CurrentGameType == 1 && !BraveInput.GetInstanceForPlayer(0).IsKeyboardAndMouse(false) && BraveInput.GetInstanceForPlayer(1).IsKeyboardAndMouse(false)) { val14 = playerTwoCursor; val13 = CoopKBnMPatches.playerTwoCursorModulation; num4 = playerTwoCursorScale; } else { val14 = playerOneCursor; val13 = CoopKBnMPatches.playerOneCursorModulation; num4 = playerOneCursorScale; } if ((Object)(object)val14 == (Object)null) { val14 = __instance.normalCursor; int currentCursorIndex7 = GameManager.Options.CurrentCursorIndex; if (currentCursorIndex7 >= 0 && currentCursorIndex7 < __instance.cursors.Length) { val14 = __instance.cursors[currentCursorIndex7]; } } } else { val14 = __instance.normalCursor; int currentCursorIndex8 = GameManager.Options.CurrentCursorIndex; if (currentCursorIndex8 >= 0 && currentCursorIndex8 < __instance.cursors.Length) { val14 = __instance.cursors[currentCursorIndex8]; } if ((int)GameManager.Instance.CurrentGameType == 1 && !BraveInput.GetInstanceForPlayer(0).IsKeyboardAndMouse(false) && BraveInput.GetInstanceForPlayer(1).IsKeyboardAndMouse(false)) { ((Color)(ref val13))..ctor(0.402f, 0.111f, 0.32f); } } Vector2 firstMousePosition2 = RawInputHandler.firstMousePosition; firstMousePosition2.y = (float)Screen.height - firstMousePosition2.y; Vector2 val15 = new Vector2((float)((Texture)val14).width, (float)((Texture)val14).height) * (float)((!((Object)(object)Pixelator.Instance != (Object)null)) ? 3 : ((int)Pixelator.Instance.ScaleTileScale)) * num4; Rect val16 = default(Rect); ((Rect)(ref val16))..ctor(firstMousePosition2.x + 0.5f - val15.x / 2f, firstMousePosition2.y + 0.5f - val15.y / 2f, val15.x, val15.y); Graphics.DrawTexture(val16, (Texture)(object)val14, new Rect(0f, 0f, 1f, 1f), 0, 0, 0, 0, val13); } else { if ((!RawInputHandler.ShowPlayerOneMouseCursor || !OptionsManager.isPrimaryPlayerOnMainCamera) && (!RawInputHandler.ShowPlayerTwoMouseCursor || OptionsManager.isPrimaryPlayerOnMainCamera)) { return; } Color val17 = default(Color); ((Color)(ref val17))..ctor(0.5f, 0.5f, 0.5f, 0.5f); float num5 = 1f; Texture2D val18; if (customCursorIsOn) { if (!OptionsManager.isPrimaryPlayerOnMainCamera) { val18 = playerTwoCursor; val17 = CoopKBnMPatches.playerTwoCursorModulation; num5 = playerTwoCursorScale; } else { val18 = playerOneCursor; val17 = CoopKBnMPatches.playerOneCursorModulation; num5 = playerOneCursorScale; } if ((Object)(object)val18 == (Object)null) { val18 = __instance.normalCursor; int currentCursorIndex9 = GameManager.Options.CurrentCursorIndex; if (currentCursorIndex9 >= 0 && currentCursorIndex9 < __instance.cursors.Length) { val18 = __instance.cursors[currentCursorIndex9]; } } } else { val18 = __instance.normalCursor; int currentCursorIndex10 = GameManager.Options.CurrentCursorIndex; if (currentCursorIndex10 >= 0 && currentCursorIndex10 < __instance.cursors.Length) { val18 = __instance.cursors[currentCursorIndex10]; } if (!OptionsManager.isPrimaryPlayerOnMainCamera) { ((Color)(ref val17))..ctor(0.402f, 0.111f, 0.32f); } } Vector2 val19 = ((!OptionsManager.restrictMouseInputPort) ? RawInputHandler.firstMousePosition : ((!OptionsManager.isPrimaryPlayerOnMainCamera) ? ((OptionsManager.currentPlayerOneMousePort != 0) ? RawInputHandler.firstMousePosition : RawInputHandler.secondMousePosition) : ((OptionsManager.currentPlayerOneMousePort == 0) ? RawInputHandler.firstMousePosition : RawInputHandler.secondMousePosition))); val19.y = (float)Screen.height - val19.y; Vector2 val20 = new Vector2((float)((Texture)val18).width, (float)((Texture)val18).height) * (float)((!((Object)(object)Pixelator.Instance != (Object)null)) ? 3 : ((int)Pixelator.Instance.ScaleTileScale)) * num5; Rect val21 = default(Rect); ((Rect)(ref val21))..ctor(val19.x + 0.5f - val20.x / 2f, val19.y + 0.5f - val20.y / 2f, val20.x, val20.y); Graphics.DrawTexture(val21, (Texture)(object)val18, new Rect(0f, 0f, 1f, 1f), 0, 0, 0, 0, val17); } } private static bool DrawCursorPatchCall_1(bool orig) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Invalid comparison between Unknown and I4 return orig && (!GameManager.HasInstance || (int)GameManager.Instance.CurrentGameType != 1); } private static bool DrawCursorPatchCall_2(bool orig) { return orig && !OptionsManager.restrictMouseInputPort; } } [HarmonyPatch(typeof(PlayerController), "DetermineAimPointInWorld")] public class DetermineAimPointInWorldPatchClass { [HarmonyILManipulator] public static void DetermineAimPointInWorldPatch(ILContext ctx) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(ctx); if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchLdfld<Vector3>(x, "x") })) { val.Emit(OpCodes.Ldarg_0); val.EmitCall<DetermineAimPointInWorldPatchClass>("DetermineAimPointInWorldPatchCall_1"); } if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchLdfld<Vector3>(x, "y") })) { val.Emit(OpCodes.Ldarg_0); val.EmitCall<DetermineAimPointInWorldPatchClass>("DetermineAimPointInWorldPatchCall_2"); } } private static float DetermineAimPointInWorldPatchCall_1(float orig, PlayerController self) { if (OptionsManager.restrictMouseInputPort) { if (self.IsPrimaryPlayer) { if (OptionsManager.currentPlayerOneMousePort == 0) { return RawInputHandler.firstMousePosition.x; } return RawInputHandler.secondMousePosition.x; } if (OptionsManager.currentPlayerOneMousePort == 0) { return RawInputHandler.secondMousePosition.x; } return RawInputHandler.firstMousePosition.x; } return orig; } private static float DetermineAimPointInWorldPatchCall_2(float orig, PlayerController self) { if (OptionsManager.restrictMouseInputPort) { if (self.IsPrimaryPlayer) { if (OptionsManager.currentPlayerOneMousePort == 0) { return RawInputHandler.firstMousePosition.y; } return RawInputHandler.secondMousePosition.y; } if (OptionsManager.currentPlayerOneMousePort == 0) { return RawInputHandler.secondMousePosition.y; } return RawInputHandler.firstMousePosition.y; } return orig; } } [HarmonyPatch(typeof(FullOptionsMenuController), "ToggleToPanel")] public class ToggleToPanelPatchClass { [HarmonyPostfix] public static void ToggleToPanelPostfix(FullOptionsMenuController __instance, dfScrollPanel targetPanel, bool doFocus) { OptionsManager.fullOptionsMenuController = __instance; if ((Object)(object)targetPanel == (Object)(object)__instance.TabControls) { int i; for (i = 0; i < ((dfControl)targetPanel).Controls.Count && !((dfControl)targetPanel).Controls[i].CanFocus; i++) { } if (((dfControl)targetPanel).Controls.Count > 0 && i < ((dfControl)targetPanel).Controls.Count) { ((Component)__instance.PrimaryCancelButton).GetComponent<UIKeyControls>().down = ((dfControl)targetPanel).Controls[i]; ((Component)__instance.PrimaryConfirmButton).GetComponent<UIKeyControls>().down = ((dfControl)targetPanel).Controls[i]; ((Component)__instance.PrimaryResetDefaultsButton).GetComponent<UIKeyControls>().down = ((dfControl)targetPanel).Controls[i]; ((Component)((dfControl)targetPanel).Controls[i]).GetComponent<BraveOptionsMenuItem>().up = (dfControl)(object)__instance.PrimaryConfirmButton; ((dfControl)targetPanel).Controls[i].Focus(true); } } } } [HarmonyPatch(typeof(BraveOptionsMenuItem), "Awake")] public class BraveOptionsMenuItemAwakePatchClass { [HarmonyPostfix] public static void BraveOptionsMenuItemAwake_Post(BraveOptionsMenuItem __instance) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 if ((int)__instance.optionType == 8) { __instance.labelOptions = new string[2] { "Borderless", "Windowed" }; } } } [HarmonyPatch(typeof(BraveOptionsMenuItem), "GetIndexFromFullscreenMode")] public class GetIndexFromFullscreenModePatchClass { [HarmonyPrefix] public static bool GetIndexFromFullscreenModePrefix(PreferredFullscreenMode fMode, ref int __result) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Invalid comparison between Unknown and I4 __result = (((int)fMode == 2) ? 1 : 0); return false; } } [HarmonyPatch(/*Could not decode attribute arguments.*/)] public class SetCurrentPreferredFullscreenModePatchClass { [HarmonyILManipulator] public static void SetCurrentPreferredFullscreenModePatch(ILContext ctx) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown ILCursor val = new ILCursor(ctx); if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchStfld<GameOptions>(x, "m_preferredFullscreenMode") })) { val.EmitCall<SetCurrentPreferredFullscreenModePatchClass>("SetCurrentPreferredFullscreenModePatchCall"); } } private static PreferredFullscreenMode SetCurrentPreferredFullscreenModePatchCall(PreferredFullscreenMode orig) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 //IL_000d: 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_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) if ((int)orig == 0) { return (PreferredFullscreenMode)1; } return orig; } } [HarmonyPatch(typeof(GameManager), "DoSetResolution")] public class DoSetResolutionPatchClass { [HarmonyPrefix] public static bool DoSetResolutionPrefix() { return false; } } [HarmonyPatch(typeof(dfInputManager), "Update")] public class DfInputManagerUpdatePatchClass { [HarmonyILManipulator] public static void DfInputManagerUpdatePatch(ILContext ctx) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_003d: 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) ILCursor val = new ILCursor(ctx); if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchStloc(x, 3) })) { val.Emit(OpCodes.Ldloca_S, (byte)3); val.Emit(OpCodes.Ldloc_2); val.EmitCall<DfInputManagerUpdatePatchClass>("DfInputManagerUpdatePatchCall"); } } private static void DfInputManagerUpdatePatchCall(ref bool orig, Vector2 vector) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Invalid comparison between Unknown and I4 //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Invalid comparison between Unknown and I4 //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Invalid comparison between Unknown and I4 orig = ((Object)(object)BraveInput.SecondaryPlayerInstance != (Object)null && BraveInput.SecondaryPlayerInstance.ActiveActions != null && ((int)((PlayerActionSet)BraveInput.SecondaryPlayerInstance.ActiveActions).LastInputType == 3 || ((int)((PlayerActionSet)BraveInput.SecondaryPlayerInstance.ActiveActions).LastInputType == 2 && ((Vector2)(ref vector)).magnitude > float.Epsilon))) || (int)((PlayerActionSet)BraveInput.PrimaryPlayerInstance.ActiveActions).LastInputType == 3 || ((int)((PlayerActionSet)BraveInput.PrimaryPlayerInstance.ActiveActions).LastInputType == 2 && ((Vector2)(ref vector)).magnitude > float.Epsilon) || Input.GetMouseButtonDown(0) || Input.GetMouseButtonUp(0); } } [HarmonyPatch(typeof(KeyboardBindingMenuOption), "GetBestInputInstance")] public class KeyboardBindingMenuOptionGetBestInputInstancePatchClass { [HarmonyILManipulator] public static void KeyboardBindingMenuOptionGetBestInputInstancePatch(ILContext ctx) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown ILCursor val = new ILCursor(ctx); if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchLdsfld<Foyer>(x, "DoMainMenu") })) { val.EmitCall<KeyboardBindingMenuOptionGetBestInputInstancePatchClass>("KeyboardBindingMenuOptionGetBestInputInstancePatchCall"); } } private static bool KeyboardBindingMenuOptionGetBestInputInstancePatchCall(bool orig) { return false; } } [HarmonyPatch(typeof(GameOptions), "GetBestInputInstance")] public class GameOptionsGetBestInputInstancePatchClass { [HarmonyILManipulator] public static void GameOptionsGetBestInputInstancePatch(ILContext ctx) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown ILCursor val = new ILCursor(ctx); if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchLdsfld<Foyer>(x, "DoMainMenu") })) { val.EmitCall<GameOptionsGetBestInputInstancePatchClass>("GameOptionsGetBestInputInstancePatchCall"); } } private static bool GameOptionsGetBestInputInstancePatchCall(bool orig) { return false; } } [HarmonyPatch(typeof(BraveInput), "CheckForActionInitialization")] public class CheckForActionInitializationPatchClass { [HarmonyILManipulator] public static void CheckForActionInitializationPatch(ILContext ctx) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0088: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(ctx); if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchLdsfld<GameManager>(x, "PreventGameManagerExistence") })) { val.EmitCall<CheckForActionInitializationPatchClass>("CheckForActionInitializationPatchCall_1"); } val.Index = 0; if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, 0) })) { val.Emit(OpCodes.Ldarg_0); val.EmitCall<CheckForActionInitializationPatchClass>("CheckForActionInitializationPatchCall_2"); } } private static bool CheckForActionInitializationPatchCall_1(bool orig) { return true; } private static int CheckForActionInitializationPatchCall_2(int orig, BraveInput self) { return (!GameManager.PreventGameManagerExistence && (!((Object)(object)GameManager.Instance.PrimaryPlayer == (Object)null) || self.m_playerID != 0) && (!((Object)(object)GameManager.Instance.PrimaryPlayer != (Object)null) || self.m_playerID != GameManager.Instance.PrimaryPlayer.PlayerIDX)) ? 1 : 0; } } [HarmonyPatch(typeof(BraveInput), "SaveBindingInfoToOptions")] public class SaveBindingInfoToOptionsPatchClass { [HarmonyILManipulator] public static void SaveBindingInfoToOptionsPatch(ILContext ctx) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown ILCursor val = new ILCursor(ctx); if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCall<Object>(x, "op_Equality") })) { val.EmitCall<SaveBindingInfoToOptionsPatchClass>("SaveBindingInfoToOptionsPatchCall"); } } private static bool SaveBindingInfoToOptionsPatchCall(bool orig) { if (orig) { for (int i = 0; i < BraveInput.m_instances.Count; i++) { if (BraveInput.m_instances[i].m_playerID == 0) { GameManager.Options.playerOneBindingDataV2 = ((PlayerActionSet)BraveInput.m_instances[i].ActiveActions).Save(); } else { GameManager.Options.playerTwoBindingDataV2 = ((PlayerActionSet)BraveInput.m_instances[i].ActiveActions).Save(); } } } return orig; } } [HarmonyPatch(typeof(FullOptionsMenuController), "CloseAndApplyChanges")] public class CloseAndApplyChangesPatchClass { [HarmonyPostfix] public static void CloseAndApplyChangesPostfix() { CoopKBnMPreferences.SavePreferences(); } } [HarmonyPatch(typeof(FullOptionsMenuController), "CloseAndRevertChanges")] public class CloseAndRevertChangesPatchClass { [HarmonyPostfix] public static void CloseAndRevertChangesPostfix() { CoopKBnMPreferences.SavePreferences(); } } [HarmonyPatch(typeof(PlayerActionSet), "Load")] public class LoadPatchClass { [HarmonyPostfix] public static void LoadPostfix() { ((MonoBehaviour)GameManager.Instance).StartCoroutine(OptionsManager.ReassignKeyboardAndMouseCrt()); ((MonoBehaviour)GameManager.Instance).StartCoroutine(OptionsManager.DelayedRemoveDuplicateBindingsCrt()); } } [HarmonyPatch(typeof(GameManager), "HandleDeviceShift")] public class HandleDeviceShiftPatchClass { [HarmonyPostfix] public static void HandleDeviceShiftPostfix() { ((MonoBehaviour)GameManager.Instance).StartCoroutine(OptionsManager.ReassignKeyboardAndMouseCrt()); } } [HarmonyPatch(typeof(BraveInput), "ForceLoadBindingInfoFromOptions")] public class ForceLoadBindingInfoFromOptionsPatchClass { [HarmonyILManipulator] public static void ForceLoadBindingInfoFromOptionsPatch(ILContext ctx) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown //IL_00e4: Unknown result type (might be due to invalid IL or missing references) ILCursor crs = new ILCursor(ctx); if (crs.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchLdsfld<GameManager>(x, "PreventGameManagerExistence") })) { crs.EmitCall<ForceLoadBindingInfoFromOptionsPatchClass>("ForceLoadBindingInfoFromOptionsPatchCall_1"); } crs.Index = 0; if (crs.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchLdfld<BraveInput>(x, "m_playerID") })) { crs.EmitCall<ForceLoadBindingInfoFromOptionsPatchClass>("ForceLoadBindingInfoFromOptionsPatchCall_2"); } crs.Index = 0; if (TheNthTime(() => crs.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, 0) }), 2)) { crs.Emit(OpCodes.Ldloc_0); crs.EmitCall<ForceLoadBindingInfoFromOptionsPatchClass>("ForceLoadBindingInfoFromOptionsPatchCall_3"); } } private static bool ForceLoadBindingInfoFromOptionsPatchCall_1(bool orig) { return true; } private static int ForceLoadBindingInfoFromOptionsPatchCall_2(int orig) { return 0; } private static int ForceLoadBindingInfoFromOptionsPatchCall_3(int orig, int i) { return (!GameManager.PreventGameManagerExistence && (!((Object)(object)GameManager.Instance.PrimaryPlayer == (Object)null) || BraveInput.m_instances[i].m_playerID != 0) && (!((Object)(object)GameManager.Instance.PrimaryPlayer != (Object)null) || BraveInput.m_instances[i].m_playerID != GameManager.Instance.PrimaryPlayer.PlayerIDX)) ? 1 : 0; } } [HarmonyPatch(typeof(BraveInput), "ReassignAllControllers")] public class ReassignAllControllersPatchClass { [HarmonyILManipulator] public static void ReassignAllControllersPatch(ILContext ctx) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown //IL_00e4: Unknown result type (might be due to invalid IL or missing references) ILCursor crs = new ILCursor(ctx); if (crs.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCall<Object>(x, "op_Equality") })) { crs.EmitCall<ReassignAllControllersPatchClass>("ReassignAllControllersPatchCall_1"); } crs.Index = 0; if (crs.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchLdfld<BraveInput>(x, "m_playerID") })) { crs.EmitCall<ReassignAllControllersPatchClass>("ReassignAllControllersPatchCall_2"); } crs.Index = 0; if (TheNthTime(() => crs.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, 0) }), 4)) { crs.Emit(OpCodes.Ldloc_S, (byte)4); crs.EmitCall<ReassignAllControllersPatchClass>("ReassignAllControllersPatchCall_3"); } } private static bool ReassignAllControllersPatchCall_1(bool orig) { return true; } private static int ReassignAllControllersPatchCall_2(int orig) { return 0; } private static int ReassignAllControllersPatchCall_3(int orig, int i) { return ((!((Object)(object)GameManager.Instance.PrimaryPlayer == (Object)null) || BraveInput.m_instances[i].m_playerID != 0) && (!((Object)(object)GameManager.Instance.PrimaryPlayer != (Object)null) || BraveInput.m_instances[i].m_playerID != GameManager.Instance.PrimaryPlayer.PlayerIDX)) ? 1 : 0; } } [HarmonyPatch(typeof(BraveInput), "SavePlayerlessBindingsToOptions")] public class SavePlayerlessBindingsToOptionsPatchClass { [HarmonyPostfix] public static void SavePlayerlessBindingsToOptionsPostfix() { if (BraveInput.m_instances.Count > 1 && BraveInput.m_instances[1].m_playerID == 1) { GameManager.Options.playerTwoBindingDataV2 = ((PlayerActionSet)BraveInput.m_instances[1].ActiveActions).Save(); } } } public class SetCustomCursorIsOnPatchClass { public static void SetCustomCursorIsOnPostfix(bool value) { customCursorIsOn = value; } } public class SetPlayerOneCursorPatchClass { public static void SetPlayerOneCursorPostfix(Texture2D value) { playerOneCursor = value; } } public class SetPlayerOneCursorModulationPatchClass { public static void SetPlayerOneCursorModulationPostfix(Color value) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) playerOneCursorModulation = value; } } public class SetPlayerOneCursorScalePatchClass { public static void SetPlayerOneCursorScalePostfix(float value) { playerOneCursorScale = value; } } public class SetPlayerTwoCursorPatchClass { public static void SetPlayerTwoCursorPostfix(Texture2D value) { playerTwoCursor = value; } } public class SetPlayerTwoCursorModulationPatchClass { public static void SetPlayerTwoCursorModulationPostfix(Color value) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) playerTwoCursorModulation = value; } } public class SetPlayerTwoCursorScalePatchClass { public static void SetPlayerTwoCursorScalePostfix(float value) { playerTwoCursorScale = value; } } public static bool customCursorIsOn; public static Texture2D playerOneCursor; public static Color playerOneCursorModulation; public static float playerOneCursorScale; public static Texture2D playerTwoCursor; public static Color playerTwoCursorModulation; public static float playerTwoCursorScale; public static void EmitCall<T>(this ILCursor iLCursor, string methodName, Type[] parameters = null, Type[] generics = null) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) MethodInfo methodInfo = AccessTools.Method(typeof(T), methodName, parameters, generics); iLCursor.Emit(OpCodes.Call, (MethodBase)methodInfo); } public static T GetFieldInEnumerator<T>(object instance, string fieldNamePattern) { return (T)instance.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).FirstOrDefault((FieldInfo f) => f.Name.Contains("$" + fieldNamePattern) || f.Name.Contains("<" + fieldNamePattern + ">")) .GetValue(instance); } public static bool TheNthTime(this Func<bool> predict, int n = 1) { for (int i = 0; i < n; i++) { if (!predict()) { return false; } } return true; } } public class CoopKBnMPreferences { public class PreferencesData : ScriptableObject { public bool isShareOneKeyboardMode; public int currentPlayerOneKeyboardPort; public int currentPlayerOneMousePort; public float normalizedPlayerOneMouseSensitivity; public float normalizedPlayerTwoMouseSensitivity; public string sharingBindingData; public string nonSharingBindingData; public PreferencesData() { isShareOneKeyboardMode = OptionsManager.isShareOneKeyboardMode; currentPlayerOneKeyboardPort = OptionsManager.currentPlayerOneKeyboardPort; currentPlayerOneMousePort = OptionsManager.currentPlayerOneMousePort; normalizedPlayerOneMouseSensitivity = OptionsManager.normalizedPlayerOneMouseSensitivity; normalizedPlayerTwoMouseSensitivity = OptionsManager.normalizedPlayerTwoMouseSensitivity; sharingBindingData = OptionsManager.sharingBindingData; nonSharingBindingData = OptionsManager.nonSharingBindingData; } } private const string fileName = "CoopKBnM_Preferences.txt"; public static void LoadPreferences() { if (File.Exists(Path.Combine(ETGMod.ResourcesDirectory, "CoopKBnM_Preferences.txt"))) { string text = File.ReadAllText(Path.Combine(ETGMod.ResourcesDirectory, "CoopKBnM_Preferences.txt")); PreferencesData preferencesData = ScriptableObject.CreateInstance<PreferencesData>(); JsonUtility.FromJsonOverwrite(text, (object)preferencesData); OptionsManager.isShareOneKeyboardMode = preferencesData.isShareOneKeyboardMode; OptionsManager.currentPlayerOneKeyboardPort = preferencesData.currentPlayerOneKeyboardPort; OptionsManager.currentPlayerOneMousePort = preferencesData.currentPlayerOneMousePort; OptionsManager.normalizedPlayerOneMouseSensitivity = preferencesData.normalizedPlayerOneMouseSensitivity; OptionsManager.normalizedPlayerTwoMouseSensitivity = preferencesData.normalizedPlayerTwoMouseSensitivity; OptionsManager.sharingBindingData = preferencesData.sharingBindingData; OptionsManager.nonSharingBindingData = preferencesData.nonSharingBindingData; } else { SavePreferences(); } } public static void SavePreferences() { string value = JsonUtility.ToJson((object)ScriptableObject.CreateInstance<PreferencesData>(), true); if (File.Exists(Path.Combine(ETGMod.ResourcesDirectory, "CoopKBnM_Preferences.txt"))) { File.Delete(Path.Combine(ETGMod.ResourcesDirectory, "CoopKBnM_Preferences.txt")); } using StreamWriter streamWriter = new StreamWriter(Path.Combine(ETGMod.ResourcesDirectory, "CoopKBnM_Preferences.txt"), append: true); streamWriter.WriteLine(value); } } internal static class KeyCodeMaps { public enum Keys { Modifiers = -65536, None = 0, Back = 8, Tab = 9, Clear = 12, Enter = 13, Shift = 16, Control = 17, Alt = 18, Pause = 19, Capital = 20, CapsLock = 20, Escape = 27, Space = 32, PageUp = 33, PageDown = 34, End = 35, Home = 36, Left = 37, Up = 38, Right = 39, Down = 40, Print = 42, PrintScreen = 44, Insert = 45, Delete = 46, D0 = 48, D1 = 49, D2 = 50, D3 = 51, D4 = 52, D5 = 53, D6 = 54, D7 = 55, D8 = 56, D9 = 57, A = 65, B = 66, C = 67, D = 68, E = 69, F = 70, G = 71, H = 72, I = 73, J = 74, K = 75, L = 76, M = 77, N = 78, O = 79, P = 80, Q = 81, R = 82, S = 83, T = 84, U = 85, V = 86, W = 87, X = 88, Y = 89, Z = 90, NumPad0 = 96, NumPad1 = 97, NumPad2 = 98, NumPad3 = 99, NumPad4 = 100, NumPad5 = 101, NumPad6 = 102, NumPad7 = 103, NumPad8 = 104, NumPad9 = 105, Multiply = 106, Add = 107, Separator = 108, Subtract = 109, Decimal = 110, Divide = 111, F1 = 112, F2 = 113, F3 = 114, F4 = 115, F5 = 116, F6 = 117, F7 = 118, F8 = 119, F9 = 120, F10 = 121, F11 = 122, F12 = 123, F13 = 124, F14 = 125, F15 = 126, F16 = 127, F17 = 128, F18 = 129, F19 = 130, F20 = 131, F21 = 132, F22 = 133, F23 = 134, F24 = 135, NumLock = 144, Scroll = 145, OemSemicolon = 186, Oem1 = 186, Oemplus = 187, Oemcomma = 188, OemMinus = 189, OemPeriod = 190, OemQuestion = 191, Oem2 = 191, Oemtilde = 192, Oem3 = 192, OemOpenBrackets = 219, Oem4 = 219, OemPipe = 220, Oem5 = 220, OemCloseBrackets = 221, Oem6 = 221, OemQuotes = 222, Oem7 = 222, Oem8 = 223, OemBackslash = 226, KeyCode = 65535 } public static Dictionary<KeyCode, Keys> KeyCodeToKeysMap = new Dictionary<KeyCode, Keys> { { (KeyCode)97, Keys.A }, { (KeyCode)98, Keys.B }, { (KeyCode)99, Keys.C }, { (KeyCode)100, Keys.D }, { (KeyCode)101, Keys.E }, { (KeyCode)102, Keys.F }, { (KeyCode)103, Keys.G }, { (KeyCode)104, Keys.H }, { (KeyCode)105, Keys.I }, { (KeyCode)106, Keys.J }, { (KeyCode)107, Keys.K }, { (KeyCode)108, Keys.L }, { (KeyCode)109, Keys.M }, { (KeyCode)110, Keys.N }, { (KeyCode)111, Keys.O }, { (KeyCode)112, Keys.P }, { (KeyCode)113, Keys.Q }, { (KeyCode)114, Keys.R }, { (KeyCode)115, Keys.S }, { (KeyCode)116, Keys.T }, { (KeyCode)117, Keys.U }, { (KeyCode)118, Keys.V }, { (KeyCode)119, Keys.W }, { (KeyCode)120, Keys.X }, { (KeyCode)121, Keys.Y }, { (KeyCode)122, Keys.Z }, { (KeyCode)48, Keys.D0 }, { (KeyCode)49, Keys.D1 }, { (KeyCode)50, Keys.D2 }, { (KeyCode)51, Keys.D3 }, { (KeyCode)52, Keys.D4 }, { (KeyCode)53, Keys.D5 }, { (KeyCode)54, Keys.D6 }, { (KeyCode)55, Keys.D7 }, { (KeyCode)56, Keys.D8 }, { (KeyCode)57, Keys.D9 }, { (KeyCode)282, Keys.F1 }, { (KeyCode)283, Keys.F2 }, { (KeyCode)284, Keys.F3 }, { (KeyCode)285, Keys.F4 }, { (KeyCode)286, Keys.F5 }, { (KeyCode)287, Keys.F6 }, { (KeyCode)288, Keys.F7 }, { (KeyCode)289, Keys.F8 }, { (KeyCode)290, Keys.F9 }, { (KeyCode)291, Keys.F10 }, { (KeyCode)292, Keys.F11 }, { (KeyCode)293, Keys.F12 }, { (KeyCode)306, Keys.Control }, { (KeyCode)305, Keys.Control }, { (KeyCode)304, Keys.Shift }, { (KeyCode)303, Keys.Shift }, { (KeyCode)308, Keys.Alt }, { (KeyCode)307, Keys.Alt }, { (KeyCode)32, Keys.Space }, { (KeyCode)13, Keys.Enter }, { (KeyCode)8, Keys.Back }, { (KeyCode)27, Keys.Escape }, { (KeyCode)9, Keys.Tab }, { (KeyCode)301, Keys.Capital }, { (KeyCode)127, Keys.Delete }, { (KeyCode)277, Keys.Insert }, { (KeyCode)278, Keys.Home }, { (KeyCode)279, Keys.End }, { (KeyCode)280, Keys.PageUp }, { (KeyCode)281, Keys.PageDown }, { (KeyCode)273, Keys.Up }, { (KeyCode)274, Keys.Down }, { (KeyCode)276, Keys.Left }, { (KeyCode)275, Keys.Right }, { (KeyCode)59, Keys.OemSemicolon }, { (KeyCode)47, Keys.OemQuestion }, { (KeyCode)92, Keys.OemPipe }, { (KeyCode)91, Keys.OemOpenBrackets }, { (KeyCode)93, Keys.OemCloseBrackets }, { (KeyCode)39, Keys.OemQuotes }, { (KeyCode)96, Keys.Oemtilde }, { (KeyCode)45, Keys.OemMinus }, { (KeyCode)61, Keys.Oemplus }, { (KeyCode)44, Keys.Oemcomma }, { (KeyCode)46, Keys.OemPeriod }, { (KeyCode)256, Keys.NumPad0 }, { (KeyCode)257, Keys.NumPad1 }, { (KeyCode)258, Keys.NumPad2 }, { (KeyCode)259, Keys.NumPad3 }, { (KeyCode)260, Keys.NumPad4 }, { (KeyCode)261, Keys.NumPad5 }, { (KeyCode)262, Keys.NumPad6 }, { (KeyCode)263, Keys.NumPad7 }, { (KeyCode)264, Keys.NumPad8 }, { (KeyCode)265, Keys.NumPad9 }, { (KeyCode)267, Keys.Divide }, { (KeyCode)268, Keys.Multiply }, { (KeyCode)269, Keys.Subtract }, { (KeyCode)270, Keys.Add }, { (KeyCode)271, Keys.Enter }, { (KeyCode)266, Keys.Decimal }, { (KeyCode)316, Keys.PrintScreen }, { (KeyCode)302, Keys.Scroll }, { (KeyCode)19, Keys.Pause } }; public static Dictionary<KeyCode, string> KeyCodeToStringMap = new Dictionary<KeyCode, string> { { (KeyCode)97, "A" }, { (KeyCode)98, "B" }, { (KeyCode)99, "C" }, { (KeyCode)100, "D" }, { (KeyCode)101, "E" }, { (KeyCode)102, "F" }, { (KeyCode)103, "G" }, { (KeyCode)104, "H" }, { (KeyCode)105, "I" }, { (KeyCode)106, "J" }, { (KeyCode)107, "K" }, { (KeyCode)108, "L" }, { (KeyCode)109, "M" }, { (KeyCode)110, "N" }, { (KeyCode)111, "O" }, { (KeyCode)112, "P" }, { (KeyCode)113, "Q" }, { (KeyCode)114, "R" }, { (KeyCode)115, "S" }, { (KeyCode)116, "T" }, { (KeyCode)117, "U" }, { (KeyCode)118, "V" }, { (KeyCode)119, "W" }, { (KeyCode)120, "X" }, { (KeyCode)121, "Y" }, { (KeyCode)122, "Z" }, { (KeyCode)48, "0" }, { (KeyCode)49, "1" }, { (KeyCode)50, "2" }, { (KeyCode)51, "3" }, { (KeyCode)52, "4" }, { (KeyCode)53, "5" }, { (KeyCode)54, "6" }, { (KeyCode)55, "7" }, { (KeyCode)56, "8" }, { (KeyCode)57, "9" }, { (KeyCode)282, "F1" }, { (KeyCode)283, "F2" }, { (KeyCode)284, "F3" }, { (KeyCode)285, "F4" }, { (KeyCode)286, "F5" }, { (KeyCode)287, "F6" }, { (KeyCode)288, "F7" }, { (KeyCode)289, "F8" }, { (KeyCode)290, "F9" }, { (KeyCode)291, "F10" }, { (KeyCode)292, "F11" }, { (KeyCode)293, "F12" }, { (KeyCode)306, "Ctrl" }, { (KeyCode)305, "Ctrl" }, { (KeyCode)304, "Shift" }, { (KeyCode)303, "Shift" }, { (KeyCode)308, "Alt" }, { (KeyCode)307, "Alt" }, { (KeyCode)32, "Space" }, { (KeyCode)13, "Enter" }, { (KeyCode)8, "Backspace" }, { (KeyCode)27, "Escape" }, { (KeyCode)9, "Tab" }, { (KeyCode)301, "CapsLock" }, { (KeyCode)127, "Delete" }, { (KeyCode)277, "Insert" }, { (KeyCode)278, "Home" }, { (KeyCode)279, "End" }, { (KeyCode)280, "PageUp" }, { (KeyCode)281, "PageDown" }, { (KeyCode)273, "Up" }, { (KeyCode)274, "Down" }, { (KeyCode)276, "Left" }, { (KeyCode)275, "Right" }, { (KeyCode)59, ";" }, { (KeyCode)47, "/" }, { (KeyCode)92, "\\" }, { (KeyCode)91, "[" }, { (KeyCode)93, "]" }, { (KeyCode)39, "'" }, { (KeyCode)96, "`" }, { (KeyCode)45, "-" }, { (KeyCode)61, "=" }, { (KeyCode)44, "," }, { (KeyCode)46, "." }, { (KeyCode)256, "Num0" }, { (KeyCode)257, "Num1" }, { (KeyCode)258, "Num2" }, { (KeyCode)259, "Num3" }, { (KeyCode)260, "Num4" }, { (KeyCode)261, "Num5" }, { (KeyCode)262, "Num6" }, { (KeyCode)263, "Num7" }, { (KeyCode)264, "Num8" }, { (KeyCode)265, "Num9" }, { (KeyCode)267, "Num/" }, { (KeyCode)268, "Num*" }, { (KeyCode)269, "Num-" }, { (KeyCode)270, "Num+" }, { (KeyCode)271, "NumEnter" }, { (KeyCode)266, "Num." }, { (KeyCode)316, "PrintScreen" }, { (KeyCode)302, "Scroll" }, { (KeyCode)19, "Pause" } }; public static Dictionary<Keys, KeyCode> KeysToKeyCodeMap = new Dictionary<Keys, KeyCode> { { Keys.A, (KeyCode)97 }, { Keys.B, (KeyCode)98 }, { Keys.C, (KeyCode)99 }, { Keys.D, (KeyCode)100 }, { Keys.E, (KeyCode)101 }, { Keys.F, (KeyCode)102 }, { Keys.G, (KeyCode)103 }, { Keys.H, (KeyCode)104 }, { Keys.I, (KeyCode)105 }, { Keys.J, (KeyCode)106 }, { Keys.K, (KeyCode)107 }, { Keys.L, (KeyCode)108 }, { Keys.M, (KeyCode)109 }, { Keys.N, (KeyCode)110 }, { Keys.O, (KeyCode)111 }, { Keys.P, (KeyCode)112 }, { Keys.Q, (KeyCode)113 }, { Keys.R, (KeyCode)114 }, { Keys.S, (KeyCode)115 }, { Keys.T, (KeyCode)116 }, { Keys.U, (KeyCode)117 }, { Keys.V, (KeyCode)118 }, { Keys.W, (KeyCode)119 }, { Keys.X, (KeyCode)120 }, { Keys.Y, (KeyCode)121 }, { Keys.Z, (KeyCode)122 }, { Keys.D0, (KeyCode)48 }, { Keys.D1, (KeyCode)49 }, { Keys.D2, (KeyCode)50 }, { Keys.D3, (KeyCode)51 }, { Keys.D4, (KeyCode)52 }, { Keys.D5, (KeyCode)53 }, { Keys.D6, (KeyCode)54 }, { Keys.D7, (KeyCode)55 }, { Keys.D8, (KeyCode)56 }, { Keys.D9, (KeyCode)57 }, { Keys.F1, (KeyCode)282 }, { Keys.F2, (KeyCode)283 }, { Keys.F3, (KeyCode)284 }, { Keys.F4, (KeyCode)285 }, { Keys.F5, (KeyCode)286 }, { Keys.F6, (KeyCode)287 }, { Keys.F7, (KeyCode)288 }, { Keys.F8, (KeyCode)289 }, { Keys.F9, (KeyCode)290 }, { Keys.F10, (KeyCode)291 }, { Keys.F11, (KeyCode)292 }, { Keys.F12, (KeyCode)293 }, { Keys.Control, (KeyCode)306 }, { Keys.Shift, (KeyCode)304 }, { Keys.Alt, (KeyCode)308 }, { Keys.Space, (KeyCode)32 }, { Keys.Enter, (KeyCode)13 }, { Keys.Back, (KeyCode)8 }, { Keys.Escape, (KeyCode)27 }, { Keys.Tab, (KeyCode)9 }, { Keys.Capital, (KeyCode)301 }, { Keys.Delete, (KeyCode)127 }, { Keys.Insert, (KeyCode)277 }, { Keys.Home, (KeyCode)278 }, { Keys.End, (KeyCode)279 }, { Keys.PageUp, (KeyCode)280 }, { Keys.PageDown, (KeyCode)281 }, { Keys.Up, (KeyCode)273 }, { Keys.Down, (KeyCode)274 }, { Keys.Left, (KeyCode)276 }, { Keys.Right, (KeyCode)275 }, { Keys.OemSemicolon, (KeyCode)59 }, { Keys.OemQuestion, (KeyCode)47 }, { Keys.OemPipe, (KeyCode)92 }, { Keys.OemOpenBrackets, (KeyCode)91 }, { Keys.OemCloseBrackets, (KeyCode)93 }, { Keys.OemQuotes, (KeyCode)39 }, { Keys.Oemtilde, (KeyCode)96 }, { Keys.OemMinus, (KeyCode)45 }, { Keys.Oemplus, (KeyCode)61 }, { Keys.Oemcomma, (KeyCode)44 }, { Keys.OemPeriod, (KeyCode)46 }, { Keys.NumPad0, (KeyCode)256 }, { Keys.NumPad1, (KeyCode)257 }, { Keys.NumPad2, (KeyCode)258 }, { Keys.NumPad3, (KeyCode)259 }, { Keys.NumPad4, (KeyCode)260 }, { Keys.NumPad5, (KeyCode)261 }, { Keys.NumPad6, (KeyCode)262 }, { Keys.NumPad7, (KeyCode)263 }, { Keys.NumPad8, (KeyCode)264 }, { Keys.NumPad9, (KeyCode)265 }, { Keys.Divide, (KeyCode)267 }, { Keys.Multiply, (KeyCode)268 }, { Keys.Subtract, (KeyCode)269 }, { Keys.Add, (KeyCode)270 }, { Keys.Decimal, (KeyCode)266 }, { Keys.PrintScreen, (KeyCode)316 }, { Keys.Scroll, (KeyCode)302 }, { Keys.Pause, (KeyCode)19 } }; } public class OptionsManager { public enum BraveOptionsOptionType { PLAYER_ONE_KEYBOARD_PORT = 256, PLAYER_ONE_MOUSE_PORT, SHARE_ONE_KEYBOARD_MODE, PLAYER_ONE_MOUSE_SENSITIVITY, PLAYER_TWO_MOUSE_SENSITIVITY } internal static bool isInitializingOptions = false; internal static GameObject masterControlsOptionsScrollablePanelObject; private static GameObject optionsMenuPanelDaveObject; private static GameObject editKeyboardBindingsButtonPanelCopyObject; private static GameObject playerOneKeyboardPortArrowSelectorPanelObject; private static GameObject playerOneMousePortArrowSelectorPanelObject; private static GameObject shareOneKeyboardPanelObject; internal static GameObject playerOneMouseSensitivityPanelObject; internal static GameObject playerTwoMouseSensitivityPanelObject; private static GameObject systemMouseLabelPanelTipPanelObject; private static GameObject shareOneKeyBoardWarningPanelObject; public static bool restrictKeyboardInputPort = true; public static bool restrictMouseInputPort = true; public static bool isShareOneKeyboardMode = false; public static int currentPlayerOneKeyboardPort = 0; public static int currentPlayerOneMousePort = 0; public static float normalizedPlayerOneMouseSensitivity = 0.4f; public static float normalizedPlayerTwoMouseSensitivity = 0.4f; public static bool isPrimaryPlayerOnMainCamera; internal static FullOptionsMenuController fullOptionsMenuController; internal static string sharingBindingData = string.Empty; internal static string nonSharingBindingData = string.Empty; internal static void OnStart() { try { CoopKBnMPreferences.LoadPreferences(); } catch (Exception ex) { Debug.LogError((object)("Failed to load Coop View Preferences." + ex)); } RawInputHandler.playerOneMouseSensitivity = Mathf.Clamp(4f * normalizedPlayerOneMouseSensitivity + 0.4f, 0.4f, 4.4f); RawInputHandler.playerTwoMouseSensitivity = Mathf.Clamp(4f * normalizedPlayerTwoMouseSensitivity + 0.4f, 0.4f, 4.4f); } internal static IEnumerator InitializeOptions() { isInitializingOptions = true; while (true) { if ((Object)(object)optionsMenuPanelDaveObject == (Object)null) { optionsMenuPanelDaveObject = GameObject.Find("OptionsMenuPanelDave"); } if ((Object)(object)optionsMenuPanelDaveObject == (Object)null) { yield return null; continue; } FullOptionsMenuController fullOptionsMenuController = optionsMenuPanelDaveObject.GetComponent<FullOptionsMenuController>(); if ((Object)(object)fullOptionsMenuController == (Object)null) { yield return null; continue; } if (!fullOptionsMenuController.IsVisible) { yield return null; continue; } if ((Object)(object)masterControlsOptionsScrollablePanelObject == (Object)null) { masterControlsOptionsScrollablePanelObject = GameObject.Find("MasterControlsOptionsScrollablePanel"); } if ((Object)(object)masterControlsOptionsScrollablePanelObject != (Object)null) { break; } yield return null; } while ((Object)(object)editKeyboardBindingsButtonPanelCopyObject == (Object)null) { GameObject editKeyboardBindingsButtonPanelObject = GameObject.Find("EditKeyboardBindingsButtonPanel"); if ((Object)(object)editKeyboardBindingsButtonPanelObject != (Object)null) { GameObject origEditKeyboardBindingsButtonObject = ((Component)editKeyboardBindingsButtonPanelObject.transform.Find("PanelEnsmallenerThatmakesDavesLifeHardandBrentsLifeEasy/EditKeyboardBindingsButton")).gameObject; editKeyboardBindingsButtonPanelCopyObject = Object.Instantiate<GameObject>(editKeyboardBindingsButtonPanelObject, editKeyboardBindingsButtonPanelObject.transform.parent); ((Object)editKeyboardBindingsButtonPanelCopyObject).name = "EditKeyboardBindingsButtonPanelCopy"; GameObject editKeyboardBindingsButtonObject = ((Component)editKeyboardBindingsButtonPanelCopyObject.transform.Find("PanelEnsmallenerThatmakesDavesLifeHardandBrentsLifeEasy/EditKeyboardBindingsButton")).gameObject; editKeyboardBindingsButtonObject.GetComponent<dfButton>().Text = (((int)GameManager.Options.CurrentLanguage == 11) ? "2P Coop KB&M 编辑按键" : "2P Coop KB&M Edit Keyboard Bindings"); editKeyboardBindingsButtonObject.GetComponent<dfButton>().HoverTextColor = new Color32(byte.MaxValue, (byte)163, (byte)52, byte.MaxValue); origEditKeyboardBindingsButtonObject.GetComponent<dfButton>().Text = (((int)GameManager.Options.CurrentLanguage == 11) ? "1P Coop KB&M 编辑按键" : "1P Coop KB&M Edit Keyboard Bindings"); origEditKeyboardBindingsButtonObject.GetComponent<dfButton>().HoverTextColor = new Color32(byte.MaxValue, (byte)163, (byte)52, byte.MaxValue); ((dfControl)editKeyboardBindingsButtonPanelObject.GetComponent<dfPanel>()).ZOrder = 4; ((dfControl)editKeyboardBindingsButtonPanelCopyObject.GetComponent<dfPanel>()).ZOrder = 10; } if ((Object)(object)editKeyboardBindingsButtonPanelCopyObject == (Object)null) { yield return null; } } while ((Object)(object)playerOneKeyboardPortArrowSelectorPanelObject == (Object)null) { GameObject controllerTypeArrowSelectorPanelObject = GameObject.Find("ControllerTypeArrowSelectorPanel"); if ((Object)(object)controllerTypeArrowSelectorPanelObject != (Object)null) { playerOneKeyboardPortArrowSelectorPanelObject = Object.Instantiate<GameObject>(controllerTypeArrowSelectorPanelObject, controllerTypeArrowSelectorPanelObject.transform.parent); ((Object)playerOneKeyboardPortArrowSelectorPanelObject).name = "PlayerOneKeyboardPortArrowSelectorPanel"; GameObject optionsArrowSelectorLabelObject = ((Component)playerOneKeyboardPortArrowSelectorPanelObject.transform.Find("PanelEnsmallenerThatmakesDavesLifeHardandBrentsLifeEasy/OptionsArrowSelectorLabel")).gameObject; optionsArrowSelectorLabelObject.GetComponent<dfLabel>().Text = (((int)GameManager.Options.CurrentLanguage == 11) ? "1P Coop KB&M 键盘接口" : "1P Coop KB&M Keyboard Port"); playerOneKeyboardPortArrowSelectorPanelObject.GetComponent<BraveOptionsMenuItem>().optionType = (BraveOptionsOptionType)256; playerOneKeyboardPortArrowSelectorPanelObject.GetComponent<BraveOptionsMenuItem>().DetermineAvailableOptions(); playerOneKeyboardPortArrowSelectorPanelObject.GetComponent<BraveOptionsMenuItem>().m_selectedIndex = currentPlayerOneKeyboardPort; playerOneKeyboardPortArrowSelectorPanelObject.GetComponent<BraveOptionsMenuItem>().HandleValueChanged(); ((dfControl)playerOneKeyboardPortArrowSelectorPanelObject.GetComponent<dfPanel>()).ZOrder = 4; } if ((Object)(object)playerOneKeyboardPortArrowSelectorPanelObject == (Object)null) { yield return null; } } while ((Object)(object)shareOneKeyboardPanelObject == (Object)null) { GameObject allowUnknownControllersObject = ((Component)masterControlsOptionsScrollablePanelObject.transform.Find("AllowUnknownControllers")).gameObject; if ((Object)(object)allowUnknownControllersObject != (Object)null) { shareOneKeyboardPanelObject = Object.Instantiate<GameObject>(allowUnknownControllersObject, allowUnknownControllersObject.transform.parent); ((Object)shareOneKeyboardPanelObject).name = "ShareOneKeyboard"; GameObject checkboxLabelObject = ((Component)shareOneKeyboardPanelObject.transform.Find("Panel/CheckboxLabel")).gameObject; shareOneKeyboardPanelObject.GetComponent<BraveOptionsMenuItem>().m_selectedIndex = (isShareOneKeyboardMode ? 1 : 0); shareOneKeyboardPanelObject.GetComponent<BraveOptionsMenuItem>().optionType = (BraveOptionsOptionType)258; shareOneKeyboardPanelObject.GetComponent<BraveOptionsMenuItem>().HandleValueChanged(); dfLabel label = checkboxLabelObject.GetComponent<dfLabel>(); Vector2 origSize = label.obtainRenderer().MeasureString(label.Text); label.Text = (((int)GameManager.Options.CurrentLanguage == 11) ? "Coop KB&M 共享一个键盘" : "Coop KB&M Share One Keyboard"); Vector2 size = label.obtainRenderer().MeasureString(label.Text); GameObject panelObject = ((Component)shareOneKeyboardPanelObject.transform.Find("Panel")).gameObject; dfPanel panel = panelObject.GetComponent<dfPanel>(); Vector2 panelSize = ((dfControl)panel).Size; ((dfControl)panel).SuspendLayout(); ((dfControl)panel).Size = new Vector2(panelSize.x + size.x - origSize.x, panelSize.y); ((dfControl)panel).ResumeLayout(); ((dfControl)shareOneKeyboardPanelObject.GetComponent<dfPanel>()).ZOrder = 2; } if ((Object)(object)shareOneKeyboardPanelObject == (Object)null) { yield return null; } } while ((Object)(object)playerOneMousePortArrowSelectorPanelObject == (Object)null) { GameObject controllerTypeArrowSelectorPanelObject3 = GameObject.Find("ControllerTypeArrowSelectorPanel"); if ((Object)(object)controllerTypeArrowSelectorPanelObject3 != (Object)null) { playerOneMousePortArrowSelectorPanelObject = Object.Instantiate<GameObject>(controllerTypeArrowSelectorPanelObject3, controllerTypeArrowSelectorPanelObject3.transform.parent); ((Object)playerOneMousePortArrowSelectorPanelObject).name = "PlayerOneMousePortArrowSelectorPanel"; GameObject optionsArrowSelectorLabelObject2 = ((Component)playerOneMousePortArrowSelectorPanelObject.transform.Find("PanelEnsmallenerThatmakesDavesLifeHardandBrentsLifeEasy/OptionsArrowSelectorLabel")).gameObject; optionsArrowSelectorLabelObject2.GetComponent<dfLabel>().Text = (((int)GameManager.Options.CurrentLanguage == 11) ? "1P Coop KB&M 鼠标接口" : "1P Coop KB&M Mouse Port"); playerOneMousePortArrowSelectorPanelObject.GetComponent<BraveOptionsMenuItem>().optionType = (BraveOptionsOptionType)257; playerOneMousePortArrowSelectorPanelObject.GetComponent<BraveOptionsMenuItem>().DetermineAvailableOptions(); playerOneMousePortArrowSelectorPanelObject.GetComponent<BraveOptionsMenuItem>().m_selectedIndex = currentPlayerOneMousePort; playerOneMousePortArrowSelectorPanelObject.GetComponent<BraveOptionsMenuItem>().HandleValueChanged(); ((dfControl)playerOneMousePortArrowSelectorPanelObject.GetComponent<dfPanel>()).ZOrder = 5; } if ((Object)(object)playerOneMousePortArrowSelectorPanelObject == (Object)null) { yield return null; } } while ((Object)(object)playerOneMouseSensitivityPanelObject == (Object)null) { GameObject controllerTypeArrowSelectorPanelObject4 = GameObject.Find("ControllerTypeArrowSelectorPanel"); GameObject screenShakeOptionPanelObject2 = GameObject.Find("ScreenShakeOptionPanel"); if ((Object)(object)controllerTypeArrowSelectorPanelObject4 != (Object)null && (Object)(object)screenShakeOptionPanelObject2 != (Object)null) { playerOneMouseSensitivityPanelObject = Object.Instantiate<GameObject>(screenShakeOptionPanelObject2, controllerTypeArrowSelectorPanelObject4.transform.parent); ((Object)playerOneMouseSensitivityPanelObject).name = "PlayerOneMouseSensitivityPanel"; GameObject musicVolumeLabelObject2 = ((Component)playerOneMouseSensitivityPanelObject.transform.Find("PanelEnsmallenerThatmakesDavesLifeHardandBrentsLifeEasy/MusicVolumeLabel")).gameObject; musicVolumeLabelObject2.GetComponent<dfLabel>().Text = (((int)GameManager.Options.CurrentLanguage == 11) ? "1P Coop KB&M 鼠标灵敏度" : "1P Coop KB&M Mouse Sensitivity"); playerOneMouseSensitivityPanelObject.GetComponent<BraveOptionsMenuItem>().optionType = (BraveOptionsOptionType)259; ((Component)playerOneMouseSensitivityPanelObject.transform.Find("PanelEnsmallenerThatmakesDavesLifeHardandBrentsLifeEasy/MusicVolumeProgressBar")).GetComponent<dfProgressBar>().Value = normalizedPlayerOneMouseSensitivity; playerOneMouseSensitivityPanelObject.GetComponent<BraveOptionsMenuItem>().m_actualFillbarValue = normalizedPlayerOneMouseSensitivity; playerOneMouseSensitivityPanelObject.GetComponent<BraveOptionsMenuItem>().HandleValueChanged(); ((dfControl)playerOneMouseSensitivityPanelObject.GetComponent<dfPanel>()).ZOrder = 7; } if ((Object)(object)playerOneMouseSensitivityPanelObject == (Object)null) { yield return null; } } while ((Object)(object)playerTwoMouseSensitivityPanelObject == (Object)null) { GameObject controllerTypeArrowSelectorPanelObject2 = GameObject.Find("ControllerTypeArrowSelectorPanel"); GameObject screenShakeOptionPanelObject = GameObject.Find("ScreenShakeOptionPanel"); if ((Object)(object)controllerTypeArrowSelectorPanelObject2 != (Object)null && (Object)(object)screenShakeOptionPanelObject != (Object)null) { playerTwoMouseSensitivityPanelObject = Object.Instantiate<GameObject>(screenShakeOptionPanelObject, controllerTypeArrowSelectorPanelObject2.transform.parent); ((Object)playerTwoMouseSensitivityPanelObject).name = "PlayerTwoMouseSensitivityPanel"; GameObject musicVolumeLabelObject = ((Component)playerTwoMouseSensitivityPanelObject.transform.Find("PanelEnsmallenerThatmakesDavesLifeHardandBrentsLifeEasy/MusicVolumeLabel")).gameObject; musicVolumeLabelObject.GetComponent<dfLabel>().Text = (((int)GameManager.Options.CurrentLanguage == 11) ? "2P Coop KB&M 鼠标灵敏度" : "2P Coop KB&M Mouse Sensitivity"); playerTwoMouseSensitivityPanelObject.GetComponent<BraveOptionsMenuItem>().optionType = (BraveOptionsOptionType)260; ((Component)playerTwoMouseSensitivityPanelObject.transform.Find("PanelEnsmallenerThatmakesDavesLifeHardandBrentsLifeEasy/MusicVolumeProgressBar")).GetComponent<dfProgressBar>().Value = normalizedPlayerTwoMouseSensitivity; playerTwoMouseSensitivityPanelObject.GetComponent<BraveOptionsMenuItem>().m_actualFillbarValue = normalizedPlayerTwoMouseSensitivity; playerTwoMouseSensitivityPanelObject.GetComponent<BraveOptionsMenuItem>().HandleValueChanged(); ((dfControl)playerTwoMouseSensitivityPanelObject.GetComponent<dfPanel>()).ZOrder = 15; } if ((Object)(object)playerTwoMouseSensitivityPanelObject == (Object)null) { yield return null; } } while ((Object)(object)systemMouseLabelPanelTipPanelObject == (Object)null) { GameObject playerOneLabelPanelObject2 = GameObject.Find("PlayerOneLabelPanel"); if ((Object)(object)playerOneLabelPanelObject2 != (Object)null) { systemMouseLabelPanelTipPanelObject = Object.Instantiate<GameObject>(playerOneLabelPanelObject2, playerOneLabelPanelObject2.transform.parent); ((Object)systemMouseLabelPanelTipPanelObject).name = "SystemMouseLabelPanelTipPanel"; GameObject labelObject2 = (