Decompiled source of Coop View v0.8.5
CoopView.dll
Decompiled a day 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.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Security; using System.Security.Permissions; using BepInEx; using HarmonyLib; using Mono.Cecil.Cil; using MonoMod.Cil; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("CoopView")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("CoopView")] [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 CoopView; [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("kleirof.etg.coopview", "Coop View", "0.8.5")] public class CoopViewModule : BaseUnityPlugin { public const string GUID = "kleirof.etg.coopview"; public const string NAME = "Coop View"; public const string VERSION = "0.8.5"; public const string TEXT_COLOR = "#CCFF33"; private static GameObject canvasObject; private static Canvas canvas; private static GameObject rawImageObject; private static RawImage rawImage; private static RenderTexture renderTexture; private static GameObject uiRawImageObject; private static RawImage uiRawImage; private static RenderTexture uiRenderTexture; public static Pixelator originCameraPixelator; public static Pixelator cameraPixelator; private static GameObject originalCameraObject; private static GameObject cameraObject; public static Camera camera; public static Camera originalCamera; private static Camera uiCamera; private static Camera minimapUiCamera; private static Camera ammoCamera; private static GameUIRoot uiRoot; private static GameUIReloadBarController reloadBarController; private static GameUIReloadBarController coopReloadBarController; private static dfGUIManager uiManager; public void Start() { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Invalid comparison between Unknown and I4 //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown if (Display.displays.Length > 1) { Display.displays[1].Activate(); WindowManager.SetSecondWindowText(); } else { Debug.LogError((object)"Target monitor not found."); } if ((int)GameManager.Options.CurrentPreferredFullscreenMode == 2) { WindowManager.RestoreMainWindowCaption(); } ETGModMainBehaviour.WaitForGameManagerStart((Action<GameManager>)GMStart); canvasObject = new GameObject("Overlay Canvas"); Object.DontDestroyOnLoad((Object)(object)canvasObject); canvas = canvasObject.AddComponent<Canvas>(); CanvasScaler val = canvasObject.AddComponent<CanvasScaler>(); GraphicRaycaster val2 = canvasObject.AddComponent<GraphicRaycaster>(); canvas.renderMode = (RenderMode)0; canvas.targetDisplay = 1; canvas.sortingOrder = 1; Harmony.CreateAndPatchAll(typeof(CoopViewPatches), (string)null); WindowManager.InitWindowHook(); ShortcutKeyHandler.InitMessageHandler(); WindowManager.referenceSecondWindowWidth = WindowManager.SecondWindowWidth; WindowManager.referenceSecondWindowHeight = WindowManager.SecondWindowHeight; } public void OnApplicationQuit() { WindowManager.ReleaseWindowHook(); ShortcutKeyHandler.ReleaseMessageHandler(); } public static void Log(string text, string color = "FFFFFF") { ETGModConsole.Log((object)("<color=" + color + ">" + text + "</color>"), false); } private static void LogCommands() { ETGModConsole.Log((object)"", false); ETGModConsole.Log((object)"Command list:", false); ETGModConsole.Log((object)"[The content in square brackets can be omitted. ]", false); ETGModConsole.Log((object)" -- <color=#CCFF33>shortcutkey [shortcut_key_ID]</color>", false); ETGModConsole.Log((object)" - Set custom shortcut keys.", false); ETGModConsole.Log((object)" - The shortcut key ID should be specified from 1 to 5 in the parameters, like 'shortcutkey 1'.", false); ETGModConsole.Log((object)" - Current shortcut keys and its shortcut key ID will be displayed to give you a hint.", false); ETGModConsole.Log((object)" -- <color=#CCFF33>switchpreset [preset_index]</color>", false); ETGModConsole.Log((object)" - Switch to window position presets.", false); ETGModConsole.Log((object)" - The preset index can be specified from 0 to 2 in the parameters, like 'switchpreset 2'.", false); ETGModConsole.Log((object)" - preset_index = 0 : Main window fullscreen on monitor 1, second window fullscreen on monitor 2.", false); ETGModConsole.Log((object)" - preset_index = 1 : Main window fullscreen on monitor 2, second window fullscreen on monitor 1.", false); ETGModConsole.Log((object)" - preset_index = 2 : Main window windowed on monitor 1, second window windowed on monitor 1.", false); ETGModConsole.Log((object)" -- <color=#CCFF33>secondwindow fullscreen [monitor_index]</color>", false); ETGModConsole.Log((object)" - Switch the second window to fullscreen mode.", false); ETGModConsole.Log((object)" - The target monitor can be specified in the parameters, like 'secondwindow fullscreen 1'.", false); ETGModConsole.Log((object)" -- <color=#CCFF33>secondwindow windowed [width] [height]</color>", false); ETGModConsole.Log((object)" - Switch the second window to windowed mode.", false); ETGModConsole.Log((object)" - The window size can be specified in the parameters, like 'secondwindow windowed 1920 1080'.", false); ETGModConsole.Log((object)" -- <color=#CCFF33>mainwindow fullscreen [monitor_index]</color>", false); ETGModConsole.Log((object)" - Switch the main window to fullscreen mode.", false); ETGModConsole.Log((object)" - The target monitor can be specified in the parameters, like 'mainwindow fullscreen 1'.", false); ETGModConsole.Log((object)" -- <color=#CCFF33>mainwindow windowed [width] [height]</color>", false); ETGModConsole.Log((object)" - Switch the main window to windowed mode.", false); ETGModConsole.Log((object)" - The window size can be specified in the parameters, like 'mainwindow windowed 1920 1080'.", false); } private static void LogHelp(string[] args) { ShortcutKeyHandler.LogShortcutKeys(); LogCommands(); } public void GMStart(GameManager g) { Log("Coop View v0.8.5 started successfully.", "#CCFF33"); ETGModConsole.Log((object)"<color=#CCFF33>Enter 'coopview help' for more options.</color>", false); ETGModConsole.Commands.AddGroup("coopview", (Action<string[]>)LogHelp); ETGModConsole.Commands.GetGroup("coopview").AddUnit("help", (Action<string[]>)LogHelp); ETGModConsole.Commands.AddGroup("secondwindow", (Action<string[]>)LogHelp); ETGModConsole.Commands.GetGroup("secondwindow").AddUnit("fullscreen", (Action<string[]>)WindowManager.SwitchSecondWindowToFullscreen); ETGModConsole.Commands.GetGroup("secondwindow").AddUnit("windowed", (Action<string[]>)WindowManager.SwitchSecondWindowToWindowed); ETGModConsole.Commands.AddGroup("mainwindow", (Action<string[]>)LogHelp); ETGModConsole.Commands.GetGroup("mainwindow").AddUnit("fullscreen", (Action<string[]>)WindowManager.SwitchMainWindowToFullscreen); ETGModConsole.Commands.GetGroup("mainwindow").AddUnit("windowed", (Action<string[]>)WindowManager.SwitchMainWindowToWindowed); ETGModConsole.Commands.AddGroup("switchpreset", (Action<string[]>)WindowManager.SwitchPreset); ETGModConsole.Commands.AddGroup("shortcutkey", (Action<string[]>)ShortcutKeyHandler.SetShortcutKey); } public void Update() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Invalid comparison between Unknown and I4 //IL_052d: Unknown result type (might be due to invalid IL or missing references) //IL_054c: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Unknown result type (might be due to invalid IL or missing references) //IL_0350: Expected O, but got Unknown //IL_036c: Unknown result type (might be due to invalid IL or missing references) //IL_0376: Expected O, but got Unknown //IL_03d6: Unknown result type (might be due to invalid IL or missing references) //IL_03e3: Unknown result type (might be due to invalid IL or missing references) //IL_0406: Unknown result type (might be due to invalid IL or missing references) //IL_040b: Unknown result type (might be due to invalid IL or missing references) //IL_041e: Unknown result type (might be due to invalid IL or missing references) //IL_0423: Unknown result type (might be due to invalid IL or missing references) //IL_0430: Unknown result type (might be due to invalid IL or missing references) //IL_043a: Expected O, but got Unknown //IL_0456: Unknown result type (might be due to invalid IL or missing references) //IL_0460: Expected O, but got Unknown //IL_04aa: Unknown result type (might be due to invalid IL or missing references) //IL_04af: Unknown result type (might be due to invalid IL or missing references) //IL_04d1: Unknown result type (might be due to invalid IL or missing references) //IL_04d6: Unknown result type (might be due to invalid IL or missing references) //IL_04f0: Unknown result type (might be due to invalid IL or missing references) //IL_04fd: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)GameManager.Instance) && (int)GameManager.Instance.CurrentGameType == 1) { if (Object.op_Implicit((Object)(object)uiRenderTexture)) { RenderTexture.active = uiRenderTexture; GL.Clear(true, true, GameManager.Instance.IsPaused ? Color.black : Color.clear); RenderTexture.active = null; } if (!Object.op_Implicit((Object)(object)uiManager)) { GameObject val = GameObject.Find("UI Root"); if (Object.op_Implicit((Object)(object)val)) { uiRoot = val.GetComponent<GameUIRoot>(); uiManager = val.GetComponent<dfGUIManager>(); } } if (!Object.op_Implicit((Object)(object)reloadBarController)) { GameObject val2 = GameObject.Find("ReloadSlider"); if (Object.op_Implicit((Object)(object)val2)) { reloadBarController = val2.GetComponent<GameUIReloadBarController>(); } } if (!Object.op_Implicit((Object)(object)coopReloadBarController)) { GameObject val3 = GameObject.Find("ReloadSlider Coop"); if (Object.op_Implicit((Object)(object)val3)) { coopReloadBarController = val3.GetComponent<GameUIReloadBarController>(); } } if (!Object.op_Implicit((Object)(object)originalCamera)) { originalCameraObject = GameObject.Find("Main Camera"); if (Object.op_Implicit((Object)(object)originalCameraObject)) { originalCamera = originalCameraObject.GetComponentInChildren<Camera>(); originCameraPixelator = ((Component)originalCamera).GetComponent<Pixelator>(); } } else if (!Object.op_Implicit((Object)(object)camera)) { cameraObject = Object.Instantiate<GameObject>(originalCameraObject); if (Object.op_Implicit((Object)(object)cameraObject)) { camera = cameraObject.GetComponent<Camera>(); ((Object)camera).name = "Camera Copy"; camera.targetTexture = renderTexture; cameraPixelator = ((Component)camera).GetComponent<Pixelator>(); } } if (!Object.op_Implicit((Object)(object)uiCamera)) { GameObject val4 = GameObject.Find("UI Root"); if (Object.op_Implicit((Object)(object)val4)) { uiCamera = val4.GetComponentInChildren<Camera>(); Minimap.Instance.ToggleMinimap(false, false); } } if (!Object.op_Implicit((Object)(object)minimapUiCamera)) { GameObject val5 = GameObject.Find("Minimap UI Root"); if (Object.op_Implicit((Object)(object)val5)) { minimapUiCamera = val5.GetComponentInChildren<Camera>(); } } if (!Object.op_Implicit((Object)(object)ammoCamera)) { GameObject val6 = GameObject.Find("Ammonomicon Root(Clone)"); if (Object.op_Implicit((Object)(object)val6)) { ammoCamera = val6.GetComponentInChildren<Camera>(); } } if (!Object.op_Implicit((Object)(object)rawImageObject) || !Object.op_Implicit((Object)(object)uiRawImageObject)) { int num; int num2; if (0.5625f < (float)WindowManager.SecondWindowHeight / (float)WindowManager.SecondWindowWidth) { num = WindowManager.SecondWindowWidth; num2 = (int)((float)WindowManager.SecondWindowWidth * 9f / 16f); } else { num = (int)((float)WindowManager.SecondWindowHeight * 16f / 9f); num2 = WindowManager.SecondWindowHeight; } renderTexture = new RenderTexture(num * WindowManager.referenceSecondWindowWidth / WindowManager.SecondWindowWidth, num2 * WindowManager.referenceSecondWindowHeight / WindowManager.SecondWindowHeight, 0, (RenderTextureFormat)0); renderTexture.enableRandomWrite = true; renderTexture.Create(); rawImageObject = new GameObject("rawImage"); Object.DontDestroyOnLoad((Object)(object)rawImageObject); rawImageObject.transform.SetParent(canvasObject.transform); rawImage = rawImageObject.AddComponent<RawImage>(); RectTransform component = rawImageObject.GetComponent<RectTransform>(); component.sizeDelta = new Vector2((float)(num * WindowManager.referenceSecondWindowWidth / WindowManager.SecondWindowWidth), (float)(num2 * WindowManager.referenceSecondWindowHeight / WindowManager.SecondWindowHeight)); component.anchoredPosition = Vector2.zero; rawImage.texture = (Texture)(object)renderTexture; float num3 = num; Rect rect = originalCamera.rect; int num4 = (int)(num3 / ((Rect)(ref rect)).width); float num5 = num2; rect = Camera.main.rect; uiRenderTexture = new RenderTexture(num4, (int)(num5 / ((Rect)(ref rect)).height), 0, (RenderTextureFormat)0); uiRenderTexture.enableRandomWrite = true; uiRenderTexture.Create(); uiRawImageObject = new GameObject("uiRawImage"); Object.DontDestroyOnLoad((Object)(object)uiRawImageObject); uiRawImageObject.transform.SetParent(canvasObject.transform); uiRawImage = uiRawImageObject.AddComponent<RawImage>(); RectTransform component2 = uiRawImageObject.GetComponent<RectTransform>(); float num6 = num; rect = originalCamera.rect; float num7 = (int)(num6 / ((Rect)(ref rect)).width * (float)WindowManager.referenceSecondWindowWidth / (float)WindowManager.SecondWindowWidth); float num8 = num2; rect = originalCamera.rect; component2.sizeDelta = new Vector2(num7, (float)(int)(num8 / ((Rect)(ref rect)).height * (float)WindowManager.referenceSecondWindowHeight / (float)WindowManager.SecondWindowHeight)); component2.anchoredPosition = Vector2.zero; uiRawImage.texture = (Texture)(object)uiRenderTexture; } } else { RenderTexture.active = renderTexture; GL.Clear(true, true, Color.black); RenderTexture.active = null; RenderTexture.active = uiRenderTexture; GL.Clear(true, true, Color.black); RenderTexture.active = null; if (Object.op_Implicit((Object)(object)originalCamera)) { originalCamera = null; } if (Object.op_Implicit((Object)(object)camera)) { Object.Destroy((Object)(object)camera); camera = null; } if (Object.op_Implicit((Object)(object)uiCamera)) { uiCamera = null; } if (Object.op_Implicit((Object)(object)minimapUiCamera)) { minimapUiCamera = null; } if (Object.op_Implicit((Object)(object)ammoCamera)) { ammoCamera = null; } if (Object.op_Implicit((Object)(object)originCameraPixelator)) { originCameraPixelator = null; } if (Object.op_Implicit((Object)(object)cameraPixelator)) { cameraPixelator = null; } if (Object.op_Implicit((Object)(object)coopReloadBarController)) { coopReloadBarController = null; } if (Object.op_Implicit((Object)(object)reloadBarController)) { reloadBarController = null; } if (Object.op_Implicit((Object)(object)originalCameraObject)) { originalCameraObject = null; } if (Object.op_Implicit((Object)(object)cameraObject)) { cameraObject = null; } if (Object.op_Implicit((Object)(object)uiRoot)) { uiRoot = null; } if (Object.op_Implicit((Object)(object)uiManager)) { uiManager = null; } } } public void LateUpdate() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Invalid comparison between Unknown and I4 if (!Object.op_Implicit((Object)(object)GameManager.Instance) || (int)GameManager.Instance.CurrentGameType != 1) { return; } if (Object.op_Implicit((Object)(object)camera)) { cameraPixelator.SetOcclusionDirty(); originCameraPixelator.SetOcclusionDirty(); } if (Object.op_Implicit((Object)(object)uiCamera)) { if (Object.op_Implicit((Object)(object)uiRoot) && Object.op_Implicit((Object)(object)uiManager) && Object.op_Implicit((Object)(object)coopReloadBarController) && Object.op_Implicit((Object)(object)reloadBarController) && !GameManager.Instance.IsPaused) { Changed_UpdateReloadLabelsOnCameraFinishedFrame(uiRoot); Changed_OnMainCameraFinishedFrame(coopReloadBarController); Changed_OnMainCameraFinishedFrame(reloadBarController); if (uiManager.isDirty && uiManager.suspendCount <= 0) { Changed_Render(uiManager); dfMaterialCache.Reset(); uiManager.updateDrawCalls(); } } uiCamera.targetTexture = uiRenderTexture; uiCamera.Render(); uiCamera.targetTexture = null; } if (Object.op_Implicit((Object)(object)minimapUiCamera) && Object.op_Implicit((Object)(object)Minimap.Instance) && Minimap.Instance.IsFullscreen) { minimapUiCamera.targetTexture = uiRenderTexture; minimapUiCamera.Render(); minimapUiCamera.targetTexture = null; } if (Object.op_Implicit((Object)(object)ammoCamera) && Object.op_Implicit((Object)(object)AmmonomiconController.Instance) && AmmonomiconController.Instance.IsOpen) { ammoCamera.targetTexture = uiRenderTexture; ammoCamera.Render(); ammoCamera.targetTexture = null; } } public static IEnumerator UpdateResolution() { if (!(WindowManager.SecondWindow == IntPtr.Zero)) { if (Object.op_Implicit((Object)(object)uiRawImageObject)) { uiRawImage.texture = null; ((Graphic)uiRawImage).color = Color.black; } yield return null; if ((int)GameManager.Options.CurrentPreferredFullscreenMode == 2) { IntPtr window = BraveOptionsMenuItem.ResolutionManagerWin.Window; int style = (int)WindowsResolutionManager.GetWindowLongPtr(window, -16); WindowsResolutionManager.SetWindowLongPtr(window, -16, style | 0xC00000 | 0x40000 | 0x80000 | 0x20000 | 0x10000); WindowsResolutionManager.SetWindowPos(window, -2, 0, 0, 0, 0, 35); } if (Object.op_Implicit((Object)(object)renderTexture)) { RenderTexture.active = renderTexture; GL.Clear(true, true, Color.black); RenderTexture.active = null; } yield return null; int width; int height; if (0.5625f < (float)WindowManager.SecondWindowHeight / (float)WindowManager.SecondWindowWidth) { width = WindowManager.SecondWindowWidth; height = (int)((float)WindowManager.SecondWindowWidth * 9f / 16f); } else { width = (int)((float)WindowManager.SecondWindowHeight * 16f / 9f); height = WindowManager.SecondWindowHeight; } if (Object.op_Implicit((Object)(object)rawImageObject)) { RectTransform rectTransform = rawImageObject.GetComponent<RectTransform>(); rectTransform.sizeDelta = new Vector2((float)(width * WindowManager.referenceSecondWindowWidth / WindowManager.SecondWindowWidth), (float)(height * WindowManager.referenceSecondWindowHeight / WindowManager.SecondWindowHeight)); } if (Object.op_Implicit((Object)(object)uiRawImageObject)) { uiRenderTexture.Release(); float num = width; Rect rect = originalCamera.rect; int num2 = (int)(num / ((Rect)(ref rect)).width); float num3 = height; rect = originalCamera.rect; uiRenderTexture = new RenderTexture(num2, (int)(num3 / ((Rect)(ref rect)).height), 0, (RenderTextureFormat)0); uiRenderTexture.enableRandomWrite = true; uiRenderTexture.Create(); RectTransform uiRectTransform = uiRawImageObject.GetComponent<RectTransform>(); float num4 = width; rect = originalCamera.rect; float num5 = (int)(num4 / ((Rect)(ref rect)).width * (float)WindowManager.referenceSecondWindowWidth / (float)WindowManager.SecondWindowWidth); float num6 = height; rect = originalCamera.rect; uiRectTransform.sizeDelta = new Vector2(num5, (float)(int)(num6 / ((Rect)(ref rect)).height * (float)WindowManager.referenceSecondWindowHeight / (float)WindowManager.SecondWindowHeight)); ((Graphic)uiRawImage).color = Color.white; uiRawImage.texture = (Texture)(object)uiRenderTexture; } } } private void Changed_Render(dfGUIManager manager) { //IL_01e7: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)manager.meshRenderer == (Object)null) { return; } ((Renderer)manager.meshRenderer).enabled = false; int framesRendered = manager.FramesRendered; manager.FramesRendered = framesRendered + 1; try { manager.occluders.Clear(); manager.occluders.EnsureCapacity(manager.NumControlsRendered); manager.NumControlsRendered = 0; manager.controlsRendered.Clear(); manager.drawCallIndices.Clear(); manager.renderGroups.Clear(); manager.TotalDrawCalls = 0; manager.TotalTriangles = 0; if ((Object)(object)manager.RenderCamera == (Object)null || !((Behaviour)this).enabled) { if ((Object)(object)manager.meshRenderer != (Object)null) { ((Renderer)manager.meshRenderer).enabled = false; } return; } if ((Object)(object)manager.meshRenderer != (Object)null && !((Renderer)manager.meshRenderer).enabled) { ((Renderer)manager.meshRenderer).enabled = true; } if (manager.renderMesh == null || manager.renderMesh.Length == 0) { Debug.LogError((object)"GUI Manager not initialized before Render() called"); return; } manager.resetDrawCalls(); dfRenderData val = null; manager.clipStack.Clear(); manager.clipStack.Push(dfTriangleClippingRegion.Obtain()); uint sTART_VALUE = dfChecksumUtil.START_VALUE; dfList<dfControl> topLevelControls = manager.getTopLevelControls(); try { manager.updateRenderOrder(topLevelControls); for (int i = 0; i < topLevelControls.Count; i++) { if (manager.abortRendering) { break; } dfControl val2 = topLevelControls[i]; manager.renderControl(ref val, val2, sTART_VALUE, 1f); } } finally { ((IDisposable)topLevelControls)?.Dispose(); } if (manager.abortRendering) { manager.clipStack.Clear(); throw new dfAbortRenderingException(); } manager.drawCallBuffers.RemoveAll((Predicate<dfRenderData>)manager.isEmptyBuffer); manager.drawCallCount = manager.drawCallBuffers.Count; manager.TotalDrawCalls = manager.drawCallCount; if (manager.drawCallBuffers.Count == 0) { if ((Object)(object)manager.renderFilter.sharedMesh != (Object)null) { manager.renderFilter.sharedMesh.Clear(); } if (manager.clipStack.Count > 0) { manager.clipStack.Pop().Release(); manager.clipStack.Clear(); } return; } dfRenderData val3 = manager.compileMasterBuffer(); manager.TotalTriangles = val3.Triangles.Count / 3; Mesh renderMesh = manager.getRenderMesh(); manager.renderFilter.sharedMesh = renderMesh; Mesh val4 = renderMesh; val4.Clear(true); val4.vertices = val3.Vertices.Items; val4.uv = val3.UV.Items; val4.colors32 = val3.Colors.Items; if (manager.generateNormals && val3.Normals.Items.Length == val3.Vertices.Items.Length) { val4.normals = val3.Normals.Items; val4.tangents = val3.Tangents.Items; } val4.subMeshCount = manager.submeshes.Count; for (int j = 0; j < manager.submeshes.Count; j++) { int num = manager.submeshes[j]; int num2 = val3.Triangles.Count - num; if (j < manager.submeshes.Count - 1) { num2 = manager.submeshes[j + 1] - num; } int[] array = dfTempArray<int>.Obtain(num2); val3.Triangles.CopyTo(num, array, 0, num2); val4.SetTriangles(array, j); } } catch (dfAbortRenderingException) { manager.isDirty = true; manager.abortRendering = false; } finally { ((Renderer)manager.meshRenderer).enabled = true; } } public static void Changed_UpdateReloadLabelsOnCameraFinishedFrame(GameUIRoot gameUI) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Invalid comparison between Unknown and I4 //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Invalid comparison between Unknown and I4 //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) Vector3 val3 = default(Vector3); for (int i = 0; i < gameUI.m_displayingReloadNeeded.Count; i++) { if (gameUI.m_displayingReloadNeeded[i]) { PlayerController val = GameManager.Instance.PrimaryPlayer; if ((int)GameManager.Instance.CurrentGameType == 1 && i != 0) { val = GameManager.Instance.SecondaryPlayer; } dfControl val2 = (dfControl)(object)gameUI.m_extantReloadLabels[i]; float num = 0.125f; if (((dfControl)gameUI.m_extantReloadLabels[i]).GetLocalizationKey() == "#RELOAD_FULL") { num = 0.1875f; } float num2 = 0f; if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)((GameActor)val).CurrentGun) && (int)((GameActor)val).CurrentGun.Handedness == 4) { num2 += 0.5f; } ((Vector3)(ref val3))..ctor(((BraveBehaviour)val).specRigidbody.UnitCenter.x - ((BraveBehaviour)val).transform.position.x + num, ((GameActor)val).SpriteDimensions.y + num2, 0f); if (Object.op_Implicit((Object)(object)camera) && Object.op_Implicit((Object)(object)originalCamera)) { val3 += -((Component)camera).transform.localPosition + ((Component)originalCamera).transform.localPosition; } Vector2 val4 = Vector2.op_Implicit(Vector3Extensions.WithZ(dfFollowObject.ConvertWorldSpaces(((BraveBehaviour)val).transform.position + val3, GameManager.Instance.MainCameraController.Camera, gameUI.Manager.RenderCamera), 0f)); ((Component)val2).transform.position = Vector2.op_Implicit(val4); ((Component)val2).transform.position = dfVectorExtensions.QuantizeFloor(((Component)val2).transform.position, val2.PixelsToUnits() / (Pixelator.Instance.ScaleTileScale / Pixelator.Instance.CurrentTileScale)); } } } public static void Changed_OnMainCameraFinishedFrame(GameUIReloadBarController controller) { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)controller.m_attachPlayer) && (((dfControl)controller.progressSlider).IsVisible || controller.AnyStatusBarVisible())) { Vector2 val = ((Object.op_Implicit((Object)(object)camera) && Object.op_Implicit((Object)(object)originalCamera)) ? Vector2.op_Implicit(controller.m_attachPlayer.LockedApproximateSpriteCenter - ((Component)camera).transform.localPosition + ((Component)originalCamera).transform.localPosition + controller.m_worldOffset) : Vector2.op_Implicit(controller.m_attachPlayer.LockedApproximateSpriteCenter + controller.m_worldOffset)); Vector2 val2 = Vector2.op_Implicit(Vector3Extensions.WithZ(controller.ConvertWorldSpaces(Vector2.op_Implicit(val), controller.worldCamera, controller.uiCamera), 0f) + controller.m_screenOffset); ((Component)controller.progressSlider).transform.position = Vector2.op_Implicit(val2); ((Component)controller.progressSlider).transform.position = dfVectorExtensions.QuantizeFloor(((Component)controller.progressSlider).transform.position, ((dfControl)controller.progressSlider).PixelsToUnits() / (Pixelator.Instance.ScaleTileScale / Pixelator.Instance.CurrentTileScale)); if ((Object)(object)controller.StatusBarPanel != (Object)null) { ((Component)controller.StatusBarPanel).transform.position = ((Component)controller.progressSlider).transform.position - new Vector3(0f, -48f * ((dfControl)controller.progressSlider).PixelsToUnits(), 0f); } } } } public static class CoopViewPatches { private static CameraController controller_PitRespawnPatch; [HarmonyILManipulator] [HarmonyPatch(typeof(CameraController), "GetCoreCurrentBasePosition")] public static void GetCoreCurrentBasePositionPatch(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>[3] { (Instruction x) => ILPatternMatchingExt.MatchCallvirt<GameManager>(x, "get_AllPlayers"), (Instruction x) => ILPatternMatchingExt.MatchLdlen(x), (Instruction x) => ILPatternMatchingExt.MatchConvI4(x) })) { val.EmitDelegate<Func<int, int>>((Func<int, int>)((int orig) => 1)); } } [HarmonyILManipulator] [HarmonyPatch(typeof(CameraController), "GetCoreOffset")] public static void GetCoreOffsetPatch(ILContext ctx) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: 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>[3] { (Instruction x) => ILPatternMatchingExt.Match(x, OpCodes.Brfalse), (Instruction x) => ILPatternMatchingExt.MatchCall<GameManager>(x, "get_Instance"), (Instruction x) => ILPatternMatchingExt.MatchCallvirt<GameManager>(x, "get_CurrentGameType") })) { val.EmitDelegate<Func<GameType, bool>>((Func<GameType, bool>)((GameType orig) => false)); } if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[3] { (Instruction x) => ILPatternMatchingExt.MatchCall<BraveInput>(x, "GetInstanceForPlayer"), (Instruction x) => ILPatternMatchingExt.MatchCallvirt<BraveInput>(x, "get_ActiveActions"), (Instruction x) => ILPatternMatchingExt.Match(x, OpCodes.Stloc_S) })) { val.Emit(OpCodes.Ldarg_0); val.EmitDelegate<Func<int, CameraController, int>>((Func<int, CameraController, int>)((int orig, CameraController self) => (!((Object)(object)self.m_player == (Object)(object)GameManager.Instance.PrimaryPlayer)) ? 1 : 0)); } val.Index += 2; if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[4] { (Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, 1), (Instruction x) => ILPatternMatchingExt.Match(x, OpCodes.Bne_Un), (Instruction x) => ILPatternMatchingExt.MatchCall<GameManager>(x, "get_Instance"), (Instruction x) => ILPatternMatchingExt.MatchCallvirt<GameManager>(x, "get_PrimaryPlayer") })) { val.Emit(OpCodes.Ldarg_0); val.EmitDelegate<Func<PlayerController, CameraController, PlayerController>>((Func<PlayerController, CameraController, PlayerController>)((PlayerController orig, CameraController self) => self.m_player)); } if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchLdfld<CameraController>(x, "OverrideZoomScale") })) { val.EmitDelegate<Func<CameraController, CameraController>>((Func<CameraController, CameraController>)((CameraController orig) => (Object.op_Implicit((Object)(object)CoopViewModule.camera) && (Object)(object)orig == (Object)(object)((Component)CoopViewModule.camera).GetComponent<CameraController>()) ? GameManager.Instance.MainCameraController : orig)); } if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[3] { (Instruction x) => ILPatternMatchingExt.Match(x, OpCodes.Bne_Un), (Instruction x) => ILPatternMatchingExt.MatchCall<GameManager>(x, "get_Instance"), (Instruction x) => ILPatternMatchingExt.MatchCallvirt<GameManager>(x, "get_CurrentGameType") })) { val.EmitDelegate<Func<GameType, bool>>((Func<GameType, bool>)((GameType orig) => false)); } } [HarmonyPrefix] [HarmonyPatch(typeof(PlayerController), "ReinitializeMovementRestrictors")] public static bool ReinitializeMovementRestrictors_Pre() { return false; } [HarmonyILManipulator] [HarmonyPatch(typeof(PlayerController), "InitializeCallbacks")] public static void InitializeCallbacksPatch(ILContext ctx) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0132: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(ctx); ILLabel val2 = val.DefineLabel(); if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[4] { (Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0), (Instruction x) => ILPatternMatchingExt.MatchLdfld<PlayerController>(x, "inventory"), (Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0), (Instruction x) => ILPatternMatchingExt.MatchLdftn<PlayerController>(x, "OnGunChanged") })) { val2 = val.MarkLabel(); } val.Index = 0; if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[3] { (Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0), (Instruction x) => ILPatternMatchingExt.MatchCall<BraveBehaviour>(x, "get_specRigidbody"), (Instruction x) => ILPatternMatchingExt.MatchDup(x) })) { val.Emit(OpCodes.Br, (object)val2); } } [HarmonyILManipulator] [HarmonyPatch(/*Could not decode attribute arguments.*/)] public static void get_UseMouseAimPatch(ILContext ctx) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0081: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(ctx); if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[3] { (Instruction x) => ILPatternMatchingExt.MatchCall<BraveInput>(x, "GetInstanceForPlayer"), (Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, 0), (Instruction x) => ILPatternMatchingExt.MatchCallvirt<BraveInput>(x, "IsKeyboardAndMouse") })) { val.Emit(OpCodes.Ldarg_0); val.EmitDelegate<Func<int, CameraController, int>>((Func<int, CameraController, int>)((int orig, CameraController self) => (!((Object)(object)self.m_player == (Object)(object)GameManager.Instance.PrimaryPlayer)) ? 1 : 0)); } } [HarmonyILManipulator] [HarmonyPatch(typeof(PlayerController), "DetermineAimPointInWorld")] 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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_012c: 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>[3] { (Instruction x) => ILPatternMatchingExt.MatchCall<GameManager>(x, "get_Instance"), (Instruction x) => ILPatternMatchingExt.MatchCallvirt<GameManager>(x, "get_MainCameraController"), (Instruction x) => ILPatternMatchingExt.MatchCallvirt<Component>(x, "GetComponent") })) { val.Emit(OpCodes.Ldarg_0); val.EmitDelegate<Func<Camera, PlayerController, Camera>>((Func<Camera, PlayerController, Camera>)((Camera orig, PlayerController self) => (Object.op_Implicit((Object)(object)CoopViewModule.camera) && Object.op_Implicit((Object)(object)CoopViewModule.originalCamera)) ? ((!BraveInput.GetInstanceForPlayer(0).IsKeyboardAndMouse(false) && !BraveInput.GetInstanceForPlayer(1).IsKeyboardAndMouse(false)) ? (self.IsPrimaryPlayer ? CoopViewModule.originalCamera : CoopViewModule.camera) : (self.IsKeyboardAndMouse() ? CoopViewModule.originalCamera : CoopViewModule.camera)) : orig)); } if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[3] { (Instruction x) => ILPatternMatchingExt.MatchStloc(x, 33), (Instruction x) => ILPatternMatchingExt.MatchCall<GameManager>(x, "get_Instance"), (Instruction x) => ILPatternMatchingExt.MatchCallvirt<GameManager>(x, "get_MainCameraController") })) { val.Emit(OpCodes.Ldloc_1); val.EmitDelegate<Func<CameraController, Camera, CameraController>>((Func<CameraController, Camera, CameraController>)((CameraController orig, Camera camera) => ((Component)camera).GetComponent<CameraController>())); } } [HarmonyILManipulator] [HarmonyPatch(typeof(PlayerController), "CheckSpawnAlertArrows")] public static void CheckSpawnAlertArrowsPatch(ILContext ctx) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_00fe: 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>[2] { (Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0), (Instruction x) => ILPatternMatchingExt.MatchCall<PlayerController>(x, "get_IsPrimaryPlayer") })) { val.EmitDelegate<Func<bool, bool>>((Func<bool, bool>)((bool orig) => true)); } if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[3] { (Instruction x) => ILPatternMatchingExt.Match(x, OpCodes.Br), (Instruction x) => ILPatternMatchingExt.MatchCall<GameManager>(x, "get_Instance"), (Instruction x) => ILPatternMatchingExt.MatchCallvirt<GameManager>(x, "get_MainCameraController") })) { val.Emit(OpCodes.Ldarg_0); val.EmitDelegate<Func<CameraController, PlayerController, CameraController>>((Func<CameraController, PlayerController, CameraController>)((CameraController orig, PlayerController self) => (Object.op_Implicit((Object)(object)CoopViewModule.camera) && Object.op_Implicit((Object)(object)CoopViewModule.originalCamera)) ? ((!BraveInput.GetInstanceForPlayer(0).IsKeyboardAndMouse(false) && !BraveInput.GetInstanceForPlayer(1).IsKeyboardAndMouse(false)) ? ((Component)(self.IsPrimaryPlayer ? CoopViewModule.originalCamera : CoopViewModule.camera)).GetComponent<CameraController>() : ((Component)(self.IsKeyboardAndMouse() ? CoopViewModule.originalCamera : CoopViewModule.camera)).GetComponent<CameraController>()) : orig)); } } [HarmonyILManipulator] [HarmonyPatch(typeof(PlayerController), "LateUpdate")] public static void PlayerControllerLateUpdatePatch(ILContext ctx) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_000c: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(ctx); while (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[2] { (Instruction x) => ILPatternMatchingExt.MatchCall<GameManager>(x, "get_Instance"), (Instruction x) => ILPatternMatchingExt.MatchCallvirt<GameManager>(x, "get_MainCameraController") })) { val.Emit(OpCodes.Ldarg_0); val.EmitDelegate<Func<CameraController, PlayerController, CameraController>>((Func<CameraController, PlayerController, CameraController>)((CameraController orig, PlayerController self) => (Object.op_Implicit((Object)(object)CoopViewModule.camera) && Object.op_Implicit((Object)(object)CoopViewModule.originalCamera)) ? ((!BraveInput.GetInstanceForPlayer(0).IsKeyboardAndMouse(false) && !BraveInput.GetInstanceForPlayer(1).IsKeyboardAndMouse(false)) ? ((Component)(self.IsPrimaryPlayer ? CoopViewModule.originalCamera : CoopViewModule.camera)).GetComponent<CameraController>() : ((Component)(self.IsKeyboardAndMouse() ? CoopViewModule.originalCamera : CoopViewModule.camera)).GetComponent<CameraController>()) : orig)); } } [HarmonyPostfix] [HarmonyPatch(typeof(Pixelator), "FadeToBlack")] private static void FadeToBlack_Post(Pixelator __instance, float duration, bool reverse = false, float holdTime = 0f) { if ((Object)(object)__instance == (Object)(object)Pixelator.Instance && Object.op_Implicit((Object)(object)CoopViewModule.cameraPixelator)) { Orig_FadeToBlack(CoopViewModule.cameraPixelator, duration, reverse, holdTime); } } private static void Orig_FadeToBlack(Pixelator self, float duration, bool reverse = false, float holdTime = 0f) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) if (reverse || self.fade != 0f) { self.m_fadeLocked = true; ((MonoBehaviour)self).StartCoroutine(self.FadeToColor_CR(duration, Color.black, reverse, holdTime)); } } [HarmonyPostfix] [HarmonyPatch(typeof(Pixelator), "FadeToColor")] private static void FadeToColor_Post(Pixelator __instance, float duration, Color c, bool reverse = false, float holdTime = 0f) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance == (Object)(object)Pixelator.Instance && Object.op_Implicit((Object)(object)CoopViewModule.cameraPixelator)) { Orig_FadeToColor(CoopViewModule.cameraPixelator, duration, c, reverse, holdTime); } } private static void Orig_FadeToColor(Pixelator self, float duration, Color c, bool reverse = false, float holdTime = 0f) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) if (!self.m_fadeLocked) { ((MonoBehaviour)self).StartCoroutine(self.FadeToColor_CR(duration, c, reverse, holdTime)); } } [HarmonyPostfix] [HarmonyPatch(typeof(CameraController), "AddFocusPoint", new Type[] { typeof(GameObject) })] private static void AddFocusPoint_Post(CameraController __instance, GameObject go) { if ((Object)(object)__instance == (Object)(object)GameManager.Instance.MainCameraController && Object.op_Implicit((Object)(object)CoopViewModule.camera)) { Orig_AddFocusPoint(((Component)CoopViewModule.camera).GetComponent<CameraController>(), go); } } private static void Orig_AddFocusPoint(CameraController self, GameObject go) { if (!self.m_focusObjects.Contains((Object)(object)go)) { self.m_focusObjects.Add((Object)(object)go); } } [HarmonyPostfix] [HarmonyPatch(typeof(CameraController), "SetZoomScaleImmediate")] private static void SetZoomScaleImmediate_Post(CameraController __instance, float zoomScale) { if ((Object)(object)__instance == (Object)(object)GameManager.Instance.MainCameraController && Object.op_Implicit((Object)(object)CoopViewModule.camera)) { Orig_SetZoomScaleImmediate(); } } private static void Orig_SetZoomScaleImmediate() { if (Object.op_Implicit((Object)(object)CoopViewModule.cameraPixelator)) { CameraController component = ((Component)CoopViewModule.originalCamera).GetComponent<CameraController>(); CoopViewModule.cameraPixelator.NUM_MACRO_PIXELS_HORIZONTAL = (int)dfNumberExtensions.Quantize((float)BraveCameraUtility.H_PIXELS / component.CurrentZoomScale, 2f); CoopViewModule.cameraPixelator.NUM_MACRO_PIXELS_VERTICAL = (int)dfNumberExtensions.Quantize((float)BraveCameraUtility.V_PIXELS / component.CurrentZoomScale, 2f); } } [HarmonyPostfix] [HarmonyPatch(typeof(CameraController), "RemoveFocusPoint", new Type[] { typeof(GameObject) })] private static void RemoveFocusPoint_Post(CameraController __instance, GameObject go) { if ((Object)(object)__instance == (Object)(object)GameManager.Instance.MainCameraController && Object.op_Implicit((Object)(object)CoopViewModule.camera)) { Orig_RemoveFocusPoint(((Component)CoopViewModule.camera).GetComponent<CameraController>(), go); } } private static void Orig_RemoveFocusPoint(CameraController self, GameObject go) { self.m_focusObjects.Remove((Object)(object)go); } [HarmonyPostfix] [HarmonyPatch(typeof(CameraController), "SetManualControl")] private static void SetManualControl_Post(CameraController __instance, bool manualControl, bool shouldLerp = true) { if ((Object)(object)__instance == (Object)(object)GameManager.Instance.MainCameraController && Object.op_Implicit((Object)(object)CoopViewModule.camera)) { Orig_SetManualControl(((Component)CoopViewModule.camera).GetComponent<CameraController>(), manualControl, shouldLerp); } } private static void Orig_SetManualControl(CameraController self, bool manualControl, bool shouldLerp = true) { self.m_manualControl = manualControl; if (self.m_manualControl) { self.m_isLerpingToManualControl = shouldLerp; } else { self.m_isRecoveringFromManualControl = shouldLerp; } } [HarmonyPostfix] [HarmonyPatch(typeof(CameraController), "DoContinuousScreenShake")] private static void DoContinuousScreenShake_Post(CameraController __instance, ScreenShakeSettings shakesettings, Component source, bool isPlayerGun = false) { if ((Object)(object)__instance == (Object)(object)GameManager.Instance.MainCameraController && Object.op_Implicit((Object)(object)CoopViewModule.camera)) { Orig_DoContinuousScreenShake(((Component)CoopViewModule.camera).GetComponent<CameraController>(), shakesettings, source, isPlayerGun); } } private static void Orig_DoContinuousScreenShake(CameraController self, ScreenShakeSettings shakesettings, Component source, bool isPlayerGun = false) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Invalid comparison between Unknown and I4 //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Invalid comparison between Unknown and I4 //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Invalid comparison between Unknown and I4 //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) float num = shakesettings.magnitude; if ((int)GameManager.Instance.CurrentGameType == 1 && GameManager.Options.CoopScreenShakeReduction) { num *= 0.3f; } if (isPlayerGun) { num *= 0.75f; } bool flag = (int)shakesettings.vibrationType > 0; if ((int)shakesettings.vibrationType == 20) { BraveInput.DoVibrationForAllPlayers(shakesettings.simpleVibrationTime, shakesettings.simpleVibrationStrength); flag = false; } IEnumerator enumerator = self.HandleContinuousScreenShake(num, shakesettings.speed, shakesettings.direction, source, flag); if (self.continuousShakeMap.ContainsKey(source)) { Debug.LogWarning((object)("Overwriting previous screen shake for " + (object)source), (Object)(object)source); self.StopContinuousScreenShake(source); } self.continuousShakeMap.Add(source, enumerator); self.activeContinuousShakes.Add(enumerator); } [HarmonyPostfix] [HarmonyPatch(typeof(CameraController), "StopContinuousScreenShake")] private static void StopContinuousScreenShake_Post(CameraController __instance, Component source) { if ((Object)(object)__instance == (Object)(object)GameManager.Instance.MainCameraController && Object.op_Implicit((Object)(object)CoopViewModule.camera)) { Orig_StopContinuousScreenShake(((Component)CoopViewModule.camera).GetComponent<CameraController>(), source); } } private static void Orig_StopContinuousScreenShake(CameraController self, Component source) { if (self.continuousShakeMap.ContainsKey(source)) { IEnumerator enumerator = self.continuousShakeMap[source]; self.m_terminateNextContinuousScreenShake = true; enumerator.MoveNext(); self.continuousShakeMap.Remove(source); self.activeContinuousShakes.Remove(enumerator); } } [HarmonyILManipulator] [HarmonyPatch(typeof(CameraController), "GetAimContribution")] public static void GetAimContributionPatch(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.MatchLdfld<CameraController>(x, "OverrideZoomScale") })) { val.EmitDelegate<Func<CameraController, CameraController>>((Func<CameraController, CameraController>)((CameraController orig) => (Object.op_Implicit((Object)(object)CoopViewModule.camera) && (Object)(object)orig == (Object)(object)((Component)CoopViewModule.camera).GetComponent<CameraController>()) ? GameManager.Instance.MainCameraController : orig)); } } [HarmonyILManipulator] [HarmonyPatch(/*Could not decode attribute arguments.*/)] public static void IsCurrentlyZoomIntermediatePatch(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.MatchLdfld<CameraController>(x, "CurrentZoomScale") })) { val.EmitDelegate<Func<CameraController, CameraController>>((Func<CameraController, CameraController>)((CameraController orig) => (Object.op_Implicit((Object)(object)CoopViewModule.camera) && (Object)(object)orig == (Object)(object)((Component)CoopViewModule.camera).GetComponent<CameraController>()) ? GameManager.Instance.MainCameraController : orig)); } if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchLdfld<CameraController>(x, "OverrideZoomScale") })) { val.EmitDelegate<Func<CameraController, CameraController>>((Func<CameraController, CameraController>)((CameraController orig) => (Object.op_Implicit((Object)(object)CoopViewModule.camera) && (Object)(object)orig == (Object)(object)((Component)CoopViewModule.camera).GetComponent<CameraController>()) ? GameManager.Instance.MainCameraController : orig)); } } [HarmonyILManipulator] [HarmonyPatch(/*Could not decode attribute arguments.*/)] public static void LockToRoomPatch(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.Match(x, OpCodes.Ldfld) })) { val.EmitDelegate<Func<CameraController, CameraController>>((Func<CameraController, CameraController>)((CameraController orig) => (Object.op_Implicit((Object)(object)CoopViewModule.camera) && (Object)(object)orig == (Object)(object)((Component)CoopViewModule.camera).GetComponent<CameraController>()) ? GameManager.Instance.MainCameraController : orig)); } } [HarmonyILManipulator] [HarmonyPatch(/*Could not decode attribute arguments.*/)] public static void PitRespawnPatch(ILContext ctx) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(ctx); FieldInfo fieldInfo = AccessTools.Field(Type.GetType("PlayerController+<PitRespawn>c__Iterator13, Assembly-CSharp"), "$this"); if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[4] { (Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0), (Instruction x) => ILPatternMatchingExt.MatchLdfld(x, "PlayerController+<PitRespawn>c__Iterator13", "$this"), (Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, 0), (Instruction x) => ILPatternMatchingExt.MatchStfld<PlayerController>(x, "m_interruptingPitRespawn") })) { val.Emit(OpCodes.Ldarg_0); val.Emit(OpCodes.Ldfld, fieldInfo); val.EmitDelegate<Action<PlayerController>>((Action<PlayerController>)delegate(PlayerController self) { if (Object.op_Implicit((Object)(object)CoopViewModule.camera) && Object.op_Implicit((Object)(object)CoopViewModule.originalCamera)) { if (!BraveInput.GetInstanceForPlayer(0).IsKeyboardAndMouse(false) && !BraveInput.GetInstanceForPlayer(1).IsKeyboardAndMouse(false)) { controller_PitRespawnPatch = ((Component)(self.IsPrimaryPlayer ? CoopViewModule.originalCamera : CoopViewModule.camera)).GetComponent<CameraController>(); } else { controller_PitRespawnPatch = ((Component)(self.IsKeyboardAndMouse() ? CoopViewModule.originalCamera : CoopViewModule.camera)).GetComponent<CameraController>(); } } else { controller_PitRespawnPatch = GameManager.Instance.MainCameraController; } }); } val.Index = 0; while (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[2] { (Instruction x) => ILPatternMatchingExt.MatchCall<GameManager>(x, "get_Instance"), (Instruction x) => ILPatternMatchingExt.MatchCallvirt<GameManager>(x, "get_MainCameraController") })) { val.EmitDelegate<Func<CameraController, CameraController>>((Func<CameraController, CameraController>)((CameraController orig) => controller_PitRespawnPatch)); } if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchRet(x) })) { val.EmitDelegate<Action>((Action)delegate { controller_PitRespawnPatch = null; }); } } [HarmonyILManipulator] [HarmonyPatch(typeof(CameraController), "LateUpdate")] public static void CameraControllerLateUpdatePatch(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_007b: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: 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.MatchStfld<ControllerCamSettings>(x, "forceTimer") })) { val.Emit(OpCodes.Ldarg_0); val.EmitDelegate<Action<CameraController>>((Action<CameraController>)delegate(CameraController self) { if (GameManager.Instance.AllPlayers.Length < 2) { self.m_player = GameManager.Instance.PrimaryPlayer; } else if (!BraveInput.GetInstanceForPlayer(0).IsKeyboardAndMouse(false) && !BraveInput.GetInstanceForPlayer(1).IsKeyboardAndMouse(false)) { if (((Object)self.Camera).name != "Camera Copy") { self.m_player = GameManager.Instance.PrimaryPlayer; } else { self.m_player = GameManager.Instance.SecondaryPlayer; } } else if (((Object)self.Camera).name != "Camera Copy") { if (BraveInput.GetInstanceForPlayer(0).IsKeyboardAndMouse(false)) { self.m_player = GameManager.Instance.PrimaryPlayer; } else { self.m_player = GameManager.Instance.SecondaryPlayer; } } else if (BraveInput.GetInstanceForPlayer(1).IsKeyboardAndMouse(false)) { self.m_player = GameManager.Instance.PrimaryPlayer; } else { self.m_player = GameManager.Instance.SecondaryPlayer; } }); } val.Index = 0; while (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCall<Pixelator>(x, "get_Instance") })) { val.Emit(OpCodes.Ldarg_0); val.EmitDelegate<Func<Pixelator, CameraController, Pixelator>>((Func<Pixelator, CameraController, Pixelator>)((Pixelator orig, CameraController self) => ((Component)self).GetComponent<Pixelator>())); } val.Index = 0; if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[2] { (Instruction x) => ILPatternMatchingExt.MatchCallvirt<Transform>(x, "set_position"), (Instruction x) => ILPatternMatchingExt.MatchCall<Camera>(x, "get_main") })) { val.Emit(OpCodes.Ldarg_0); val.EmitDelegate<Func<Camera, CameraController, Camera>>((Func<Camera, CameraController, Camera>)((Camera orig, CameraController self) => self.Camera)); } if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[2] { (Instruction x) => ILPatternMatchingExt.MatchStfld<CameraController>(x, "m_cachedMinPos"), (Instruction x) => ILPatternMatchingExt.MatchCall<Camera>(x, "get_main") })) { val.Emit(OpCodes.Ldarg_0); val.EmitDelegate<Func<Camera, CameraController, Camera>>((Func<Camera, CameraController, Camera>)((Camera orig, CameraController self) => self.Camera)); } val.Index = 0; while (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchLdfld<CameraController>(x, "CurrentZoomScale") })) { val.EmitDelegate<Func<CameraController, CameraController>>((Func<CameraController, CameraController>)((CameraController orig) => (Object.op_Implicit((Object)(object)CoopViewModule.camera) && (Object)(object)orig == (Object)(object)((Component)CoopViewModule.camera).GetComponent<CameraController>()) ? GameManager.Instance.MainCameraController : orig)); int index = val.Index; val.Index = index + 1; } val.Index = 0; while (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchLdfld<CameraController>(x, "OverrideZoomScale") })) { val.EmitDelegate<Func<CameraController, CameraController>>((Func<CameraController, CameraController>)((CameraController orig) => (Object.op_Implicit((Object)(object)CoopViewModule.camera) && (Object)(object)orig == (Object)(object)((Component)CoopViewModule.camera).GetComponent<CameraController>()) ? GameManager.Instance.MainCameraController : orig)); int index = val.Index; val.Index = index + 1; } val.Index = 0; if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[2] { (Instruction x) => ILPatternMatchingExt.MatchLdfld<CameraController>(x, "controllerCamera"), (Instruction x) => ILPatternMatchingExt.MatchLdfld<ControllerCamSettings>(x, "isTransitioning") })) { val.EmitDelegate<Func<CameraController, CameraController>>((Func<CameraController, CameraController>)((CameraController orig) => (Object.op_Implicit((Object)(object)CoopViewModule.camera) && (Object)(object)orig == (Object)(object)((Component)CoopViewModule.camera).GetComponent<CameraController>()) ? GameManager.Instance.MainCameraController : orig)); } val.Index = 0; if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchLdfld<CameraController>(x, "OverridePosition") })) { val.EmitDelegate<Func<CameraController, CameraController>>((Func<CameraController, CameraController>)((CameraController orig) => (Object.op_Implicit((Object)(object)CoopViewModule.camera) && (Object)(object)orig == (Object)(object)((Component)CoopViewModule.camera).GetComponent<CameraController>()) ? GameManager.Instance.MainCameraController : orig)); } } [HarmonyILManipulator] [HarmonyPatch(typeof(GameUIReloadBarController), "OnMainCameraFinishedFrame")] public static void OnMainCameraFinishedFramePatch(ILContext ctx) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_004e: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(ctx); if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchStloc(x, 0) })) { int index = val.Index; val.Index = index - 1; val.Emit(OpCodes.Ldarg_0); val.EmitDelegate<Func<Vector3, GameUIReloadBarController, Vector3>>((Func<Vector3, GameUIReloadBarController, Vector3>)((Vector3 orig, GameUIReloadBarController self) => (!Object.op_Implicit((Object)(object)CoopViewModule.camera) || !Object.op_Implicit((Object)(object)CoopViewModule.originalCamera)) ? (orig - ((Component)CoopViewModule.camera).transform.localPosition + ((Component)CoopViewModule.originalCamera).transform.localPosition) : orig)); } } [HarmonyILManipulator] [HarmonyPatch(/*Could not decode attribute arguments.*/)] public static void HandleThreatArrowPatch(ILContext ctx) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) FieldInfo fieldInfo = AccessTools.Field(Type.GetType("PlayerController+<HandleThreatArrow>c__IteratorB, Assembly-CSharp"), "$this"); ILCursor val = new ILCursor(ctx); while (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[2] { (Instruction x) => ILPatternMatchingExt.MatchCall<GameManager>(x, "get_Instance"), (Instruction x) => ILPatternMatchingExt.MatchCallvirt<GameManager>(x, "get_MainCameraController") })) { val.Emit(OpCodes.Ldarg_0); val.Emit(OpCodes.Ldfld, fieldInfo); val.EmitDelegate<Func<CameraController, PlayerController, CameraController>>((Func<CameraController, PlayerController, CameraController>)((CameraController orig, PlayerController self) => (Object.op_Implicit((Object)(object)CoopViewModule.camera) && Object.op_Implicit((Object)(object)CoopViewModule.originalCamera)) ? ((!BraveInput.GetInstanceForPlayer(0).IsKeyboardAndMouse(false) && !BraveInput.GetInstanceForPlayer(1).IsKeyboardAndMouse(false)) ? ((Component)(self.IsPrimaryPlayer ? CoopViewModule.originalCamera : CoopViewModule.camera)).GetComponent<CameraController>() : ((Component)(self.IsKeyboardAndMouse() ? CoopViewModule.originalCamera : CoopViewModule.camera)).GetComponent<CameraController>()) : orig)); } } [HarmonyILManipulator] [HarmonyPatch(typeof(GameUIRoot), "UpdateReloadLabelsOnCameraFinishedFrame")] public static void UpdateReloadLabelsOnCameraFinishedFramePatch(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.MatchLdloc(x, 5) })) { val.Emit(OpCodes.Ldarg_0); val.EmitDelegate<Func<Vector3, GameUIReloadBarController, Vector3>>((Func<Vector3, GameUIReloadBarController, Vector3>)((Vector3 orig, GameUIReloadBarController self) => (!Object.op_Implicit((Object)(object)CoopViewModule.camera) || !Object.op_Implicit((Object)(object)CoopViewModule.originalCamera)) ? (orig - ((Component)CoopViewModule.camera).transform.localPosition + ((Component)CoopViewModule.originalCamera).transform.localPosition) : orig)); } } [HarmonyILManipulator] [HarmonyPatch(/*Could not decode attribute arguments.*/)] public static void InstancePatch(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.MatchStsfld<Pixelator>(x, "m_instance") })) { val.EmitDelegate<Func<Pixelator, Pixelator>>((Func<Pixelator, Pixelator>)((Pixelator orig) => Object.op_Implicit((Object)(object)CoopViewModule.originCameraPixelator) ? CoopViewModule.originCameraPixelator : orig)); } } [HarmonyPrefix] [HarmonyPatch(typeof(DemonWallDeathController), "OnBossDeath")] public static bool DemonWallDeathControllerOnBossDeath_Pre(DemonWallDeathController __instance) { ((Component)__instance).GetComponent<DemonWallController>().ModifyCamera(false); return true; } [HarmonyPrefix] [HarmonyPatch(typeof(HelicopterDeathController), "OnBossDeath")] public static bool HelicopterDeathControllerOnBossDeath_Pre(HelicopterDeathController __instance) { ((Component)__instance).GetComponent<HelicopterIntroDoer>().ModifyCamera(false); return true; } [HarmonyILManipulator] [HarmonyPatch(typeof(BraveOptionsMenuItem), "Awake")] public static void BraveOptionsMenuItemAwakePatch(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<dfControl>(x, "ResolutionChangedPostLayout") })) { val.EmitDelegate<Func<Action<dfControl, Vector3, Vector3>, Action<dfControl, Vector3, Vector3>>>((Func<Action<dfControl, Vector3, Vector3>, Action<dfControl, Vector3, Vector3>>)((Action<dfControl, Vector3, Vector3> orig) => null)); } } [HarmonyPostfix] [HarmonyPatch(typeof(BraveOptionsMenuItem), "HandleScreenDataChanged")] public static void HandleScreenDataChanged_Post() { ((MonoBehaviour)GameManager.Instance).StartCoroutine(CoopViewModule.UpdateResolution()); } [HarmonyILManipulator] [HarmonyPatch(typeof(TextBoxManager), "LateUpdate")] public static void TextBoxManagerLateUpdatePatch(ILContext ctx) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0063: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(ctx); if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchStsfld<TextBoxManager>(x, "UNPIXELATED_LAYER") })) { val.EmitDelegate<Func<int>>((Func<int>)(() => LayerMask.NameToLayer("Unoccluded"))); val.Emit<TextBoxManager>(OpCodes.Stsfld, "UNPIXELATED_LAYER"); } } [HarmonyILManipulator] [HarmonyPatch(typeof(EndTimesNebulaController), "BecomeActive")] public static void BecomeActivePatch(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)0, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCall<Pixelator>(x, "get_Instance") })) { return; } val.Emit(OpCodes.Ldarg_0); val.EmitDelegate<Action<EndTimesNebulaController>>((Action<EndTimesNebulaController>)delegate(EndTimesNebulaController self) { if (Object.op_Implicit((Object)(object)CoopViewModule.cameraPixelator)) { CoopViewModule.cameraPixelator.AdditionalBGCamera = self.NebulaCamera; } }); } [HarmonyILManipulator] [HarmonyPatch(typeof(EndTimesNebulaController), "BecomeInactive")] public static void BecomeInactivePatch(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)0, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCall<Pixelator>(x, "get_HasInstance") })) { return; } val.Emit(OpCodes.Ldarg_0); val.EmitDelegate<Action<EndTimesNebulaController>>((Action<EndTimesNebulaController>)delegate(EndTimesNebulaController self) { if (Object.op_Implicit((Object)(object)CoopViewModule.cameraPixelator) && (Object)(object)CoopViewModule.cameraPixelator.AdditionalBGCamera == (Object)(object)self.NebulaCamera) { CoopViewModule.cameraPixelator.AdditionalBGCamera = null; } }); } [HarmonyILManipulator] [HarmonyPatch(typeof(CameraController), "GetBoundedCameraPositionInRect")] public static void GetBoundedCameraPositionInRectPatch(ILContext ctx) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0122: 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>[2] { (Instruction x) => ILPatternMatchingExt.MatchLdloca(x, 1), (Instruction x) => ILPatternMatchingExt.MatchLdfld<Vector2>(x, "x") })) { val.Emit(OpCodes.Ldloc_1); val.Emit(OpCodes.Ldloc_2); val.EmitDelegate<Func<float, Vector2, Vector2, float>>((Func<float, Vector2, Vector2, float>)((float orig, Vector2 cameraBottomLeft, Vector2 cameraTopRight) => (cameraTopRight.x + cameraBottomLeft.x) / 2f - (cameraTopRight.y - cameraBottomLeft.y) * 16f / 9f / 2f)); } if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[3] { (Instruction x) => ILPatternMatchingExt.MatchLdloca(x, 1), (Instruction x) => ILPatternMatchingExt.MatchLdfld<Vector2>(x, "x"), (Instruction x) => ILPatternMatchingExt.MatchSub(x) })) { val.Emit(OpCodes.Ldloc_1); val.Emit(OpCodes.Ldloc_2); val.EmitDelegate<Func<float, Vector2, Vector2, float>>((Func<float, Vector2, Vector2, float>)((float orig, Vector2 cameraBottomLeft, Vector2 cameraTopRight) => (cameraTopRight.y - cameraBottomLeft.y) * 16f / 9f)); } } } internal static class KeyCodeMaps { public enum Keys { Modifiers = -65536, None = 0, Back = 8, Tab = 9, Clear = 12, Enter = 13, 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, Shift = 65536, Control = 131072, Alt = 262144 } 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 class ShortcutKeyHandler { private struct WNDCLASS { public uint style; public WNDPROC lpfn; public int cbClsExtra; public int cbWndExtra; public IntPtr hInstance; public IntPtr hIcon; public IntPtr hCursor; public IntPtr hbrBackground; public IntPtr lpszMenuName; public string lpszClassName; } private delegate IntPtr WNDPROC(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam); public const string TEXT_COLOR = "#CCFF33"; private const uint MOD_CONTROL = 2u; private const uint MOD_SHIFT = 4u; private const uint MOD_ALT = 1u; private const uint WS_POPUP = 2147483648u; private const uint WS_EX_TOOLWINDOW = 128u; private const uint WM_DESTROY = 2u; private const uint WM_ShortcutKey = 786u; private const int SW_HIDE = 0; private static IntPtr _windowHandle; private static WNDPROC _windowProc; private static List<string> currentModifierList = new List<string>(); private static KeyCode? currentNormalKey = null; private static uint modifierKey = 0u; private static uint normalKey = 0u; private static string[] shortcutKeyString = new string[5] { "Ctrl + Shift + P", "Ctrl + Shift + [", "Ctrl + Shift + ]", "Ctrl + Shift + -", "Ctrl + Shift + =" }; private static bool hotkeyCapturing = false; [DllImport("user32.dll")] private static extern bool RegisterHotKey(IntPtr hWnd, int id, uint fsModifiers, uint vk); [DllImport("user32.dll")] private static extern bool UnregisterHotKey(IntPtr hWnd, int id); [DllImport("user32.dll", SetLastError = true)] private static extern IntPtr CreateWindowEx(uint dwExStyle, string lpClassName, string lpWindowName, uint dwStyle, int x, int y, int nWidth, int nHeight, IntPtr hWndParent, IntPtr hMenu, IntPtr hInstance, IntPtr lpParam); [DllImport("user32.dll", SetLastError = true)] private static extern bool DestroyWindow(IntPtr hWnd); [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)] private static extern IntPtr GetModuleHandle(string lpModuleName); [DllImport("user32.dll", SetLastError = true)] private static extern bool RegisterClass(ref WNDCLASS lpWndClass); [DllImport("user32.dll")] private static extern IntPtr DefWindowProc(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam); [DllImport("user32.dll")] private static extern bool ShowWindow(IntPtr hWnd, int nCmdShow); public static void SetShortcutKey(string[] args) { int num; if (args.Length == 1) { num = int.Parse(args[0]); if (num < 0 || num > 5) { num = 0; } } else { num = 0; } if (!hotkeyCapturing) { LogShortcutKeys(); if (num != 0) { ((MonoBehaviour)GameManager.Instance).StartCoroutine(SetShortcutKeyCrt(num)); return; } ETGModConsole.Log((object)"", false); ETGModConsole.Log((object)" - Usage: <color=#CCFF33>shortcutkey [shortcut_key_ID]</color>", false); ETGModConsole.Log((object)" - Set custom shortcut keys.", false); ETGModConsole.Log((object)" - The shortcut key ID should be specified from 1 to 5 in the parameters, like 'shortcutkey 1'.", false); } } private static IEnumerator SetShortcutKeyCrt(int shortcutKeyId) { hotkeyCapturing = true; ETGModConsole.Log((object)"", false); ETGModConsole.Log((object)string.Format("Please enter the shortcut key for shortcut_key_ID = <color={0}>{1}</color>: ", "#CCFF33", shortcutKeyId), false); while (hotkeyCapturing) { currentModifierList.Clear(); currentNormalKey = null; modifierKey = 0u; normalKey = 0u; if (Input.GetKey((KeyCode)306) || Input.GetKey((KeyCode)305)) { currentModifierList.Add(KeyCodeToString((KeyCode)306)); modifierKey |= 2u; } if (Input.GetKey((KeyCode)308) || Input.GetKey((KeyCode)307)) { currentModifierList.Add(KeyCodeToString((KeyCode)308)); modifierKey |= 1u; } if (Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303)) { currentModifierList.Add(KeyCodeToString((KeyCode)304)); modifierKey |= 4u; } if (modifierKey != 0) { foreach (KeyCode keyCode in Enum.GetValues(typeof(KeyCode))) { if (!IsModifierKey(keyCode) && Input.GetKeyDown(keyCode) && !currentNormalKey.HasValue) { currentNormalKey = keyCode; normalKey = (uint)KeyCodeToKeys(keyCode); } } } if (Input.anyKeyDown) { if (currentModifierList.Count > 0 && currentNormalKey.HasValue) { currentModifierList.Add(KeyCodeToString(currentNormalKey.Value)); UnregisterHotKey(_windowHandle, shortcutKeyId); if (!RegisterHotKey(_windowHandle, shortcutKeyId, modifierKey, normalKey)) { ETGModConsole.Log((object)$"Failed to register shortcut key, shortcut_key_ID = {shortcutKeyId}.", false); } else { string keyString = string.Join(" + ", currentModifierList.ToArray()); shortcutKeyString[shortcutKeyId - 1] = keyString; ETGModConsole.Log((object)string.Format("Register shortcut key <color={0}>{1}</color>, shortcut_key_ID = <color={2}>{3}</color>.", "#CCFF33", keyString, "#CCFF33", shortcutKeyId), false); } hotkeyCapturing = false; break; } currentModifierList.Clear(); currentNormalKey = null; modifierKey = 0u; normalKey = 0u; } yield return null; } } private static bool IsModifierKey(KeyCode key) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Invalid comparison between Unknown and I4 //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Invalid comparison between Unknown and I4 //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Invalid comparison between Unknown and I4 //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Invalid comparison between Unknown and I4 //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Invalid comparison between Unknown and I4 //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Invalid comparison between Unknown and I4 return (int)key == 306 || (int)key == 305 || (int)key == 304 || (int)key == 303 || (int)key == 308 || (int)key == 307 || (int)key == 313; } private static KeyCodeMaps.Keys KeyCodeToKeys(KeyCode keyCode) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) KeyCodeMaps.Keys value; return KeyCodeMaps.KeyCodeToKeysMap.TryGetValue(keyCode, out value) ? value : KeyCodeMaps.Keys.None; } private static string KeyCodeToString(KeyCode keyCode) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) string value; return KeyCodeMaps.KeyCodeToStringMap.TryGetValue(keyCode, out value) ? value : ""; } public static void LogShortcutKeys() { ETGModConsole.Log((object)"", false); ETGModConsole.Log((object)"Current shortcut keys:", false); ETGModConsole.Log((object)(" -- <color=#CCFF33>" + shortcutKeyString[0] + "</color> , shortcut_key_ID = <color=#CCFF33>1</color> : Switch to window position presets."), false); ETGModConsole.Log((object)(" -- <color=#CCFF33>" + shortcutKeyString[1] + "</color> , shortcut_key_ID = <color=#CCFF33>2</color> : Switch the second window between fullscreen and windowed mode."), false); ETGModConsole.Log((object)(" -- <color=#CCFF33>" + shortcutKeyString[2] + "</color> , shortcut_key_ID = <color=#CCFF33>3</color> : Fullscreen the second window on the next monitor."), false); ETGModConsole.Log((object)(" -- <color=#CCFF33>" + shortcutKeyString[3] + "</color> , shortcut_key_ID = <color=#CCFF33>4</color> : Switch the main window between fullscreen and windowed mode."), false); ETGModConsole.Log((object)(" -- <color=#CCFF33>" + shortcutKeyString[4] + "</color> , shortcut_key_ID = <color=#CCFF33>5</color> : Fullscreen the main window on the next monitor."), false); } public static void InitMessageHandler() { _windowProc = WindowProc; WNDCLASS wNDCLASS = default(WNDCLASS); wNDCLASS.style = 0u; wNDCLASS.lpfn = _windowProc; wNDCLASS.lpszClassName = "UnityMessageWindowClass"; wNDCLASS.hInstance = GetModuleHandle(null); WNDCLASS lpWndClass = wNDCLASS; RegisterClass(ref lpWndClass); _windowHandle = CreateWindowEx(128u, "UnityMessageWindowClass", "UnityMessageWindow", 2147483648u, 0, 0, 0, 0, IntPtr.Zero, IntPtr.Zero, GetModuleHandle(null), IntPtr.Zero); if (_windowHandle != IntPtr.Zero) { ShowWindow(_windowHandle, 0); } if (_windowHandle == IntPtr.Zero) { ETGModConsole.Log((object)"Failed to create message window.", false); } SetGlobalShortcutKey(); } public static void ReleaseMessageHandler() { if (_windowHandle != IntPtr.Zero) { DestroyWindow(_windowHandle); } UnregisterGlobalShortcutKey(); } private static IntPtr WindowProc(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam) { switch (msg) { case 2u: return IntPtr.Zero; case 786u: { int shortcutKeyId = wParam.ToInt32(); HandleShortcutKeyPressed(shortcutKeyId); return IntPtr.Zero; } default: return DefWindowProc(hWnd, msg, wParam, lParam); } } public static void SetGlobalShortcutKey() { uint fsModifiers = 6u; uint vk = 80u; if (!RegisterHotKey(_windowHandle, 1, fsModifiers, vk)) { ETGModConsole.Log((object)("Failed to register shortcut key " + shortcutKeyString[0] + ", shortcut_key_ID = 1."), false); } fsModifiers = 6u; vk = 219u; if (!RegisterHotKey(_windowHandle, 2, fsModifiers, vk)) { ETGModConsole.Log((object)("Failed to register shortcut key " + shortcutKeyString[1] + ", shortcut_key_ID = 2."), false); } fsModifiers = 6u; vk = 221u; if (!RegisterHotKey(_windowHandle, 3, fsModifiers, vk)) { ETGModConsole.Log((object)("Failed to register shortcut key " + shortcutKeyString[2] + ", shortcut_key_ID = 3."), false); } fsModifiers = 6u; vk = 189u; if (!RegisterHotKey(_windowHandle, 4, fsModifiers, vk)) { ETGModConsole.Log((object)("Failed to register shortcut key " + shortcutKeyString[3] + ", shortcut_key_ID = 4."), false); } fsModifiers = 6u; vk = 187u; if (!RegisterHotKey(_windowHandle, 5, fsModifiers, vk)) { ETGModConsole.Log((object)("Failed to register shortcut key " + shortcutKeyString[4] + ", shortcut_key_ID = 5."), false); } } public static void UnregisterGlobalShortcutKey() { for (int i = 1; i <= 5; i++) { UnregisterHotKey(_windowHandle, i); } } private static void HandleShortcutKeyPressed(int shortcutKeyId) { switch (shortcutKeyId) { case 1: { string[] args = new string[0]; WindowManager.SwitchPreset(args); break; } case 2: WindowManager.SwitchSecondWindowFullscreenOrWindowed(); break; case 3: WindowManager.SwitchSecondWindowFullScreenMonitor(); break; case 4: WindowManager.SwitchMainWindowFullscreenOrWindowed(); break; case 5: WindowManager.SwitchMainWindowFullScreenMonitor(); break; default: ETGModConsole.Log((object)"Unknown shortcut key", false); break; } } } internal static class WindowManager { private delegate bool MonitorEnumProc(IntPtr hMonitor, IntPtr hdcMonitor, ref RECT lprcMonitor, IntPtr dwData); private delegate void WinEventDelegate(IntPtr hWinEventHook, uint eventType, IntPtr hwnd, int idObject, int idChild, uint dwEventThread, uint dwmsEventTime); private delegate IntPtr HookProc(int nCode, IntPtr wParam, IntPtr lParam); private struct RECT { public int left; public int top; public int right; public int bottom; } private const int GWL_STYLE = -16; private const int GWL_EXSTYLE = -20; private const uint WS_POPUP = 2147483648u; private const uint WS_CAPTION = 12582912u; private const uint WS_THICKFRAME = 262144u; private const uint WS_SYSMENU = 524288u; private const uint WS_MINIMIZEBOX = 131072u; private const uint WS_MAXIMIZEBOX = 65536u; private const uint SWP_NOSIZE = 1u; private const uint SWP_NOMOVE = 2u; private const uint SWP_NOACTIVATE = 16u; private const uint SWP_NOZORDER = 4u; private const uint SWP_SHOWWINDOW = 64u; private const uint SWP_FRAMECHANGED = 32u; private const uint EVENT_OBJECT_LOCATIONCHANGE = 32779u; private const uint WINEVENT_OUTOFCONTEXT = 0u; private const uint WM_SETICON = 128u; private const int GCLP_HICON = -14; private const int GCLP_HICONSM = -34; private static IntPtr ICON_SMALL = new IntPtr(0); private static IntPtr ICON_BIG = new IntPtr(1); private static WinEventDelegate winEventDelegate; public static int referenceSecondWindowWidth; public static int referenceSecondWindowHeight; private static RECT secondWindowMonitorRect; private static int secondWindowMonitorIndex = 0; private static int destSecondWindowMonitorIndex = 0; private static int currentSecondWindowMonitorIndex = 2; private static RECT mainWindowMonitorRect; private static int mainWindowMonitorIndex = 0; private static int destMainWindowMonitorIndex = 0; private static int currentMainWindowMonitorIndex = 1; private static IntPtr windowHookID = IntPtr.Zero; private static RECT lastRect; private static IntPtr keyboardHookID = IntPtr.Zero; private static int presetStatus = 2; private static bool secondWindowFullscreenStatus = true; private static bool mainWindowFullscreenStatus = true; public static IntPtr SecondWindow => FindWindow(null, "Coop View Second Window"); public static IntPtr MainWindow => FindWindow(null, "Enter the Gungeon"); public static int SecondWindowWidth { get { IntPtr secondWindow = SecondWindow; if (secondWindow != IntPtr.Zero) { RECT lpRect = default(RECT); if (GetClientRect(secondWindow, ref lpRect)) { return lpRect.right - lpRect.left; } return -2; } return -1; } } public static int SecondWindowHeight { get { IntPtr secondWindow = SecondWindow; if (secondWindow != IntPtr.Zero) { RECT lpRect = default(RECT); if (GetClientRect(secondWindow, ref lpRect)) { return lpRect.bottom - lpRect.top; } return -2; } return -1; } } [DllImport("user32.dll")] private static extern IntPtr GetForegroundWindow(); [DllImport("user32.dll", SetLastError = true)] private static extern IntPtr GetWindowLongPtr(IntPtr hWnd, int nIndex); [DllImport("user32.dll", SetLastError = true)] private static extern IntPtr SetWindowLongPtr(IntPtr hWnd, int nIndex, IntPtr dwNewLong); [DllImport("user32.dll", SetLastError = true)] private static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags); [DllImport("user32.dll", SetLastError = true)] private static extern bool GetClientRect(IntPtr hWnd, ref RECT lpRect); [DllImport("user32.dll", SetLastError = true)] private static extern bool AdjustWindowRectEx(ref RECT lpRect, int dwStyle, bool bMenu, int dwExStyle); [DllImport("user32.dll", SetLastError = true)] private static extern IntPtr FindWindow(string lpClassName, string lpWindowName); [DllImport("user32.dll", SetLastError = true)] private static extern bool SetWindowText(IntPtr hWnd, string lpString); [DllImport("user32.dll", SetLastError = true)] private static extern IntPtr LoadIcon(IntPtr hWnd, IntPtr lpIconName); [DllImport("user32.dll", SetLastError = true)] private static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam); [DllImport("user32.dll", SetLastError = true)] private static extern IntPtr GetClassLongPtr(IntPtr hWnd, int nIndex); [DllImport("user32.dll", SetLastError = true)] private static extern bool EnumDisplayMonitors(IntPtr hdcMonitor, IntPtr lprcMonitor, MonitorEnumProc lpEnumFunc, IntPtr dwData); [DllImport("user32.dll", SetLastError = true)] private static extern IntPtr GetDC(IntPtr hWnd); [DllImport("user32.dll", SetLastError = true)] private static extern bool ReleaseDC(IntPtr hWnd, IntPtr hDC); [DllImport("user32.dll", SetLastError = true)] private static extern IntPtr SetWinEventHook(uint eventMin, uint eventMax, IntPtr hmodWinEventProc, WinEventDelegate lpfnWinEventProc, uint idProcess, uint idThread, uint dwFlags); [DllImport("user32.dll", SetLastError = true)] private static extern bool UnhookWinEvent(IntPtr hWinEventHook); [DllImport("user32.dll", SetLastError = true)] private static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId); [DllImport("user32.dll", SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] private static extern bool UnhookWindowsHookEx(IntPtr hhk); [DllImport("user32.dll")] private static extern IntPtr CallNextHookEx(IntPtr hhk, int nCode, IntPtr wParam, IntPtr lParam); [DllImport("user32.dll", SetLastError = true)] private static extern short GetAsyncKeyState(int vKey); public static void SetSecondWindowText() { IntPtr hWnd = FindWindow(null, "Unity Secondary Display"); SetWindowText(hWnd, "Coop View Second Window"); } public static void SwitchSecondWindowToFullscreen(string[] args) { if (args.Length != 0) { destSecondWindowMonitorIndex = int.Parse(args[0]); if (destSecondWindowMonitorIndex <= 0 || destSecondWindowMonitorIndex > Display.displays.Length) { destSecondWindowMonitorIndex = Display.displays.Length; } } else { destSecondWindowMonitorIndex = Display.displays.Length; } EnumDisplayMonitors(IntPtr.Zero, IntPtr.Zero, SecondWindowMonitorEnumCallback, IntPtr.Zero); if (secondWindowMonitorIndex == destSecondWindowMonitorIndex) { IntPtr secondWindow = SecondWindow; if (secondWindow != IntPtr.Zero) { SetWindowLongPtr(secondWindow, -16, (IntPtr)2147483648L); SetWindowPos(secondWindow, IntPtr.Zero, secondWindowMonitorRect.left, secondWindowMonitorRect.top, secondWindowMonitorRect.right - secondWindowMonitorRect.left, secondWindowMonitorRect.bottom - secondWindowMonitorRect.top, 84u); currentSecondWindowMonitorIndex = destSecondWindowMonitorIndex; secondWindowFullscreenStatus = true; ((MonoBehaviour)GameManager.Instance).StartCoroutine(CoopViewModule.UpdateResolution()); ETGModConsole.Log((object)$"Successfully switched second window to fullscreen, target monitor = {destSecondWindowMonitorIndex}.", false); } else { Debug.LogError((object)"Second window not found.")