Due to update 2.4.3, some mods may no longer function. FixedConfig may be necessary.
Decompiled source of KOpti v1.6.0
KOpti.dll
Decompiled 7 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using HarmonyLib; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.InputSystem.Utilities; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("KOpti")] [assembly: AssemblyCompany("Kriperovich")] [assembly: AssemblyProduct("KOpti")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("0ce876e2-dcce-4dc7-bc20-3a80bc7cdb13")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] namespace KOPTI; public class KOPTIFpsCounter : MonoBehaviour { private static readonly Color FpsTextColor = new Color(0.2f, 0.95f, 0.2f, 1f); private const int CanvasSortOrder = 9990; private GameObject _root; private TextMeshProUGUI _fpsText; private float _smoothedDeltaTime = 0.05f; private void Update() { if (!KOPTISettings.ShowFpsCounter) { if ((Object)(object)_root != (Object)null && _root.activeSelf) { _root.SetActive(false); } return; } EnsureUi(); if (!((Object)(object)_fpsText == (Object)null)) { _smoothedDeltaTime += (Time.unscaledDeltaTime - _smoothedDeltaTime) * 0.12f; if (_smoothedDeltaTime <= 0f) { _smoothedDeltaTime = 0.001f; } int num = Mathf.Clamp(Mathf.RoundToInt(1f / _smoothedDeltaTime), 0, 9999); ((TMP_Text)_fpsText).text = $"FPS:{num}"; } } private void EnsureUi() { if ((Object)(object)_root == (Object)null) { BuildUi(); } _root.SetActive(true); } private void BuildUi() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Expected O, but got Unknown //IL_00af: 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) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) _root = new GameObject("KOPTI_FpsCounter"); Object.DontDestroyOnLoad((Object)(object)_root); Canvas obj = _root.AddComponent<Canvas>(); obj.renderMode = (RenderMode)0; obj.sortingOrder = 9990; CanvasScaler obj2 = _root.AddComponent<CanvasScaler>(); obj2.uiScaleMode = (ScaleMode)1; obj2.referenceResolution = new Vector2(1920f, 1080f); _root.AddComponent<GraphicRaycaster>(); GameObject val = new GameObject("FpsText", new Type[1] { typeof(RectTransform) }); val.transform.SetParent(_root.transform, false); RectTransform component = val.GetComponent<RectTransform>(); component.anchorMin = new Vector2(0f, 1f); component.anchorMax = new Vector2(0f, 1f); component.pivot = new Vector2(0f, 1f); component.anchoredPosition = new Vector2(16f, -16f); component.sizeDelta = new Vector2(220f, 48f); _fpsText = val.AddComponent<TextMeshProUGUI>(); ((TMP_Text)_fpsText).font = ResolveGameFont(); ((TMP_Text)_fpsText).fontSize = 28f; ((TMP_Text)_fpsText).fontStyle = (FontStyles)1; ((TMP_Text)_fpsText).alignment = (TextAlignmentOptions)257; ((Graphic)_fpsText).color = FpsTextColor; ((TMP_Text)_fpsText).outlineWidth = 0.25f; ((TMP_Text)_fpsText).outlineColor = Color32.op_Implicit(Color.black); ((Graphic)_fpsText).raycastTarget = false; ((TMP_Text)_fpsText).text = "FPS:0"; } private static TMP_FontAsset ResolveGameFont() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)LocalizedText.localizationTable != (Object)null) { TMP_FontAsset font = LocalizedText.localizationTable.GetFont(Settings.Get().Language, true); if ((Object)(object)font != (Object)null) { return font; } } TextMeshProUGUI[] array = Resources.FindObjectsOfTypeAll<TextMeshProUGUI>(); foreach (TextMeshProUGUI val in array) { if ((Object)(object)val != (Object)null && (Object)(object)((TMP_Text)val).font != (Object)null) { Scene scene = ((Component)val).gameObject.scene; if (((Scene)(ref scene)).isLoaded) { return ((TMP_Text)val).font; } } } return TMP_Settings.defaultFontAsset; } } internal static class KOPTISettings { public static bool ShowFpsCounter { get; set; } public static bool DimBackgroundWhenMenuOpen { get; set; } } [HarmonyPatch(typeof(Player), "AbilityButtonIsDown")] internal static class KOPTIPatch_Player_AbilityButtonIsDown { private static bool Prefix(ref bool __result) { if (KOPTIMenuState.IsOpen) { __result = false; return false; } return true; } } [HarmonyPatch(typeof(Player), "AbilityButton_1_IsDown")] [HarmonyPatch(typeof(Player), "AbilityButton_2_IsDown")] [HarmonyPatch(typeof(Player), "AbilityButton_3_IsDown")] [HarmonyPatch(typeof(Player), "AbilityButton_1_IsDown_RAW")] [HarmonyPatch(typeof(Player), "AbilityButton_2_IsDown_RAW")] [HarmonyPatch(typeof(Player), "AbilityButton_3_IsDown_RAW")] internal static class KOPTIPatch_Player_AbilityButtons { private static bool Prefix(ref bool __result) { if (KOPTIMenuState.IsOpen) { __result = false; return false; } return true; } } internal static class KOPTIMenuState { public static bool IsOpen { get; set; } } public class KOPTIBlueWaterReplacer : MonoBehaviour { private enum ReplacementLayer { Fill, Overlay } private readonly struct WaterRegion { public float XMin { get; } public float XMax { get; } public float TopY { get; } public float BottomY { get; } public bool IsValid { get { if (XMax > XMin) { return TopY > BottomY; } return false; } } public Vector3 Center => new Vector3((XMin + XMax) * 0.5f, (TopY + BottomY) * 0.5f, 0f); public Vector2 Size => new Vector2(Mathf.Abs(XMax - XMin), Mathf.Abs(TopY - BottomY)); public WaterRegion(float xMin, float xMax, float topY, float bottomY) { XMin = xMin; XMax = xMax; TopY = topY; BottomY = bottomY; } } private static readonly Color BlueFillBackground = new Color(0.06f, 0.16f, 0.38f, 1f); private static readonly Color BlueFillOverlay = new Color(0.118f, 0.392f, 0.855f, 1f); private static readonly string[] LevelWaterVisualNames = new string[4] { "ReflectiveWater", "WaterGradient", "WaterTextureMask", "Water2D PlayerMask" }; private readonly List<GameObject> _spawnedReplacements = new List<GameObject>(); private Transform _replacementRoot; private Sprite _blueSprite; public bool IsEnabled { get; private set; } private void Awake() { SceneManager.sceneLoaded += OnSceneLoaded; } private void OnDestroy() { SceneManager.sceneLoaded -= OnSceneLoaded; ClearReplacements(); } private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { if (IsEnabled) { Apply(); } } public void SetEnabled(bool enabled) { if (IsEnabled != enabled) { IsEnabled = enabled; if (enabled) { Apply(); } else { ClearReplacements(); } } } public void Apply() { ClearReplacements(); EnsureRoot(); if (!Constants.isSpaceLevel) { if (!TryGetWaterRegions(out var fillRegion, out var overlayRegion)) { fillRegion = CreateFallbackFillRegion(); overlayRegion = CreateFallbackOverlayRegion(fillRegion); } CreateReplacementSprite(fillRegion, ReplacementLayer.Fill); CreateReplacementSprite(overlayRegion, ReplacementLayer.Overlay); } } private void EnsureRoot() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown if (!((Object)(object)_replacementRoot != (Object)null)) { GameObject val = new GameObject("KOPTI_BlueWaterReplacements"); Object.DontDestroyOnLoad((Object)(object)val); _replacementRoot = val.transform; } } private static WaterRegion CreateFallbackFillRegion() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) float xMin = (float)SceneBounds.Camera_XMin; float xMax = (float)SceneBounds.Camera_XMax; float num = (float)SceneBounds.WaterHeight; float topY = num + 8f; float bottomY = Mathf.Min(num - 18f, (float)SceneBounds.Camera_YMin); return new WaterRegion(xMin, xMax, topY, bottomY); } private static WaterRegion CreateFallbackOverlayRegion(WaterRegion fillRegion) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) float topY = (float)SceneBounds.WaterHeight; return new WaterRegion(fillRegion.XMin, fillRegion.XMax, topY, fillRegion.BottomY); } private static bool TryGetWaterRegions(out WaterRegion fillRegion, out WaterRegion overlayRegion) { //IL_0029: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0119: 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) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) fillRegion = default(WaterRegion); overlayRegion = default(WaterRegion); bool flag = false; float num = float.PositiveInfinity; float num2 = float.NegativeInfinity; float num3 = float.NegativeInfinity; float num4 = float.PositiveInfinity; float num5 = (float)SceneBounds.WaterHeight; string[] levelWaterVisualNames = LevelWaterVisualNames; for (int i = 0; i < levelWaterVisualNames.Length; i++) { foreach (GameObject item in FindLevelWaterObjects(levelWaterVisualNames[i])) { if (TryGetReplacementBounds(item, out var bounds)) { num = Mathf.Min(num, ((Bounds)(ref bounds)).min.x); num2 = Mathf.Max(num2, ((Bounds)(ref bounds)).max.x); num3 = Mathf.Max(num3, ((Bounds)(ref bounds)).max.y); num4 = Mathf.Min(num4, ((Bounds)(ref bounds)).min.y); flag = true; } } } foreach (GameObject item2 in FindLevelWaterObjects("LevelWater")) { if (TryGetReplacementBounds(item2, out var bounds2)) { num = Mathf.Min(num, ((Bounds)(ref bounds2)).min.x); num2 = Mathf.Max(num2, ((Bounds)(ref bounds2)).max.x); num3 = Mathf.Max(num3, ((Bounds)(ref bounds2)).max.y); num4 = Mathf.Min(num4, ((Bounds)(ref bounds2)).min.y); flag = true; } } foreach (GameObject item3 in FindLevelWaterObjects("WaterHitBox")) { if (TryGetReplacementBounds(item3, out var bounds3)) { num5 = Mathf.Max(num5, ((Bounds)(ref bounds3)).max.y); } } if (!flag) { return false; } fillRegion = new WaterRegion(num, num2, num3, num4); overlayRegion = new WaterRegion(num, num2, num5, num4); if (fillRegion.IsValid) { return overlayRegion.IsValid; } return false; } private void CreateReplacementSprite(WaterRegion region, ReplacementLayer layer) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown //IL_002f: 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_004f: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject((layer == ReplacementLayer.Fill) ? "KOPTI_BlueWater_Fill" : "KOPTI_BlueWater_Overlay"); val.transform.SetParent(_replacementRoot, false); val.transform.position = region.Center; SpriteRenderer obj = val.AddComponent<SpriteRenderer>(); obj.sprite = GetBlueSprite(); obj.color = ((layer == ReplacementLayer.Fill) ? BlueFillBackground : BlueFillOverlay); obj.drawMode = (SpriteDrawMode)1; obj.size = region.Size; ApplySorting(obj, layer); _spawnedReplacements.Add(val); } private static void ApplySorting(SpriteRenderer target, ReplacementLayer layer) { if (layer == ReplacementLayer.Fill) { if (!TryCopySortingFromLevelWaterObject(target, "WaterGradient", 0) && !TryCopySortingFromLevelWaterObject(target, "ReflectiveWater", 0)) { ((Renderer)target).sortingLayerName = "Default"; ((Renderer)target).sortingOrder = -500; } } else if (TryCopySortingFromLevelWaterObject(target, "Water2D PlayerMask", 0)) { BoostAboveSceneSprites(target, 50); } else if (TryCopySortingFromLevelWaterObject(target, "WaterTextureMask", 0)) { BoostAboveSceneSprites(target, 50); } else { ((Renderer)target).sortingLayerName = "Default"; BoostAboveSceneSprites(target, 100); } } private static bool TryCopySortingFromLevelWaterObject(SpriteRenderer target, string objectName, int orderOffset) { foreach (GameObject item in FindLevelWaterObjects(objectName)) { Renderer component = item.GetComponent<Renderer>(); if (!((Object)(object)component == (Object)null)) { ((Renderer)target).sortingLayerID = component.sortingLayerID; ((Renderer)target).sortingOrder = component.sortingOrder + orderOffset; return true; } } return false; } private static void BoostAboveSceneSprites(SpriteRenderer target, int orderBoost) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) int sortingLayerID = ((Renderer)target).sortingLayerID; int num = SortingLayer.GetLayerValueFromID(sortingLayerID); int sortingOrder = ((Renderer)target).sortingOrder; SpriteRenderer[] array = Resources.FindObjectsOfTypeAll<SpriteRenderer>(); foreach (SpriteRenderer val in array) { if ((Object)(object)val == (Object)null || (Object)(object)((Component)val).gameObject == (Object)null) { continue; } Scene scene = ((Component)val).gameObject.scene; if (((Scene)(ref scene)).isLoaded && !((Object)((Component)val).gameObject).name.StartsWith("KOPTI_")) { int layerValueFromID = SortingLayer.GetLayerValueFromID(((Renderer)val).sortingLayerID); if (layerValueFromID > num || (layerValueFromID == num && ((Renderer)val).sortingOrder > sortingOrder)) { sortingLayerID = ((Renderer)val).sortingLayerID; num = layerValueFromID; sortingOrder = ((Renderer)val).sortingOrder; } } } ((Renderer)target).sortingLayerID = sortingLayerID; ((Renderer)target).sortingOrder = sortingOrder + orderBoost; } private static bool TryGetReplacementBounds(GameObject sourceObject, out Bounds bounds) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) bounds = default(Bounds); bool flag = false; SpriteRenderer component = sourceObject.GetComponent<SpriteRenderer>(); Vector3 size; if ((Object)(object)component != (Object)null) { bounds = ((Renderer)component).bounds; size = ((Bounds)(ref bounds)).size; flag = ((Vector3)(ref size)).sqrMagnitude > 0.01f; } Collider2D component2 = sourceObject.GetComponent<Collider2D>(); if ((Object)(object)component2 != (Object)null) { if (!flag) { bounds = component2.bounds; size = ((Bounds)(ref bounds)).size; flag = ((Vector3)(ref size)).sqrMagnitude > 0.01f; } else { ((Bounds)(ref bounds)).Encapsulate(component2.bounds); } } Renderer component3 = sourceObject.GetComponent<Renderer>(); if ((Object)(object)component3 != (Object)null && !(component3 is SpriteRenderer)) { if (!flag) { bounds = component3.bounds; size = ((Bounds)(ref bounds)).size; flag = ((Vector3)(ref size)).sqrMagnitude > 0.01f; } else { ((Bounds)(ref bounds)).Encapsulate(component3.bounds); } } if (!flag && ((Object)sourceObject).name == "LevelWater") { Renderer[] componentsInChildren = sourceObject.GetComponentsInChildren<Renderer>(true); foreach (Renderer val in componentsInChildren) { if (!flag) { bounds = val.bounds; size = ((Bounds)(ref bounds)).size; flag = ((Vector3)(ref size)).sqrMagnitude > 0.01f; } else { ((Bounds)(ref bounds)).Encapsulate(val.bounds); } } } return flag; } private static IEnumerable<GameObject> FindLevelWaterObjects(string objectName) { foreach (GameObject item in FindObjectsByName(objectName)) { if (IsUnderLevelWater(item)) { yield return item; } } } private static bool IsUnderLevelWater(GameObject obj) { Transform val = obj.transform; while ((Object)(object)val != (Object)null) { if (((Object)val).name == "LevelWater") { return true; } if (((Object)val).name == "Background") { return false; } val = val.parent; } return false; } private Sprite GetBlueSprite() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_0022: 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_0065: 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) if ((Object)(object)_blueSprite != (Object)null) { return _blueSprite; } Texture2D val = new Texture2D(1, 1, (TextureFormat)4, false); val.SetPixel(0, 0, Color.white); val.Apply(); ((Texture)val).wrapMode = (TextureWrapMode)1; ((Texture)val).filterMode = (FilterMode)0; _blueSprite = Sprite.Create(val, new Rect(0f, 0f, 1f, 1f), new Vector2(0.5f, 0.5f), 1f, 0u, (SpriteMeshType)0, new Vector4(0f, 0f, 0f, 0f)); return _blueSprite; } private void ClearReplacements() { for (int i = 0; i < _spawnedReplacements.Count; i++) { if ((Object)(object)_spawnedReplacements[i] != (Object)null) { Object.Destroy((Object)(object)_spawnedReplacements[i]); } } _spawnedReplacements.Clear(); } private static IEnumerable<GameObject> FindObjectsByName(string objectName) { GameObject[] array = Resources.FindObjectsOfTypeAll<GameObject>(); GameObject[] array2 = array; foreach (GameObject val in array2) { if (!((Object)(object)val == (Object)null) && (int)((Object)val).hideFlags == 0) { Scene scene = val.scene; if (((Scene)(ref scene)).isLoaded && ((Object)val).name == objectName) { yield return val; } } } } } public class KOPTIDraggableWindow : MonoBehaviour, IBeginDragHandler, IEventSystemHandler, IDragHandler { private RectTransform _window; private Vector2 _dragOffset; public void SetWindow(RectTransform window) { _window = window; } public void OnBeginDrag(PointerEventData eventData) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_0052: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_window == (Object)null)) { Transform parent = ((Transform)_window).parent; RectTransform val = (RectTransform)(object)((parent is RectTransform) ? parent : null); Vector2 val2 = default(Vector2); if (!((Object)(object)val == (Object)null) && RectTransformUtility.ScreenPointToLocalPointInRectangle(val, eventData.position, eventData.pressEventCamera, ref val2)) { _dragOffset = _window.anchoredPosition - val2; } } } public void OnDrag(PointerEventData eventData) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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) if (!((Object)(object)_window == (Object)null)) { Transform parent = ((Transform)_window).parent; RectTransform val = (RectTransform)(object)((parent is RectTransform) ? parent : null); Vector2 val2 = default(Vector2); if (!((Object)(object)val == (Object)null) && RectTransformUtility.ScreenPointToLocalPointInRectangle(val, eventData.position, eventData.pressEventCamera, ref val2)) { _window.anchoredPosition = val2 + _dragOffset; } } } } internal static class KOPTIXpMenuStyles { public static readonly Color WindowBorder = new Color(0f, 0.329f, 0.89f, 1f); public static readonly Color WindowBackground = new Color(0.925f, 0.914f, 0.847f, 1f); public static readonly Color TitleBarTop = new Color(0.039f, 0.141f, 0.416f, 1f); public static readonly Color TitleBarBottom = new Color(0.192f, 0.416f, 0.773f, 1f); public static readonly Color CloseButtonNormal = new Color(0.831f, 0.282f, 0.282f, 1f); public static readonly Color CloseButtonHover = new Color(0.949f, 0.4f, 0.4f, 1f); public static readonly Color CloseButtonPressed = new Color(0.651f, 0.149f, 0.149f, 1f); public static readonly Color ListBorderDark = new Color(0.494f, 0.494f, 0.494f, 1f); public static readonly Color ListBorderLight = new Color(1f, 1f, 1f, 1f); public static readonly Color ListBackground = Color.white; public static readonly Color ListRowHover = new Color(0.192f, 0.416f, 0.773f, 1f); public static readonly Color ListRowNormalText = Color.black; public static readonly Color ListRowHoverText = Color.white; public static readonly Color SettingsButtonNormal = new Color(0.78f, 0.78f, 0.72f, 1f); public static readonly Color SettingsButtonHover = new Color(0.9f, 0.9f, 0.84f, 1f); public static readonly Color SettingsButtonPressed = new Color(0.62f, 0.62f, 0.56f, 1f); public static readonly Color MenuDimOverlay = new Color(0f, 0f, 0f, 0.72f); public static readonly Color StatusText = new Color(0.35f, 0.35f, 0.35f, 1f); public static Text CreateText(Transform parent, string text, int fontSize, TextAnchor alignment, Color color, Font font) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) GameObject obj = CreateUiObject("Text", parent); StretchToParent(obj.GetComponent<RectTransform>()); Text obj2 = obj.AddComponent<Text>(); obj2.font = font; obj2.text = text; obj2.fontSize = fontSize; obj2.alignment = alignment; ((Graphic)obj2).color = color; obj2.supportRichText = false; return obj2; } public static Button CreateCloseButton(Transform parent, Font font, UnityAction onClick) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) return CreateTitleBarButton(parent, font, "X", -4f, CloseButtonNormal, CloseButtonHover, CloseButtonPressed, Color.white, onClick); } public static Button CreateSettingsButton(Transform parent, Font font, UnityAction onClick) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) return CreateTitleBarButton(parent, font, "...", -29f, SettingsButtonNormal, SettingsButtonHover, SettingsButtonPressed, Color.black, onClick); } private static Button CreateTitleBarButton(Transform parent, Font font, string label, float anchoredRight, Color normalColor, Color hoverColor, Color pressedColor, Color labelColor, UnityAction onClick) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) GameObject val = CreateUiObject("TitleBarButton", parent); RectTransform component = val.GetComponent<RectTransform>(); component.anchorMin = new Vector2(1f, 0.5f); component.anchorMax = new Vector2(1f, 0.5f); component.pivot = new Vector2(1f, 0.5f); component.anchoredPosition = new Vector2(anchoredRight, 0f); component.sizeDelta = new Vector2(21f, 21f); Image val2 = val.AddComponent<Image>(); ((Graphic)val2).color = normalColor; Button obj = val.AddComponent<Button>(); ((Selectable)obj).targetGraphic = (Graphic)(object)val2; ColorBlock colors = ((Selectable)obj).colors; ((ColorBlock)(ref colors)).normalColor = normalColor; ((ColorBlock)(ref colors)).highlightedColor = hoverColor; ((ColorBlock)(ref colors)).pressedColor = pressedColor; ((ColorBlock)(ref colors)).selectedColor = hoverColor; ((Selectable)obj).colors = colors; ((UnityEvent)obj.onClick).AddListener(onClick); CreateText(val.transform, label, (label == "X") ? 14 : 12, (TextAnchor)4, labelColor, font); return obj; } public static GameObject CreateDimOverlay(Transform parent) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) GameObject obj = CreateUiObject("DimOverlay", parent); StretchToParent(obj.GetComponent<RectTransform>()); Image obj2 = obj.AddComponent<Image>(); ((Graphic)obj2).color = MenuDimOverlay; ((Graphic)obj2).raycastTarget = false; obj.transform.SetAsFirstSibling(); obj.SetActive(false); return obj; } public static Toggle CreateCheckboxRow(Transform parent, Font font, string label, bool isOn, UnityAction<bool> onValueChanged, float leftIndent = 0f, bool showBranchPrefix = false) { //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0153: 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_017b: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Expected O, but got Unknown //IL_0317: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0088: 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_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) GameObject val = CreateUiObject("CheckboxRow", parent); LayoutElement obj = val.AddComponent<LayoutElement>(); obj.minHeight = 24f; obj.preferredHeight = 24f; float num = 6f + leftIndent; if (showBranchPrefix) { GameObject obj2 = CreateUiObject("BranchPrefix", val.transform); RectTransform component = obj2.GetComponent<RectTransform>(); component.anchorMin = new Vector2(0f, 0.5f); component.anchorMax = new Vector2(0f, 0.5f); component.pivot = new Vector2(0f, 0.5f); component.anchoredPosition = new Vector2(num, 0f); component.sizeDelta = new Vector2(16f, 16f); Text obj3 = obj2.AddComponent<Text>(); obj3.font = font; obj3.text = "--"; obj3.fontSize = 14; obj3.alignment = (TextAnchor)3; ((Graphic)obj3).color = ListRowNormalText; ((Graphic)obj3).raycastTarget = false; num += 16f; } GameObject val2 = CreateUiObject("Checkbox", val.transform); RectTransform component2 = val2.GetComponent<RectTransform>(); component2.anchorMin = new Vector2(0f, 0.5f); component2.anchorMax = new Vector2(0f, 0.5f); component2.pivot = new Vector2(0f, 0.5f); component2.anchoredPosition = new Vector2(num, 0f); component2.sizeDelta = new Vector2(13f, 13f); Image val3 = val2.AddComponent<Image>(); ((Graphic)val3).color = ListBackground; AddSunkenBorder(val2.transform); GameObject obj4 = CreateUiObject("Checkmark", val2.transform); StretchToParent(obj4.GetComponent<RectTransform>()); Text val4 = obj4.AddComponent<Text>(); val4.font = font; val4.text = "x"; val4.fontSize = 11; val4.fontStyle = (FontStyle)1; val4.alignment = (TextAnchor)4; ((Graphic)val4).color = Color.black; ((Graphic)val4).raycastTarget = false; Toggle toggle = val2.AddComponent<Toggle>(); ((Selectable)toggle).targetGraphic = (Graphic)(object)val3; toggle.graphic = (Graphic)(object)val4; toggle.isOn = isOn; ((UnityEvent<bool>)(object)toggle.onValueChanged).AddListener(onValueChanged); GameObject val5 = CreateUiObject("Label", val.transform); RectTransform component3 = val5.GetComponent<RectTransform>(); component3.anchorMin = Vector2.zero; component3.anchorMax = Vector2.one; component3.offsetMin = new Vector2(num + 13f + 6f, 0f); component3.offsetMax = new Vector2(-6f, 0f); Image val6 = val5.AddComponent<Image>(); ((Graphic)val6).color = Color.clear; Button obj5 = val5.AddComponent<Button>(); ((Selectable)obj5).transition = (Transition)0; ((Selectable)obj5).targetGraphic = (Graphic)(object)val6; ((UnityEvent)obj5.onClick).AddListener((UnityAction)delegate { toggle.isOn = !toggle.isOn; }); GameObject obj6 = CreateUiObject("Text", val5.transform); StretchToParent(obj6.GetComponent<RectTransform>()); Text obj7 = obj6.AddComponent<Text>(); obj7.font = font; obj7.text = label; obj7.fontSize = 14; obj7.alignment = (TextAnchor)3; ((Graphic)obj7).color = ListRowNormalText; ((Graphic)obj7).raycastTarget = false; return toggle; } public static void AddSunkenBorder(Transform parent) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: 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_006b: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: 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_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) CreateBorderLine(parent, "Top", new Vector2(0f, 1f), new Vector2(1f, 1f), new Vector2(0f, 0f), new Vector2(0f, 1f), ListBorderDark); CreateBorderLine(parent, "Left", new Vector2(0f, 0f), new Vector2(0f, 1f), new Vector2(0f, 0f), new Vector2(1f, 0f), ListBorderDark); CreateBorderLine(parent, "Bottom", new Vector2(0f, 0f), new Vector2(1f, 0f), new Vector2(0f, -1f), new Vector2(0f, 0f), ListBorderLight); CreateBorderLine(parent, "Right", new Vector2(1f, 0f), new Vector2(1f, 1f), new Vector2(-1f, 0f), new Vector2(0f, 0f), ListBorderLight); } private static void CreateBorderLine(Transform parent, string name, Vector2 anchorMin, Vector2 anchorMax, Vector2 offsetMin, Vector2 offsetMax, Color color) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) GameObject obj = CreateUiObject(name, parent); RectTransform component = obj.GetComponent<RectTransform>(); component.anchorMin = anchorMin; component.anchorMax = anchorMax; component.offsetMin = offsetMin; component.offsetMax = offsetMax; Image obj2 = obj.AddComponent<Image>(); ((Graphic)obj2).color = color; ((Graphic)obj2).raycastTarget = false; } public static GameObject CreateUiObject(string name, Transform parent) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) }); val.transform.SetParent(parent, false); return val; } public static void StretchToParent(RectTransform rectTransform) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) rectTransform.anchorMin = Vector2.zero; rectTransform.anchorMax = Vector2.one; rectTransform.offsetMin = Vector2.zero; rectTransform.offsetMax = Vector2.zero; } } [BepInPlugin("com.kriperovich.kopti", "KOpti", "1.6.0")] public class KOPTIMod : BaseUnityPlugin { public const string PluginGuid = "com.kriperovich.kopti"; public const string PluginName = "KOpti"; public const string PluginVersion = "1.6.0"; private void Awake() { CharacterSelectHandler_online.clientSideMods_you_can_increment_this_to_enable_matchmaking_for_your_mods__please_dont_use_it_to_cheat_thats_really_cringe_especially_if_its_desyncing_others___you_didnt_even_win_on_your_opponents_screen___I_cannot_imagine_a_sadder_existence++; Harmony.CreateAndPatchAll(typeof(KOPTIMod).Assembly, (string)null); ((BaseUnityPlugin)this).Logger.LogInfo((object)"KOpti loaded"); ((Component)this).gameObject.AddComponent<KOPTIMenuController>(); } } public class KOPTIMenuController : MonoBehaviour { private const string CheatCode = "KOPTI"; private const float CheatCodeTimeoutSeconds = 4f; private const float NestedCheckboxIndent = 18f; private readonly StringBuilder _typedBuffer = new StringBuilder(); private float _lastKeyPressTime; private GameObject _menuRoot; private GameObject _dimOverlay; private GameObject _settingsRoot; private bool _menuVisible; private bool _settingsVisible; private Toggle _fpsCounterToggle; private Toggle _dimBackgroundToggle; private KOPTIVisualWaterRemover _visualWaterRemover; private KOPTIBlueWaterReplacer _blueWaterReplacer; private Toggle _hideWaterToggle; private Toggle _blueReplacementToggle; private GameObject _blueReplacementRow; private void Awake() { _visualWaterRemover = ((Component)this).gameObject.AddComponent<KOPTIVisualWaterRemover>(); _blueWaterReplacer = ((Component)this).gameObject.AddComponent<KOPTIBlueWaterReplacer>(); ((Component)this).gameObject.AddComponent<KOPTIFpsCounter>(); } private void Update() { HandleCheatCodeInput(); HandleMenuCloseInput(); } private void HandleCheatCodeInput() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) if (_menuVisible) { return; } if (Time.unscaledTime - _lastKeyPressTime > 4f) { _typedBuffer.Length = 0; } Keyboard current = Keyboard.current; if (current == null) { return; } Enumerator<KeyControl> enumerator = current.allKeys.GetEnumerator(); try { while (enumerator.MoveNext()) { KeyControl current2 = enumerator.Current; if (((ButtonControl)current2).wasPressedThisFrame && TryGetLetter(current2, out var letter)) { _lastKeyPressTime = Time.unscaledTime; _typedBuffer.Append(letter); if (_typedBuffer.Length > "KOPTI".Length) { _typedBuffer.Remove(0, _typedBuffer.Length - "KOPTI".Length); } if (_typedBuffer.ToString() == "KOPTI") { _typedBuffer.Length = 0; ShowMenu(); } break; } } } finally { ((IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } } private void HandleMenuCloseInput() { if (_menuVisible) { Keyboard current = Keyboard.current; if (current != null && ((ButtonControl)current.escapeKey).wasPressedThisFrame) { HideMenu(); } } } private static bool TryGetLetter(KeyControl key, out char letter) { letter = '\0'; if (key == null) { return false; } string name = ((InputControl)key).name; if (name.Length != 1) { return false; } char c = name[0]; if (!char.IsLetter(c)) { return false; } letter = char.ToUpperInvariant(c); return true; } private void ShowMenu() { if ((Object)(object)_menuRoot == (Object)null) { _menuRoot = BuildMenu(); } SyncMenuToggles(); UpdateDimOverlay(); KOPTIMenuState.IsOpen = true; _menuRoot.SetActive(true); _menuVisible = true; } private void HideMenu() { HideSettings(); if ((Object)(object)_menuRoot != (Object)null) { _menuRoot.SetActive(false); } _menuVisible = false; KOPTIMenuState.IsOpen = false; UpdateDimOverlay(); } private void ShowSettings() { if (!((Object)(object)_settingsRoot == (Object)null)) { SyncSettingsToggles(); _settingsRoot.SetActive(true); _settingsVisible = true; } } private void HideSettings() { if ((Object)(object)_settingsRoot != (Object)null) { _settingsRoot.SetActive(false); } _settingsVisible = false; } private void ToggleSettings() { if (_settingsVisible) { HideSettings(); } else { ShowSettings(); } } private void UpdateDimOverlay() { if (!((Object)(object)_dimOverlay == (Object)null)) { _dimOverlay.SetActive(_menuVisible && KOPTISettings.DimBackgroundWhenMenuOpen); } } private void OnFpsCounterToggleChanged(bool isOn) { KOPTISettings.ShowFpsCounter = isOn; } private void OnDimBackgroundToggleChanged(bool isOn) { KOPTISettings.DimBackgroundWhenMenuOpen = isOn; UpdateDimOverlay(); } private void SyncSettingsToggles() { if ((Object)(object)_fpsCounterToggle != (Object)null) { _fpsCounterToggle.SetIsOnWithoutNotify(KOPTISettings.ShowFpsCounter); } if ((Object)(object)_dimBackgroundToggle != (Object)null) { _dimBackgroundToggle.SetIsOnWithoutNotify(KOPTISettings.DimBackgroundWhenMenuOpen); } } private void OnHideWaterToggleChanged(bool isOn) { _visualWaterRemover.SetEnabled(isOn); if ((Object)(object)_blueReplacementRow != (Object)null) { _blueReplacementRow.SetActive(isOn); } if (!isOn) { _blueWaterReplacer.SetEnabled(enabled: false); if ((Object)(object)_blueReplacementToggle != (Object)null) { _blueReplacementToggle.SetIsOnWithoutNotify(false); } } } private void OnBlueReplacementToggleChanged(bool isOn) { _blueWaterReplacer.SetEnabled(isOn); } private void SyncMenuToggles() { if ((Object)(object)_hideWaterToggle != (Object)null) { _hideWaterToggle.SetIsOnWithoutNotify(_visualWaterRemover.IsEnabled); } if ((Object)(object)_blueReplacementRow != (Object)null) { _blueReplacementRow.SetActive(_visualWaterRemover.IsEnabled); } if ((Object)(object)_blueReplacementToggle != (Object)null) { _blueReplacementToggle.SetIsOnWithoutNotify(_blueWaterReplacer.IsEnabled); } } private GameObject BuildMenu() { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: 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) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_0311: Unknown result type (might be due to invalid IL or missing references) //IL_031c: Unknown result type (might be due to invalid IL or missing references) //IL_0331: Unknown result type (might be due to invalid IL or missing references) //IL_0345: Unknown result type (might be due to invalid IL or missing references) //IL_037d: Unknown result type (might be due to invalid IL or missing references) //IL_039c: Unknown result type (might be due to invalid IL or missing references) //IL_03a6: Expected O, but got Unknown //IL_03b6: Unknown result type (might be due to invalid IL or missing references) //IL_03c0: Expected O, but got Unknown //IL_03dc: Unknown result type (might be due to invalid IL or missing references) //IL_03e7: Unknown result type (might be due to invalid IL or missing references) //IL_03fc: Unknown result type (might be due to invalid IL or missing references) //IL_0410: Unknown result type (might be due to invalid IL or missing references) //IL_043c: Unknown result type (might be due to invalid IL or missing references) //IL_0451: Unknown result type (might be due to invalid IL or missing references) //IL_0466: Unknown result type (might be due to invalid IL or missing references) //IL_047b: Unknown result type (might be due to invalid IL or missing references) //IL_048f: Unknown result type (might be due to invalid IL or missing references) //IL_04bf: Unknown result type (might be due to invalid IL or missing references) //IL_04ee: Unknown result type (might be due to invalid IL or missing references) //IL_0503: Unknown result type (might be due to invalid IL or missing references) //IL_0518: Unknown result type (might be due to invalid IL or missing references) //IL_052c: Unknown result type (might be due to invalid IL or missing references) //IL_053d: Unknown result type (might be due to invalid IL or missing references) //IL_056e: Unknown result type (might be due to invalid IL or missing references) //IL_0579: Unknown result type (might be due to invalid IL or missing references) //IL_058e: Unknown result type (might be due to invalid IL or missing references) //IL_05a2: Unknown result type (might be due to invalid IL or missing references) //IL_05e5: Unknown result type (might be due to invalid IL or missing references) //IL_05ef: Expected O, but got Unknown //IL_06ac: Unknown result type (might be due to invalid IL or missing references) //IL_06c1: Unknown result type (might be due to invalid IL or missing references) //IL_06d6: Unknown result type (might be due to invalid IL or missing references) //IL_06e1: Unknown result type (might be due to invalid IL or missing references) //IL_06f5: Unknown result type (might be due to invalid IL or missing references) //IL_070c: Unknown result type (might be due to invalid IL or missing references) EnsureEventSystem(); Font builtinResource = Resources.GetBuiltinResource<Font>("LegacyRuntime.ttf"); GameObject val = KOPTIXpMenuStyles.CreateUiObject("KOPTIMenu", null); Object.DontDestroyOnLoad((Object)(object)val); Canvas obj = val.AddComponent<Canvas>(); obj.renderMode = (RenderMode)0; obj.sortingOrder = 10000; CanvasScaler obj2 = val.AddComponent<CanvasScaler>(); obj2.uiScaleMode = (ScaleMode)1; obj2.referenceResolution = new Vector2(1920f, 1080f); val.AddComponent<GraphicRaycaster>(); _dimOverlay = KOPTIXpMenuStyles.CreateDimOverlay(val.transform); GameObject val2 = KOPTIXpMenuStyles.CreateUiObject("Window", val.transform); RectTransform component = val2.GetComponent<RectTransform>(); component.anchorMin = new Vector2(0.5f, 0.5f); component.anchorMax = new Vector2(0.5f, 0.5f); component.pivot = new Vector2(0.5f, 0.5f); component.sizeDelta = new Vector2(420f, 300f); component.anchoredPosition = Vector2.zero; Image obj3 = val2.AddComponent<Image>(); ((Graphic)obj3).color = KOPTIXpMenuStyles.WindowBorder; ((Graphic)obj3).raycastTarget = true; GameObject val3 = KOPTIXpMenuStyles.CreateUiObject("Content", val2.transform); RectTransform component2 = val3.GetComponent<RectTransform>(); component2.anchorMin = Vector2.zero; component2.anchorMax = Vector2.one; component2.offsetMin = new Vector2(3f, 3f); component2.offsetMax = new Vector2(-3f, -3f); Image obj4 = val3.AddComponent<Image>(); ((Graphic)obj4).color = KOPTIXpMenuStyles.WindowBackground; ((Graphic)obj4).raycastTarget = true; GameObject val4 = KOPTIXpMenuStyles.CreateUiObject("TitleBar", val3.transform); RectTransform component3 = val4.GetComponent<RectTransform>(); component3.anchorMin = new Vector2(0f, 1f); component3.anchorMax = new Vector2(1f, 1f); component3.pivot = new Vector2(0.5f, 1f); component3.anchoredPosition = Vector2.zero; component3.sizeDelta = new Vector2(0f, 30f); GameObject obj5 = KOPTIXpMenuStyles.CreateUiObject("TitleBarTop", val4.transform); RectTransform component4 = obj5.GetComponent<RectTransform>(); component4.anchorMin = new Vector2(0f, 0.5f); component4.anchorMax = new Vector2(1f, 1f); component4.offsetMin = Vector2.zero; component4.offsetMax = Vector2.zero; Image obj6 = obj5.AddComponent<Image>(); ((Graphic)obj6).color = KOPTIXpMenuStyles.TitleBarTop; ((Graphic)obj6).raycastTarget = false; GameObject obj7 = KOPTIXpMenuStyles.CreateUiObject("TitleBarBottom", val4.transform); RectTransform component5 = obj7.GetComponent<RectTransform>(); component5.anchorMin = new Vector2(0f, 0f); component5.anchorMax = new Vector2(1f, 0.5f); component5.offsetMin = Vector2.zero; component5.offsetMax = Vector2.zero; Image obj8 = obj7.AddComponent<Image>(); ((Graphic)obj8).color = KOPTIXpMenuStyles.TitleBarBottom; ((Graphic)obj8).raycastTarget = false; Image obj9 = val4.AddComponent<Image>(); ((Graphic)obj9).color = new Color(1f, 1f, 1f, 0f); ((Graphic)obj9).raycastTarget = true; val4.AddComponent<KOPTIDraggableWindow>().SetWindow(component); GameObject obj10 = KOPTIXpMenuStyles.CreateUiObject("TitleText", val4.transform); RectTransform component6 = obj10.GetComponent<RectTransform>(); component6.anchorMin = Vector2.zero; component6.anchorMax = Vector2.one; component6.offsetMin = new Vector2(8f, 0f); component6.offsetMax = new Vector2(-56f, 0f); Text obj11 = obj10.AddComponent<Text>(); obj11.font = builtinResource; obj11.text = "KOpti"; obj11.fontSize = 13; obj11.fontStyle = (FontStyle)1; obj11.alignment = (TextAnchor)3; ((Graphic)obj11).color = Color.white; ((Graphic)obj11).raycastTarget = false; KOPTIXpMenuStyles.CreateSettingsButton(val4.transform, builtinResource, new UnityAction(ToggleSettings)); KOPTIXpMenuStyles.CreateCloseButton(val4.transform, builtinResource, new UnityAction(HideMenu)); GameObject val5 = KOPTIXpMenuStyles.CreateUiObject("ClientArea", val3.transform); RectTransform component7 = val5.GetComponent<RectTransform>(); component7.anchorMin = Vector2.zero; component7.anchorMax = Vector2.one; component7.offsetMin = new Vector2(8f, 28f); component7.offsetMax = new Vector2(-8f, -34f); GameObject obj12 = KOPTIXpMenuStyles.CreateUiObject("SectionLabel", val5.transform); RectTransform component8 = obj12.GetComponent<RectTransform>(); component8.anchorMin = new Vector2(0f, 1f); component8.anchorMax = new Vector2(1f, 1f); component8.pivot = new Vector2(0.5f, 1f); component8.anchoredPosition = new Vector2(0f, 0f); component8.sizeDelta = new Vector2(0f, 18f); Text obj13 = obj12.AddComponent<Text>(); obj13.font = builtinResource; obj13.text = "Features"; obj13.fontSize = 13; obj13.alignment = (TextAnchor)3; ((Graphic)obj13).color = Color.black; GameObject val6 = KOPTIXpMenuStyles.CreateUiObject("ListFrame", val5.transform); RectTransform component9 = val6.GetComponent<RectTransform>(); component9.anchorMin = new Vector2(0f, 0f); component9.anchorMax = new Vector2(1f, 1f); component9.offsetMin = new Vector2(0f, 0f); component9.offsetMax = new Vector2(0f, -22f); ((Graphic)val6.AddComponent<Image>()).color = KOPTIXpMenuStyles.ListBackground; KOPTIXpMenuStyles.AddSunkenBorder(val6.transform); GameObject val7 = KOPTIXpMenuStyles.CreateUiObject("ListViewport", val6.transform); RectTransform component10 = val7.GetComponent<RectTransform>(); component10.anchorMin = Vector2.zero; component10.anchorMax = Vector2.one; component10.offsetMin = new Vector2(2f, 2f); component10.offsetMax = new Vector2(-2f, -2f); VerticalLayoutGroup obj14 = val7.AddComponent<VerticalLayoutGroup>(); ((LayoutGroup)obj14).childAlignment = (TextAnchor)0; ((HorizontalOrVerticalLayoutGroup)obj14).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)obj14).childControlHeight = true; ((HorizontalOrVerticalLayoutGroup)obj14).childForceExpandWidth = true; ((HorizontalOrVerticalLayoutGroup)obj14).childForceExpandHeight = false; ((HorizontalOrVerticalLayoutGroup)obj14).spacing = 0f; ((LayoutGroup)obj14).padding = new RectOffset(0, 0, 0, 0); _hideWaterToggle = KOPTIXpMenuStyles.CreateCheckboxRow(val7.transform, builtinResource, "Hide Water", _visualWaterRemover.IsEnabled, OnHideWaterToggleChanged); _blueReplacementToggle = KOPTIXpMenuStyles.CreateCheckboxRow(val7.transform, builtinResource, "Replace With Blue Rectangle", _blueWaterReplacer.IsEnabled, OnBlueReplacementToggleChanged, 18f, showBranchPrefix: true); _blueReplacementRow = ((Component)((Component)_blueReplacementToggle).transform.parent).gameObject; _blueReplacementRow.SetActive(_visualWaterRemover.IsEnabled); GameObject obj15 = KOPTIXpMenuStyles.CreateUiObject("StatusBar", val3.transform); RectTransform component11 = obj15.GetComponent<RectTransform>(); component11.anchorMin = new Vector2(0f, 0f); component11.anchorMax = new Vector2(1f, 0f); component11.pivot = new Vector2(0.5f, 0f); component11.anchoredPosition = Vector2.zero; component11.sizeDelta = new Vector2(0f, 22f); KOPTIXpMenuStyles.CreateText(obj15.transform, "Esc to close", 12, (TextAnchor)3, KOPTIXpMenuStyles.StatusText, builtinResource); _settingsRoot = BuildSettingsWindow(val.transform, builtinResource); _settingsRoot.SetActive(false); val.SetActive(false); return val; } private GameObject BuildSettingsWindow(Transform parent, Font font) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00af: 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) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_017d: 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_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_02ff: Expected O, but got Unknown //IL_031a: Unknown result type (might be due to invalid IL or missing references) //IL_0325: Unknown result type (might be due to invalid IL or missing references) //IL_033a: Unknown result type (might be due to invalid IL or missing references) //IL_034e: Unknown result type (might be due to invalid IL or missing references) //IL_0373: Unknown result type (might be due to invalid IL or missing references) //IL_037e: Unknown result type (might be due to invalid IL or missing references) //IL_0389: Unknown result type (might be due to invalid IL or missing references) //IL_0393: Unknown result type (might be due to invalid IL or missing references) //IL_03a4: Unknown result type (might be due to invalid IL or missing references) //IL_03d5: Unknown result type (might be due to invalid IL or missing references) //IL_03e0: Unknown result type (might be due to invalid IL or missing references) //IL_03f5: Unknown result type (might be due to invalid IL or missing references) //IL_0409: Unknown result type (might be due to invalid IL or missing references) GameObject val = KOPTIXpMenuStyles.CreateUiObject("SettingsWindow", parent); RectTransform component = val.GetComponent<RectTransform>(); component.anchorMin = new Vector2(0.5f, 0.5f); component.anchorMax = new Vector2(0.5f, 0.5f); component.pivot = new Vector2(0.5f, 0.5f); component.sizeDelta = new Vector2(380f, 240f); component.anchoredPosition = new Vector2(0f, -20f); ((Graphic)val.AddComponent<Image>()).color = KOPTIXpMenuStyles.WindowBorder; GameObject val2 = KOPTIXpMenuStyles.CreateUiObject("Content", val.transform); RectTransform component2 = val2.GetComponent<RectTransform>(); component2.anchorMin = Vector2.zero; component2.anchorMax = Vector2.one; component2.offsetMin = new Vector2(3f, 3f); component2.offsetMax = new Vector2(-3f, -3f); ((Graphic)val2.AddComponent<Image>()).color = KOPTIXpMenuStyles.WindowBackground; GameObject val3 = KOPTIXpMenuStyles.CreateUiObject("TitleBar", val2.transform); RectTransform component3 = val3.GetComponent<RectTransform>(); component3.anchorMin = new Vector2(0f, 1f); component3.anchorMax = new Vector2(1f, 1f); component3.pivot = new Vector2(0.5f, 1f); component3.sizeDelta = new Vector2(0f, 30f); GameObject obj = KOPTIXpMenuStyles.CreateUiObject("TitleBarTop", val3.transform); RectTransform component4 = obj.GetComponent<RectTransform>(); component4.anchorMin = new Vector2(0f, 0.5f); component4.anchorMax = new Vector2(1f, 1f); component4.offsetMin = Vector2.zero; component4.offsetMax = Vector2.zero; ((Graphic)obj.AddComponent<Image>()).color = KOPTIXpMenuStyles.TitleBarTop; GameObject obj2 = KOPTIXpMenuStyles.CreateUiObject("TitleBarBottom", val3.transform); RectTransform component5 = obj2.GetComponent<RectTransform>(); component5.anchorMin = new Vector2(0f, 0f); component5.anchorMax = new Vector2(1f, 0.5f); component5.offsetMin = Vector2.zero; component5.offsetMax = Vector2.zero; ((Graphic)obj2.AddComponent<Image>()).color = KOPTIXpMenuStyles.TitleBarBottom; ((Graphic)val3.AddComponent<Image>()).color = new Color(1f, 1f, 1f, 0f); val3.AddComponent<KOPTIDraggableWindow>().SetWindow(component); GameObject obj3 = KOPTIXpMenuStyles.CreateUiObject("TitleText", val3.transform); RectTransform component6 = obj3.GetComponent<RectTransform>(); component6.anchorMin = Vector2.zero; component6.anchorMax = Vector2.one; component6.offsetMin = new Vector2(8f, 0f); component6.offsetMax = new Vector2(-30f, 0f); Text obj4 = obj3.AddComponent<Text>(); obj4.font = font; obj4.text = "Settings"; obj4.fontSize = 13; obj4.fontStyle = (FontStyle)1; obj4.alignment = (TextAnchor)3; ((Graphic)obj4).color = Color.white; ((Graphic)obj4).raycastTarget = false; KOPTIXpMenuStyles.CreateCloseButton(val3.transform, font, new UnityAction(HideSettings)); GameObject val4 = KOPTIXpMenuStyles.CreateUiObject("ClientArea", val2.transform); RectTransform component7 = val4.GetComponent<RectTransform>(); component7.anchorMin = Vector2.zero; component7.anchorMax = Vector2.one; component7.offsetMin = new Vector2(8f, 28f); component7.offsetMax = new Vector2(-8f, -8f); GameObject val5 = KOPTIXpMenuStyles.CreateUiObject("ListFrame", val4.transform); RectTransform component8 = val5.GetComponent<RectTransform>(); component8.anchorMin = Vector2.zero; component8.anchorMax = Vector2.one; component8.offsetMin = Vector2.zero; component8.offsetMax = Vector2.zero; ((Graphic)val5.AddComponent<Image>()).color = KOPTIXpMenuStyles.ListBackground; KOPTIXpMenuStyles.AddSunkenBorder(val5.transform); GameObject val6 = KOPTIXpMenuStyles.CreateUiObject("ListViewport", val5.transform); RectTransform component9 = val6.GetComponent<RectTransform>(); component9.anchorMin = Vector2.zero; component9.anchorMax = Vector2.one; component9.offsetMin = new Vector2(2f, 2f); component9.offsetMax = new Vector2(-2f, -2f); VerticalLayoutGroup obj5 = val6.AddComponent<VerticalLayoutGroup>(); ((LayoutGroup)obj5).childAlignment = (TextAnchor)0; ((HorizontalOrVerticalLayoutGroup)obj5).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)obj5).childControlHeight = true; ((HorizontalOrVerticalLayoutGroup)obj5).childForceExpandWidth = true; ((HorizontalOrVerticalLayoutGroup)obj5).childForceExpandHeight = false; _fpsCounterToggle = KOPTIXpMenuStyles.CreateCheckboxRow(val6.transform, font, "Show FPS Counter", KOPTISettings.ShowFpsCounter, OnFpsCounterToggleChanged); _dimBackgroundToggle = KOPTIXpMenuStyles.CreateCheckboxRow(val6.transform, font, "Dim Background When Menu Open", KOPTISettings.DimBackgroundWhenMenuOpen, OnDimBackgroundToggleChanged); return val; } private static void EnsureEventSystem() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Object.FindObjectOfType<EventSystem>() != (Object)null)) { GameObject val = new GameObject("KOPTI_EventSystem"); Object.DontDestroyOnLoad((Object)val); val.AddComponent<EventSystem>(); val.AddComponent<StandaloneInputModule>(); } } } public class KOPTIVisualWaterRemover : MonoBehaviour { private static readonly string[] VisualWaterObjectNames = new string[5] { "ReflectiveWater", "Water2D PlayerMask", "WaterTextureMask", "WaterGradient", "platform+WaterMaskCamera" }; private readonly Dictionary<int, bool> _savedActiveStates = new Dictionary<int, bool>(); public bool IsEnabled { get; private set; } private void Awake() { SceneManager.sceneLoaded += OnSceneLoaded; } private void OnDestroy() { SceneManager.sceneLoaded -= OnSceneLoaded; } private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { if (IsEnabled) { Apply(); } } public void SetEnabled(bool enabled) { if (IsEnabled != enabled) { IsEnabled = enabled; if (enabled) { Apply(); } else { Restore(); } } } public void Apply() { string[] visualWaterObjectNames = VisualWaterObjectNames; for (int i = 0; i < visualWaterObjectNames.Length; i++) { foreach (GameObject item in FindObjectsByName(visualWaterObjectNames[i])) { if (ShouldHideWaterObject(item)) { int instanceID = ((Object)item).GetInstanceID(); if (!_savedActiveStates.ContainsKey(instanceID)) { _savedActiveStates[instanceID] = item.activeSelf; } item.SetActive(false); } } } } private static bool ShouldHideWaterObject(GameObject target) { if (((Object)target).name == "platform+WaterMaskCamera") { return true; } Transform val = target.transform; while ((Object)(object)val != (Object)null) { if (((Object)val).name == "LevelWater") { return true; } if (((Object)val).name == "Background") { return false; } val = val.parent; } return false; } private void Restore() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) GameObject[] array = Resources.FindObjectsOfTypeAll<GameObject>(); foreach (GameObject val in array) { if ((Object)(object)val == (Object)null) { continue; } int instanceID = ((Object)val).GetInstanceID(); if (_savedActiveStates.TryGetValue(instanceID, out var value)) { Scene scene = val.scene; if (((Scene)(ref scene)).isLoaded) { val.SetActive(value); } } } _savedActiveStates.Clear(); } private static IEnumerable<GameObject> FindObjectsByName(string objectName) { GameObject[] array = Resources.FindObjectsOfTypeAll<GameObject>(); GameObject[] array2 = array; foreach (GameObject val in array2) { if (!((Object)(object)val == (Object)null) && (int)((Object)val).hideFlags == 0) { Scene scene = val.scene; if (((Scene)(ref scene)).isLoaded && ((Object)val).name == objectName) { yield return val; } } } } }