Decompiled source of Onion QOL v0.1.1
BepInEx/plugins/OnionQOL-Onion_QOL/OnionQOL.dll
Decompiled 10 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using DiskCardGame; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")] [assembly: AssemblyCompany("OnionQOL")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.1.0.0")] [assembly: AssemblyInformationalVersion("0.1.0+e00c83018dbd2f1af230f6c008efad4b70f41747")] [assembly: AssemblyProduct("OnionQOL")] [assembly: AssemblyTitle("OnionQOL")] [assembly: AssemblyVersion("0.1.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace OnionQOL { public enum DeckWindowMode { Deck, DrawPile } public class DeckWindow : MonoBehaviour { public static DeckWindow Instance; private const int DisplayLayer = 31; private const float BackgroundAlpha = 0.7f; private GameObject displayRoot; private Camera renderCamera; private RenderTexture renderTexture; private GameObject uiRoot; private static Vector2 cardSize = new Vector2(1.4f, 2f); private RectTransform rawRect; private Text hintText; private GameObject hoveredCard; private Vector3 hoveredOriginalPos; private Vector3 hoveredOriginalRot; private Vector3 hoveredOriginalScale; private readonly List<GameObject> spawnedCards = new List<GameObject>(); private GameObject encyclopediaPanel; private Text encyclopediaTitle; private Text encyclopediaBody; private ViewLockState cachedLockState; private bool restoredLockOnce; private string openedScene = string.Empty; private static bool layoutLoaded; private static GameObject cardPrefab; private static DeckWindowMode windowMode = DeckWindowMode.Deck; private static int maxRows = 2; private static int maxCardsPerRow = 10; private static float rowSpacing = 2f; private static float arrayWidth = 7f; private static float leftAnchor = -3.25f; private static float curveFactor = 1f; public static void Open(DeckWindowMode mode) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown if (!((Object)(object)Instance != (Object)null)) { windowMode = mode; GameObject val = new GameObject("OnionQOL_DeckWindow"); Object.DontDestroyOnLoad((Object)val); Instance = val.AddComponent<DeckWindow>(); Instance.Build(); } } public static void Close() { if (!((Object)(object)Instance == (Object)null)) { Instance.Teardown(); Object.Destroy((Object)(object)((Component)Instance).gameObject); Instance = null; } } private void Update() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) if (!string.IsNullOrEmpty(openedScene)) { Scene activeScene = SceneManager.GetActiveScene(); if (((Scene)(ref activeScene)).name != openedScene) { goto IL_0053; } } if (!((Object)(object)Singleton<ViewManager>.Instance == (Object)null) && SaveManager.SaveFile != null && (windowMode != DeckWindowMode.DrawPile || !((Object)(object)Singleton<CardDrawPiles>.Instance == (Object)null))) { UpdateEncyclopediaInput(); UpdateHover(); if ((Object)(object)hintText != (Object)null) { hintText.text = "[" + CloseKey() + "] 关闭"; } return; } goto IL_0053; IL_0053: ManualLogSource log = OnionQOLPlugin.Log; if (log != null) { log.LogWarning((object)"Onion QOL: 场景已切换,关闭牌组窗口"); } Close(); } private static string CloseKey() { //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_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) if (windowMode != DeckWindowMode.DrawPile) { return ((object)OnionQOLPlugin.DeckViewerKey.Value/*cast due to .constrained prefix*/).ToString(); } return ((object)OnionQOLPlugin.DrawPileKey.Value/*cast due to .constrained prefix*/).ToString(); } private void OnDestroy() { Teardown(); } private void Build() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) try { Scene activeScene = SceneManager.GetActiveScene(); openedScene = ((Scene)(ref activeScene)).name; List<CardInfo> cards = GetCards(windowMode); if (cards == null || cards.Count == 0) { ManualLogSource log = OnionQOLPlugin.Log; if (log != null) { log.LogWarning((object)"Onion QOL: 当前牌组/抽牌堆为空"); } Close(); return; } LoadLayoutData(); if ((Object)(object)cardPrefab == (Object)null) { ManualLogSource log2 = OnionQOLPlugin.Log; if (log2 != null) { log2.LogError((object)"Onion QOL: 未能取得 3D 卡面 prefab,无法建立牌组窗口"); } Close(); } else { BuildDisplaySpace(cards); BuildRenderCamera(); BuildUi(cards.Count); LockPlayerInput(); HideCursor(); } } catch (Exception ex) { ManualLogSource log3 = OnionQOLPlugin.Log; if (log3 != null) { log3.LogError((object)("Onion QOL: 建立牌组窗口失败: " + ex)); } Close(); } } private static List<CardInfo> GetCards(DeckWindowMode mode) { try { if (mode == DeckWindowMode.DrawPile) { CardDrawPiles instance = Singleton<CardDrawPiles>.Instance; if ((Object)(object)instance == (Object)null || (Object)(object)instance.Deck == (Object)null) { return null; } return new List<CardInfo>(instance.Deck.Cards); } if (SaveManager.SaveFile == null) { return null; } return new List<CardInfo>(((CardCollectionInfo)SaveManager.SaveFile.CurrentDeck).Cards); } catch (Exception ex) { ManualLogSource log = OnionQOLPlugin.Log; if (log != null) { log.LogError((object)("Onion QOL: 读取牌组/抽牌堆失败: " + ex)); } return null; } } private static void LoadLayoutData() { if (layoutLoaded) { return; } layoutLoaded = true; try { DeckReviewSequencer instance = Singleton<DeckReviewSequencer>.Instance; if ((Object)(object)instance == (Object)null) { ManualLogSource log = OnionQOLPlugin.Log; if (log != null) { log.LogWarning((object)"Onion QOL: 当前场景没有 DeckReviewSequencer,使用默认卡面布局参数"); } return; } object? obj = AccessTools.Field(typeof(DeckReviewSequencer), "cardArray")?.GetValue(instance); SelectableCardArray val = (SelectableCardArray)((obj is SelectableCardArray) ? obj : null); if (!((Object)(object)val == (Object)null)) { object? obj2 = AccessTools.Field(typeof(SelectableCardArray), "selectableCardPrefab")?.GetValue(val); cardPrefab = (GameObject)((obj2 is GameObject) ? obj2 : null); maxRows = ReadInt(val, "maxRows", maxRows); maxCardsPerRow = ReadInt(val, "maxCardsPerRow", maxCardsPerRow); rowSpacing = ReadFloat(val, "rowSpacing", rowSpacing); arrayWidth = ReadFloat(val, "arrayWidth", arrayWidth); leftAnchor = ReadFloat(val, "leftAnchor", leftAnchor); curveFactor = ReadFloat(val, "curveFactor", curveFactor); } } catch (Exception ex) { ManualLogSource log2 = OnionQOLPlugin.Log; if (log2 != null) { log2.LogError((object)("Onion QOL: 读取原版布局参数失败: " + ex)); } } } private static int ReadInt(object target, string field, int fallback) { try { return (AccessTools.Field(target.GetType(), field)?.GetValue(target) is int num) ? num : fallback; } catch { return fallback; } } private static float ReadFloat(object target, string field, float fallback) { try { return (AccessTools.Field(target.GetType(), field)?.GetValue(target) is float num) ? num : fallback; } catch { return fallback; } } private void BuildDisplaySpace(List<CardInfo> cards) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: 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_00bc: 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_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: 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_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_0100: 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) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) displayRoot = new GameObject("OnionQOL_DeckDisplay"); displayRoot.transform.position = new Vector3(0f, 5000f, 0f); int num = Mathf.Min(cards.Count / (maxCardsPerRow + 1) + 1, Mathf.Max(1, maxRows)); int cardsPerRow = Mathf.Max(1, cards.Count / num); for (int i = 0; i < cards.Count; i++) { Vector4 cardPositionAndRotation = GetCardPositionAndRotation(i, cards.Count, num, cardsPerRow); GameObject val = Object.Instantiate<GameObject>(cardPrefab, displayRoot.transform); ((Object)val).name = "OnionQOL_Card_" + i; val.transform.localPosition = new Vector3(cardPositionAndRotation.x, cardPositionAndRotation.y, cardPositionAndRotation.z); if (i == 0) { Bounds cardBounds = GetCardBounds(val); if (((Bounds)(ref cardBounds)).size.x > 0.01f && ((Bounds)(ref cardBounds)).size.y > 0.01f) { cardSize = new Vector2(((Bounds)(ref cardBounds)).size.x, ((Bounds)(ref cardBounds)).size.y); } } val.transform.localRotation = Quaternion.Euler(90f, 0f, cardPositionAndRotation.w); SelectableCard component = val.GetComponent<SelectableCard>(); if ((Object)(object)component != (Object)null) { component.Initialize(cards[i], (Action<SelectableCard>)null, (Action<SelectableCard>)null, false, (Action<SelectableCard>)null); component.SetParticlesEnabled(false); ((Card)component).SetInteractionEnabled(false); } AbilityIconInteractable[] componentsInChildren = val.GetComponentsInChildren<AbilityIconInteractable>(true); for (int j = 0; j < componentsInChildren.Length; j++) { ((InteractableBase)componentsInChildren[j]).SetEnabled(true); } SetLayerRecursive(val, 31); SetCardRenderQueue(val, 3000 + i * 10); spawnedCards.Add(val); } } private static void SetCardRenderQueue(GameObject cardGo, int queue) { try { Renderer[] componentsInChildren = cardGo.GetComponentsInChildren<Renderer>(true); for (int i = 0; i < componentsInChildren.Length; i++) { Material[] materials = componentsInChildren[i].materials; for (int j = 0; j < materials.Length; j++) { materials[j].renderQueue = queue; } } } catch (Exception ex) { ManualLogSource log = OnionQOLPlugin.Log; if (log != null) { log.LogWarning((object)("Onion QOL: 设置卡牌渲染顺序失败: " + ex)); } } } private static Bounds GetCardBounds(GameObject go) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) Bounds bounds = default(Bounds); ((Bounds)(ref bounds))..ctor(go.transform.position, Vector3.zero); bool flag = false; Renderer[] componentsInChildren = go.GetComponentsInChildren<Renderer>(true); foreach (Renderer val in componentsInChildren) { if (!flag) { bounds = val.bounds; flag = true; } else { ((Bounds)(ref bounds)).Encapsulate(val.bounds); } } return bounds; } private static Vector4 GetCardPositionAndRotation(int cardIndex, int numCards, int numRows, int cardsPerRow) { //IL_00ca: Unknown result type (might be due to invalid IL or missing references) int num = Mathf.Min(numRows - 1, Mathf.FloorToInt((float)cardIndex / (float)cardsPerRow)); int num2 = ((num == numRows - 1) ? (numCards - num * cardsPerRow) : cardsPerRow); float num3 = arrayWidth / (float)num2; float num4 = leftAnchor + num3 * 0.5f; float num5 = num4 + num3 * (float)(cardIndex % num2); float num6 = Mathf.Abs(num5 - num4) / arrayWidth; num6 = num6 * 2f - 1f; float num7 = num6 * -11f * curveFactor; float num8 = rowSpacing * (float)num; float num9 = 0f - rowSpacing * (float)(numRows - 1) * 0.5f + num8 + 0.25f * (0f - Mathf.Abs(num6)) * curveFactor; float num10 = 0.01f - 0.00015f * (float)(numCards - 1 - cardIndex); return new Vector4(num5, num10, num9, num7); } private static void SetLayerRecursive(GameObject go, int layer) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) go.layer = layer; foreach (Transform item in go.transform) { SetLayerRecursive(((Component)item).gameObject, layer); } } private void BuildRenderCamera() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0036: 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_0092: 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_0110: Expected O, but got Unknown GameObject val = new GameObject("OnionQOL_DeckCamera"); val.transform.SetParent(displayRoot.transform); val.transform.localPosition = new Vector3(0f, 9.5f, -2.6f); val.transform.LookAt(displayRoot.transform.position, Vector3.up); renderCamera = val.AddComponent<Camera>(); renderCamera.clearFlags = (CameraClearFlags)2; renderCamera.backgroundColor = new Color(0f, 0f, 0f, 0f); renderCamera.cullingMask = int.MinValue; renderCamera.fieldOfView = 45f; renderCamera.nearClipPlane = 0.1f; renderCamera.farClipPlane = 100f; renderCamera.depth = -10f; ((Behaviour)renderCamera).enabled = true; renderTexture = new RenderTexture(1920, 1080, 16, (RenderTextureFormat)0); ((Texture)renderTexture).filterMode = (FilterMode)1; renderCamera.targetTexture = renderTexture; AddDisplayLight(); } private void AddDisplayLight() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_009a: 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_00ea: Unknown result type (might be due to invalid IL or missing references) try { GameObject val = new GameObject("OnionQOL_DeckLight"); val.transform.SetParent(displayRoot.transform); val.transform.localPosition = new Vector3(0f, 12f, 0f); Light obj = val.AddComponent<Light>(); obj.type = (LightType)2; obj.range = 80f; obj.intensity = 1f; obj.color = new Color(1f, 0.9f, 0.78f); GameObject val2 = new GameObject("OnionQOL_DeckLight2"); val2.transform.SetParent(displayRoot.transform); val2.transform.localPosition = new Vector3(0f, 4f, 8f); Light obj2 = val2.AddComponent<Light>(); obj2.type = (LightType)2; obj2.range = 50f; obj2.intensity = 0.45f; obj2.color = new Color(1f, 0.85f, 0.7f); } catch (Exception ex) { ManualLogSource log = OnionQOLPlugin.Log; if (log != null) { log.LogWarning((object)("Onion QOL: 添加展示灯光失败: " + ex)); } } } private void BuildUi(int cardCount) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0145: 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_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0223: 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_028e: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Unknown result type (might be due to invalid IL or missing references) uiRoot = new GameObject("OnionQOL_DeckUI", new Type[1] { typeof(RectTransform) }); Object.DontDestroyOnLoad((Object)(object)uiRoot); Canvas obj = uiRoot.AddComponent<Canvas>(); obj.renderMode = (RenderMode)0; obj.sortingOrder = 30000; CanvasScaler obj2 = uiRoot.AddComponent<CanvasScaler>(); obj2.uiScaleMode = (ScaleMode)1; obj2.referenceResolution = new Vector2(1920f, 1080f); obj2.matchWidthOrHeight = 0.5f; uiRoot.AddComponent<GraphicRaycaster>(); Font chineseFont = GetChineseFont(); GameObject obj3 = CreateUiObject("Background", uiRoot.transform); ((Graphic)obj3.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0.7f); Stretch(obj3.GetComponent<RectTransform>()); string content = ((windowMode == DeckWindowMode.DrawPile) ? ("抽牌堆(" + cardCount + " 张)") : ("本局牌组(" + cardCount + " 张)")); RectTransform rectTransform = ((Graphic)CreateText("Title", uiRoot.transform, chineseFont, 40, content)).rectTransform; rectTransform.anchorMin = new Vector2(0.5f, 1f); rectTransform.anchorMax = new Vector2(0.5f, 1f); rectTransform.pivot = new Vector2(0.5f, 1f); rectTransform.anchoredPosition = new Vector2(0f, -40f); rectTransform.sizeDelta = new Vector2(1200f, 80f); GameObject obj4 = CreateUiObject("DeckView", uiRoot.transform); RawImage obj5 = obj4.AddComponent<RawImage>(); obj5.texture = (Texture)(object)renderTexture; ((Graphic)obj5).color = Color.white; RectTransform component = obj4.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.anchoredPosition = new Vector2(0f, 0f); component.sizeDelta = new Vector2(1760f, 990f); rawRect = component; RectTransform rectTransform2 = ((Graphic)(hintText = CreateText("Hint", uiRoot.transform, chineseFont, 30, "[" + CloseKey() + "] 关闭"))).rectTransform; rectTransform2.anchorMin = new Vector2(0.5f, 0f); rectTransform2.anchorMax = new Vector2(0.5f, 0f); rectTransform2.pivot = new Vector2(0.5f, 0f); rectTransform2.anchoredPosition = new Vector2(0f, 40f); rectTransform2.sizeDelta = new Vector2(600f, 60f); BuildEncyclopediaPanel(chineseFont); } private void BuildEncyclopediaPanel(Font font) { //IL_0031: 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_005b: 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_007a: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0110: 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_0139: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: 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_0215: 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_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) encyclopediaPanel = CreateUiObject("Encyclopedia", uiRoot.transform); RectTransform component = encyclopediaPanel.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.anchoredPosition = Vector2.zero; component.sizeDelta = new Vector2(1000f, 640f); ((Graphic)encyclopediaPanel.AddComponent<Image>()).color = new Color(0.04f, 0.04f, 0.04f, 0.97f); encyclopediaTitle = CreateText("EncyclopediaTitle", encyclopediaPanel.transform, font, 36, string.Empty); RectTransform rectTransform = ((Graphic)encyclopediaTitle).rectTransform; rectTransform.anchorMin = new Vector2(0f, 1f); rectTransform.anchorMax = new Vector2(1f, 1f); rectTransform.pivot = new Vector2(0.5f, 1f); rectTransform.anchoredPosition = new Vector2(0f, -28f); rectTransform.sizeDelta = new Vector2(-60f, 70f); encyclopediaBody = CreateText("EncyclopediaBody", encyclopediaPanel.transform, font, 26, string.Empty); encyclopediaBody.alignment = (TextAnchor)0; encyclopediaBody.horizontalOverflow = (HorizontalWrapMode)0; encyclopediaBody.verticalOverflow = (VerticalWrapMode)0; RectTransform rectTransform2 = ((Graphic)encyclopediaBody).rectTransform; rectTransform2.anchorMin = new Vector2(0f, 0f); rectTransform2.anchorMax = new Vector2(1f, 1f); rectTransform2.offsetMin = new Vector2(50f, 90f); rectTransform2.offsetMax = new Vector2(-50f, -110f); RectTransform rectTransform3 = ((Graphic)CreateText("EncyclopediaHint", encyclopediaPanel.transform, font, 24, "[右键] 关闭")).rectTransform; rectTransform3.anchorMin = new Vector2(0.5f, 0f); rectTransform3.anchorMax = new Vector2(0.5f, 0f); rectTransform3.pivot = new Vector2(0.5f, 0f); rectTransform3.anchoredPosition = new Vector2(0f, 24f); rectTransform3.sizeDelta = new Vector2(500f, 50f); encyclopediaPanel.SetActive(false); } private void UpdateEncyclopediaInput() { if (!Input.GetMouseButtonDown(1)) { return; } if ((Object)(object)encyclopediaPanel != (Object)null && encyclopediaPanel.activeSelf) { encyclopediaPanel.SetActive(false); return; } AbilityInfo hoveredAbilityInfo = GetHoveredAbilityInfo(); if ((Object)(object)hoveredAbilityInfo != (Object)null) { ShowEncyclopedia(hoveredAbilityInfo); } } private AbilityInfo GetHoveredAbilityInfo() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006e: 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_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0090: 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_00cd: 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_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)renderCamera == (Object)null || (Object)(object)rawRect == (Object)null || (Object)(object)renderTexture == (Object)null) { return null; } if (!RectTransformUtility.RectangleContainsScreenPoint(rawRect, Vector2.op_Implicit(Input.mousePosition), (Camera)null)) { return null; } Vector2 val = default(Vector2); if (!RectTransformUtility.ScreenPointToLocalPointInRectangle(rawRect, Vector2.op_Implicit(Input.mousePosition), (Camera)null, ref val)) { return null; } float x = val.x; Rect rect = rawRect.rect; float num = x / ((Rect)(ref rect)).width + 0.5f; float y = val.y; rect = rawRect.rect; float num2 = y / ((Rect)(ref rect)).height + 0.5f; RaycastHit val2 = default(RaycastHit); if (Physics.Raycast(renderCamera.ScreenPointToRay(new Vector3(num * (float)((Texture)renderTexture).width, num2 * (float)((Texture)renderTexture).height, 0f)), ref val2, 300f, int.MinValue)) { AbilityIconInteractable componentInParent = ((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent<AbilityIconInteractable>(); if ((Object)(object)componentInParent != (Object)null && (int)componentInParent.Ability != 0) { return AbilitiesUtil.GetInfo(componentInParent.Ability); } } return null; } private void ShowEncyclopedia(AbilityInfo info) { if (!((Object)(object)encyclopediaPanel == (Object)null) && !((Object)(object)encyclopediaTitle == (Object)null) && !((Object)(object)encyclopediaBody == (Object)null)) { encyclopediaPanel.SetActive(true); encyclopediaTitle.text = Localization.Translate(info.rulebookName); encyclopediaBody.text = info.LocalizedRulebookDescription; } } private 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; } private static Text CreateText(string name, Transform parent, Font font, int size, string content) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) Text obj = CreateUiObject(name, parent).AddComponent<Text>(); obj.font = font; obj.fontSize = size; obj.alignment = (TextAnchor)4; ((Graphic)obj).color = Color.white; obj.text = content; ((Graphic)obj).raycastTarget = false; return obj; } private static void Stretch(RectTransform rt) { //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) rt.anchorMin = Vector2.zero; rt.anchorMax = Vector2.one; rt.offsetMin = Vector2.zero; rt.offsetMax = Vector2.zero; } private static Font GetChineseFont() { try { FontReplacementData.Initialize(); if ((Object)(object)FontReplacementData.instance != (Object)null) { LanguageFontReplacements val = FontReplacementData.instance.languageFontReplacements.Find((LanguageFontReplacements x) => x.languages.Contains((Language)10)); if (val != null && val.fontReplacements != null && val.fontReplacements.Count > 0) { Font font = val.fontReplacements[0].Font; if ((Object)(object)font != (Object)null) { return font; } } } } catch { } return Resources.GetBuiltinResource<Font>("Arial.ttf"); } private void LockPlayerInput() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) try { ViewManager instance = Singleton<ViewManager>.Instance; if ((Object)(object)instance != (Object)null && (Object)(object)instance.Controller != (Object)null) { cachedLockState = instance.Controller.LockState; instance.Controller.LockState = (ViewLockState)1; restoredLockOnce = true; } } catch (Exception ex) { ManualLogSource log = OnionQOLPlugin.Log; if (log != null) { log.LogWarning((object)("Onion QOL: 锁定输入失败: " + ex)); } } } private void RestorePlayerInput() { //IL_0035: Unknown result type (might be due to invalid IL or missing references) try { if (restoredLockOnce) { restoredLockOnce = false; ViewManager instance = Singleton<ViewManager>.Instance; if ((Object)(object)instance != (Object)null && (Object)(object)instance.Controller != (Object)null) { instance.Controller.LockState = cachedLockState; } } } catch (Exception ex) { ManualLogSource log = OnionQOLPlugin.Log; if (log != null) { log.LogWarning((object)("Onion QOL: 恢复输入失败: " + ex)); } } } private void HideCursor() { try { InteractionCursor instance = Singleton<InteractionCursor>.Instance; if ((Object)(object)instance != (Object)null) { instance.SetHidden(true); } Cursor.visible = true; } catch (Exception ex) { ManualLogSource log = OnionQOLPlugin.Log; if (log != null) { log.LogWarning((object)("Onion QOL: 处理光标失败: " + ex)); } } } private void ShowCursor() { try { Cursor.visible = false; InteractionCursor instance = Singleton<InteractionCursor>.Instance; if ((Object)(object)instance != (Object)null) { instance.SetHidden(false); } } catch (Exception ex) { ManualLogSource log = OnionQOLPlugin.Log; if (log != null) { log.LogWarning((object)("Onion QOL: 恢复光标失败: " + ex)); } } } private void UpdateHover() { //IL_0041: 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_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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: 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_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: 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) //IL_00e3: 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_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_022f: 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_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0245: 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_0256: Unknown result type (might be due to invalid IL or missing references) //IL_0262: 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_027b: Unknown result type (might be due to invalid IL or missing references) //IL_028c: 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_012d: Unknown result type (might be due to invalid IL or missing references) //IL_013d: 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_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_015d: 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_0174: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: 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_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)displayRoot == (Object)null || (Object)(object)renderCamera == (Object)null || (Object)(object)rawRect == (Object)null || (Object)(object)renderTexture == (Object)null) { return; } GameObject val = null; Vector2 val2 = default(Vector2); if (RectTransformUtility.RectangleContainsScreenPoint(rawRect, Vector2.op_Implicit(Input.mousePosition), (Camera)null) && RectTransformUtility.ScreenPointToLocalPointInRectangle(rawRect, Vector2.op_Implicit(Input.mousePosition), (Camera)null, ref val2)) { float x = val2.x; Rect rect = rawRect.rect; float num = x / ((Rect)(ref rect)).width + 0.5f; float y = val2.y; rect = rawRect.rect; float num2 = y / ((Rect)(ref rect)).height + 0.5f; Ray val3 = renderCamera.ScreenPointToRay(new Vector3(num * (float)((Texture)renderTexture).width, num2 * (float)((Texture)renderTexture).height, 0f)); RaycastHit val4 = default(RaycastHit); if (Physics.Raycast(val3, ref val4, 300f, int.MinValue)) { SelectableCard componentInParent = ((Component)((RaycastHit)(ref val4)).collider).GetComponentInParent<SelectableCard>(); if ((Object)(object)componentInParent != (Object)null) { val = ((Component)componentInParent).gameObject; } } if ((Object)(object)val == (Object)null) { Plane val5 = default(Plane); ((Plane)(ref val5))..ctor(Vector3.up, displayRoot.transform.position + Vector3.up * 0.02f); float num3 = default(float); if (((Plane)(ref val5)).Raycast(val3, ref num3)) { Vector3 point = ((Ray)(ref val3)).GetPoint(num3); foreach (GameObject spawnedCard in spawnedCards) { if (!((Object)(object)spawnedCard == (Object)null)) { Vector3 val6 = spawnedCard.transform.InverseTransformPoint(point); if (Mathf.Abs(val6.x) <= cardSize.x * 0.5f && Mathf.Abs(val6.y) <= cardSize.y * 0.5f) { val = spawnedCard; } } } } } } if (!((Object)(object)val == (Object)(object)hoveredCard)) { RestoreHovered(); if ((Object)(object)val != (Object)null) { hoveredCard = val; hoveredOriginalPos = val.transform.localPosition; hoveredOriginalRot = val.transform.localEulerAngles; hoveredOriginalScale = val.transform.localScale; val.transform.localPosition = hoveredOriginalPos + new Vector3(0f, 0.4f, 0f); val.transform.localScale = hoveredOriginalScale * 1.12f; SetCardRenderQueue(val, 9000); } } } private void RestoreHovered() { //IL_001a: 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) //IL_0046: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)hoveredCard != (Object)null) { hoveredCard.transform.localPosition = hoveredOriginalPos; hoveredCard.transform.localEulerAngles = hoveredOriginalRot; hoveredCard.transform.localScale = hoveredOriginalScale; int num = spawnedCards.IndexOf(hoveredCard); SetCardRenderQueue(hoveredCard, (num >= 0) ? (3000 + num * 10) : 3000); hoveredCard = null; } } private void Teardown() { RestorePlayerInput(); ShowCursor(); hoveredCard = null; spawnedCards.Clear(); if ((Object)(object)renderCamera != (Object)null) { renderCamera.targetTexture = null; } if ((Object)(object)renderTexture != (Object)null) { renderTexture.Release(); Object.Destroy((Object)(object)renderTexture); renderTexture = null; } if ((Object)(object)displayRoot != (Object)null) { Object.Destroy((Object)(object)displayRoot); displayRoot = null; } renderCamera = null; if ((Object)(object)uiRoot != (Object)null) { Object.Destroy((Object)(object)uiRoot); uiRoot = null; } } } [HarmonyPatch(typeof(InputButtons))] internal static class InputPatches { private static bool Blocked { get { if (!((Object)(object)DeckWindow.Instance != (Object)null)) { return (Object)(object)SettingsWindow.Instance != (Object)null; } return true; } } [HarmonyPatch("GetButton")] [HarmonyPostfix] private static void GetButton_Postfix(ref bool __result) { if (Blocked) { __result = false; } } [HarmonyPatch("GetButtonDown")] [HarmonyPostfix] private static void GetButtonDown_Postfix(ref bool __result) { if (Blocked) { __result = false; } } [HarmonyPatch("GetButtonUp")] [HarmonyPostfix] private static void GetButtonUp_Postfix(ref bool __result) { if (Blocked) { __result = false; } } [HarmonyPatch("GetButtonRepeating")] [HarmonyPostfix] private static void GetButtonRepeating_Postfix(ref bool __result) { if (Blocked) { __result = false; } } [HarmonyPatch("GetAxis")] [HarmonyPostfix] private static void GetAxis_Postfix(ref float __result) { if (Blocked) { __result = 0f; } } [HarmonyPatch("AnyGamepadButton")] [HarmonyPostfix] private static void AnyGamepadButton_Postfix(ref bool __result) { if (Blocked) { __result = false; } } } public enum BindingTarget { Deck, DrawPile, Settings } [BepInPlugin("onion.qol", "Onion QOL", "0.1.0")] public class OnionQOLPlugin : BaseUnityPlugin { public const string GUID = "onion.qol"; public const string PluginDisplayName = "Onion QOL"; public const string PluginVersion = "0.1.0"; public static OnionQOLPlugin Instance; public static ManualLogSource Log; public static ConfigEntry<bool> EnableDeckViewer; public static ConfigEntry<KeyCode> DeckViewerKey; public static ConfigEntry<bool> EnableDrawPileViewer; public static ConfigEntry<KeyCode> DrawPileKey; public static ConfigEntry<KeyCode> SettingsKey; public static ConfigEntry<bool> EnableSkipButton; internal bool awaitingKeyBind; internal BindingTarget bindingTarget; public bool AwaitingKeyBind => awaitingKeyBind; public BindingTarget BindingTarget => bindingTarget; private void Awake() { //IL_00dc: Unknown result type (might be due to invalid IL or missing references) Instance = this; Log = ((BaseUnityPlugin)this).Logger; EnableDeckViewer = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnableDeckViewer", true, "启用牌组查看:在凯西模组对局中按下快捷键打开本局牌组。"); DeckViewerKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "DeckViewerKey", (KeyCode)113, "打开牌组的按键(仅支持键盘键,可在设置面板中修改)。"); EnableDrawPileViewer = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnableDrawPileViewer", true, "启用抽牌堆查看:战斗中按下快捷键查看抽牌堆剩余牌。"); DrawPileKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "DrawPileKey", (KeyCode)101, "查看抽牌堆的按键(仅支持键盘键,可在设置面板中修改)。"); SettingsKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "SettingsKey", (KeyCode)282, "打开设置面板的按键(仅支持键盘键,可在设置面板中修改)。"); EnableSkipButton = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnableSkipButton", true, "启用选牌/奖励界面的跳过按钮。"); try { new Harmony("onion.qol").PatchAll(Assembly.GetExecutingAssembly()); RoomHint.Initialize(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Onion QOL 已加载"); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Onion QOL Harmony 初始化失败: " + ex)); } } private void Update() { //IL_004e: 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) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: 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_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) try { if (awaitingKeyBind) { if (Input.GetKeyDown((KeyCode)27)) { awaitingKeyBind = false; SettingsWindow.RefreshLabels(); return; } KeyCode pressedKeyboardKey = GetPressedKeyboardKey(); if ((int)pressedKeyboardKey != 0) { ApplyBinding(bindingTarget, pressedKeyboardKey); awaitingKeyBind = false; SettingsWindow.RefreshLabels(); } } else if (Input.GetKeyDown(SettingsKey.Value)) { if ((Object)(object)SettingsWindow.Instance != (Object)null) { SettingsWindow.Close(); } else { SettingsWindow.Open(); } } else if ((Object)(object)SettingsWindow.Instance != (Object)null && Input.GetKeyDown((KeyCode)27)) { SettingsWindow.Close(); } else { bool flag = DeckViewerKey.Value == DrawPileKey.Value; if (EnableDeckViewer.Value && Input.GetKeyDown(DeckViewerKey.Value)) { ToggleDeckWindow(DeckWindowMode.Deck); return; } if (!flag && EnableDrawPileViewer.Value && Input.GetKeyDown(DrawPileKey.Value)) { ToggleDeckWindow(DeckWindowMode.DrawPile); return; } RoomHint.Update(); SkipButton.UpdateAttach(); } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Onion QOL Update 异常: " + ex)); } } private unsafe void ApplyBinding(BindingTarget target, KeyCode key) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0079: 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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0031: 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_006b: Unknown result type (might be due to invalid IL or missing references) try { switch (target) { case BindingTarget.Deck: if (key == DrawPileKey.Value || key == SettingsKey.Value) { SettingsWindow.ShowMessage("该按键已被其他功能占用"); return; } DeckViewerKey.Value = key; break; case BindingTarget.DrawPile: if (key == DeckViewerKey.Value || key == SettingsKey.Value) { SettingsWindow.ShowMessage("该按键已被其他功能占用"); return; } DrawPileKey.Value = key; break; default: if (key == DeckViewerKey.Value || key == DrawPileKey.Value) { SettingsWindow.ShowMessage("该按键已被其他功能占用"); return; } SettingsKey.Value = key; break; } ((BaseUnityPlugin)this).Config.Save(); SettingsWindow.ShowMessage("已设置为 " + ((object)(*(KeyCode*)(&key))/*cast due to .constrained prefix*/).ToString()); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Onion QOL 设置按键失败: " + ex)); } } private void ToggleDeckWindow(DeckWindowMode mode) { if ((Object)(object)DeckWindow.Instance != (Object)null) { DeckWindow.Close(); return; } if (mode == DeckWindowMode.DrawPile) { CardDrawPiles instance = Singleton<CardDrawPiles>.Instance; if ((Object)(object)instance == (Object)null || (Object)(object)instance.Deck == (Object)null) { return; } } DeckWindow.Open(mode); } private static KeyCode GetPressedKeyboardKey() { //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_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Invalid comparison between Unknown and I4 //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Invalid comparison between Unknown and I4 //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Invalid comparison between Unknown and I4 //IL_0047: 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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) if (Input.anyKeyDown) { foreach (KeyCode value in Enum.GetValues(typeof(KeyCode))) { if ((int)value != 0 && ((int)value < 323 || (int)value > 329) && (int)value < 330 && Input.GetKeyDown(value)) { return value; } } return (KeyCode)0; } return (KeyCode)0; } internal void StartKeyBind(BindingTarget target) { awaitingKeyBind = true; bindingTarget = target; SettingsWindow.RefreshLabels(); } } public static class RoomHint { private static readonly Dictionary<string, string> Meanings = new Dictionary<string, string>(); private static string defaultMeaning = "……"; private static bool initialized; private const string DefaultConfig = "# Onion QOL —— 地图房间含义配置\n# 右键地图上的任意房间,莱西会直接说出该房间的作用。\n# 格式:节点类型=莱西要说的话\n# 修改后重启游戏生效;未列出的房间使用 _default 的文本。\n# 卡牌选择类的节点类型带 .Random/.Cost/.Tribe/.Deathcard 后缀。\n\n# —— 图标:黑色方框里的白色问号(右下角蹲坐小人)→ 选一张牌加入\nCardChoicesNodeData.Random=你可以从三张随机造物中选择一张加入牌组\n\n# —— 图标:黑色方框问号旁边的侧脸 → 选牌加入\nCardChoicesNodeData.Cost=你可以获取一张特定花费的随机造物\n\n# —— 图标:带角的黑色骷髅脸 → 选族牌加入\nCardChoicesNodeData.Tribe=你可以获取一张指定族群的随机造物\n\n# —— 图标:黑色方框里的白色问号(死亡卡)→ 死亡卡选择\nCardChoicesNodeData.Deathcard=你可以获取一张死亡卡\n\n# —— 图标:黑色短柄锤子 → 加强一张牌(按幸存者状态分支)\nCardStatBoostNodeData.Alive=温暖的篝火……你可以强化一个造物的属性\nCardStatBoostNodeData.Dead=温暖的篝火……十分安静\n\n# —— 图标:黑色背包/布袋 → 增加一个道具\nGainConsumablesNodeData=你可以增加一个道具\n\n# —— 图标:黑色剪刀 → 删一张牌\nCardRemoveNodeData=你可以删一张牌\n\n# —— 图标:带符号的黑色图腾柱/石柱 → 附魔(献祭转移印记)\nCardMergeNodeData=你需要献祭一个造物来把它的印记转移到另一个造物上\n\n# —— 图标:黑色画架/画笔(画画房间)→ 复制一张牌\nCopyCardNodeData=我不建议你去那里\n\n# —— 图标:两朵黑色蘑菇(一大一小)→ 2 张合 1\nDuplicateMergeNodeData=你可以把两张造物合成一张\n\n# —— 图标:黑色骷髅头 → 普通敌人\nCardBattleNodeData=这里是普通敌人\n\n# —— 图标:带翅膀的黑色骷髅(蝙蝠状)→ 带 buff 的敌人\nTotemBattleNodeData=这是自带雕像的敌人\n\n# —— 图标:王冠骷髅 → Boss 战\nBossBattleNodeData=这里是 Boss 战\n\n# —— 图标:带问号的卡片立在台座上 → 皮毛换牌\nTradePeltsNodeData=你可以用皮毛换取一张造物\n\n# —— 图标:黑色月牙/镰刀 → 金牙换毛皮\nBuyPeltsNodeData=你可以用金牙换取毛皮\n\n# —— 图标:黑色拱形/门形 → 通过得牌\nDeckTrialNodeData=如果你通过了这个试炼,就可以拿取一张带额外印记的造物\n\n# —— 图标:黑色小人举着工具/锤子 → 组装好给自己加 buff\nBuildTotemNodeData=你可以组装好给自己加 buff\n\n# —— 图标:黑色小人举着镐子凿地 → 矿工凿巨石\nBoulderChoiceNodeData=矿工会给你三块巨石,你选一块,他会凿开它,把一个带印记的造物交给你\n\n# —— 图标:黑色小屋 → 小屋\nCabinNodeData=很好,你来到了这里\n\n# —— 兜底:未匹配的房间\n_default=……\n"; public static void Initialize() { if (initialized) { return; } initialized = true; try { string text = Path.Combine(Paths.ConfigPath, "Onion QOL"); Directory.CreateDirectory(text); string path = Path.Combine(text, "room_meanings.txt"); if (!File.Exists(path)) { File.WriteAllText(path, "# Onion QOL —— 地图房间含义配置\n# 右键地图上的任意房间,莱西会直接说出该房间的作用。\n# 格式:节点类型=莱西要说的话\n# 修改后重启游戏生效;未列出的房间使用 _default 的文本。\n# 卡牌选择类的节点类型带 .Random/.Cost/.Tribe/.Deathcard 后缀。\n\n# —— 图标:黑色方框里的白色问号(右下角蹲坐小人)→ 选一张牌加入\nCardChoicesNodeData.Random=你可以从三张随机造物中选择一张加入牌组\n\n# —— 图标:黑色方框问号旁边的侧脸 → 选牌加入\nCardChoicesNodeData.Cost=你可以获取一张特定花费的随机造物\n\n# —— 图标:带角的黑色骷髅脸 → 选族牌加入\nCardChoicesNodeData.Tribe=你可以获取一张指定族群的随机造物\n\n# —— 图标:黑色方框里的白色问号(死亡卡)→ 死亡卡选择\nCardChoicesNodeData.Deathcard=你可以获取一张死亡卡\n\n# —— 图标:黑色短柄锤子 → 加强一张牌(按幸存者状态分支)\nCardStatBoostNodeData.Alive=温暖的篝火……你可以强化一个造物的属性\nCardStatBoostNodeData.Dead=温暖的篝火……十分安静\n\n# —— 图标:黑色背包/布袋 → 增加一个道具\nGainConsumablesNodeData=你可以增加一个道具\n\n# —— 图标:黑色剪刀 → 删一张牌\nCardRemoveNodeData=你可以删一张牌\n\n# —— 图标:带符号的黑色图腾柱/石柱 → 附魔(献祭转移印记)\nCardMergeNodeData=你需要献祭一个造物来把它的印记转移到另一个造物上\n\n# —— 图标:黑色画架/画笔(画画房间)→ 复制一张牌\nCopyCardNodeData=我不建议你去那里\n\n# —— 图标:两朵黑色蘑菇(一大一小)→ 2 张合 1\nDuplicateMergeNodeData=你可以把两张造物合成一张\n\n# —— 图标:黑色骷髅头 → 普通敌人\nCardBattleNodeData=这里是普通敌人\n\n# —— 图标:带翅膀的黑色骷髅(蝙蝠状)→ 带 buff 的敌人\nTotemBattleNodeData=这是自带雕像的敌人\n\n# —— 图标:王冠骷髅 → Boss 战\nBossBattleNodeData=这里是 Boss 战\n\n# —— 图标:带问号的卡片立在台座上 → 皮毛换牌\nTradePeltsNodeData=你可以用皮毛换取一张造物\n\n# —— 图标:黑色月牙/镰刀 → 金牙换毛皮\nBuyPeltsNodeData=你可以用金牙换取毛皮\n\n# —— 图标:黑色拱形/门形 → 通过得牌\nDeckTrialNodeData=如果你通过了这个试炼,就可以拿取一张带额外印记的造物\n\n# —— 图标:黑色小人举着工具/锤子 → 组装好给自己加 buff\nBuildTotemNodeData=你可以组装好给自己加 buff\n\n# —— 图标:黑色小人举着镐子凿地 → 矿工凿巨石\nBoulderChoiceNodeData=矿工会给你三块巨石,你选一块,他会凿开它,把一个带印记的造物交给你\n\n# —— 图标:黑色小屋 → 小屋\nCabinNodeData=很好,你来到了这里\n\n# —— 兜底:未匹配的房间\n_default=……\n", new UTF8Encoding(encoderShouldEmitUTF8Identifier: false)); } Load(path); ManualLogSource log = OnionQOLPlugin.Log; if (log != null) { log.LogInfo((object)("Onion QOL: 房间含义配置已加载(" + Meanings.Count + " 条)")); } } catch (Exception ex) { ManualLogSource log2 = OnionQOLPlugin.Log; if (log2 != null) { log2.LogError((object)("Onion QOL: 房间含义配置加载失败: " + ex)); } } } private static void Load(string path) { Meanings.Clear(); string[] array = File.ReadAllLines(path); for (int i = 0; i < array.Length; i++) { string text = array[i].Trim(); if (text.Length == 0 || text.StartsWith("#")) { continue; } int num = text.IndexOf('='); if (num > 0) { string text2 = text.Substring(0, num).Trim(); string value = text.Substring(num + 1).Trim(); if (text2 == "_default") { defaultMeaning = value; } else { Meanings[text2] = value; } } } } public static void Update() { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: 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) //IL_0043: Invalid comparison between Unknown and I4 //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Invalid comparison between Unknown and I4 //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Invalid comparison between Unknown and I4 //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Invalid comparison between Unknown and I4 if ((Object)(object)SettingsWindow.Instance != (Object)null || (Object)(object)DeckWindow.Instance != (Object)null || (Object)(object)Singleton<MapNodeManager>.Instance == (Object)null) { return; } ViewManager instance = Singleton<ViewManager>.Instance; if ((Object)(object)instance == (Object)null) { return; } View currentView = instance.CurrentView; if (((int)currentView == 12 || (int)currentView == 13 || (int)currentView == 23) && (!((Object)(object)instance.Controller != (Object)null) || (int)instance.Controller.LockState != 1) && Input.GetMouseButtonDown(1)) { MapNode val = FindNodeUnderMouse(); if (!((Object)(object)val == (Object)null) && val.Data != null) { Speak(GetMeaning(val.Data)); } } } private static MapNode FindNodeUnderMouse() { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0083: 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_0092: 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_00a0: Unknown result type (might be due to invalid IL or missing references) MapNodeManager instance = Singleton<MapNodeManager>.Instance; if ((Object)(object)instance == (Object)null || instance.nodes == null) { return null; } Camera val = Camera.main; if ((Object)(object)val == (Object)null) { val = Object.FindObjectOfType<Camera>(); } if ((Object)(object)val == (Object)null) { return null; } Vector2 val2 = Vector2.op_Implicit(Input.mousePosition); MapNode result = null; float num = 110f; foreach (MapNode node in instance.nodes) { if ((Object)(object)node == (Object)null) { continue; } Vector3 val3 = val.WorldToScreenPoint(((Component)node).transform.position); if (!(val3.z < 0f)) { float num2 = Vector2.Distance(val2, new Vector2(val3.x, val3.y)); if (num2 < num) { num = num2; result = node; } } } return result; } private static string GetMeaning(NodeData data) { string text = ((object)data).GetType().Name; CardChoicesNodeData val = (CardChoicesNodeData)(object)((data is CardChoicesNodeData) ? data : null); if (val != null) { text = text + "." + ((object)Unsafe.As<CardChoicesType, CardChoicesType>(ref val.choicesType)/*cast due to .constrained prefix*/).ToString(); } else if (data is CardStatBoostNodeData) { bool flag = RunState.Run != null && RunState.Run.survivorsDead; text += (flag ? ".Dead" : ".Alive"); } if (Meanings.TryGetValue(text, out var value) && !string.IsNullOrEmpty(value)) { return value; } string name = ((object)data).GetType().Name; if (name != text && Meanings.TryGetValue(name, out var value2) && !string.IsNullOrEmpty(value2)) { return value2; } return defaultMeaning; } private static void Speak(string meaning) { try { TextDisplayer instance = Singleton<TextDisplayer>.Instance; if (!((Object)(object)instance == (Object)null)) { if (instance.Displaying) { instance.Clear(); } ((MonoBehaviour)instance).StartCoroutine(instance.ShowUntilInput(meaning, -0.65f, 0.4f, (Emotion)0, (LetterAnimation)0, (Speaker)1, (string[])null, true)); } } catch (Exception ex) { ManualLogSource log = OnionQOLPlugin.Log; if (log != null) { log.LogError((object)("Onion QOL: 莱西说话失败: " + ex)); } } } } public class SettingsWindow : MonoBehaviour { public static SettingsWindow Instance; private GameObject uiRoot; private Text enableDeckValueText; private Text deckKeyText; private Text enableDrawValueText; private Text drawKeyText; private Text enableSkipValueText; private Text settingsKeyText; private Text messageText; private RectTransform enableDeckRow; private RectTransform deckKeyRow; private RectTransform enableDrawRow; private RectTransform drawKeyRow; private RectTransform enableSkipRow; private RectTransform settingsKeyRow; private string message = string.Empty; private float messageUntil; public static void Open() { //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 if (!((Object)(object)Instance != (Object)null)) { GameObject val = new GameObject("OnionQOL_SettingsWindow"); Object.DontDestroyOnLoad((Object)val); Instance = val.AddComponent<SettingsWindow>(); Instance.Build(); } } public static void Close() { if (!((Object)(object)Instance == (Object)null)) { Instance.Teardown(); Object.Destroy((Object)(object)((Component)Instance).gameObject); Instance = null; } } public static void RefreshLabels() { if ((Object)(object)Instance != (Object)null) { Instance.RefreshLabelsInternal(); } } public static void ShowMessage(string text) { if ((Object)(object)Instance != (Object)null) { Instance.ShowMessageInternal(text); } } private void Build() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: 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_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_014d: 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) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_0304: Unknown result type (might be due to invalid IL or missing references) //IL_0324: Unknown result type (might be due to invalid IL or missing references) //IL_0339: 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_0363: Unknown result type (might be due to invalid IL or missing references) //IL_0377: Unknown result type (might be due to invalid IL or missing references) //IL_03a9: Unknown result type (might be due to invalid IL or missing references) //IL_03be: Unknown result type (might be due to invalid IL or missing references) //IL_03d3: Unknown result type (might be due to invalid IL or missing references) //IL_03e8: 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) uiRoot = new GameObject("OnionQOL_SettingsUI", new Type[1] { typeof(RectTransform) }); Object.DontDestroyOnLoad((Object)(object)uiRoot); Canvas obj = uiRoot.AddComponent<Canvas>(); obj.renderMode = (RenderMode)0; obj.sortingOrder = 30000; CanvasScaler obj2 = uiRoot.AddComponent<CanvasScaler>(); obj2.uiScaleMode = (ScaleMode)1; obj2.referenceResolution = new Vector2(1920f, 1080f); obj2.matchWidthOrHeight = 0.5f; Font chineseFont = GetChineseFont(); GameObject obj3 = CreateUiObject("Background", uiRoot.transform); ((Graphic)obj3.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0.7f); Stretch(obj3.GetComponent<RectTransform>()); GameObject val = CreateUiObject("Panel", uiRoot.transform); ((Graphic)val.AddComponent<Image>()).color = new Color(0.05f, 0.05f, 0.05f, 0.97f); 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(900f, 880f); RectTransform rectTransform = ((Graphic)CreateText("Title", val.transform, chineseFont, 40, "Onion QOL 设置")).rectTransform; rectTransform.anchorMin = new Vector2(0.5f, 1f); rectTransform.anchorMax = new Vector2(0.5f, 1f); rectTransform.pivot = new Vector2(0.5f, 1f); rectTransform.anchoredPosition = new Vector2(0f, -30f); rectTransform.sizeDelta = new Vector2(800f, 60f); enableDeckRow = CreateRow(val.transform, "EnableDeckRow", -110f, "启用牌组查看", out enableDeckValueText, chineseFont); deckKeyRow = CreateRow(val.transform, "DeckKeyRow", -200f, "打开牌组按键", out deckKeyText, chineseFont); enableDrawRow = CreateRow(val.transform, "EnableDrawRow", -290f, "启用抽牌堆查看", out enableDrawValueText, chineseFont); drawKeyRow = CreateRow(val.transform, "DrawKeyRow", -380f, "查看抽牌堆按键", out drawKeyText, chineseFont); enableSkipRow = CreateRow(val.transform, "EnableSkipRow", -470f, "启用跳过按钮", out enableSkipValueText, chineseFont); settingsKeyRow = CreateRow(val.transform, "SettingsKeyRow", -560f, "设置面板按键", out settingsKeyText, chineseFont); messageText = CreateText("Message", val.transform, chineseFont, 26, string.Empty); ((Graphic)messageText).color = new Color(1f, 0.75f, 0.4f, 1f); RectTransform rectTransform2 = ((Graphic)messageText).rectTransform; rectTransform2.anchorMin = new Vector2(0.5f, 1f); rectTransform2.anchorMax = new Vector2(0.5f, 1f); rectTransform2.pivot = new Vector2(0.5f, 1f); rectTransform2.anchoredPosition = new Vector2(0f, -650f); rectTransform2.sizeDelta = new Vector2(800f, 44f); RectTransform rectTransform3 = ((Graphic)CreateText("Hint", val.transform, chineseFont, 26, "按设置键或 ESC 关闭")).rectTransform; rectTransform3.anchorMin = new Vector2(0.5f, 0f); rectTransform3.anchorMax = new Vector2(0.5f, 0f); rectTransform3.pivot = new Vector2(0.5f, 0f); rectTransform3.anchoredPosition = new Vector2(0f, 26f); rectTransform3.sizeDelta = new Vector2(700f, 50f); RefreshLabelsInternal(); HideCursor(); } private RectTransform CreateRow(Transform panel, string name, float y, string label, out Text valueText, Font font) { //IL_0022: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_008d: 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_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0117: 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) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) GameObject val = CreateUiObject(name, panel); ((Graphic)val.AddComponent<Image>()).color = new Color(0.16f, 0.16f, 0.18f, 0.95f); RectTransform component = val.GetComponent<RectTransform>(); component.anchorMin = new Vector2(0.5f, 1f); component.anchorMax = new Vector2(0.5f, 1f); component.pivot = new Vector2(0.5f, 1f); component.anchoredPosition = new Vector2(0f, y); component.sizeDelta = new Vector2(800f, 76f); Text obj = CreateText("Label", val.transform, font, 30, label); obj.alignment = (TextAnchor)3; RectTransform rectTransform = ((Graphic)obj).rectTransform; rectTransform.anchorMin = new Vector2(0f, 0.5f); rectTransform.anchorMax = new Vector2(0f, 0.5f); rectTransform.pivot = new Vector2(0f, 0.5f); rectTransform.anchoredPosition = new Vector2(28f, 0f); rectTransform.sizeDelta = new Vector2(430f, 56f); valueText = CreateText("Value", val.transform, font, 30, string.Empty); valueText.alignment = (TextAnchor)5; RectTransform rectTransform2 = ((Graphic)valueText).rectTransform; rectTransform2.anchorMin = new Vector2(1f, 0.5f); rectTransform2.anchorMax = new Vector2(1f, 0.5f); rectTransform2.pivot = new Vector2(1f, 0.5f); rectTransform2.anchoredPosition = new Vector2(-28f, 0f); rectTransform2.sizeDelta = new Vector2(320f, 56f); return component; } private void Update() { try { if (Input.GetMouseButtonDown(0)) { if (RectContains(enableDeckRow)) { ToggleBool(OnionQOLPlugin.EnableDeckViewer); } else if (RectContains(deckKeyRow)) { OnionQOLPlugin.Instance?.StartKeyBind(BindingTarget.Deck); } else if (RectContains(enableDrawRow)) { ToggleBool(OnionQOLPlugin.EnableDrawPileViewer); } else if (RectContains(drawKeyRow)) { OnionQOLPlugin.Instance?.StartKeyBind(BindingTarget.DrawPile); } else if (RectContains(enableSkipRow)) { ToggleBool(OnionQOLPlugin.EnableSkipButton); } else if (RectContains(settingsKeyRow)) { OnionQOLPlugin.Instance?.StartKeyBind(BindingTarget.Settings); } } RefreshLabelsInternal(); if ((Object)(object)messageText != (Object)null) { if (!string.IsNullOrEmpty(message) && Time.unscaledTime > messageUntil) { message = string.Empty; } messageText.text = message; } } catch (Exception ex) { ManualLogSource log = OnionQOLPlugin.Log; if (log != null) { log.LogError((object)("Onion QOL: 设置窗口异常: " + ex)); } } } private void ToggleBool(ConfigEntry<bool> entry) { entry.Value = !entry.Value; if ((Object)(object)OnionQOLPlugin.Instance != (Object)null) { ((BaseUnityPlugin)OnionQOLPlugin.Instance).Config.Save(); } if (entry == OnionQOLPlugin.EnableDeckViewer && !entry.Value && (Object)(object)DeckWindow.Instance != (Object)null) { DeckWindow.Close(); } } private void RefreshLabelsInternal() { //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_0127: 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_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)enableDeckValueText != (Object)null) { enableDeckValueText.text = (OnionQOLPlugin.EnableDeckViewer.Value ? "开" : "关"); } if ((Object)(object)enableDrawValueText != (Object)null) { enableDrawValueText.text = (OnionQOLPlugin.EnableDrawPileViewer.Value ? "开" : "关"); } if ((Object)(object)enableSkipValueText != (Object)null) { enableSkipValueText.text = (OnionQOLPlugin.EnableSkipButton.Value ? "开" : "关"); } bool flag = (Object)(object)OnionQOLPlugin.Instance != (Object)null && OnionQOLPlugin.Instance.AwaitingKeyBind; BindingTarget bindingTarget = (((Object)(object)OnionQOLPlugin.Instance != (Object)null) ? OnionQOLPlugin.Instance.BindingTarget : BindingTarget.Deck); if ((Object)(object)deckKeyText != (Object)null) { deckKeyText.text = ((flag && bindingTarget == BindingTarget.Deck) ? "按任意键...(ESC 取消)" : ((object)OnionQOLPlugin.DeckViewerKey.Value/*cast due to .constrained prefix*/).ToString()); } if ((Object)(object)drawKeyText != (Object)null) { drawKeyText.text = ((flag && bindingTarget == BindingTarget.DrawPile) ? "按任意键...(ESC 取消)" : ((object)OnionQOLPlugin.DrawPileKey.Value/*cast due to .constrained prefix*/).ToString()); } if ((Object)(object)settingsKeyText != (Object)null) { settingsKeyText.text = ((flag && bindingTarget == BindingTarget.Settings) ? "按任意键...(ESC 取消)" : ((object)OnionQOLPlugin.SettingsKey.Value/*cast due to .constrained prefix*/).ToString()); } } private void ShowMessageInternal(string text) { message = text; messageUntil = Time.unscaledTime + 2.5f; } private static bool RectContains(RectTransform rt) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)rt != (Object)null) { return RectTransformUtility.RectangleContainsScreenPoint(rt, Vector2.op_Implicit(Input.mousePosition), (Camera)null); } return false; } private void HideCursor() { try { InteractionCursor instance = Singleton<InteractionCursor>.Instance; if ((Object)(object)instance != (Object)null) { instance.SetHidden(true); } Cursor.visible = true; } catch (Exception ex) { ManualLogSource log = OnionQOLPlugin.Log; if (log != null) { log.LogWarning((object)("Onion QOL: 处理光标失败: " + ex)); } } } private void ShowCursor() { try { Cursor.visible = false; InteractionCursor instance = Singleton<InteractionCursor>.Instance; if ((Object)(object)instance != (Object)null) { instance.SetHidden(false); } } catch (Exception ex) { ManualLogSource log = OnionQOLPlugin.Log; if (log != null) { log.LogWarning((object)("Onion QOL: 恢复光标失败: " + ex)); } } } private void Teardown() { ShowCursor(); if ((Object)(object)uiRoot != (Object)null) { Object.Destroy((Object)(object)uiRoot); uiRoot = null; } } private 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; } private static Text CreateText(string name, Transform parent, Font font, int size, string content) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) Text obj = CreateUiObject(name, parent).AddComponent<Text>(); obj.font = font; obj.fontSize = size; obj.alignment = (TextAnchor)4; ((Graphic)obj).color = Color.white; obj.text = content; ((Graphic)obj).raycastTarget = false; return obj; } private static void Stretch(RectTransform rt) { //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) rt.anchorMin = Vector2.zero; rt.anchorMax = Vector2.one; rt.offsetMin = Vector2.zero; rt.offsetMax = Vector2.zero; } private static Font GetChineseFont() { try { FontReplacementData.Initialize(); if ((Object)(object)FontReplacementData.instance != (Object)null) { LanguageFontReplacements val = FontReplacementData.instance.languageFontReplacements.Find((LanguageFontReplacements x) => x.languages.Contains((Language)10)); if (val != null && val.fontReplacements != null && val.fontReplacements.Count > 0) { Font font = val.fontReplacements[0].Font; if ((Object)(object)font != (Object)null) { return font; } } } } catch { } return Resources.GetBuiltinResource<Font>("Arial.ttf"); } } public class SkipButton : MonoBehaviour { private static SkipButton current; private CardChoicesSequencer sequence; private GainConsumablesSequencer consumables; private BuyPeltsSequencer buyPelts; private GameObject uiRoot; private RectTransform buttonRect; public static void UpdateAttach() { //IL_003b: Unknown result type (might be due to invalid IL or missing references) try { if (!OnionQOLPlugin.EnableSkipButton.Value) { if ((Object)(object)current != (Object)null) { current.DestroyButton(); } return; } GameFlowManager instance = Singleton<GameFlowManager>.Instance; int num = ((!((Object)(object)instance != (Object)null)) ? 1 : ((int)instance.CurrentGameState)); bool flag = num == 3; bool num2 = num == 0; NodeData currentNodeData = GetCurrentNodeData(); CardSingleChoicesSequencer val = null; if (num2 || (flag && IsCardChoiceRoom(currentNodeData))) { val = FindActiveCardSequencer(); } BoulderChoiceSequencer val2 = (((Object)(object)val == (Object)null && flag && currentNodeData is BoulderChoiceNodeData) ? FindActiveBoulderSequencer() : null); BuyPeltsSequencer val3 = (((Object)(object)val == (Object)null && (Object)(object)val2 == (Object)null && flag && currentNodeData is BuyPeltsNodeData) ? FindActiveBuyPelts() : null); GainConsumablesSequencer val4 = (((Object)(object)val == (Object)null && (Object)(object)val2 == (Object)null && (Object)(object)val3 == (Object)null && flag && currentNodeData is GainConsumablesNodeData && IsConsumablesFull()) ? FindActiveGainSequencer() : null); if ((Object)(object)val == (Object)null && (Object)(object)val2 == (Object)null && (Object)(object)val3 == (Object)null && (Object)(object)val4 == (Object)null) { if ((Object)(object)current != (Object)null) { current.DestroyButton(); } return; } if ((Object)(object)current != (Object)null) { if (((Object)(object)val != (Object)null && (Object)(object)current.sequence == (Object)(object)val) || ((Object)(object)val2 != (Object)null && (Object)(object)current.sequence == (Object)(object)val2) || ((Object)(object)val3 != (Object)null && (Object)(object)current.buyPelts == (Object)(object)val3) || ((Object)(object)val4 != (Object)null && (Object)(object)current.consumables == (Object)(object)val4)) { return; } current.DestroyButton(); } LogTrigger(val, val2, val3, val4, instance, currentNodeData); current = Create((CardChoicesSequencer)(((object)val) ?? ((object)val2)), val3, val4, currentNodeData); } catch (Exception ex) { ManualLogSource log = OnionQOLPlugin.Log; if (log != null) { log.LogError((object)("Onion QOL: 跳过按钮更新异常: " + ex)); } } } private static NodeData GetCurrentNodeData() { try { MapNodeManager instance = Singleton<MapNodeManager>.Instance; if ((Object)(object)instance == (Object)null || instance.nodes == null || RunState.Run == null) { return null; } MapNode val = instance.nodes.Find((MapNode n) => (Object)(object)n != (Object)null && n.nodeId == RunState.Run.currentNodeId); return ((Object)(object)val != (Object)null) ? val.Data : null; } catch { return null; } } private static bool IsCardChoiceRoom(NodeData data) { if (!(data is CardChoicesNodeData) && !(data is CardBundleChoicesNodeData)) { return data is ChooseRareCardNodeData; } return true; } private static bool IsConsumablesFull() { if (RunState.Run != null && RunState.Run.consumables != null) { return RunState.Run.consumables.Count >= RunState.Run.MaxConsumables; } return false; } private static CardSingleChoicesSequencer FindActiveCardSequencer() { CardSingleChoicesSequencer[] array = Object.FindObjectsOfType<CardSingleChoicesSequencer>(); foreach (CardSingleChoicesSequencer val in array) { if (!((Object)(object)val == (Object)null) && ((Component)val).gameObject.activeInHierarchy && !(val is TradeCardsSequencer)) { if (GetCards((CardChoicesSequencer)(object)val).Count > 0) { return val; } if ((Object)(object)GetChosenReward((CardChoicesSequencer)(object)val) != (Object)null) { return val; } } } return null; } private static BoulderChoiceSequencer FindActiveBoulderSequencer() { BoulderChoiceSequencer[] array = Object.FindObjectsOfType<BoulderChoiceSequencer>(); foreach (BoulderChoiceSequencer val in array) { if (!((Object)(object)val == (Object)null) && ((Component)val).gameObject.activeInHierarchy && GetCards((CardChoicesSequencer)(object)val).Exists((SelectableCard c) => (Object)(object)c != (Object)null && (Object)(object)((Card)c).Info != (Object)null && ((Object)((Card)c).Info).name == "Boulder")) { return val; } } return null; } private static BuyPeltsSequencer FindActiveBuyPelts() { BuyPeltsSequencer[] array = Object.FindObjectsOfType<BuyPeltsSequencer>(); foreach (BuyPeltsSequencer val in array) { if (!((Object)(object)val == (Object)null) && ((Component)val).gameObject.activeInHierarchy) { object? obj = AccessTools.Field(typeof(BuyPeltsSequencer), "trap")?.GetValue(val); GameObject val2 = (GameObject)((obj is GameObject) ? obj : null); if ((Object)(object)val2 != (Object)null && val2.activeSelf) { return val; } } } return null; } private static GainConsumablesSequencer FindActiveGainSequencer() { GainConsumablesSequencer[] array = Object.FindObjectsOfType<GainConsumablesSequencer>(); foreach (GainConsumablesSequencer val in array) { if (!((Object)(object)val == (Object)null) && ((Component)val).gameObject.activeInHierarchy && RunState.Run != null && RunState.Run.consumables != null && RunState.Run.consumables.Count >= RunState.Run.MaxConsumables) { return val; } } return null; } private static List<SelectableCard> GetCards(CardChoicesSequencer sequencer) { try { return (AccessTools.Field(typeof(CardChoicesSequencer), "selectableCards")?.GetValue(sequencer) as List<SelectableCard>) ?? new List<SelectableCard>(); } catch { return new List<SelectableCard>(); } } private static SelectableCard GetChosenReward(CardChoicesSequencer sequencer) { try { object? obj = AccessTools.Field(typeof(CardSingleChoicesSequencer), "chosenReward")?.GetValue(sequencer); return (SelectableCard)((obj is SelectableCard) ? obj : null); } catch { return null; } } private static SkipButton Create(CardChoicesSequencer cardSequencer, BuyPeltsSequencer buySequencer, GainConsumablesSequencer consumablesSequencer, NodeData currentData) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Expected O, but got Unknown //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: 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_00f7: 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) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0149: 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_017d: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("OnionQOL_SkipButton", new Type[1] { typeof(RectTransform) }); Object.DontDestroyOnLoad((Object)(object)val); Canvas obj = val.AddComponent<Canvas>(); obj.renderMode = (RenderMode)0; obj.sortingOrder = 30000; CanvasScaler obj2 = val.AddComponent<CanvasScaler>(); obj2.uiScaleMode = (ScaleMode)1; obj2.referenceResolution = new Vector2(1920f, 1080f); obj2.matchWidthOrHeight = 0.5f; GameObject val2 = new GameObject("Skip", new Type[1] { typeof(RectTransform) }); val2.transform.SetParent(val.transform, false); ((Graphic)val2.AddComponent<Image>()).color = new Color(0.15f, 0.15f, 0.15f, 0.85f); RectTransform component = val2.GetComponent<RectTransform>(); component.anchorMin = new Vector2(1f, 0f); component.anchorMax = new Vector2(1f, 0f); component.pivot = new Vector2(1f, 0f); component.anchoredPosition = new Vector2(-40f, 40f); component.sizeDelta = new Vector2(340f, 96f); Font chineseFont = GetChineseFont(); GameObject val3 = new GameObject("Label", new Type[1] { typeof(RectTransform) }); val3.transform.SetParent(val2.transform, false); Text obj3 = val3.AddComponent<Text>(); obj3.font = chineseFont; obj3.fontSize = 34; obj3.alignment = (TextAnchor)4; ((Graphic)obj3).color = Color.white; obj3.text = "跳过(不拿牌)"; ((Graphic)obj3).raycastTarget = false; RectTransform component2 = val3.GetComponent<RectTransform>(); component2.anchorMin = Vector2.zero; component2.anchorMax = Vector2.one; component2.offsetMin = Vector2.zero; component2.offsetMax = Vector2.zero; SkipButton skipButton = val.AddComponent<SkipButton>(); skipButton.sequence = cardSequencer; skipButton.buyPelts = buySequencer; skipButton.consumables = consumablesSequencer; skipButton.uiRoot = val; skipButton.buttonRect = component; try { InteractionCursor instance = Singleton<InteractionCursor>.Instance; if ((Object)(object)instance != (Object)null) { instance.OSCursorShown = true; } Cursor.visible = true; } catch { } ManualLogSource log = OnionQOLPlugin.Log; if (log != null) { log.LogInfo((object)("Onion QOL: skip button shown target=" + DescribeTarget(cardSequencer, buySequencer, consumablesSequencer) + " room=" + ((currentData != null) ? ((object)currentData).GetType().Name : "null"))); } return skipButton; } private static void LogTrigger(CardSingleChoicesSequencer cardSequencer, BoulderChoiceSequencer boulderSequencer, BuyPeltsSequencer buySequencer, GainConsumablesSequencer consumablesSequencer, GameFlowManager flow, NodeData currentData) { //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) try { string text = (((Object)(object)flow != (Object)null) ? ((object)flow.CurrentGameState/*cast due to .constrained prefix*/).ToString() : "null"); string text2 = ((currentData != null) ? ((object)currentData).GetType().Name : "null"); if ((Object)(object)cardSequencer != (Object)null) { ManualLogSource log = OnionQOLPlugin.Log; if (log != null) { log.LogInfo((object)("Onion QOL: skip trigger=cardchoice object=" + ((Object)cardSequencer).name + " type=" + ((object)cardSequencer).GetType().Name + " cards=" + GetCards((CardChoicesSequencer)(object)cardSequencer).Count + " chosen=" + ((Object)(object)GetChosenReward((CardChoicesSequencer)(object)cardSequencer) != (Object)null) + " room=" + text2 + " state=" + text)); } } else if ((Object)(object)boulderSequencer != (Object)null) { object? obj = AccessTools.Field(typeof(CardChoicesSequencer), "deckPile")?.GetValue(boulderSequencer); CardPile val = (CardPile)((obj is CardPile) ? obj : null); ManualLogSource log2 = OnionQOLPlugin.Log; if (log2 != null) { log2.LogInfo((object)("Onion QOL: skip trigger=boulder object=" + ((Object)boulderSequencer).name + " pileActive=" + ((Object)(object)val != (Object)null && ((Component)val).gameObject.activeSelf) + " room=" + text2 + " state=" + text)); } } else if ((Object)(object)buySequencer != (Object)null) { object? obj2 = AccessTools.Field(typeof(BuyPeltsSequencer), "trap")?.GetValue(buySequencer); GameObject val2 = (GameObject)((obj2 is GameObject) ? obj2 : null); ManualLogSource log3 = OnionQOLPlugin.Log; if (log3 != null) { log3.LogInfo((object)("Onion QOL: skip trigger=buypelts object=" + ((Object)buySequencer).name + " trapActive=" + ((Object)(object)val2 != (Object)null && val2.activeSelf) + " room=" + text2 + " state=" + text)); } } else if ((Object)(object)consumablesSequencer != (Object)null) { object? obj3 = AccessTools.Field(typeof(GainConsumablesSequencer), "rat")?.GetValue(consumablesSequencer); GameObject val3 = (GameObject)((obj3 is GameObject) ? obj3 : null); ManualLogSource log4 = OnionQOLPlugin.Log; if (log4 != null) { log4.LogInfo((object)("Onion QOL: skip trigger=consumables object=" + ((Object)consumablesSequencer).name + " ratActive=" + ((Object)(object)val3 != (Object)null && val3.activeSelf) + " room=" + text2 + " state=" + text)); } } } catch { } } private static string DescribeTarget(CardChoicesSequencer cardSequencer, BuyPeltsSequencer buySequencer, GainConsumablesSequencer consumablesSequencer) { if (cardSequencer is BoulderChoiceSequencer) { return "boulder"; } if ((Object)(object)cardSequencer != (Object)null) { return "cardchoice"; } if ((Object)(object)buySequencer != (Object)null) { return "buypelts"; } return "consumables"; } private void Update() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) try { if (!((Object)(object)buttonRect == (Object)null) && Input.GetMouseButtonDown(0) && RectTransformUtility.RectangleContainsScreenPoint(buttonRect, Vector2.op_Implicit(Input.mousePosition), (Camera)null)) { Skip(); } } catch (Exception ex) { ManualLogSource log = OnionQOLPlugin.Log; if (log != null) { log.LogError((object)("Onion QOL: skip button error: " + ex)); } } } private void Skip() { try { if ((Object)(object)buyPelts != (Object)null) { SkipBuyPelts(); } else if ((Object)(object)consumables != (Object)null) { SkipConsumables(); } else { CardChoicesSequencer obj = sequence; BoulderChoiceSequencer val = (BoulderChoiceSequencer)(object)((obj is BoulderChoiceSequencer) ? obj : null); if (val != null) { SkipBoulder(val); } else if ((Object)(object)sequence != (Object)null) { SkipCardChoice(); } } } catch (Exception ex) { ManualLogSource log = OnionQOLPlugin.Log; if (log != null) { log.LogError((object)("Onion QOL: skip failed: " + ex)); } } DestroyButton(); } private void SkipCardChoice() { CardChoicesSequencer val = sequence; ((MonoBehaviour)val).StopAllCoroutines(); try { AccessTools.Method(typeof(CardSingleChoicesSequencer), "CleanUpCards", (Type[])null, (Type[])null)?.Invoke(val, new object[1] { true }); } catch { } DestroyAllSelectableCards(); GameObject[] array = Object.FindObjectsOfType<GameObject>(); foreach (GameObject val2 in array) { if (!((Object)(object)val2 == (Object)null)) { string text = ((Object)val2).name.ToLowerInvariant(); if (text.Contains("cardpack") || text.Contains("rarecardbox")) { Object.Destroy((Object)(object)val2); } } } CleanUpClover(); try { object? obj2 = AccessTools.Field(typeof(CardChoicesSequencer), "deckPile")?.GetValue(val); CardPile val3 = (CardPile)((obj2 is CardPile) ? obj2 : null); if ((Object)(object)val3 != (Object)null) { ((MonoBehaviour)val3).StartCoroutine(val3.DestroyCards(0.5f)); } } catch { } ReturnToMap(); ManualLogSource log = OnionQOLPlugin.Log; if (log != null) { log.LogInfo((object)"Onion QOL: skipped card choice"); } } private void SkipBoulder(BoulderChoiceSequencer seq) { ((MonoBehaviour)seq).StopAllCoroutines(); DestroyAllSelectableCards(); try { object? obj = AccessTools.Field(typeof(CardChoicesSequencer), "deckPile")?.GetValue(seq); CardPile val = (CardPile)((obj is CardPile) ? obj : null); if ((Object)(object)val != (Object)null) { ((MonoBehaviour)val).StartCoroutine(val.DestroyCards(0.5f)); ((Component)val).gameObject.SetActive(false); } } catch { } try { LeshyAnimationController instance = LeshyAnimationController.Instance; if ((Object)(object)instance != (Object)null) { instance.RightArm.SetTrigger("prospector_hide"); instance.ClearHeldObjects(); ((MonoBehaviour)instance).StartCoroutine(instance.TakeOffMask()); } } catch { } ReturnToMap(); ManualLogSource log = OnionQOLPlugin.Log; if (log != null) { log.LogInfo((object)"Onion QOL: skipped boulder"); } } private void SkipBuyPelts() { BuyPeltsSequencer val = buyPelts; ((MonoBehaviour)val).StopAllCoroutines(); DestroyAllSelectableCards(); object? obj = AccessTools.Field(typeof(BuyPeltsSequencer), "trap")?.GetValue(val); HideObject((GameObject)((obj is GameObject) ? obj : null)); object? obj2 = AccessTools.Field(typeof(BuyPeltsSequencer), "knife")?.GetValue(val); HideObject((GameObject)((obj2 is GameObject) ? obj2 : null)); object? obj3 = AccessTools.Field(typeof(BuyPeltsSequencer), "weightsBlocker")?.GetValue(val); HideObject((GameObject)((obj3 is GameObject) ? obj3 : null)); try { object? obj4 = AccessTools.Field(typeof(BuyPeltsSequencer), "deckPile")?.GetValue(val); CardPile val2 = (CardPile)((obj4 is CardPile) ? obj4 : null); if ((Object)(object)val2 != (Object)null) { ((MonoBehaviour)val2).StartCoroutine(val2.DestroyCards(0.5f)); } } catch { } try { LeshyAnimationController instance = LeshyAnimationController.Instance; if ((Object)(object)instance != (Object)null) { instance.ClearHeldObjects(); ((MonoBehaviour)instance).StartCoroutine(instance.TakeOffMask()); } } catch { } ReturnToMap(); ManualLogSource log = OnionQOLPlugin.Log; if (log != null) { log.LogInfo((object)"Onion QOL: skipped buypelts"); } } private static void HideObject(GameObject go) { if ((Object)(object)go != (Object)null) { go.SetActive(false); } } private void SkipConsumables() { GainConsumablesSequencer val = consumables; ((MonoBehaviour)val).StopAllCoroutines(); object? obj = AccessTools.Field(typeof(GainConsumablesSequencer), "rat")?.GetValue(val); HideObject((GameObject)((obj is GameObject) ? obj : null)); object? obj2 = AccessTools.Field(typeof(GainConsumablesSequencer), "ratCard")?.GetValue(val); SelectableCard val2 = (SelectableCard)((obj2 is SelectableCard) ? obj2 : null); if ((Object)(object)val2 != (Object)null) { ((Component)val2).gameObject.SetActive(false); } object? obj3 = AccessTools.Field(typeof(GainConsumablesSequencer), "backpack")?.GetValue(val); HideObject((GameObject)((obj3 is GameObject) ? obj3 : null)); DestroyAllSelectableCards(); ReturnToMap(); ManualLogSource log = OnionQOLPlugin.Log; if (log != null) { log.LogInfo((object)"Onion QOL: skipped consumables"); } } private static void DestroyAllSelectableCards() { SelectableCard[] array = Object.FindObjectsOfType<SelectableCard>(); foreach (SelectableCard val in array) { if ((Object)(object)val != (Object)null) { ((Card)val).SetInteractionEnabled(false); Object.Destroy((Object)(object)((Component)val).gameObject); } } } private static void CleanUpClover() { GameObject[] array = Object.FindObjectsOfType<GameObject>(); foreach (GameObject val in array) { if (!((Object)(object)val == (Object)null)) { string text = ((Object)val).name.ToLowerInvariant(); if (text.Contains("clover") || text.Contains("reroll")) { Object.Destroy((Object)(object)val); } } } } private static void ReturnToMap() { ViewManager instance = Singleton<ViewManager>.Instance; if ((Object)(object)in