Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Hard Item Randomizer v1.7.7
BepInEx/plugins/HKSilksong_SceneRandomizer.dll
Decompiled 2 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using StartingAbilityPicker; using UnityEngine; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("0.0.0.0")] namespace HKSilksong_Randomizer; public static class RoomMapGenerator { private static readonly bool[,] letters; static RoomMapGenerator() { letters = new bool[128, 25]; string[] array = new string[26] { "01110100011000111111000110001", "11110100011111010001100011111", "01110100011000010000100000111", "11110100011000110001100011110", "11111100001111010000100011111", "11111100001111010000100010000", "01110100011000010111100001111", "10001100011111110001100011000", "01110001000010000100001000111", "00111000100001000100011001100", "10001100101110010010100011000", "10000100001000010000100001111", "10001110111010110001100011000", "10001110011010110011100011000", "01110100011000110001100010111", "11110100011111010000100010000", "01110100011000110001101010101", "11110100011111010010100011001", "01111100000111000001100011110", "11111001000010000100001000010", "10001100011000110001100001110", "10001100011000101010001000100", "10001100011000110101101011010", "10001010100010001010100010001", "10001010100010000100001000010", "11111000100010001000100011111" }; for (int i = 0; i < 26; i++) { string text = array[i]; for (int j = 0; j < 25; j++) { letters[65 + i, j] = text[j] == '1'; } } string[] array2 = new string[10] { "01110100011000110001100010111", "00100011000010000100001000111", "01110100010001000100010001111", "11110000111100000011100011110", "10001100111110000010000100010", "11111100001111000001100011111", "01110100001111010001100010111", "11111000010001000100001000010", "01110100011000101110100010111", "01110100011000101111000011110" }; for (int k = 0; k < 10; k++) { string text2 = array2[k]; for (int l = 0; l < 25; l++) { letters[48 + k, l] = text2[l] == '1'; } } string text3 = "00000000000000000000011111"; for (int m = 0; m < 25; m++) { letters[95, m] = text3[m] == '1'; } } public static bool GenerateFromFile(string connectionsFilePath, string outputImagePath) { if (!File.Exists(connectionsFilePath)) { Debug.LogWarning((object)("File not found: " + connectionsFilePath)); return false; } string[] array = File.ReadAllLines(connectionsFilePath); Dictionary<string, HashSet<string>> dictionary = new Dictionary<string, HashSet<string>>(StringComparer.OrdinalIgnoreCase); string[] array2 = array; for (int i = 0; i < array2.Length; i++) { string text = array2[i]?.Trim(); if (string.IsNullOrEmpty(text) || text.StartsWith("#")) { continue; } string[] array3 = text.Split(new char[1] { '|' }); if (array3.Length != 4) { continue; } string text2 = array3[0]; string text3 = array3[2]; if (!string.IsNullOrEmpty(text2) && !string.IsNullOrEmpty(text3)) { if (!dictionary.ContainsKey(text2)) { dictionary[text2] = new HashSet<string>(StringComparer.OrdinalIgnoreCase); } if (!dictionary.ContainsKey(text3)) { dictionary[text3] = new HashSet<string>(StringComparer.OrdinalIgnoreCase); } dictionary[text2].Add(text3); dictionary[text3].Add(text2); } } if (dictionary.Count == 0) { Debug.LogWarning((object)"No connections found."); return false; } GenerateMapTexture(dictionary, outputImagePath); Debug.Log((object)("Map saved to " + outputImagePath)); return true; } private static void GenerateMapTexture(Dictionary<string, HashSet<string>> graph, string outputPath) { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown //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_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) int num = 250; int num2 = 120; int num3 = 100; int num4 = 80; List<string> list = graph.Keys.ToList(); int num5 = (int)Math.Ceiling(Math.Sqrt(list.Count)); int num6 = (int)Math.Ceiling((double)list.Count / (double)num5); int num7 = num5 * (num + num3) + num3; int num8 = num6 * (num2 + num4) + num4; Texture2D val = new Texture2D(num7, num8, (TextureFormat)4, false); Color[] array = (Color[])(object)new Color[num7 * num8]; for (int i = 0; i < array.Length; i++) { array[i] = Color.black; } val.SetPixels(array); Dictionary<string, Vector2> dictionary = new Dictionary<string, Vector2>(); int num9 = 0; int num10 = 0; foreach (string item in list) { dictionary[item] = new Vector2((float)(num3 + num9 * (num + num3)), (float)(num4 + num10 * (num2 + num4))); num9++; if (num9 >= num5) { num9 = 0; num10++; } } foreach (KeyValuePair<string, HashSet<string>> item2 in graph) { if (!dictionary.TryGetValue(item2.Key, out var value)) { continue; } foreach (string item3 in item2.Value) { if (dictionary.TryGetValue(item3, out var value2)) { DrawLine(val, (int)(value.x + (float)(num / 2)) + 2, (int)(value.y + (float)(num2 / 2)) + 2, (int)(value2.x + (float)(num / 2)) + 2, (int)(value2.y + (float)(num2 / 2)) + 2, Color.gray, 3); } } } foreach (KeyValuePair<string, Vector2> item4 in dictionary) { DrawEmptyRectangle(val, (int)item4.Value.x, (int)item4.Value.y, num, num2, Color.gray); DrawTextBitmap(val, (int)item4.Value.x + 10, (int)item4.Value.y + 35, item4.Key, Color.white); } val.Apply(); string directoryName = Path.GetDirectoryName(outputPath); if (!string.IsNullOrEmpty(directoryName) && !Directory.Exists(directoryName)) { Directory.CreateDirectory(directoryName); } File.WriteAllBytes(outputPath, ImageConversion.EncodeToPNG(val)); Object.DestroyImmediate((Object)(object)val); } private static void DrawEmptyRectangle(Texture2D tex, int x, int y, int w, int h, Color color) { //IL_0021: 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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) for (int i = x; i < x + w; i++) { if (i >= 0 && i < ((Texture)tex).width) { if (y >= 0 && y < ((Texture)tex).height) { tex.SetPixel(i, y, color); } if (y + h - 1 >= 0 && y + h - 1 < ((Texture)tex).height) { tex.SetPixel(i, y + h - 1, color); } } } for (int j = y; j < y + h; j++) { if (j >= 0 && j < ((Texture)tex).height) { if (x >= 0 && x < ((Texture)tex).width) { tex.SetPixel(x, j, color); } if (x + w - 1 >= 0 && x + w - 1 < ((Texture)tex).width) { tex.SetPixel(x + w - 1, j, color); } } } } private static void DrawTextBitmap(Texture2D tex, int x, int y, string text, Color color) { //IL_00c6: Unknown result type (might be due to invalid IL or missing references) int num = x; int num2 = 4; int num3 = 1; string text2 = text.ToUpper(); foreach (char c in text2) { if ((c < 'A' || c > 'Z') && (c < '0' || c > '9') && c != '_') { num += 5 * num2 + num2; continue; } for (int j = 0; j < 5; j++) { for (int k = 0; k < 5; k++) { if (!letters[(uint)c, j * 5 + k]) { continue; } int num4 = ((c != '_') ? (4 - j) : (4 - j - num3)); for (int l = 0; l < num2; l++) { for (int m = 0; m < num2; m++) { int num5 = num + k * num2 + l; int num6 = y + num4 * num2 + m; if (num5 >= 0 && num5 < ((Texture)tex).width && num6 >= 0 && num6 < ((Texture)tex).height) { tex.SetPixel(num5, num6, color); } } } } } num += 5 * num2 + num2; } } private static void DrawLine(Texture2D tex, int x0, int y0, int x1, int y1, Color color, int thickness = 2) { //IL_006d: Unknown result type (might be due to invalid IL or missing references) int num = Math.Abs(x1 - x0); int num2 = ((x0 < x1) ? 1 : (-1)); int num3 = -Math.Abs(y1 - y0); int num4 = ((y0 < y1) ? 1 : (-1)); int num5 = num + num3; while (true) { for (int i = -thickness / 2; i <= thickness / 2; i++) { for (int j = -thickness / 2; j <= thickness / 2; j++) { int num6 = x0 + i; int num7 = y0 + j; if (num6 >= 0 && num6 < ((Texture)tex).width && num7 >= 0 && num7 < ((Texture)tex).height) { tex.SetPixel(num6, num7, color); } } } if (x0 != x1 || y0 != y1) { int num8 = 2 * num5; if (num8 >= num3) { num5 += num3; x0 += num2; } if (num8 <= num) { num5 += num; y0 += num4; } continue; } break; } } } [BepInPlugin("com.yourname.randomsceneloader", "Random Scene Loader", "0.1.1")] public class RandomSceneLoader : BaseUnityPlugin { internal class SceneConfig { public List<string> Exits; public SceneConfig(List<string> exits) { Exits = exits ?? new List<string>(); } } [CompilerGenerated] private sealed class <AutoDiscoverAfterLoad>d__42 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public RandomSceneLoader <>4__this; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <AutoDiscoverAfterLoad>d__42(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { int num = <>1__state; RandomSceneLoader randomSceneLoader = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; <>2__current = randomSceneLoader.waitHalfSecond; <>1__state = 1; return true; case 1: <>1__state = -1; randomSceneLoader.DiscoverGatesInCurrentScene(); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <DetectEntryGateAfterLoad>d__45 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public RandomSceneLoader <>4__this; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <DetectEntryGateAfterLoad>d__45(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: 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_00de: Unknown result type (might be due to invalid IL or missing references) int num = <>1__state; RandomSceneLoader randomSceneLoader = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; <>2__current = randomSceneLoader.waitThirdSecond; <>1__state = 1; return true; case 1: <>1__state = -1; try { HeroController instance = HeroController.instance; if ((Object)(object)instance != (Object)null) { Vector3 position = ((Component)instance).transform.position; GameObject[] array = Object.FindObjectsByType<GameObject>((FindObjectsSortMode)0); foreach (GameObject val in array) { string text = ((Object)val).name.ToLower(); if ((text.StartsWith("left") || text.StartsWith("right") || text.StartsWith("top") || text.StartsWith("bot")) && text.Length <= 6 && char.IsDigit(text[text.Length - 1]) && (double)Vector3.Distance(position, val.transform.position) < 10.0) { if (string.IsNullOrEmpty(randomSceneLoader.lastEntryGateUsed)) { randomSceneLoader.lastEntryGateUsed = ((Object)val).name; randomSceneLoader.log.LogInfo((object)("Auto-detected entry gate: " + ((Object)val).name)); } break; } } } } catch (Exception ex) { randomSceneLoader.log.LogWarning((object)("DetectEntryGate failed: " + ex.Message)); } return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <LoadSceneCoroutine>d__40 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public RandomSceneLoader <>4__this; public string entryGate; public string sceneName; private float <timeout>5__2; private float <startTime>5__3; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <LoadSceneCoroutine>d__40(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_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_009a: 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_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: 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_00c0: Expected O, but got Unknown int num = <>1__state; RandomSceneLoader randomSceneLoader = <>4__this; Scene activeScene; switch (num) { default: return false; case 0: <>1__state = -1; if (randomSceneLoader.isTransitioning) { break; } randomSceneLoader.loadRequested = false; randomSceneLoader.isTransitioning = true; randomSceneLoader.lastEntryGateUsed = entryGate; <timeout>5__2 = 8f; <startTime>5__3 = Time.time; if (!string.IsNullOrEmpty(sceneName) && (Object)(object)GameManager.instance != (Object)null) { try { GameManager.instance.BeginSceneTransition(new SceneLoadInfo { SceneName = sceneName, EntryGateName = entryGate, PreventCameraFadeOut = false, WaitForSceneTransitionCameraFade = true, Visualization = (SceneLoadVisualizations)0 }); } catch (Exception ex) { randomSceneLoader.log.LogWarning((object)("BeginSceneTransition failed: " + ex.Message)); randomSceneLoader.isTransitioning = false; SuppressTransitionPatch = false; return false; } goto IL_014f; } try { SceneManager.LoadScene(sceneName); } catch (Exception ex2) { randomSceneLoader.log.LogWarning((object)("SceneManager.LoadScene failed: " + ex2.Message)); } finally { randomSceneLoader.isTransitioning = false; } break; case 1: <>1__state = -1; goto IL_014f; case 2: { <>1__state = -1; randomSceneLoader.isTransitioning = false; break; } IL_014f: activeScene = SceneManager.GetActiveScene(); if (((Scene)(ref activeScene)).name != sceneName) { if (Time.time - <startTime>5__3 > <timeout>5__2) { randomSceneLoader.log.LogWarning((object)("LoadSceneCoroutine timeout waiting for scene " + sceneName)); randomSceneLoader.isTransitioning = false; SuppressTransitionPatch = false; return false; } <>2__current = randomSceneLoader.waitTenthSecond; <>1__state = 1; return true; } <>2__current = randomSceneLoader.waitFifthSecond; <>1__state = 2; return true; } SuppressTransitionPatch = false; return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } internal ManualLogSource log; private Random rng; internal readonly Dictionary<string, SceneConfig> sceneConfigs = new Dictionary<string, SceneConfig>(StringComparer.OrdinalIgnoreCase) { { "Tut_01", new SceneConfig(new List<string> { "left1", "left2", "left3", "right1", "right2", "top1" }) }, { "Tut_01b", new SceneConfig(new List<string> { "left1", "left2", "right1" }) }, { "Tut_02", new SceneConfig(new List<string> { "right1", "right2" }) }, { "Tut_03", new SceneConfig(new List<string> { "right1", "top1" }) }, { "Bonetown", new SceneConfig(new List<string> { "bot1", "bot2", "left1", "left2", "right1", "right2", "top1", "top2", "top3", "top4", "top5", "top6" }) }, { "Weave_02", new SceneConfig(new List<string> { "left2", "left3", "left4", "right1", "right2", "right3" }) }, { "Weave_03", new SceneConfig(new List<string> { "right1" }) }, { "Weave_04", new SceneConfig(new List<string> { "left1", "right2" }) }, { "Weave_05b", new SceneConfig(new List<string> { "left1" }) }, { "Weave_07", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Weave_08", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Weave_10", new SceneConfig(new List<string> { "left1" }) }, { "Weave_11", new SceneConfig(new List<string> { "right1", "top1" }) }, { "Weave_12", new SceneConfig(new List<string> { "left1" }) }, { "Weave_13", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Weave_14", new SceneConfig(new List<string> { "bot1" }) }, { "Bone_01", new SceneConfig(new List<string> { "left2", "right1", "right2", "top2" }) }, { "Bone_04", new SceneConfig(new List<string> { "bot2", "left1", "left2", "right1", "top1" }) }, { "Bone_05", new SceneConfig(new List<string> { "bot1", "left1", "right1" }) }, { "Bone_03", new SceneConfig(new List<string> { "bot1", "left1", "left2", "left4", "right1", "right3", "top1" }) }, { "Bone_05b", new SceneConfig(new List<string> { "left1", "top1" }) }, { "Bone_06", new SceneConfig(new List<string> { "bot1", "left1", "right1" }) }, { "Bone_07", new SceneConfig(new List<string> { "left1", "right1", "right2", "top1" }) }, { "Bone_08", new SceneConfig(new List<string> { "bot1", "left2", "left3", "right2", "right3" }) }, { "Bone_09", new SceneConfig(new List<string> { "left1", "right1", "right2", "top1" }) }, { "Bone_10", new SceneConfig(new List<string> { "bot1", "left1", "right1" }) }, { "Bone_11", new SceneConfig(new List<string> { "bot1", "left1", "right1", "right2", "top1" }) }, { "Bone_14", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Bone_15", new SceneConfig(new List<string> { "bot1", "left1" }) }, { "Bone_16", new SceneConfig(new List<string> { "left1", "right1", "top1" }) }, { "Bone_17", new SceneConfig(new List<string> { "right1" }) }, { "Bone_18", new SceneConfig(new List<string> { "left1" }) }, { "Bone_19", new SceneConfig(new List<string> { "bot1" }) }, { "Bone_East_01", new SceneConfig(new List<string> { "left1", "left2", "right1", "right2", "right3" }) }, { "Bone_East_02", new SceneConfig(new List<string> { "left1", "right1", "top1" }) }, { "Bone_East_04", new SceneConfig(new List<string> { "bot1", "left1", "right1", "right2", "top2" }) }, { "Bone_East_05", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Bone_East_07", new SceneConfig(new List<string> { "left1", "left2", "left3", "left4", "right1", "right2", "right3", "right4", "right5", "top1" }) }, { "Bone_East_09", new SceneConfig(new List<string> { "left2", "left3", "right1", "right2", "top1" }) }, { "Bone_East_10", new SceneConfig(new List<string> { "left1", "left2", "right1", "right2" }) }, { "Bone_East_11", new SceneConfig(new List<string> { "bot1", "left1", "right1", "right2" }) }, { "Bone_East_12", new SceneConfig(new List<string> { "bot1", "left1", "right1" }) }, { "Bone_East_13", new SceneConfig(new List<string> { "left1" }) }, { "Bone_East_14", new SceneConfig(new List<string> { "left1", "left2", "right1", "right2" }) }, { "Bone_East_15", new SceneConfig(new List<string> { "bot1", "left1", "right1" }) }, { "Bone_East_16", new SceneConfig(new List<string> { "bot1", "right1" }) }, { "Bone_East_17", new SceneConfig(new List<string> { "bot1", "left1", "right1" }) }, { "Bone_East_18", new SceneConfig(new List<string> { "left1", "right1", "top1" }) }, { "Bone_East_18b", new SceneConfig(new List<string> { "left1", "top1" }) }, { "Bone_East_18c", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Bone_East_20", new SceneConfig(new List<string> { "right1" }) }, { "Bone_East_22", new SceneConfig(new List<string> { "left1" }) }, { "Bone_East_24", new SceneConfig(new List<string> { "bot1", "left1", "right1" }) }, { "Bone_East_25", new SceneConfig(new List<string> { "left1" }) }, { "Bone_East_26", new SceneConfig(new List<string> { "bot1", "top1" }) }, { "Bone_East_27", new SceneConfig(new List<string> { "bot1", "left1", "right1" }) }, { "Bone_East_04c", new SceneConfig(new List<string> { "left1" }) }, { "Bone_East_04b", new SceneConfig(new List<string> { "left1", "right1", "top1" }) }, { "Bone_East_09b", new SceneConfig(new List<string> { "bot1", "left1", "top1" }) }, { "Bone_East_14b", new SceneConfig(new List<string> { "left1", "left2", "right1" }) }, { "Ant_02", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Ant_03", new SceneConfig(new List<string> { "left2", "right3" }) }, { "Ant_04", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Ant_04_left", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Ant_04_mid", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Ant_05b", new SceneConfig(new List<string> { "bot1", "bot2", "right1" }) }, { "Ant_05c", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Ant_09", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Ant_14", new SceneConfig(new List<string> { "left1", "left2", "left3", "left4", "left5", "right2", "right3" }) }, { "Ant_17", new SceneConfig(new List<string> { "right1" }) }, { "Ant_19", new SceneConfig(new List<string> { "left1" }) }, { "Ant_20", new SceneConfig(new List<string> { "left1" }) }, { "Ant_21", new SceneConfig(new List<string> { "right1" }) }, { "Ant_Merchant", new SceneConfig(new List<string> { "right1" }) }, { "Ant_Queen", new SceneConfig(new List<string> { "left1" }) }, { "Aspid_01", new SceneConfig(new List<string> { "bot1", "bot2", "bot3", "bot4", "bot5", "bot6", "bot7", "bot8", "left1", "left2", "right2", "right3", "right4", "top1", "top2", "top3", "top4", "top5", "top6", "top7" }) }, { "Belltown_04", new SceneConfig(new List<string> { "bot1", "left1", "left2" }) }, { "Belltown_06", new SceneConfig(new List<string> { "left1", "left3", "right1" }) }, { "Belltown_Room_shellwood", new SceneConfig(new List<string> { "left1" }) }, { "Belltown_Shrine", new SceneConfig(new List<string> { "right1", "top1" }) }, { "Belltown_basement_03", new SceneConfig(new List<string> { "left1", "top1" }) }, { "Bellshrine", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Bellshrine_03", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Bonegrave", new SceneConfig(new List<string> { "right1", "right2", "top1" }) }, { "Bone_01c", new SceneConfig(new List<string> { "left1", "left2", "right1" }) }, { "Bone_02", new SceneConfig(new List<string> { "left1", "right1", "top1", "top2" }) }, { "Bellshrine_05", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Bellway_03", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Greymoor_01", new SceneConfig(new List<string> { "bot1", "left1", "left2", "right1", "right2", "right3" }) }, { "Bellshrine_02", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Greymoor_02", new SceneConfig(new List<string> { "left1", "left2", "left3", "right1", "right2", "right3" }) }, { "Greymoor_15", new SceneConfig(new List<string> { "left1", "left3", "right2", "right3" }) }, { "Greymoor_15b", new SceneConfig(new List<string> { "left2", "left3", "right1", "top1" }) }, { "Room_CrowCourt", new SceneConfig(new List<string> { "bot1", "left1" }) }, { "Room_CrowCourt_02", new SceneConfig(new List<string> { "top1" }) }, { "Clover_01", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Greymoor_22", new SceneConfig(new List<string> { "bot1" }) }, { "Greymoor_12", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Greymoor_03", new SceneConfig(new List<string> { "left1", "left2", "left3", "right1", "right2", "right3", "right4", "right5" }) }, { "Dust_01", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Dust_02", new SceneConfig(new List<string> { "left1", "left2", "right1", "right2", "right3", "top1" }) }, { "Dust_03", new SceneConfig(new List<string> { "bot1", "left1", "top1" }) }, { "Dust_Chef", new SceneConfig(new List<string> { "bot1", "left1" }) }, { "Dust_04", new SceneConfig(new List<string> { "left1", "left2", "right1" }) }, { "Dust_Shack", new SceneConfig(new List<string> { "left1" }) }, { "Dust_10", new SceneConfig(new List<string> { "right1" }) }, { "Dust_05", new SceneConfig(new List<string> { "bot1", "left1", "right1" }) }, { "Dust_06", new SceneConfig(new List<string> { "left1", "right1", "right2", "right3" }) }, { "Dust_12", new SceneConfig(new List<string> { "left1" }) }, { "Dust_11", new SceneConfig(new List<string> { "bot1", "left1" }) }, { "Greymoor_17", new SceneConfig(new List<string> { "left1", "top1" }) }, { "Halfway_01", new SceneConfig(new List<string> { "bot1", "left1", "right1" }) }, { "Greymoor_04", new SceneConfig(new List<string> { "left1", "left2", "left3", "right1", "right2" }) }, { "Greymoor_11", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Greymoor_06", new SceneConfig(new List<string> { "left1", "left2", "left3", "right1", "right2", "right3", "right4", "top1" }) }, { "Greymoor_10", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Wisp_03", new SceneConfig(new List<string> { "right1", "top1" }) }, { "Wisp_06", new SceneConfig(new List<string> { "bot1" }) }, { "Greymoor_07", new SceneConfig(new List<string> { "bot1", "left1", "right1", "right2" }) }, { "Greymoor_20b", new SceneConfig(new List<string> { "right1" }) }, { "Greymoor_20c", new SceneConfig(new List<string> { "left1" }) }, { "Greymoor_08", new SceneConfig(new List<string> { "left2", "right1", "top1" }) }, { "Greymoor_16", new SceneConfig(new List<string> { "left1", "top1" }) }, { "Bellway_04", new SceneConfig(new List<string> { "bot1", "left1" }) }, { "Greymoor_05", new SceneConfig(new List<string> { "left1", "left2", "right1", "right2" }) }, { "Belltown", new SceneConfig(new List<string> { "left3", "right2" }) }, { "Memory_Needolin", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Belltown_07", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Shellwood_01", new SceneConfig(new List<string> { "left1", "left2", "right1", "right2" }) }, { "Shellwood_02", new SceneConfig(new List<string> { "left2", "left3", "right1", "right2" }) }, { "Shellwood_16", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Shellwood_03", new SceneConfig(new List<string> { "bot1", "left1", "left3", "right1", "right2", "right3" }) }, { "Shellwood_04b", new SceneConfig(new List<string> { "left1", "right1", "top1", "top2" }) }, { "Shellwood_08c", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Shellwood_04c", new SceneConfig(new List<string> { "bot1", "top1" }) }, { "Shellwood_08", new SceneConfig(new List<string> { "bot1", "left1", "right1" }) }, { "Coral_19", new SceneConfig(new List<string> { "bot1", "bot2", "bot3", "bot4", "bot5", "bot6", "bot7", "right1", "top1", "top2", "top3", "top4", "top5", "top6", "top7", "top8" }) }, { "Shellwood_19", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Shellwood_14", new SceneConfig(new List<string> { "left1" }) }, { "Shellwood_10", new SceneConfig(new List<string> { "left1", "left2", "left3", "right1", "right2", "right3" }) }, { "Shellwood_11", new SceneConfig(new List<string> { "right1", "right2" }) }, { "Shellwood_26", new SceneConfig(new List<string> { "bot1", "left1" }) }, { "Shellwood_18", new SceneConfig(new List<string> { "left1", "right1", "top1" }) }, { "Shellwood_13", new SceneConfig(new List<string> { "left1", "left2", "right1" }) }, { "Shellwood_01b", new SceneConfig(new List<string> { "left1", "left2", "right1", "right2", "right3" }) }, { "Shellwood_20", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Shellwood_Witch", new SceneConfig(new List<string> { "right1" }) }, { "Dock_08", new SceneConfig(new List<string> { "left1", "left2", "right1" }) }, { "Dock_01", new SceneConfig(new List<string> { "left1", "right1", "right2" }) }, { "Bellway_02", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Dock_16", new SceneConfig(new List<string> { "right1" }) }, { "Bone_East_03", new SceneConfig(new List<string> { "left1", "top1" }) }, { "Room_Forge", new SceneConfig(new List<string> { "left1", "right1", "top1" }) }, { "Dock_04", new SceneConfig(new List<string> { "left1", "right1", "right2", "right3" }) }, { "Dock_06_Church", new SceneConfig(new List<string> { "bot1", "right1" }) }, { "Dock_10", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Dock_15", new SceneConfig(new List<string> { "left1", "left2", "right1", "right2", "right3" }) }, { "Dock_13", new SceneConfig(new List<string> { "right1" }) }, { "Dock_11", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Dock_12", new SceneConfig(new List<string> { "left1" }) }, { "Dock_14", new SceneConfig(new List<string> { "left1" }) }, { "Dock_09", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Dock_02", new SceneConfig(new List<string> { "left1", "left2", "right1", "right2", "right3" }) }, { "Dock_02b", new SceneConfig(new List<string> { "left1", "left2", "left3", "right1", "right2" }) }, { "Dock_03c", new SceneConfig(new List<string> { "left2", "top1", "top2" }) }, { "Dock_03", new SceneConfig(new List<string> { "bot1", "left1", "right1" }) }, { "Dock_03b", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Shellwood_15", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Coral_19b", new SceneConfig(new List<string> { "bot1" }) }, { "Coral_02", new SceneConfig(new List<string> { "bot2", "right1" }) }, { "Coral_03", new SceneConfig(new List<string> { "bot1", "bot2", "bot3", "bot4", "bot5", "bot6", "left1", "left2", "left3", "right1", "right2", "right3" }) }, { "Coral_12", new SceneConfig(new List<string> { "left2", "left3", "right1" }) }, { "Coral_11", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Coral_11b", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Coral_34", new SceneConfig(new List<string> { "right1", "top1" }) }, { "Coral_25", new SceneConfig(new List<string> { "bot1", "right1" }) }, { "Coral_23", new SceneConfig(new List<string> { "left1", "left2", "right1" }) }, { "Coral_39", new SceneConfig(new List<string> { "right1" }) }, { "Coral_35b", new SceneConfig(new List<string> { "bot1", "left2", "left3", "left4", "left5", "right1", "right2" }) }, { "Coral_40", new SceneConfig(new List<string> { "right1" }) }, { "Coral_41", new SceneConfig(new List<string> { "right1" }) }, { "Coral_35", new SceneConfig(new List<string> { "left1", "left2", "right1", "right2", "top1" }) }, { "Coral_24", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Coral_26", new SceneConfig(new List<string> { "left1", "left2", "right1" }) }, { "Coral_38", new SceneConfig(new List<string> { "bot1", "left1", "right1" }) }, { "Coral_44", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Coral_29", new SceneConfig(new List<string> { "left1" }) }, { "Coral_27", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Coral_28", new SceneConfig(new List<string> { "right1" }) }, { "Coral_Tower_01", new SceneConfig(new List<string> { "left1" }) }, { "Coral_42", new SceneConfig(new List<string> { "right1" }) }, { "Coral_43", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Bellway_08", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Coral_32", new SceneConfig(new List<string> { "left1", "right1", "top1" }) }, { "Coral_Judge_Arena", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Coral_10", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Song_19_entrance", new SceneConfig(new List<string> { "left1", "right1", "right2" }) }, { "Song_01c", new SceneConfig(new List<string> { "left1", "top1" }) }, { "Song_01", new SceneConfig(new List<string> { "bot1", "right2", "top1" }) }, { "Under_07b", new SceneConfig(new List<string> { "bot1", "left1" }) }, { "Song_01b", new SceneConfig(new List<string> { "bot1", "right1", "top1" }) }, { "Song_05", new SceneConfig(new List<string> { "left3", "left4", "left5", "right2", "right3", "right4" }) }, { "Song_02", new SceneConfig(new List<string> { "left2", "right1" }) }, { "Ward_01", new SceneConfig(new List<string> { "left1", "left2", "left3", "right1", "right2", "right3" }) }, { "Ward_02", new SceneConfig(new List<string> { "bot1", "right1", "top1" }) }, { "Ward_02b", new SceneConfig(new List<string> { "bot1", "right1" }) }, { "Ward_03", new SceneConfig(new List<string> { "bot1", "left1", "top1" }) }, { "Ward_07", new SceneConfig(new List<string> { "bot1" }) }, { "Ward_06", new SceneConfig(new List<string> { "bot1", "top1" }) }, { "Song_07", new SceneConfig(new List<string> { "right1" }) }, { "Song_27", new SceneConfig(new List<string> { "left1", "right1", "top1" }) }, { "Song_20", new SceneConfig(new List<string> { "left1", "left2", "right4", "right5", "right6", "top1" }) }, { "Bellway_City", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Library_13", new SceneConfig(new List<string> { "left1", "right1", "right2" }) }, { "Song_11", new SceneConfig(new List<string> { "left1", "left2", "left3", "left4", "right1", "right2", "right3" }) }, { "Song_15", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Song_17", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Hang_01", new SceneConfig(new List<string> { "right1", "right2" }) }, { "Hang_02", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Hang_03", new SceneConfig(new List<string> { "left1", "left2", "right1", "right2", "top1" }) }, { "Hang_10", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Hang_03_top", new SceneConfig(new List<string> { "bot1" }) }, { "Hang_13", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Hang_08", new SceneConfig(new List<string> { "bot1", "left1", "left2", "left3", "left4", "right1" }) }, { "Hang_09", new SceneConfig(new List<string> { "right1" }) }, { "Hang_16", new SceneConfig(new List<string> { "right1" }) }, { "Hang_06", new SceneConfig(new List<string> { "bot1", "left1", "right1", "top1" }) }, { "Hang_06b", new SceneConfig(new List<string> { "left1" }) }, { "Hang_17b", new SceneConfig(new List<string> { "left1" }) }, { "Hang_04", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Hang_12", new SceneConfig(new List<string> { "right1" }) }, { "Hang_07", new SceneConfig(new List<string> { "bot1", "left1", "right1", "top1" }) }, { "Song_09", new SceneConfig(new List<string> { "bot1", "right1", "top1" }) }, { "Song_09b", new SceneConfig(new List<string> { "left1", "top1" }) }, { "Cog_05", new SceneConfig(new List<string> { "left1", "right2", "top1" }) }, { "Cog_Dancers", new SceneConfig(new List<string> { "bot1", "bot2", "left1", "right1", "top1" }) }, { "Cog_04", new SceneConfig(new List<string> { "left2", "right2", "right3", "top1", "top2" }) }, { "Cog_Bench", new SceneConfig(new List<string> { "left1" }) }, { "Song_25", new SceneConfig(new List<string> { "bot1", "left1", "right1", "top1", "top2" }) }, { "Song_Enclave", new SceneConfig(new List<string> { "bot1", "left1", "left2", "top1" }) }, { "Song_Enclave_Tube", new SceneConfig(new List<string> { "bot1" }) }, { "Under_01", new SceneConfig(new List<string> { "left1", "left2", "left3", "right1" }) }, { "Under_27", new SceneConfig(new List<string> { "left1", "right1", "right2" }) }, { "Shellwood_22", new SceneConfig(new List<string> { "right1" }) }, { "Shellwood_11b", new SceneConfig(new List<string> { "right1" }) }, { "Under_01b", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Under_02", new SceneConfig(new List<string> { "left1", "left3", "right1", "right2", "right3", "right4" }) }, { "Under_14", new SceneConfig(new List<string> { "left1" }) }, { "Under_16", new SceneConfig(new List<string> { "right1" }) }, { "Under_03b", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Under_07", new SceneConfig(new List<string> { "left3", "right2" }) }, { "Under_07c", new SceneConfig(new List<string> { "left2", "top1" }) }, { "Under_06", new SceneConfig(new List<string> { "left1", "right1", "top1" }) }, { "Under_08", new SceneConfig(new List<string> { "bot1", "top1" }) }, { "Under_05", new SceneConfig(new List<string> { "left1", "left2", "left3", "right1", "right2", "right3" }) }, { "Under_11", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Under_23", new SceneConfig(new List<string> { "bot1", "right1" }) }, { "Wisp_09", new SceneConfig(new List<string> { "right1", "top1" }) }, { "Wisp_05", new SceneConfig(new List<string> { "bot1", "left1" }) }, { "Wisp_02", new SceneConfig(new List<string> { "left1", "right1", "top1" }) }, { "Belltown_08", new SceneConfig(new List<string> { "right1" }) }, { "Wisp_04", new SceneConfig(new List<string> { "bot1", "left1", "right1" }) }, { "Wisp_08", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Wisp_07", new SceneConfig(new List<string> { "left1" }) }, { "Under_04", new SceneConfig(new List<string> { "left1", "right1", "top1" }) }, { "Under_03c", new SceneConfig(new List<string> { "left1", "left2", "right1" }) }, { "Under_03", new SceneConfig(new List<string> { "right1" }) }, { "Under_10", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Under_12", new SceneConfig(new List<string> { "left1" }) }, { "Under_13", new SceneConfig(new List<string> { "left1", "left2", "left3", "left4", "right1", "right2", "right3" }) }, { "Under_22", new SceneConfig(new List<string> { "right1" }) }, { "Under_21", new SceneConfig(new List<string> { "right1" }) }, { "Under_19", new SceneConfig(new List<string> { "left1", "top1" }) }, { "Under_19c", new SceneConfig(new List<string> { "bot1", "left1", "left2" }) }, { "Under_19b", new SceneConfig(new List<string> { "right1" }) }, { "Under_18", new SceneConfig(new List<string> { "left1", "right1", "top1", "top2" }) }, { "Under_17", new SceneConfig(new List<string> { "bot1", "bot2", "left1", "right1", "top1" }) }, { "Library_11b", new SceneConfig(new List<string> { "left3", "right1" }) }, { "Library_11", new SceneConfig(new List<string> { "left1", "left2", "left3", "right1", "right2" }) }, { "Library_13b", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Library_04", new SceneConfig(new List<string> { "left1", "left2", "left3", "left4", "right1", "right2", "right3", "right4", "right5", "right6", "top1" }) }, { "Library_16", new SceneConfig(new List<string> { "right1" }) }, { "Library_10", new SceneConfig(new List<string> { "bot1", "left1" }) }, { "Library_12b", new SceneConfig(new List<string> { "left1", "top1" }) }, { "Library_12", new SceneConfig(new List<string> { "left1", "left2", "right1" }) }, { "Library_05", new SceneConfig(new List<string> { "left1", "left2", "right1", "right2" }) }, { "Library_06", new SceneConfig(new List<string> { "left1", "left2", "right1" }) }, { "Library_07", new SceneConfig(new List<string> { "bot1", "bot2", "bot3", "left1", "left2", "top1" }) }, { "Library_08", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Library_09", new SceneConfig(new List<string> { "bot1", "left1" }) }, { "Library_14", new SceneConfig(new List<string> { "left1" }) }, { "Library_01", new SceneConfig(new List<string> { "left1", "left2", "left3", "right1", "right2" }) }, { "Library_15", new SceneConfig(new List<string> { "right1" }) }, { "Library_03", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Song_24", new SceneConfig(new List<string> { "right1" }) }, { "Song_20b", new SceneConfig(new List<string> { "bot1", "left2", "left4", "right2", "right3", "top1" }) }, { "Library_02", new SceneConfig(new List<string> { "left1", "left2", "right1", "right2" }) }, { "Song_29", new SceneConfig(new List<string> { "right1" }) }, { "Arborium_01", new SceneConfig(new List<string> { "bot1", "left1", "left2", "left3", "right1", "right2", "right3", "right4", "right5" }) }, { "Cog_10", new SceneConfig(new List<string> { "bot1" }) }, { "Cog_07", new SceneConfig(new List<string> { "left1" }) }, { "Cog_06", new SceneConfig(new List<string> { "left2", "right1" }) }, { "Arborium_04", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Arborium_03", new SceneConfig(new List<string> { "left1", "left2", "left3", "left4", "right1", "right2" }) }, { "Arborium_02", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Arborium_05", new SceneConfig(new List<string> { "right1", "top1" }) }, { "Arborium_06", new SceneConfig(new List<string> { "bot1", "left1", "right1" }) }, { "Arborium_09", new SceneConfig(new List<string> { "right1", "right2" }) }, { "Arborium_Tube", new SceneConfig(new List<string> { "right1" }) }, { "Arborium_07", new SceneConfig(new List<string> { "left1", "top1" }) }, { "Arborium_08", new SceneConfig(new List<string> { "bot1", "left1" }) }, { "Song_13", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Song_18", new SceneConfig(new List<string> { "bot1", "left1" }) }, { "Song_03", new SceneConfig(new List<string> { "bot1", "top1" }) }, { "Song_04", new SceneConfig(new List<string> { "bot1", "left1", "right1", "right2" }) }, { "Song_10", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Song_12", new SceneConfig(new List<string> { "left1", "left2", "left3", "left4", "right1", "right2", "right3" }) }, { "Song_14", new SceneConfig(new List<string> { "left1" }) }, { "Song_26", new SceneConfig(new List<string> { "right1" }) }, { "Song_28", new SceneConfig(new List<string> { "right1" }) }, { "Song_08", new SceneConfig(new List<string> { "right1" }) }, { "Slab_01", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Slab_02", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Slab_03", new SceneConfig(new List<string> { "left1", "left2", "left3", "left4", "left5", "left6", "left7", "left8", "right1", "right2", "right3", "right4", "right5", "right7", "right8", "right9" }) }, { "Slab_04", new SceneConfig(new List<string> { "bot1", "right1", "top1" }) }, { "Slab_23", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Slab_21", new SceneConfig(new List<string> { "left1", "left3", "top1" }) }, { "Slab_22", new SceneConfig(new List<string> { "bot1", "bot2" }) }, { "Slab_Cell_Creature", new SceneConfig(new List<string> { "left1" }) }, { "Slab_20", new SceneConfig(new List<string> { "left1" }) }, { "Slab_17", new SceneConfig(new List<string> { "left1" }) }, { "Slab_18", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Slab_16", new SceneConfig(new List<string> { "bot1", "left1", "right1", "top1" }) }, { "Slab_15", new SceneConfig(new List<string> { "bot1", "left1", "right1", "top1" }) }, { "Peak_01", new SceneConfig(new List<string> { "left1", "left2", "left3", "left4", "right1", "right2", "right3", "right4", "top1", "top2", "top3", "top4" }) }, { "Slab_14", new SceneConfig(new List<string> { "right1", "top1" }) }, { "Slab_13", new SceneConfig(new List<string> { "bot1", "left1", "right1" }) }, { "Slab_05", new SceneConfig(new List<string> { "bot1", "right1", "top1" }) }, { "Slab_06", new SceneConfig(new List<string> { "left1", "top1" }) }, { "Peak_07", new SceneConfig(new List<string> { "bot1", "bot2", "bot3", "bot4", "bot5", "top1", "top2" }) }, { "Peak_08b", new SceneConfig(new List<string> { "bot4", "bot5", "bot6", "left1", "left2" }) }, { "Peak_08", new SceneConfig(new List<string> { "bot1", "right1", "top1" }) }, { "Peak_05d", new SceneConfig(new List<string> { "bot1" }) }, { "Peak_05", new SceneConfig(new List<string> { "bot1", "right3", "top2" }) }, { "Peak_05c", new SceneConfig(new List<string> { "left2", "right1" }) }, { "Peak_05e", new SceneConfig(new List<string> { "left1", "right1", "right2" }) }, { "Peak_06b", new SceneConfig(new List<string> { "left1" }) }, { "Peak_02", new SceneConfig(new List<string> { "left1", "left2", "left3", "right1", "right2", "right3", "right4" }) }, { "Peak_04d", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Peak_04", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Bellway_Peak", new SceneConfig(new List<string> { "left1", "left2", "right1", "right2", "top1" }) }, { "Bellway_Peak_02", new SceneConfig(new List<string> { "left1" }) }, { "Peak_04c", new SceneConfig(new List<string> { "right1", "right2" }) }, { "Peak_10", new SceneConfig(new List<string> { "right1" }) }, { "Slab_08", new SceneConfig(new List<string> { "left1" }) }, { "Slab_Cell_Quiet", new SceneConfig(new List<string> { "left1", "left2" }) }, { "Slab_19b", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Slab_07", new SceneConfig(new List<string> { "right1", "right2" }) }, { "Slab_12", new SceneConfig(new List<string> { "left1" }) }, { "Slab_10c", new SceneConfig(new List<string> { "left1" }) }, { "Slab_10b", new SceneConfig(new List<string> { "left1" }) }, { "Cog_10_Destroyed", new SceneConfig(new List<string> { "bot1", "left1" }) }, { "Cog_09_Destroyed", new SceneConfig(new List<string> { "right1", "top1" }) }, { "Song_Tower_Destroyed", new SceneConfig(new List<string> { "bot1", "top1" }) }, { "Arborium_10", new SceneConfig(new List<string> { "left1" }) }, { "Arborium_11", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Aqueduct_01", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Aqueduct_02", new SceneConfig(new List<string> { "left1", "left2", "left3", "right1", "right2", "right3" }) }, { "Bellway_Aqueduct", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Aqueduct_07", new SceneConfig(new List<string> { "right1" }) }, { "Aqueduct_04", new SceneConfig(new List<string> { "bot1", "right1" }) }, { "Aqueduct_03", new SceneConfig(new List<string> { "left1", "right1", "top1" }) }, { "Aqueduct_06", new SceneConfig(new List<string> { "bot1", "left1", "left2" }) }, { "Aqueduct_08", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Aqueduct_05", new SceneConfig(new List<string> { "left1" }) }, { "Shadow_01", new SceneConfig(new List<string> { "left1", "left2", "left3", "right1", "right2", "right3", "top1" }) }, { "Shadow_18", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Shadow_12", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Shadow_19", new SceneConfig(new List<string> { "left1", "left2", "right1", "right2" }) }, { "Shadow_24", new SceneConfig(new List<string> { "left1" }) }, { "Shadow_10", new SceneConfig(new List<string> { "bot1", "left1", "right1" }) }, { "Shadow_25", new SceneConfig(new List<string> { "left1" }) }, { "Shadow_08", new SceneConfig(new List<string> { "left1", "top1" }) }, { "Shadow_27", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Shadow_26", new SceneConfig(new List<string> { "left1", "left2", "right1", "right2" }) }, { "Shadow_16", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Shadow_15", new SceneConfig(new List<string> { "right1", "right2" }) }, { "Shadow_14", new SceneConfig(new List<string> { "right1", "right2" }) }, { "Shadow_02", new SceneConfig(new List<string> { "left1", "left2", "right1", "right2", "right3" }) }, { "Shadow_11", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Shadow_13", new SceneConfig(new List<string> { "left1" }) }, { "Shadow_23", new SceneConfig(new List<string> { "left1" }) }, { "Shadow_03", new SceneConfig(new List<string> { "left1", "right1", "top1" }) }, { "Shadow_21", new SceneConfig(new List<string> { "bot1" }) }, { "Shadow_09", new SceneConfig(new List<string> { "left1", "left2", "left3", "right1" }) }, { "Shadow_Weavehome", new SceneConfig(new List<string> { "left1" }) }, { "Shadow_05", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Shadow_04b", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Shadow_04", new SceneConfig(new List<string> { "left1", "right1", "right2", "top1" }) }, { "Shadow_20", new SceneConfig(new List<string> { "bot1", "top1" }) }, { "Bellway_Shadow", new SceneConfig(new List<string> { "left1" }) }, { "Tube_Hub", new SceneConfig(new List<string> { "left1", "left3", "left4" }) }, { "Cradle_01", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Cradle_02", new SceneConfig(new List<string> { "left2", "right1", "right2" }) }, { "Cradle_02b", new SceneConfig(new List<string> { "right1" }) }, { "Cradle_03", new SceneConfig(new List<string> { "left2", "right2" }) }, { "Crawl_04", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Crawl_02", new SceneConfig(new List<string> { "left1", "left2", "right1", "right2", "right3" }) }, { "Crawl_06", new SceneConfig(new List<string> { "left1" }) }, { "Crawl_01", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Crawl_03", new SceneConfig(new List<string> { "bot1", "left1", "right1", "top1" }) }, { "Crawl_08", new SceneConfig(new List<string> { "bot1" }) }, { "Crawl_05", new SceneConfig(new List<string> { "right1" }) }, { "Crawl_03b", new SceneConfig(new List<string> { "bot1", "right1", "top1" }) }, { "Crawl_07", new SceneConfig(new List<string> { "bot1", "left1", "top1" }) }, { "Crawl_09", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Crawl_10", new SceneConfig(new List<string> { "right1" }) }, { "Abyss_12", new SceneConfig(new List<string> { "left1", "right2" }) }, { "Abyss_05", new SceneConfig(new List<string> { "left2", "right1" }) }, { "Abyss_08", new SceneConfig(new List<string> { "left1" }) }, { "Abyss_07", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Abyss_01", new SceneConfig(new List<string> { "left1", "right2", "right3", "right4" }) }, { "Abyss_06", new SceneConfig(new List<string> { "right1" }) }, { "Abyss_04", new SceneConfig(new List<string> { "left1" }) }, { "Abyss_02b", new SceneConfig(new List<string> { "left2", "right1", "top1" }) }, { "Abyss_02", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Abyss_03", new SceneConfig(new List<string> { "left1", "left2" }) }, { "Abyss_13", new SceneConfig(new List<string> { "left1", "right1", "top1" }) }, { "Abyss_11", new SceneConfig(new List<string> { "bot1", "right1" }) }, { "Abyss_09", new SceneConfig(new List<string> { "bot1", "top1" }) }, { "Greymoor_13", new SceneConfig(new List<string> { "bot1", "left1", "right1" }) }, { "Clover_01b", new SceneConfig(new List<string> { "right1" }) }, { "Clover_02c", new SceneConfig(new List<string> { "left1", "left2", "right1" }) }, { "Clover_05c", new SceneConfig(new List<string> { "left1", "left2", "right1", "right2", "right3" }) }, { "Clover_21", new SceneConfig(new List<string> { "right1" }) }, { "Clover_16", new SceneConfig(new List<string> { "right1", "top1" }) }, { "Clover_06", new SceneConfig(new List<string> { "bot1", "bot2" }) }, { "Clover_19", new SceneConfig(new List<string> { "left1", "top1" }) }, { "Clover_04b", new SceneConfig(new List<string> { "left1", "left2", "right1" }) }, { "Clover_11", new SceneConfig(new List<string> { "right1" }) }, { "Clover_03", new SceneConfig(new List<string> { "left1", "left2", "right1" }) }, { "Clover_18", new SceneConfig(new List<string> { "left1" }) }, { "Tut_04", new SceneConfig(new List<string> { "left1", "right1" }) }, { "Cog_09", new SceneConfig(new List<string> { "bot1" }) }, { "Cog_08", new SceneConfig(new List<string> { "bot1", "top1" }) } }; private string lastEntryGateUsed; private string previousSceneName; private string currentSceneName = "(unknown)"; private bool isTransitioning; private bool loadRequested; public static bool SuppressTransitionPatch; private bool autoDiscoveryMode; private HashSet<string> discoveredScenes = new HashSet<string>(StringComparer.OrdinalIgnoreCase); private string discoveryFilePath; private readonly List<string> preferredSceneSubstrings = new List<string>(); private WaitForSeconds waitHalfSecond; private WaitForSeconds waitThirdSecond; private WaitForSeconds waitTenthSecond; private WaitForSeconds waitFifthSecond; private GUIStyle sceneLabelStyle; private string cachedSceneLabel = ""; private string lastRenderedScene = ""; private ConfigEntry<bool> cfgShowSceneLabel; private ConfigEntry<string> cfgTeleportScene; private ConfigEntry<bool> cfgTeleportConfirm; private HashSet<string> visitedScenesF6 = new HashSet<string>(StringComparer.OrdinalIgnoreCase); public static bool EnableRandomization; private ConfigEntry<bool> cfgEnableRandomization; private ConfigEntry<bool> cfgInstantMusicTransition; private bool _apiInitialized; public static int CurrentSeed { get; internal set; } private void Awake() { //IL_0017: 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_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Expected O, but got Unknown //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Expected O, but got Unknown //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02ff: 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_0315: Expected O, but got Unknown //IL_034f: Unknown result type (might be due to invalid IL or missing references) //IL_0354: Unknown result type (might be due to invalid IL or missing references) //IL_0365: Expected O, but got Unknown log = ((BaseUnityPlugin)this).Logger; rng = new Random(); Scene activeScene = SceneManager.GetActiveScene(); currentSceneName = ((Scene)(ref activeScene)).name; waitHalfSecond = new WaitForSeconds(0.5f); waitThirdSecond = new WaitForSeconds(0.3f); waitTenthSecond = new WaitForSeconds(0.1f); waitFifthSecond = new WaitForSeconds(0.2f); sceneLabelStyle = new GUIStyle(); try { cfgShowSceneLabel = ((BaseUnityPlugin)this).Config.Bind<bool>("UI", "ShowSceneLabel", true, "Show small scene label in upper-left (toggle)"); } catch { } try { cfgTeleportScene = ((BaseUnityPlugin)this).Config.Bind<string>("Teleport", "TeleportScene", "", "Scene name to teleport to (type exact scene name)"); } catch { } try { cfgTeleportConfirm = ((BaseUnityPlugin)this).Config.Bind<bool>("Teleport", "TeleportConfirm", false, "Set to true to teleport to scene in TeleportScene (resets automatically)"); } catch { } try { cfgEnableRandomization = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnableRandomization", false, "Enable/disable scene transition randomization"); EnableRandomization = cfgEnableRandomization.Value; } catch { } try { cfgInstantMusicTransition = ((BaseUnityPlugin)this).Config.Bind<bool>("Audio", "InstantMusicTransition", true, "Instant music transition when changing scenes (disable fade in/out)"); } catch { } discoveryFilePath = Path.Combine(Paths.PluginPath, "discovered_exits.txt"); log.LogInfo((object)("RandomSceneLoader loaded. Current scene: " + currentSceneName + ". F5=random, F7=discover")); try { if (sceneConfigs != null) { discoveredScenes.UnionWith(sceneConfigs.Keys); log.LogInfo((object)$"Preloaded {discoveredScenes.Count} known scenes into discovered set"); } } catch { } try { string path = Path.Combine(Paths.PluginPath, "roomrando_connections.txt"); if (File.Exists(path)) { string[] array = File.ReadAllLines(path); foreach (string text in array) { if (text.StartsWith("#seed|", StringComparison.OrdinalIgnoreCase)) { string[] array2 = text.Split(new char[1] { '|' }); if (array2.Length >= 2 && int.TryParse(array2[1], out var result)) { CurrentSeed = result; log.LogInfo((object)$"Preloaded room random seed: {CurrentSeed}"); break; } } } } } catch (Exception ex) { log.LogWarning((object)("Failed to preload room random seed: " + ex.Message)); } if (autoDiscoveryMode) { log.LogInfo((object)("Auto-discovery mode enabled. RoomRando disabled. Results saved to: " + discoveryFilePath)); return; } try { new Harmony("com.yourname.randomsceneloader").PatchAll(); log.LogInfo((object)"Harmony patches applied successfully"); } catch (Exception ex2) { log.LogError((object)("Failed to apply Harmony patches: " + ex2.Message)); } try { if ((Object)(object)GameObject.Find("__RoomRando") == (Object)null) { GameObject val = new GameObject("__RoomRando"); val.AddComponent<RoomRando>().Initialize(this); Object.DontDestroyOnLoad((Object)val); } } catch (Exception ex3) { log.LogError((object)("Failed to create RoomRando: " + ex3.Message)); } try { if ((Object)(object)GameObject.Find("__SeedManager") == (Object)null) { GameObject val2 = new GameObject("__SeedManager"); val2.AddComponent<SeedManager>().Initialize(this); Object.DontDestroyOnLoad((Object)val2); } } catch (Exception ex4) { log.LogError((object)("Failed to create SeedManager: " + ex4.Message)); } GameObject obj7 = GameObject.Find("__RoomRando"); RoomRando rando = ((obj7 != null) ? obj7.GetComponent<RoomRando>() : null); HKSilksong_RandomizerAPI.Initialize(this, rando); _apiInitialized = true; } public string GetCurrentSceneName() { return currentSceneName; } public void SetShowSceneLabel(bool show) { if (cfgShowSceneLabel != null) { cfgShowSceneLabel.Value = show; } } public bool GetShowSceneLabel() { return cfgShowSceneLabel?.Value ?? true; } public void SetLastEntryGate(string gateName) { lastEntryGateUsed = gateName; } public void TeleportToScene(string sceneName) { try { if (isTransitioning) { log.LogInfo((object)"Teleport skipped: transition already in progress"); return; } if (string.IsNullOrWhiteSpace(sceneName)) { log.LogWarning((object)"TeleportToScene called with empty scene name"); return; } string text = null; string scenePart = sceneName.Trim(); int num = scenePart.LastIndexOf(' '); if (num > 0) { text = scenePart.Substring(num + 1).Trim(); scenePart = scenePart.Substring(0, num).Trim(); if (string.IsNullOrEmpty(text)) { text = null; } } string text2 = null; SceneConfig value = null; string text3 = null; if (sceneConfigs != null && sceneConfigs.TryGetValue(scenePart, out value)) { text3 = scenePart; } else if (sceneConfigs != null) { List<string> source = sceneConfigs.Keys.ToList(); string inputLetters = new string(scenePart.Where(char.IsLetter).ToArray()); string inputDigits = new string(scenePart.Where(char.IsDigit).ToArray()); text3 = source.FirstOrDefault((string s) => string.Equals(s, scenePart, StringComparison.OrdinalIgnoreCase)); if (text3 == null && !string.IsNullOrEmpty(inputLetters) && !string.IsNullOrEmpty(inputDigits)) { text3 = source.FirstOrDefault(delegate(string s) { string text4 = new string(s.Where(char.IsDigit).ToArray()); string text5 = new string(s.Where(char.IsLetter).ToArray()); return !string.IsNullOrEmpty(text4) && text5.IndexOf(inputLetters, StringComparison.OrdinalIgnoreCase) >= 0 && text4.IndexOf(inputDigits, StringComparison.OrdinalIgnoreCase) >= 0; }); } if (text3 == null && !string.IsNullOrEmpty(inputLetters) && string.IsNullOrEmpty(inputDigits)) { text3 = source.FirstOrDefault((string s) => string.IsNullOrEmpty(new string(s.Where(char.IsDigit).ToArray())) && s.IndexOf(inputLetters, StringComparison.OrdinalIgnoreCase) >= 0); } if (text3 == null) { text3 = source.FirstOrDefault((string s) => s.IndexOf(scenePart, StringComparison.OrdinalIgnoreCase) >= 0); } } if (text3 != null && sceneConfigs.TryGetValue(text3, out value)) { if (text != null) { if (value.Exits != null && value.Exits.Contains<string>(text, StringComparer.OrdinalIgnoreCase)) { text2 = text; } else { log.LogWarning((object)("TeleportToScene: entry '" + text + "' not valid for scene '" + text3 + "', will pick random.")); if (value.Exits != null && value.Exits.Count > 0) { text2 = value.Exits[rng.Next(value.Exits.Count)]; } } } else if (value.Exits != null && value.Exits.Count > 0) { text2 = value.Exits[rng.Next(value.Exits.Count)]; } log.LogInfo((object)("Teleport: " + scenePart + " -> " + text3 + " (entry '" + (text2 ?? "(null)") + "')")); } else { log.LogWarning((object)("TeleportToScene: scene '" + scenePart + "' not found in sceneConfigs. Attempting direct load.")); text3 = scenePart; if (text != null) { text2 = text; } } SuppressTransitionPatch = true; ((MonoBehaviour)this).StartCoroutine(LoadSceneCoroutine(text3, text2)); } catch (Exception arg) { log.LogError((object)$"TeleportToScene failed: {arg}"); } } private void LoadRandomUniqueScene() { if (isTransitioning) { log.LogInfo((object)"LoadRandomUniqueScene skipped: transition already in progress"); return; } List<string> list = sceneConfigs.Keys.Where((string k) => !string.Equals(k, currentSceneName, StringComparison.OrdinalIgnoreCase) && !visitedScenesF6.Contains(k)).ToList(); if (list.Count == 0) { log.LogInfo((object)"F6: All scenes have been visited already (or no candidates available). Clearing visited list."); visitedScenesF6.Clear(); list = sceneConfigs.Keys.Where((string k) => !string.Equals(k, currentSceneName, StringComparison.OrdinalIgnoreCase)).ToList(); if (list.Count == 0) { return; } } List<string> list2 = null; try { List<string> lowered = (from s in preferredSceneSubstrings where !string.IsNullOrWhiteSpace(s) select s.ToLower()).ToList(); list2 = list.Where((string c) => lowered.Any((string sub) => c.ToLower().Contains(sub))).ToList(); } catch { } List<string> list3 = ((list2 != null && list2.Count > 0) ? list2 : list); string text = list3[rng.Next(list3.Count)]; SceneConfig sceneConfig = (sceneConfigs.ContainsKey(text) ? sceneConfigs[text] : null); string text2 = null; if (sceneConfig != null && sceneConfig.Exits != null && sceneConfig.Exits.Count > 0) { text2 = sceneConfig.Exits[rng.Next(sceneConfig.Exits.Count)]; } visitedScenesF6.Add(text); lastEntryGateUsed = text2; log.LogInfo((object)("[F6] Selected unique random scene: " + text + " (enter via gate '" + (text2 ?? "(null)") + "')")); SuppressTransitionPatch = true; ((MonoBehaviour)this).StartCoroutine(LoadSceneCoroutine(text, text2)); } private void LoadRandomScene() { if (isTransitioning) { log.LogInfo((object)"LoadRandomScene skipped: transition already in progress"); return; } loadRequested = true; List<string> list = sceneConfigs.Keys.Where((string k) => !string.Equals(k, currentSceneName, StringComparison.OrdinalIgnoreCase)).ToList(); if (list.Count == 0) { log.LogWarning((object)"No candidate scenes found in sceneConfigs."); return; } List<string> list2 = null; try { List<string> lowered = (from s in preferredSceneSubstrings where !string.IsNullOrWhiteSpace(s) select s.ToLower()).ToList(); list2 = list.Where((string c) => lowered.Any((string sub) => c.ToLower().Contains(sub))).ToList(); } catch { } List<string> list3 = ((list2 != null && list2.Count > 0) ? list2 : list); string text = list3[rng.Next(list3.Count)]; SceneConfig sceneConfig = (sceneConfigs.ContainsKey(text) ? sceneConfigs[text] : null); string text2 = null; if (sceneConfig != null && sceneConfig.Exits != null && sceneConfig.Exits.Count > 0) { text2 = sceneConfig.Exits[rng.Next(sceneConfig.Exits.Count)]; } lastEntryGateUsed = text2; log.LogInfo((object)("Selected random scene: " + text + " (enter via gate '" + (text2 ?? "(null)") + "')")); SuppressTransitionPatch = true; ((MonoBehaviour)this).StartCoroutine(LoadSceneCoroutine(text, text2)); } [IteratorStateMachine(typeof(<LoadSceneCoroutine>d__40))] private IEnumerator LoadSceneCoroutine(string sceneName, string entryGate) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <LoadSceneCoroutine>d__40(0) { <>4__this = this, sceneName = sceneName, entryGate = entryGate }; } private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { currentSceneName = ((Scene)(ref scene)).name; cachedSceneLabel = Locale.Get("Scene: ") + currentSceneName; lastRenderedScene = currentSceneName; log.LogInfo((object)("Scene loaded: " + currentSceneName)); if (autoDiscoveryMode) { ((MonoBehaviour)this).StartCoroutine(AutoDiscoverAfterLoad()); } else { ((MonoBehaviour)this).StartCoroutine(DetectEntryGateAfterLoad()); } if (cfgInstantMusicTransition != null && cfgInstantMusicTransition.Value) { SetMusicRegionsInstantTransition(); } if (_apiInitialized && ((Scene)(ref scene)).name != "Menu_Title" && ((Scene)(ref scene)).name != "Menu" && ((Scene)(ref scene)).name != "Loading" && (Object)(object)HeroController.instance != (Object)null) { HKSilksong_RandomizerAPI.MarkGameReady(); } } [IteratorStateMachine(typeof(<AutoDiscoverAfterLoad>d__42))] private IEnumerator AutoDiscoverAfterLoad() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <AutoDiscoverAfterLoad>d__42(0) { <>4__this = this }; } private void DiscoverGatesInCurrentScene() { //IL_0100: Unknown result type (might be due to invalid IL or missing references) log.LogInfo((object)"=== DISCOVERING GATES ==="); log.LogInfo((object)("Scene: " + currentSceneName)); try { List<GameObject> list = Object.FindObjectsByType<GameObject>((FindObjectsSortMode)0).Where(delegate(GameObject obj) { string text2 = ((Object)obj).name.ToLower(); return (text2.StartsWith("left") || text2.StartsWith("right") || text2.StartsWith("top") || text2.StartsWith("bot")) && text2.Length <= 6 && char.IsDigit(text2[text2.Length - 1]); }).ToList(); log.LogInfo((object)$"Found {list.Count} gates:"); IOrderedEnumerable<IGrouping<string, GameObject>> orderedEnumerable = from g in list group g by ((Object)g).name into g orderby g.Key select g; foreach (IGrouping<string, GameObject> item in orderedEnumerable) { log.LogInfo((object)$" - {item.Key} (count: {item.Count()}, pos: {item.First().transform.position})"); } List<string> list2 = orderedEnumerable.Select((IGrouping<string, GameObject> g) => g.Key).ToList(); if (list2.Count > 0) { string text = "{ \"" + currentSceneName + "\", new SceneConfig(new List<string> { " + string.Join(", ", list2.Select((string e) => "\"" + e + "\"")) + " }) },"; log.LogInfo((object)("Suggested: " + text)); if (autoDiscoveryMode) { SaveDiscoveryToFile(currentSceneName, list2, text); } } } catch (Exception ex) { log.LogError((object)("DiscoverGates failed: " + ex.Message)); } } private void SaveDiscoveryToFile(string sceneName, List<string> exitNames, string configLine) { try { if (!discoveredScenes.Contains(sceneName)) { if (sceneConfigs != null && sceneConfigs.ContainsKey(sceneName)) { log.LogInfo((object)("Discovery skipped for " + sceneName + ": already exists in sceneConfigs.")); discoveredScenes.Add(sceneName); return; } discoveredScenes.Add(sceneName); File.AppendAllText(discoveryFilePath, string.Format("\n[{0:yyyy-MM-dd HH:mm:ss}] {1}\n Gates found: {2}\n Config: {3}\n", DateTime.Now, sceneName, string.Join(", ", exitNames), configLine)); log.LogInfo((object)$"Saved discovery for {sceneName} to file ({exitNames.Count} exits)"); } } catch (Exception ex) { log.LogError((object)("Failed to save discovery to file: " + ex.Message)); } } [IteratorStateMachine(typeof(<DetectEntryGateAfterLoad>d__45))] private IEnumerator DetectEntryGateAfterLoad() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <DetectEntryGateAfterLoad>d__45(0) { <>4__this = this }; } private void OnActiveSceneChanged(Scene prev, Scene next) { if (((Scene)(ref next)).name == "Menu_Title" || ((Scene)(ref next)).name == "Quit_To_Menu") { lastEntryGateUsed = null; return; } previousSceneName = currentSceneName; currentSceneName = ((Scene)(ref next)).name; try { GameObject obj = GameObject.Find("__RoomRando"); RoomRando roomRando = ((obj != null) ? obj.GetComponent<RoomRando>() : null); if ((Object)(object)roomRando != (Object)null && !string.IsNullOrEmpty(previousSceneName) && !string.IsNullOrEmpty(lastEntryGateUsed)) { roomRando.OnExitUsed(previousSceneName, lastEntryGateUsed); } } catch (Exception ex) { log.LogWarning((object)("RoomRando notify failed: " + ex.Message)); } lastEntryGateUsed = null; } private void OnGUI() { //IL_000b: 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_0036: 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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown //IL_00bd: Unknown result type (might be due to invalid IL or missing references) try { if (sceneLabelStyle.normal.textColor != Color.white || sceneLabelStyle.fontSize != 14) { GUIStyle val = new GUIStyle(GUI.skin.label); val.normal.textColor = Color.white; val.fontSize = 14; sceneLabelStyle = val; } if (cfgShowSceneLabel == null || cfgShowSceneLabel.Value) { if (currentSceneName != lastRenderedScene) { cachedSceneLabel = Locale.Get("Scene: ") + currentSceneName; lastRenderedScene = currentSceneName; } GUI.Label(new Rect(8f, 8f, 300f, 20f), cachedSceneLabel, sceneLabelStyle); } } catch { } } private void SetMusicRegionsInstantTransition() { //IL_009c: 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) try { Type type = Type.GetType("MusicRegion, Assembly-CSharp"); if (type == null) { return; } Object[] array = Resources.FindObjectsOfTypeAll(type); FieldInfo field = type.GetField("enterTransitionTime"); FieldInfo field2 = type.GetField("exitTransitionTime"); FieldInfo field3 = type.GetField("delay"); if (field == null || field2 == null) { return; } int num = 0; Object[] array2 = array; foreach (Object val in array2) { if (val == (Object)null) { continue; } Object obj = ((val is Component) ? val : null); GameObject val2 = ((obj != null) ? ((Component)obj).gameObject : null); if ((Object)(object)val2 != (Object)null && val2.scene == SceneManager.GetActiveScene()) { field.SetValue(val, 0f); field2.SetValue(val, 0f); if (field3 != null) { field3.SetValue(val, 0); } num++; } } if (num > 0) { log.LogInfo((object)$"Set {num} MusicRegion transition times to 0."); } } catch (Exception ex) { log.LogWarning((object)("SetMusicRegionsInstantTransition error: " + ex.Message)); } } } public class RoomRando : MonoBehaviour { private Dictionary<string, (string targetScene, string targetGate)> connections = new Dictionary<string, (string, string)>(StringComparer.OrdinalIgnoreCase); private List<string> availableScenes = new List<string>(); private bool enableRandomization = true; private RandomSceneLoader sceneLoader; private string saveFilePath; private Random rng; private int generationSeed; private bool enableMapGeneration; private List<(string beforeScene, string afterScene)> precedencePairs = new List<(string, string)>(); private bool forceExactSeed; private static readonly HashSet<string> BlacklistedExits = new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "Bone_11_top1", "Bellshrine_right1", "Bellshrine_05_right1", "Dock_06_Church_right1", "Bone_East_09_top1", "Bellshrine_02_left1", "Dust_04_right1", "Dust_05_right1", "Dust_06_left1", "Shadow_20_bot1", "Bellshrine_03_right1", "Shellwood_19_left1", "Shellwood_01b_right2", "Bellshrine_02_right1", "Dust_06_right1", "Mosstown_03_top1", "Coral_10_left1", "Song_27_left1", "Dock_01_right1", "Dock_01_right2", "Bone_East_14_right1", "Bone_East_14_right2", "Greymoor_01_right1", "Greymoor_01_right2", "Dust_02_right1", "Dust_02_right2", "Dust_04_left1", "Dust_04_left2", "Song_25_top1", "Song_25_top2", "Arborium_05_top1", "Hang_07_top1", "Hang_07_left1", "Slab_02_left1", "Slab_05_right1", "Cog_06_right1", "Library_11b_right1", "Dock_03_bot1", "Dock_03c_top1", "Dock_03c_left2", "Dock_02_left1", "Shellwood_02_right2", "Shellwood_01_left2", "Dust_Chef_left1", "Song_11_left4", "Slab_03_right1", "Slab_03_right2", "Slab_03_right5", "Slab_03_right7", "Slab_03_left6", "Under_05_left2", "Under_02_right4", "Under_02_left1", "Bone_East_12_right1", "Shadow_27_right1", "Halfway_01_right1", "Wisp_03_top1", "Arborium_01_right1", "Arborium_04_left1", "Library_13_left1", "Hang_03_right2", "Aqueduct_02_right3", "Song_19_entrance_left1", "Weave_04_right2", "Slab_16_right1", "Bone_East_04_left1", "Bone_East_10_right1", "Bone_East_18c_left1", "Greymoor_05_left1", "Hang_08_left1", "Arborium_08_left1" }; private static readonly HashSet<string> SkipExits = new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "Bone_01_bot1", "Bone_01_left4", "Bone_01_right3", "Aspid_01_bot8", "Aspid_01_left2", "Aspid_01_right4", "Crawl_03b_right1", "Shellwood_10_left3", "Shellwood_10_right3", "Dust_02_left2", "Dust_02_right2", "Coral_24_left1", "Coral_24_right1", "Coral_35b_bot1", "Coral_35b_left5", "Coral_35b_right2", "Peak_07_bot5", "Peak_07_top2", "Peak_01_left4", "Peak_01_right4", "Peak_01_top4", "Peak_02_left3", "Peak_02_right4", "Peak_04_left1", "Peak_04_right1", "Peak_05_bot1", "Peak_05_right3", "Peak_05_top2", "Peak_05c_left2", "Peak_05c_right1", "Peak_05e_left1", "Peak_05e_right2", "Song_05_left5", "Song_05_right4", "Song_11_right3", "Song_01c" }; private static readonly Dictionary<string, int> SingleExitPairedCounts = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase); private static readonly HashSet<string> HighPriorityRooms = new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "Bonegrave", "Shellwood_04c", "Coral_02", "Coral_35", "Coral_32", "Coral_24", "Coral_23", "Coral_25", "Dust_03", "Dust_06", "Shadow_05", "Shadow_08", "Shadow_09", "Shadow_16", "Shadow_10", "Shadow_19", "Shadow_24", "Shadow_01", "Shadow_14", "Aqueduct_04", "Aqueduct_03", "Aqueduct_01", "Arborium_11", "Arborium_09", "Arborium_05", "Song_Enclave", "Song_09b", "Song_11", "Song_01", "Song_19_entrance", "Under_02", "Under_07c", "Under_27", "Under_17", "Under_10", "Under_19c", "Library_11", "Library_12", "Library_12b", "Library_02", "Song_20b", "Song_20", "Library_03", "Slab_06", "Slab_05", "Slab_19b", "Slab_15", "Coral_27", "Coral_44", "Abyss_13", "Abyss_01", "Cog_08", "Cog_09", "Ward_02", "Wisp_05", "Wisp_08", "Slab_07", "Weave_08", "Song_03", "Abyss_05", "Cradle_02", "Hang_02", "Hang_03", "Hang_13", "Hang_10", "Hang_16", "Bone_East_15", "Cog_04", "Arborium_08", "Under_23", "Bellway_03", "Dock_15", "Dust_04" }; private RoomRandomConfig _cachedConfig; private bool _hasPendingConfig; private bool _isInitialized; public void Initialize(RandomSceneLoader loader) { sceneLoader = loader; if ((Object)(object)sceneLoader != (Object)null) { foreach (string key in sceneLoader.sceneConfigs.Keys) { if (key.StartsWith("Peak_", StringComparison.OrdinalIgnoreCase)) { HighPriorityRooms.Add(key); } if (key.StartsWith("Ward_", StringComparison.OrdinalIgnoreCase)) { HighPriorityRooms.Add(key); } if (key.StartsWith("Clover_", StringComparison.OrdinalIgnoreCase)) { HighPriorityRooms.Add(key); } } } _isInitialized = true; if (_hasPendingConfig && _cachedConfig != null) { ApplyConfig(); } else { InitializeRoomRando(); } } public void SetConfig(RoomRandomConfig config) { _cachedConfig = config; _hasPendingConfig = true; if (_isInitialized) { ApplyConfig(); } } private void ApplyConfig() { if (_cachedConfig != null) { generationSeed = _cachedConfig.Seed; enableRandomization = _cachedConfig.EnableRandomization; enableMapGeneration = _cachedConfig.EnableMapGeneration; precedencePairs = new List<(string, string)>(_cachedConfig.PrecedencePairs); _hasPendingConfig = false; if (enableRandomization) { InitializeRoomRando(); } } } private void InitializeRoomRando() { try { availableScenes = sceneLoader.sceneConfigs.Keys.ToList(); } catch (Exception ex) { Debug.LogWarning((object)("RoomRando: failed to populate availableScenes from sceneLoader: " + ex.Message)); } InitializePredefinedConnections(); try { saveFilePath = Path.Combine(Paths.PluginPath, "roomrando_connections.txt"); } catch { saveFilePath = "roomrando_connections.txt"; } Debug.Log((object)$"RoomRando: saveFilePath set to '{saveFilePath}' (exists={File.Exists(saveFilePath)})"); if (!enableRandomization) { return; } if (TryLoadConnectionsFromFile()) { bool flag = false; foreach (KeyValuePair<string, (string, string)> connection in connections) { int num = connection.Key.LastIndexOf('_'); if (num > 0) { string sceneA = connection.Key.Substring(0, num); string exitA = connection.Key.Substring(num + 1); string item = connection.Value.Item1; string item2 = connection.Value.Item2; if (!IsConnectionAllowed(sceneA, exitA, item, item2)) { flag = true; break; } } } if (flag) { Debug.LogWarning((object)"RoomRando: Loaded connections conflict with current rules. Forcing regeneration..."); connections.Clear(); GenerateAllConnectionsAtStart(); SaveConnectionsToFile(); } else { Debug.Log((object)("RoomRando: loaded randomized connections from " + saveFilePath)); } } else { GenerateAllConnectionsAtStart(); SaveConnectionsToFile(); } if (enableMapGeneration) { TryGenerateMap(); } } private void GenerateAllConnectionsAtStart() { int num = ((generationSeed == 0) ? Environment.TickCount : generationSeed); int finalConnectionCount = 0; RandomSceneLoader.SceneConfig value5; List<string> list = availableScenes.Where((string s) => (Object)(object)sceneLoader != (Object)null && sceneLoader.sceneConfigs.TryGetValue(s, out value5) && value5.Exits != null && value5.Exits.Count > 0).ToList(); List<string> list2 = new List<string>(); List<string> list3 = new List<string>(); List<string> list4 = new List<string>(); foreach (string item4 in list) { if (GetActualExitCount(item4) == 1) { list4.Add(item4); } else if (HighPriorityRooms.Contains(item4)) { list3.Add(item4); } else { list2.Add(item4); } } Debug.Log((object)$"RoomRando: 普通房间(>1出口)数量: {list2.Count}, 高房间(>1出口)数量: {list3.Count}, 单出口房间数量: {list4.Count}"); bool flag = false; int num2 = (forceExactSeed ? 1 : 8); for (int i = 0; i < num2; i++) { if (flag) { break; } int num3 = (forceExactSeed ? num : (num + i)); rng = new Random(num3); connections.Clear(); finalConnectionCount = 0; Debug.Log((object)$"RoomRando: generation attempt {i + 1}/{num2} using seed={num3}"); InitializePredefinedConnections(); Dictionary<string, List<string>> dictionary = BuildFreeExits(list2); SingleExitPairedCounts.Clear(); foreach (KeyValuePair<string, (string, string)> item5 in connections.ToList()) { int num4 = item5.Key.LastIndexOf('_'); if (num4 > 0) { string key = item5.Key.Substring(0, num4); string item = item5.Key.Substring(num4 + 1); if (dictionary.ContainsKey(key)) { dictionary[key].Remove(item); } } } try { foreach (var (text, text2) in precedencePairs) { if (!string.IsNullOrEmpty(text) && !string.IsNullOrEmpty(text2) && dictionary.ContainsKey(text) && dictionary.ContainsKey(text2) && dictionary[text].Count > 0 && dictionary[text2].Count > 0) { ConnectScenesWithFreeExits(text, text2, dictionary); } } } catch (Exception ex) { Debug.LogWarning((object)("precedencePairs error: " + ex.Message)); } List<string> list5 = list2.OrderBy((string _) => rng.Next()).ToList(); for (int j = 1; j < list5.Count; j++) { string text3 = null; string text4 = null; for (int num5 = j - 1; num5 >= 0; num5--) { if (dictionary[list5[num5]].Count > 0) { text3 = list5[num5]; break; } } for (int k = j; k < list5.Count; k++) { if (dictionary[list5[k]].Count > 0) { text4 = list5[k]; break; } } if (text3 != null && text4 != null && !string.Equals(text3, text4, StringComparison.OrdinalIgnoreCase)) { ConnectScenesWithFreeExits(text3, text4, dictionary); } } Dictionary<string, HashSet<string>> neighbors = new Dictionary<string, HashSet<string>>(StringComparer.OrdinalIgnoreCase); foreach (KeyValuePair<string, (string, string)> connection in connections) { int num6 = connection.Key.LastIndexOf('_'); if (num6 > 0) { AddNeighborEdge(neighbors, connection.Key.Substring(0, num6), connection.Value.Item1); } } List<(string, string)> source = dictionary.SelectMany((KeyValuePair<string, List<string>> kv) => kv.Value.Select((string e) => (kv.Key, e))).ToList(); bool flag2 = false; int num7 = 6; for (int l = 0; l < num7; l++) { if (flag2) { break; } List<(string, string)> list6 = source.OrderBy(((string, string) _) => rng.Next()).ToList(); HashSet<int> hashSet = new HashSet<int>(); List<((string, string), (string, string))> list7 = new List<((string, string), (string, string))>(); bool flag3 = false; for (int m = 0; m < list6.Count; m++) { if (hashSet.Contains(m)) { continue; } (string, string) tuple2 = list6[m]; int num8 = -1; int num9 = int.MinValue; for (int num10 = m + 1; num10 < list6.Count; num10++) { if (hashSet.Contains(num10)) { continue; } (string, string) tuple3 = list6[num10]; if (!string.Equals(tuple2.Item1, tuple3.Item1, StringComparison.OrdinalIgnoreCase)) { int num11 = 0; if (!IsOriginalSingle(tuple3.Item1)) { num11 += 20; } if (!IsOriginalSingle(tuple2.Item1)) { num11 += 10; } if (IsOriginalSingle(tuple2.Item1) && IsOriginalSingle(tuple3.Item1)) { num11 -= 1000; } neighbors.TryGetValue(tuple2.Item1, out var value); neighbors.TryGetValue(tuple3.Item1, out var value2); int num12 = value?.Count((string n) => IsLeaf(neighbors, n)) ?? 0; int num13 = value2?.Count((string n) => IsLeaf(neighbors, n)) ?? 0; bool flag4 = IsLeaf(neighbors, tuple3.Item1); bool flag5 = IsLeaf(neighbors, tuple2.Item1); if (num12 + (flag4 ? 1 : 0) > 1) { num11 -= 50; } if (num13 + (flag5 ? 1 : 0) > 1) { num11 -= 50; } if (num11 > num9) { num9 = num11; num8 = num10; } } } if (num8 < 0) { flag3 = true; break; } hashSet.Add(m); hashSet.Add(num8); list7.Add((list6[m], list6[num8])); AddNeighborEdge(neighbors, list6[m].Item1, list6[num8].Item1); } if (flag3) { neighbors.Clear(); foreach (KeyValuePair<string, (string, string)> connection2 in connections) { int num14 = connection2.Key.LastIndexOf('_'); if (num14 > 0) { AddNeighborEdge(neighbors, connection2.Key.Substring(0, num14), connection2.Value.Item1); } } continue; } bool flag6 = false; foreach (var (tuple5, tuple6) in list7) { if (IsOriginalSingle(tuple5.Item1) && IsOriginalSingle(tuple6.Item1)) { flag6 = true; break; } } Dictionary<string, int> dictionary2 = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase); foreach (KeyValuePair<string, HashSet<string>> item6 in neighbors) { dictionary2[item6.Key] = item6.Value.Count((string n) => IsLeaf(neighbors, n)); } if (dictionary2.Values.Any((int c) => c > 1)) { flag6 = true; } if (flag6) { neighbors.Clear(); foreach (KeyValuePair<string, (string, string)> connection3 in connections) { int num15 = connection3.Key.LastIndexOf('_'); if (num15 > 0) { AddNeighborEdge(neighbors, connection3.Key.Substring(0, num15), connection3.Value.Item1); } } continue; } foreach (var item7 in list7) { (string, string) item2 = item7.Item1; (string, string) item3 = item7.Item2; string key2 = MakeKey(item2.Item1, item2.Item2); string key3 = MakeKey(item3.Item1, item3.Item2); if (!connections.ContainsKey(key2) && !connections.ContainsKey(key3)) { connections[key2] = (item3.Item1, item3.Item2); connections[key3] = (item2.Item1, item2.Item2); dictionary[item2.Item1].Remove(item2.Item2); dictionary[item3.Item1].Remove(item3.Item2); finalConnectionCount++; } } flag2 = true; } if (!flag2) { Debug.LogWarning((object)"第一阶段智能配对失败,使用贪心配对"); List<(string, string)> list8 = source.OrderBy(((string, string) _) => rng.Next()).ToList(); for (int num16 = 0; num16 + 1 < list8.Count; num16 += 2) { (string, string) tuple7 = list8[num16]; (string, string) tuple8 = list8[num16 + 1]; if (!string.Equals(tuple7.Item1, tuple8.Item1, StringComparison.OrdinalIgnoreCase)) { string key4 = MakeKey(tuple7.Item1, tuple7.Item2); string key5 = MakeKey(tuple8.Item1, tuple8.Item2); if (!connections.ContainsKey(key4) && !connections.ContainsKey(key5)) { connections[key4] = (tuple8.Item1, tuple8.Item2); connections[key5] = (tuple7.Item1, tuple7.Item2); finalConnectionCount++; dictionary[tuple7.Item1].Remove(tuple7.Item2); dictionary[tuple8.Item1].Remove(tuple8.Item2); } } } } List<(string, string)> list9 = dictionary.SelectMany((KeyValuePair<string, List<string>> kv) => kv.Value.Select((string e) => (kv.Key, e))).ToList(); if (list9.Count > 0) { Debug.LogWarning((object)$"第一阶段剩余 {list9.Count} 个未配对出口"); } Dictionary<string, List<string>> dictionary3 = BuildFreeExits(list3); List<(string, string)> list10 = new List<(string, string)>(); list10.AddRange(list9); foreach (KeyValuePair<string, List<string>> item8 in dictionary3) { foreach (string item9 in item8.Value) { list10.Add((item8.Key, item9)); } } if (list10.Count > 0) { Debug.Log((object)$"第二阶段开始,共 {list10.Count} 个出口"); PairExitsSimple(list10); } neighbors.Clear(); foreach (KeyValuePair<string, (string, string)> connection4 in connections) { int num17 = connection4.Key.LastIndexOf('_'); if (num17 > 0) { AddNeighborEdge(neighbors, connection4.Key.Substring(0, num17), connection4.Value.Item1); } } bool flag7 = false; foreach (KeyValuePair<string, HashSet<string>> item10 in neighbors) { if (item10.Value.Count((string n) => IsLeaf(neighbors, n)) > 3) { flag7 = true; break; } } if (!flag7) { flag = true; generationSeed = num3; RandomSceneLoader.CurrentSeed = generationSeed; Debug.Log((object)$"成功,种子={num3}"); } else { Debug.LogWarning((object)$"尝试 {i + 1} 失败:叶子节点过多"); } } if (!flag) { Debug.LogWarning((object)$"所有尝试失败,使用最后一次结果,种子={generationSeed}"); } Debug.Log((object)$"生成了 {finalConnectionCount} 对双向连接 ({connections.Count} 条单向)"); static void AddNeighborEdge(Dictionary<string, HashSet<string>> graph, string s1, string s2) { if (!string.Equals(s1, s2, StringComparison.OrdinalIgnoreCase)) { if (!graph.ContainsKey(s1)) { graph[s1] = new HashSet<string>(StringComparer.OrdinalIgnoreCase); } if (!graph.ContainsKey(s2)) { graph[s2] = new HashSet<string>(StringComparer.OrdinalIgnoreCase); } graph[s1].Add(s2); graph[s2].Add(s1); } } void ConnectScenesWithFreeExits(string scA, string scB, Dictionary<string, List<string>> freeExits) { if (freeExits.ContainsKey(scA) && freeExits.ContainsKey(scB) && freeExits[scA].Count != 0 && freeExits[scB].Count != 0) { string text5 = freeExits[scA][rng.Next(freeExits[scA].Count)]; string text6 = freeExits[scB][rng.Next(freeExits[scB].Count)]; if (IsConnectionAllowed(scA, text5, scB, text6)) { string key6 = MakeKey(scA, text5); string key7 = MakeKey(scB, text6); if (!connections.ContainsKey(key6) && !connections.ContainsKey(key7)) { connections[key6] = (scB, text6); connections[key7] = (scA, text5); freeExits[scA].Remove(text5); freeExits[scB].Remove(text6); finalConnectionCount++; UpdateSingleExitCount(scA, scB); } } } } static bool IsLeaf(Dictionary<string, HashSet<string>> graph, string scene) { if (graph.TryGetValue(scene, out var value3)) { return value3.Count == 1; } return false; } bool IsOriginalSingle(string scene) { if (sceneLoader.sceneConfigs.TryGetValue(scene, out var value4) && value4.Exits != null) { return value4.Exits.Count == 1; } return false; } } private Dictionary<string, List<string>> BuildFreeExits(List<string> scenes) { Dictionary<string, List<string>> dictionary = new Dictionary<string, List<string>>(StringComparer.OrdinalIgnoreCase); foreach (string scene in scenes) { List<string> list = new List<string>(sceneLoader.sceneConfigs[scene].Exits); foreach (string blacklistedExit in BlacklistedExits) { int num = blacklistedExit.LastIndexOf('_'); if (num > 0) { string a = blacklistedExit.Substring(0, num); string item = blacklistedExit.Substring(num + 1); if (string.Equals(a, scene, StringComparison.OrdinalIgnoreCase)) { list.Remove(item); } } } dictionary[scene] = list; } return dictionary; } private void PairExitsSimple(List<(string scene, string exit)> exitPool) { List<(string, string)> list = exitPool.OrderBy(((string scene, string exit) _) => rng.Next()).ToList(); HashSet<int> hashSet = new HashSet<int>(); for (int i = 0; i < list.Count; i++) { if (hashSet.Contains(i)) { continue; } (string, string) tuple = list[i]; int num = -1; for (int j = i + 1; j < list.Count; j++) { if (!hashSet.Contains(j)) { (string, string) tuple2 = list[j]; if (!string.Equals(tuple.Item1, tuple2.Item1, StringComparison.OrdinalIgnoreCase) && (!(tuple.Item1 == "Tut_01") || !HighPriorityRooms.Contains(tuple2.Item1)) && (!(tuple2.Item1 == "Tut_01") || !HighPriorityRooms.Contains(tuple.Item1))) { num = j; break; } } } if (num >= 0) { hashSet.Add(i); hashSet.Add(num); (string, string) tuple3 = list[num]; string key = MakeKey(tuple.Item1, tuple.Item2); string key2 = MakeKey(tuple3.Item1, tuple3.Item2); if (!connections.ContainsKey(key) && !connections.ContainsKey(key2)) { connections[key] = (tuple3.Item1, tuple3.Item2); connections[key2] = (tuple.Item1, tuple.Item2); } } } if (list.Count - hashSet.Count > 0) { Debug.LogWarning((object)$"第二阶段配对后剩余 {list.Count - hashSet.Count} 个未配对出口"); } } private int GetActualExitCount(string scene) { RandomSceneLoader.SceneConfig sceneConfig = sceneLoader.sceneConfigs[scene]; int num = sceneConfig.Exits.Count((string e) => BlacklistedExits.Contains(MakeKey(scene, e))); return sceneConfig.Exits.Count - num; } private bool IsConnectionAllowed(string sceneA, string exitA, string sceneB, string exitB) { if (string.Equals(sceneA, sceneB, StringComparison.OrdinalIgnoreCase)) { return false; } if ((sceneA == "Tut_01" && HighPriorityRooms.Contains(sceneB)) || (sceneB == "Tut_01" && HighPriorityRooms.Contains(sceneA))) { return false; } string text = MakeKey(sceneA, exitA); string text2 = MakeKey(sceneB, exitB); if (BlacklistedExits.Contains(text) || BlacklistedExits.Contains(text2)) { return false; } int count = sceneLoader.sceneConfigs[sceneA].Exits.Count; int count2 = sceneLoader.sceneConfigs[sceneB].Exits.Count; int num = sceneLoader.sceneConfigs[sceneA].Exits.Count((string e) => BlacklistedExits.Contains(MakeKey(sceneA, e))); int num2 = sceneLoader.sceneConfigs[sceneB].Exits.Count((string e) => BlacklistedExits.Contains(MakeKey(sceneB, e))); int num3 = count - num; int num4 = count2 - num2; if (num3 == 1 && num4 < 3) { return false; } if (num4 == 1 && num3 < 3) { return false; } if (num3 == 1 && num4 >= 3 && (SingleExitPairedCounts.TryGetValue(sceneB, out var value) ? value : 0) >= num4 - 2) { return false; } if (num4 == 1 && num3 >= 3 && (SingleExitPairedCounts.TryGetValue(sceneA, out var value2) ? value2 : 0) >= num3 - 2) { return false; } if (text == "Tut_01_left3" || text2 == "Tut_01_left3") { if (!(text == "Tut_01_left3")) { _ = sceneA; } else { _ = sceneB; } _ =
BepInEx/plugins/MenuChanger.dll
Decompiled 2 weeks agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using GlobalEnums; using HKSilksong_Randomizer; using HarmonyLib; using Microsoft.CodeAnalysis; using NativeUIMaker; using SilksongItemRandomizer; using SkillTriggerMod; using StartingAbilityPicker; using UnityEngine; using UnityEngine.Events; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("0.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.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 MenuChanger { [BepInPlugin("YourName.MenuChanger", "Menu Changer", "1.0.0")] public class MenuChangerMod : BaseUnityPlugin { [CompilerGenerated] private sealed class <ApplyPendingNextFrame>d__7 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public MenuChangerMod <>4__this; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <ApplyPendingNextFrame>d__7(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = null; <>1__state = 1; return true; case 1: <>1__state = -1; <>4__this.ApplyPendingSettings(); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <DelayedInit>d__8 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public MenuChangerMod <>4__this; private UIManager <ui>5__1; private string <configPath>5__2; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <DelayedInit>d__8(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <ui>5__1 = null; <configPath>5__2 = null; <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <ui>5__1 = null; goto IL_0085; case 1: <>1__state = -1; goto IL_0085; case 2: <>1__state = -1; goto IL_00ae; case 3: <>1__state = -1; PrefabMenuObjects.Initialize(); <>2__current = null; <>1__state = 4; return true; case 4: <>1__state = -1; NativeConfigPanel.Instance.Initialize(); <>2__current = null; <>1__state = 5; return true; case 5: <>1__state = -1; <configPath>5__2 = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)<>4__this).Info.Location), "NativeUIMaker_Config.json"); if (!File.Exists(<configPath>5__2)) { <configPath>5__2 = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)<>4__this).Info.Location), "PageConfigs", "NativeUIMaker_Config.json"); } UIManagerEx.InitializeUI(<configPath>5__2); <>2__current = null; <>1__state = 6; return true; case 6: <>1__state = -1; break; case 7: { <>1__state = -1; break; } IL_00ae: if ((Object)(object)<ui>5__1.UICanvas == (Object)null) { <>2__current = null; <>1__state = 2; return true; } <>2__current = null; <>1__state = 3; return true; IL_0085: if ((Object)(object)<ui>5__1 == (Object)null) { <ui>5__1 = Object.FindObjectOfType<UIManager>(); <>2__current = null; <>1__state = 1; return true; } goto IL_00ae; } if (!UIManagerEx.IsUIReady) { <>2__current = null; <>1__state = 7; return true; } NativeConfigPanel.Instance.RefreshPageList(); NativeConfigPanel.Instance.BindModeSelectButtons(); NativeConfigPanel.Instance.RefreshAllValues(); Canvas.ForceUpdateCanvases(); Debug.Log((object)"[MenuChanger] 初始化完成"); return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private bool _pendingApplied = false; internal static MenuChangerMod Instance { get; private set; } private void Awake() { Instance = this; Harmony.CreateAndPatchAll(typeof(PlayModeMenuPatch), (string)null); Harmony.CreateAndPatchAll(typeof(SkipToFirstAct), (string)null); SceneManager.sceneLoaded += OnSceneLoaded; ((MonoBehaviour)this).StartCoroutine(DelayedInit()); } private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { if (!_pendingApplied && !(((Scene)(ref scene)).name == "Menu_Title") && !(((Scene)(ref scene)).name == "Menu") && !(((Scene)(ref scene)).name == "Loading")) { _pendingApplied = true; if (PendingSettingsStore.HasPending) { ((MonoBehaviour)this).StartCoroutine(ApplyPendingNextFrame()); } } } [IteratorStateMachine(typeof(<ApplyPendingNextFrame>d__7))] private IEnumerator ApplyPendingNextFrame() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <ApplyPendingNextFrame>d__7(0) { <>4__this = this }; } [IteratorStateMachine(typeof(<DelayedInit>d__8))] private IEnumerator DelayedInit() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <DelayedInit>d__8(0) { <>4__this = this }; } public static void HideAllMenuPages() { if (NativeConfigPanel.Instance != null && NativeConfigPanel.Instance.IsShowing) { NativeConfigPanel.Instance.Hide(); } } private void Update() { if (NativeConfigPanel.Instance != null && Input.GetKeyDown((KeyCode)289)) { if (NativeConfigPanel.Instance.IsShowing) { NativeConfigPanel.Instance.Hide(); } else { NativeConfigPanel.Instance.Show(); } } } private void ApplyPendingSettings() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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_0033: 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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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) //IL_0075: 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_0098: 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_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: 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_00ca: 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_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: 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_010c: 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_0127: Expected O, but got Unknown //IL_0128: Expected O, but got Unknown try { int result; StartingSettings val = new StartingSettings { AllowUpward = PendingSettingsStore.allowUpward, AllowLeft = PendingSettingsStore.allowLeft, AllowRight = PendingSettingsStore.allowRight, UseTypeMode = PendingSettingsStore.skillMode, SkillTotal = PendingSettingsStore.skillTotal, SkillVertical = PendingSettingsStore.skillV, SkillHorizontal = PendingSettingsStore.skillH, SkillSpecial = PendingSettingsStore.skillS, SkillAttack = PendingSettingsStore.skillA, StartingItemCount = PendingSettingsStore.itemCount, Seed = (int.TryParse(PendingSettingsStore.seedInput, out result) ? result : 0), ResetSeedWorld = PendingSettingsStore.resetPickups, FullRandomMode = PendingSettingsStore.fullRandomMode, CrestCurseEnabled = PendingSettingsStore.crestCurseEnabled, ForceCompletionDisplay = PendingSettingsStore.forceCompletionDisplay, MovementPermissions = new DirectionPermissions { DashLeft = PendingSettingsStore.allowDashLeft, DashRight = PendingSettingsStore.allowDashRight, HarpoonLeft = PendingSettingsStore.allowHarpoonLeft, HarpoonRight = PendingSettingsStore.allowHarpoonRight, FloatLeft = PendingSettingsStore.allowFloatLeft, FloatRight = PendingSettingsStore.allowFloatRight, WallJumpLeft = PendingSettingsStore.allowWallJumpLeft, WallJumpRight = PendingSettingsStore.allowWallJumpRight, AllowHeal = PendingSettingsStore.allowHeal } }; StartingAbilityPickerAPI.ApplySettingsNow(val); SilksongItemRandomizerAPI.SetEnabled(PendingSettingsStore.itemRandomEnabled); SilksongItemRandomizerAPI.SetCrestRandomEnabled(PendingSettingsStore.crestRandomEnabled); SilksongItemRandomizerAPI.SetSkillItemRandomEnabled(PendingSettingsStore.skillItemRandomEnabled); SilksongItemRandomizerAPI.SetRelicRandomEnabled(PendingSettingsStore.relicRandomEnabled); SilksongItemRandomizerAPI.SetTrapEnabled(PendingSettingsStore.trapEnabled); SilksongItemRandomizerAPI.SetTrapMovementEnabled(PendingSettingsStore.trapMovementEnabled); SilksongItemRandomizerAPI.SetTrapDifficulty(PendingSettingsStore.trapDifficulty); SilksongItemRandomizerAPI.SetCurrencyThresholds(PendingSettingsStore.currencyFirstThreshold, PendingSettingsStore.currencySecondThreshold); SilksongItemRandomizerAPI.SetSilkSpearPityCount(PendingSettingsStore.silkSpearPityCount); SilksongItemRandomizerAPI.ApplyNow(); HKSilksong_RandomizerAPI.SetEnabled(PendingSettingsStore.sceneRandomEnabled); HKSilksong_RandomizerAPI.SetShowSceneLabel(PendingSettingsStore.showSceneLabel); HKSilksong_RandomizerAPI.SetShowSeedOnScreen(PendingSettingsStore.showSeedLabel); if (PendingSettingsStore.roomSeed != 0) { HKSilksong_RandomizerAPI.RegenerateWithSeed(PendingSettingsStore.roomSeed); } HKSilksong_RandomizerAPI.ApplyPending(); SkillTriggerAPI.SetEnabled(PendingSettingsStore.skillTriggerEnabled); SkillTriggerAPI.ApplyNow(); PropertyInfo propertyInfo = Type.GetType("SilksongItemRandomizer.EnemyRandoAdjuster, SilksongItemRandomizer")?.GetProperty("Enabled", BindingFlags.Static | BindingFlags.Public); if (propertyInfo != null) { propertyInfo.SetValue(null, PendingSettingsStore.enemyRandomEnabled); } PendingSettingsStore.Clear(); Debug.Log((object)"[MenuChanger] 所有设置已应用完成(包含技能/物品给予)"); } catch (Exception arg) { Debug.LogError((object)$"[MenuChanger] 应用设置失败: {arg}"); } } private void OnDestroy() { SceneManager.sceneLoaded -= OnSceneLoaded; } } [HarmonyPatch(typeof(UIManager))] public static class PlayModeMenuPatch { [CompilerGenerated] private sealed class <ShowModeSelect>d__1 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public UIManager ui; private MethodInfo <setMenuState>5__1; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <ShowModeSelect>d__1(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <setMenuState>5__1 = null; <>1__state = -2; } private bool MoveNext() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Invalid comparison between Unknown and I4 switch (<>1__state) { default: return false; case 0: <>1__state = -1; ManagerSingleton<InputHandler>.Instance.StopUIInput(); if ((int)ui.menuState == 6) { <>2__current = ui.HideSaveProfileMenu(true); <>1__state = 1; return true; } break; case 1: <>1__state = -1; break; } UIManagerEx.ShowPage("ModeSelect"); ManagerSingleton<InputHandler>.Instance.StartUIInput(); <setMenuState>5__1 = typeof(UIManager).GetMethod("SetMenuState", BindingFlags.Instance | BindingFlags.NonPublic); <setMenuState>5__1?.Invoke(ui, new object[1] { (object)(MainMenuState)18 }); return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [HarmonyPrefix] [HarmonyPatch("UIGoToPlayModeMenu")] public static bool Prefix(UIManager __instance) { if (!UIManagerEx.IsUIReady) { return true; } ((MonoBehaviour)__instance).StartCoroutine(ShowModeSelect(__instance)); return false; } [IteratorStateMachine(typeof(<ShowModeSelect>d__1))] private static IEnumerator ShowModeSelect(UIManager ui) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <ShowModeSelect>d__1(0) { ui = ui }; } } public class NativeConfigPanel { [CompilerGenerated] private sealed class <FadeIn>d__38 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public NativeConfigPanel <>4__this; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <FadeIn>d__38(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>4__this.canvasGroup.alpha = 0f; <>4__this.canvasGroup.interactable = true; <>4__this.canvasGroup.blocksRaycasts = true; break; case 1: <>1__state = -1; break; } if (<>4__this.canvasGroup.alpha < 1f) { CanvasGroup canvasGroup = <>4__this.canvasGroup; canvasGroup.alpha += Time.unscaledDeltaTime * 3f; <>2__current = null; <>1__state = 1; return true; } <>4__this.canvasGroup.alpha = 1f; return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <FadeOut>d__39 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public NativeConfigPanel <>4__this; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <FadeOut>d__39(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>4__this.canvasGroup.interactable = false; <>4__this.canvasGroup.blocksRaycasts = false; break; case 1: <>1__state = -1; break; } if (<>4__this.canvasGroup.alpha > 0f) { CanvasGroup canvasGroup = <>4__this.canvasGroup; canvasGroup.alpha -= Time.unscaledDeltaTime * 3f; <>2__current = null; <>1__state = 1; return true; } <>4__this.canvasGroup.alpha = 0f; if ((Object)(object)<>4__this.root != (Object)null) { <>4__this.root.SetActive(false); } if (<>4__this.parentPage != null) { <>4__this.parentPage.Show(true); } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private static NativeConfigPanel _instance; private GameObject root; private CanvasGroup canvasGroup; private UIManager uiManager; private NativePage parentPage; private NativeLabel pageIndicator; private List<string> pageOrder = new List<string>(); private List<NativeInput> _repeatLimitInputs = new List<NativeInput>(); public static NativeConfigPanel Instance => _instance ?? (_instance = new NativeConfigPanel()); public bool IsShowing => (Object)(object)root != (Object)null && root.activeSelf; private NativeConfigPanel() { } public void Initialize() { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Expected O, but got Unknown //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: 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_011a: 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) //IL_016c: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)root != (Object)null)) { PrefabMenuObjects.Initialize(); uiManager = UIManager.instance; if (!((Object)(object)uiManager == (Object)null)) { root = new GameObject("NativeConfigPanel"); root.transform.SetParent(((Component)uiManager.UICanvas).transform, false); canvasGroup = root.AddComponent<CanvasGroup>(); canvasGroup.alpha = 0f; canvasGroup.interactable = false; canvasGroup.blocksRaycasts = false; root.SetActive(false); GameObject val = new GameObject("Panel"); val.transform.SetParent(root.transform, false); RectTransform val2 = val.AddComponent<RectTransform>(); val2.sizeDelta = new Vector2(1200f, 800f); val2.anchorMin = Vector2.zero; val2.anchorMax = Vector2.one; val2.pivot = new Vector2(0.5f, 0.5f); val2.anchoredPosition = Vector2.zero; pageIndicator = NativeLabel.Create(val2); pageIndicator.SetText("1/1"); pageIndicator.SetFontSize(32); pageIndicator.SetPosition(new Vector2(0f, -420f)); pageIndicator.SetSize(200f, 60f); pageIndicator.SetAlignment((TextAnchor)4); pageIndicator.gameObject.SetActive(false); SubscribeToGlobalEvents(); BindRepeatLimitInputs(); } } } private void BindRepeatLimitInputs() { NativePage val = ((IEnumerable<NativePage>)NativePage.AllInstances).FirstOrDefault((Func<NativePage, bool>)((NativePage p) => ((Object)p.gameObject).name == "RepeatLimitPage")); if (val == null) { return; } _repeatLimitInputs = val.gameObject.GetComponentsInChildren<NativeInput>(true).ToList(); if (_repeatLimitInputs.Count == 0) { Debug.LogWarning((object)"[NativeConfigPanel] RepeatLimitPage 下没有找到任何 NativeInput 控件"); return; } Dictionary<string, Action<int>> dictionary = new Dictionary<string, Action<int>> { { "Input_LimitSkillItem", delegate(int v) { ItemLimitConfig.LimitSkillItem = v; } }, { "Input_LimitRelic", delegate(int v) { ItemLimitConfig.LimitRelic = v; } }, { "Input_LimitOtherItem", delegate(int v) { ItemLimitConfig.LimitOtherItem = v; } }, { "Input_LimitUpSlash", delegate(int v) { ItemLimitConfig.LimitUpSlash = v; } }, { "Input_LimitLeftSlash", delegate(int v) { ItemLimitConfig.LimitLeftSlash = v; } }, { "Input_LimitRightSlash", delegate(int v) { ItemLimitConfig.LimitRightSlash = v; } }, { "Input_LimitDashLeft", delegate(int v) { ItemLimitConfig.LimitDashLeft = v; } }, { "Input_LimitDashRight", delegate(int v) { ItemLimitConfig.LimitDashRight = v; } }, { "Input_LimitHarpoonLeft", delegate(int v) { ItemLimitConfig.LimitHarpoonLeft = v; } }, { "Input_LimitHarpoonRight", delegate(int v) { ItemLimitConfig.LimitHarpoonRight = v; } }, { "Input_LimitFloatLeft", delegate(int v) { ItemLimitConfig.LimitFloatLeft = v; } }, { "Input_LimitFloatRight", delegate(int v) { ItemLimitConfig.LimitFloatRight = v; } }, { "Input_LimitWallJumpLeft", delegate(int v) { ItemLimitConfig.LimitWallJumpLeft = v; } }, { "Input_LimitWallJumpRight", delegate(int v) { ItemLimitConfig.LimitWallJumpRight = v; } }, { "Input_LimitHeal", delegate(int v) { ItemLimitConfig.LimitHeal = v; } }, { "Input_LimitNeedleThrow", delegate(int v) { ItemLimitConfig.LimitNeedleThrow = v; } }, { "Input_LimitThreadSphere", delegate(int v) { ItemLimitConfig.LimitThreadSphere = v; } }, { "Input_LimitHarpoonDash", delegate(int v) { ItemLimitConfig.LimitHarpoonDash = v; } }, { "Input_LimitSilkCharge", delegate(int v) { ItemLimitConfig.LimitSilkCharge = v; } }, { "Input_LimitSilkBomb", delegate(int v) { ItemLimitConfig.LimitSilkBomb = v; } }, { "Input_LimitSilkBossNeedle", delegate(int v) { ItemLimitConfig.LimitSilkBossNeedle = v; } }, { "Input_LimitNeedolin", delegate(int v) { ItemLimitConfig.LimitNeedolin = v; } }, { "Input_LimitParry", delegate(int v) { ItemLimitConfig.LimitParry = v; } }, { "Input_LimitNeedolinMemory", delegate(int v) { ItemLimitConfig.LimitNeedolinMemory = v; } }, { "Input_LimitFastTravel", delegate(int v) { ItemLimitConfig.LimitFastTravel = v; } }, { "Input_LimitEvaHeal", delegate(int v) { ItemLimitConfig.LimitEvaHeal = v; } }, { "Input_LimitDash", delegate(int v) { ItemLimitConfig.LimitDash = v; } }, { "Input_LimitBrolly", delegate(int v) { ItemLimitConfig.LimitBrolly = v; } }, { "Input_LimitDoubleJump", delegate(int v) { ItemLimitConfig.LimitDoubleJump = v; } }, { "Input_LimitSuperJump", delegate(int v) { ItemLimitConfig.LimitSuperJump = v; } }, { "Input_LimitWallJump", delegate(int v) { ItemLimitConfig.LimitWallJump = v; } }, { "Input_LimitChargeSlash", delegate(int v) { ItemLimitConfig.LimitChargeSlash = v; } }, { "Input_LimitHeartPiece", delegate(int v) { ItemLimitConfig.LimitHeartPiece = v; } }, { "Input_LimitSpoolPart", delegate(int v) { ItemLimitConfig.LimitSpoolPart = v; } }, { "Input_LimitMaxSilkRegenUp", delegate(int v) { ItemLimitConfig.LimitMaxSilkRegenUp = v; } }, { "Input_LimitUnlockCrestSlot", delegate(int v) { ItemLimitConfig.LimitUnlockCrestSlot = v; } } }; foreach (NativeInput repeatLimitInput in _repeatLimitInputs) { if (!dictionary.TryGetValue(((Object)repeatLimitInput.gameObject).name, out var setter)) { continue; } repeatLimitInput.SetText(GetLimitValue(((Object)repeatLimitInput.gameObject).name).ToString()); repeatLimitInput.AddTextChangedListener((Action<string>)delegate(string text) { if (int.TryParse(text, out var result)) { setter(result); } }); } } private int GetLimitValue(string inputName) { return inputName switch { "Input_LimitSkillItem" => ItemLimitConfig.LimitSkillItem, "Input_LimitRelic" => ItemLimitConfig.LimitRelic, "Input_LimitOtherItem" => ItemLimitConfig.LimitOtherItem, "Input_LimitUpSlash" => ItemLimitConfig.LimitUpSlash, "Input_LimitLeftSlash" => ItemLimitConfig.LimitLeftSlash, "Input_LimitRightSlash" => ItemLimitConfig.LimitRightSlash, "Input_LimitDashLeft" => ItemLimitConfig.LimitDashLeft, "Input_LimitDashRight" => ItemLimitConfig.LimitDashRight, "Input_LimitHarpoonLeft" => ItemLimitConfig.LimitHarpoonLeft, "Input_LimitHarpoonRight" => ItemLimitConfig.LimitHarpoonRight, "Input_LimitFloatLeft" => ItemLimitConfig.LimitFloatLeft, "Input_LimitFloatRight" => ItemLimitConfig.LimitFloatRight, "Input_LimitWallJumpLeft" => ItemLimitConfig.LimitWallJumpLeft, "Input_LimitWallJumpRight" => ItemLimitConfig.LimitWallJumpRight, "Input_LimitHeal" => ItemLimitConfig.LimitHeal, "Input_LimitNeedleThrow" => ItemLimitConfig.LimitNeedleThrow, "Input_LimitThreadSphere" => ItemLimitConfig.LimitThreadSphere, "Input_LimitHarpoonDash" => ItemLimitConfig.LimitHarpoonDash, "Input_LimitSilkCharge" => ItemLimitConfig.LimitSilkCharge, "Input_LimitSilkBomb" => ItemLimitConfig.LimitSilkBomb, "Input_LimitSilkBossNeedle" => ItemLimitConfig.LimitSilkBossNeedle, "Input_LimitNeedolin" => ItemLimitConfig.LimitNeedolin, "Input_LimitParry" => ItemLimitConfig.LimitParry, "Input_LimitNeedolinMemory" => ItemLimitConfig.LimitNeedolinMemory, "Input_LimitFastTravel" => ItemLimitConfig.LimitFastTravel, "Input_LimitEvaHeal" => ItemLimitConfig.LimitEvaHeal, "Input_LimitDash" => ItemLimitConfig.LimitDash, "Input_LimitBrolly" => ItemLimitConfig.LimitBrolly, "Input_LimitDoubleJump" => ItemLimitConfig.LimitDoubleJump, "Input_LimitSuperJump" => ItemLimitConfig.LimitSuperJump, "Input_LimitWallJump" => ItemLimitConfig.LimitWallJump, "Input_LimitChargeSlash" => ItemLimitConfig.LimitChargeSlash, "Input_LimitHeartPiece" => ItemLimitConfig.LimitHeartPiece, "Input_LimitSpoolPart" => ItemLimitConfig.LimitSpoolPart, "Input_LimitMaxSilkRegenUp" => ItemLimitConfig.LimitMaxSilkRegenUp, "Input_LimitUnlockCrestSlot" => ItemLimitConfig.LimitUnlockCrestSlot, _ => 0, }; } private void RefreshRepeatLimitInputs() { foreach (NativeInput repeatLimitInput in _repeatLimitInputs) { repeatLimitInput.SetText(GetLimitValue(((Object)repeatLimitInput.gameObject).name).ToString()); } } private void SubscribeToGlobalEvents() { NativeUIEventDispatcher.OnNativeUIEvent += delegate(object sender, NativeUIEventArgs args) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Invalid comparison between Unknown and I4 //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Invalid comparison between Unknown and I4 //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: Invalid comparison between Unknown and I4 //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Invalid comparison between Unknown and I4 //IL_0a7e: Unknown result type (might be due to invalid IL or missing references) //IL_0a84: Invalid comparison between Unknown and I4 //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Invalid comparison between Unknown and I4 //IL_0d72: Unknown result type (might be due to invalid IL or missing references) //IL_0d78: Invalid comparison between Unknown and I4 //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Invalid comparison between Unknown and I4 //IL_0df0: Unknown result type (might be due to invalid IL or missing references) //IL_0df6: Invalid comparison between Unknown and I4 //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Invalid comparison between Unknown and I4 //IL_0eb7: Unknown result type (might be due to invalid IL or missing references) //IL_0ebd: Invalid comparison between Unknown and I4 //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Invalid comparison between Unknown and I4 //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Invalid comparison between Unknown and I4 //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Invalid comparison between Unknown and I4 //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Invalid comparison between Unknown and I4 //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Invalid comparison between Unknown and I4 //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Invalid comparison between Unknown and I4 //IL_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Invalid comparison between Unknown and I4 if ((args.ControlName == "LeftArrow" || args.ControlName.StartsWith("LeftArrow_")) && (int)args.EventType == 0) { SwitchPage(-1); } else if ((args.ControlName == "RightArrow" || args.ControlName.StartsWith("RightArrow_")) && (int)args.EventType == 0) { SwitchPage(1); } else if (args.ControlName == "RandomModeBtn" && (int)args.EventType == 0) { ShowPage(pageOrder.Contains("Main") ? "Main" : pageOrder[0]); } else if (args.ControlName == "DetailBtn" && (int)args.EventType == 0) { UIManagerEx.ShowPage("Detail0"); } else if (args.ControlName == "BackToMainBtn" && (int)args.EventType == 0) { ShowPage("Main"); } else if (args.ControlName == "BackToModeSelectBtn" && (int)args.EventType == 0) { ShowPage("ModeSelect"); } else if (args.ControlName == "ItemPoolBtn" && (int)args.EventType == 0) { ShowPage("ItemPoolPage"); } else if (args.ControlName == "StartLocationBtn" && (int)args.EventType == 0) { ShowPage("StartLocationPage"); } else if (args.ControlName == "CurseBtn" && (int)args.EventType == 0) { ShowPage("Detail2"); } else if (args.ControlName == "RepeatBtn" && (int)args.EventType == 0) { ShowPage("RepeatLimitPage"); } else if (args.ControlName == "BackToMainBtn_ItemPool" && (int)args.EventType == 0) { ShowPage("Main"); } else if (args.ControlName == "BackToMainBtn_Repeat" && (int)args.EventType == 0) { ShowPage("Main"); } else if (args.ControlName == "BackToMainBtn_StartLoc" && (int)args.EventType == 0) { ShowPage("Main"); } if (args.ControlType == "Button" && (int)args.EventType == 0) { object source = args.Source; NativeButton val = (NativeButton)((source is NativeButton) ? source : null); if (val == null) { return; } switch (args.ControlName) { case "RoomBtn": { bool flag7 = (PendingSettingsStore.sceneRandomEnabled = !PendingSettingsStore.sceneRandomEnabled); StartingAbilityPickerAPI.SetSceneRandomEnabled(flag7); val.SetToggleIndex(flag7 ? 1 : 0); break; } case "ItemBtn": { bool flag6 = (PendingSettingsStore.itemRandomEnabled = !PendingSettingsStore.itemRandomEnabled); StartingAbilityPickerAPI.SetItemRandomEnabled(flag6); val.SetToggleIndex(flag6 ? 1 : 0); break; } case "TrapBtn": { bool flag8 = (PendingSettingsStore.trapEnabled = !PendingSettingsStore.trapEnabled); StartingAbilityPickerAPI.SetTrapRandomEnabled(flag8); val.SetToggleIndex(flag8 ? 1 : 0); break; } case "EnemyBtn": { bool flag5 = (PendingSettingsStore.enemyRandomEnabled = !PendingSettingsStore.enemyRandomEnabled); StartingAbilityPickerAPI.SetEnemyRandomEnabled(flag5); val.SetToggleIndex(flag5 ? 1 : 0); break; } default: { bool flag = val.GetTitle() == "开"; switch (args.ControlName) { case "CrestCurseBtn": StartingAbilityPickerAPI.SetCrestCurseEnabled(flag); break; case "FullRandomBtn": StartingAbilityPickerAPI.SetFullRandomMode(flag); UpdateFullRandomUI(); break; case "TrapMovementBtn": SilksongItemRandomizerAPI.SetTrapMovementEnabled(flag); break; case "EnemyScaleRandomBtn": (Type.GetType("SilksongItemRandomizer.EnemyRandoAdjuster, SilksongItemRandomizer")?.GetProperty("ScaleRandomEnabled", BindingFlags.Static | BindingFlags.Public))?.SetValue(null, flag); break; case "UpBtn": { (bool, bool, bool) attackPermissions = StartingAbilityPickerAPI.GetAttackPermissions(); StartingAbilityPickerAPI.SetAttackPermissions(flag, attackPermissions.Item2, attackPermissions.Item3); UpdateCategoryButtonStates(); break; } case "LeftBtn": { (bool, bool, bool) attackPermissions = StartingAbilityPickerAPI.GetAttackPermissions(); StartingAbilityPickerAPI.SetAttackPermissions(attackPermissions.Item1, flag, attackPermissions.Item3); UpdateCategoryButtonStates(); break; } case "RightBtn": { (bool, bool, bool) attackPermissions = StartingAbilityPickerAPI.GetAttackPermissions(); StartingAbilityPickerAPI.SetAttackPermissions(attackPermissions.Item1, attackPermissions.Item2, flag); UpdateCategoryButtonStates(); break; } case "ShowRoomNameBtn": HKSilksong_RandomizerAPI.SetShowSceneLabel(flag); break; case "ShowRoomSeedBtn": HKSilksong_RandomizerAPI.SetShowSeedOnScreen(flag); break; case "SilkHeartBtn": RoomRandomMode.Toggle(); break; case "CompletionBtn": StartingAbilityPickerAPI.SetForceCompletionDisplay(flag); break; case "TrapDifficultyBtn": { string title = val.GetTitle(); int trapDifficulty = ((!(title == "初猎")) ? ((title == "专注") ? 1 : 2) : 0); SilksongItemRandomizerAPI.SetTrapDifficulty(trapDifficulty); if (SilksongItemRandomizerAPI.IsTrapEnabled()) { SilksongItemRandomizerAPI.RegenerateTrapsNow(); } break; } case "CategoryBtn1": if (StartingAbilityPickerAPI.GetFullRandomMode()) { DirectionPermissions movementPermissions5 = StartingAbilityPickerAPI.GetMovementPermissions(); movementPermissions5.DashLeft = flag; movementPermissions5.DashRight = flag; StartingAbilityPickerAPI.SetMovementPermissions(movementPermissions5); } break; case "CategoryBtn2": if (StartingAbilityPickerAPI.GetFullRandomMode()) { DirectionPermissions movementPermissions4 = StartingAbilityPickerAPI.GetMovementPermissions(); movementPermissions4.HarpoonLeft = flag; movementPermissions4.HarpoonRight = flag; StartingAbilityPickerAPI.SetMovementPermissions(movementPermissions4); } break; case "CategoryBtn3": if (StartingAbilityPickerAPI.GetFullRandomMode()) { DirectionPermissions movementPermissions3 = StartingAbilityPickerAPI.GetMovementPermissions(); movementPermissions3.FloatLeft = flag; movementPermissions3.FloatRight = flag; StartingAbilityPickerAPI.SetMovementPermissions(movementPermissions3); } break; case "CategoryBtn4": if (StartingAbilityPickerAPI.GetFullRandomMode()) { DirectionPermissions movementPermissions2 = StartingAbilityPickerAPI.GetMovementPermissions(); movementPermissions2.WallJumpLeft = flag; movementPermissions2.WallJumpRight = flag; StartingAbilityPickerAPI.SetMovementPermissions(movementPermissions2); } break; case "CategoryBtn5": if (StartingAbilityPickerAPI.GetFullRandomMode()) { DirectionPermissions movementPermissions = StartingAbilityPickerAPI.GetMovementPermissions(); movementPermissions.AllowHeal = flag; StartingAbilityPickerAPI.SetMovementPermissions(movementPermissions); } break; case "CategoryBtn6": if (StartingAbilityPickerAPI.GetFullRandomMode()) { StartingAbilityPickerAPI.SetAttackPermissions(!flag, !flag, !flag); } break; case "CrestTypeBtn": { bool flag4 = !SilksongItemRandomizerAPI.IsCrestRandomEnabled(); SilksongItemRandomizerAPI.SetCrestRandomEnabled(flag4); UpdateTypeButtonColor(val, flag4); break; } case "SkillTypeBtn": { bool flag3 = !SilksongItemRandomizerAPI.IsSkillItemRandomEnabled(); SilksongItemRandomizerAPI.SetSkillItemRandomEnabled(flag3); UpdateTypeButtonColor(val, flag3); break; } case "RelicTypeBtn": { bool flag2 = !SilksongItemRandomizerAPI.IsRelicRandomEnabled(); SilksongItemRandomizerAPI.SetRelicRandomEnabled(flag2); UpdateTypeButtonColor(val, flag2); break; } } break; } } } if (args.ControlType == "Slider" && (int)args.EventType == 1) { float num = (float)args.Value; switch (args.ControlName) { case "ItemCountSlider": StartingAbilityPickerAPI.SetStartingItemCount((int)num); break; case "TotalSkillSlider": { (int, int, int, int, int) skillCounts = StartingAbilityPickerAPI.GetSkillCounts(); StartingAbilityPickerAPI.SetSkillCounts((int)num, skillCounts.Item2, skillCounts.Item3, skillCounts.Item4, skillCounts.Item5); break; } case "VSlider": { (int, int, int, int, int) skillCounts = StartingAbilityPickerAPI.GetSkillCounts(); StartingAbilityPickerAPI.SetSkillCounts(skillCounts.Item1, (int)num, skillCounts.Item3, skillCounts.Item4, skillCounts.Item5); break; } case "HSlider": { (int, int, int, int, int) skillCounts = StartingAbilityPickerAPI.GetSkillCounts(); StartingAbilityPickerAPI.SetSkillCounts(skillCounts.Item1, skillCounts.Item2, (int)num, skillCounts.Item4, skillCounts.Item5); break; } case "SSlider": { (int, int, int, int, int) skillCounts = StartingAbilityPickerAPI.GetSkillCounts(); StartingAbilityPickerAPI.SetSkillCounts(skillCounts.Item1, skillCounts.Item2, skillCounts.Item3, (int)num, skillCounts.Item5); break; } case "ASlider": { (int, int, int, int, int) skillCounts = StartingAbilityPickerAPI.GetSkillCounts(); StartingAbilityPickerAPI.SetSkillCounts(skillCounts.Item1, skillCounts.Item2, skillCounts.Item3, skillCounts.Item4, (int)num); break; } case "EnemyScaleMinSlider": (Type.GetType("SilksongItemRandomizer.EnemyRandoAdjuster, SilksongItemRandomizer")?.GetProperty("ScaleMin", BindingFlags.Static | BindingFlags.Public))?.SetValue(null, num); break; case "EnemyScaleMaxSlider": (Type.GetType("SilksongItemRandomizer.EnemyRandoAdjuster, SilksongItemRandomizer")?.GetProperty("ScaleMax", BindingFlags.Static | BindingFlags.Public))?.SetValue(null, num); break; } } if (args.ControlType == "Option" && (int)args.EventType == 2) { int num2 = (int)args.Value; string controlName = args.ControlName; string text = controlName; if (!(text == "SkillModeOption")) { if (text == "ResetOption") { StartingAbilityPickerAPI.SetResetSeedWorld(num2 == 1); } } else { StartingAbilityPickerAPI.SetSkillRandomMode(num2 == 1); UpdateSlidersVisibility(); } } if (args.ControlType == "Input" && (int)args.EventType == 1) { string s = (string)args.Value; switch (args.ControlName) { case "CurrencyFirstThresholdInput": { if (int.TryParse(s, out var result2)) { (int, int) currencyThresholds = SilksongItemRandomizerAPI.GetCurrencyThresholds(); SilksongItemRandomizerAPI.SetCurrencyThresholds(result2, currencyThresholds.Item2); } break; } case "CurrencySecondThresholdInput": { if (int.TryParse(s, out var result3)) { SilksongItemRandomizerAPI.SetCurrencyThresholds(SilksongItemRandomizerAPI.GetCurrencyThresholds().Item1, result3); } break; } case "SilkSpearPityInput": { if (int.TryParse(s, out var result)) { SilksongItemRandomizerAPI.SetSilkSpearPityCount(result); } break; } } } if ((int)args.EventType == 0) { switch (args.ControlName) { case "ConfirmBtn": Confirm(); break; case "ResetShopBtn": SilksongItemRandomizerAPI.ResetAllData(); break; case "ResetPickupBtn": Type.GetType("SilksongItemRandomizer.Extracurrencypickup, SilksongItemRandomizer")?.GetMethod("ResetAll", BindingFlags.Static | BindingFlags.Public)?.Invoke(null, null); break; case "ResetFrostBlacklistBtn": Type.GetType("SilksongItemRandomizer.TrapRandomizer, SilksongItemRandomizer")?.GetMethod("ResetFrostBannedScenes", BindingFlags.Static | BindingFlags.Public)?.Invoke(null, null); break; case "ApplyRoomSeedBtn": ApplyRoomSeed(); break; } } }; } private bool IsFullRandomEnabled() { return StartingAbilityPickerAPI.GetFullRandomMode(); } private void UpdateFullRandomUI() { bool flag = IsFullRandomEnabled(); string[] array = new string[6] { "CategoryBtn1", "CategoryBtn2", "CategoryBtn3", "CategoryBtn4", "CategoryBtn5", "CategoryBtn6" }; string[] array2 = array; foreach (string name in array2) { NativeButton val = ((IEnumerable<NativeButton>)NativeButton.AllInstances).FirstOrDefault((Func<NativeButton, bool>)((NativeButton b) => ((Object)b.gameObject).name == name)); if (val != null && (Object)(object)val.menuButton != (Object)null) { ((Selectable)val.menuButton).interactable = flag; } } NativeButton val2 = ((IEnumerable<NativeButton>)NativeButton.AllInstances).FirstOrDefault((Func<NativeButton, bool>)((NativeButton b) => ((Object)b.gameObject).name == "UpBtn")); NativeButton val3 = ((IEnumerable<NativeButton>)NativeButton.AllInstances).FirstOrDefault((Func<NativeButton, bool>)((NativeButton b) => ((Object)b.gameObject).name == "LeftBtn")); NativeButton val4 = ((IEnumerable<NativeButton>)NativeButton.AllInstances).FirstOrDefault((Func<NativeButton, bool>)((NativeButton b) => ((Object)b.gameObject).name == "RightBtn")); if (val2 != null && (Object)(object)val2.menuButton != (Object)null) { ((Selectable)val2.menuButton).interactable = !flag; } if (val3 != null && (Object)(object)val3.menuButton != (Object)null) { ((Selectable)val3.menuButton).interactable = !flag; } if (val4 != null && (Object)(object)val4.menuButton != (Object)null) { ((Selectable)val4.menuButton).interactable = !flag; } } private void UpdateCategoryButtonStates() { if (IsFullRandomEnabled()) { DirectionPermissions movementPermissions = StartingAbilityPickerAPI.GetMovementPermissions(); NativeButton val = ((IEnumerable<NativeButton>)NativeButton.AllInstances).FirstOrDefault((Func<NativeButton, bool>)((NativeButton b) => ((Object)b.gameObject).name == "CategoryBtn1")); if (val != null) { val.SetToggleIndex((movementPermissions.DashLeft && movementPermissions.DashRight) ? 1 : 0); } NativeButton val2 = ((IEnumerable<NativeButton>)NativeButton.AllInstances).FirstOrDefault((Func<NativeButton, bool>)((NativeButton b) => ((Object)b.gameObject).name == "CategoryBtn2")); if (val2 != null) { val2.SetToggleIndex((movementPermissions.HarpoonLeft && movementPermissions.HarpoonRight) ? 1 : 0); } NativeButton val3 = ((IEnumerable<NativeButton>)NativeButton.AllInstances).FirstOrDefault((Func<NativeButton, bool>)((NativeButton b) => ((Object)b.gameObject).name == "CategoryBtn3")); if (val3 != null) { val3.SetToggleIndex((movementPermissions.FloatLeft && movementPermissions.FloatRight) ? 1 : 0); } NativeButton val4 = ((IEnumerable<NativeButton>)NativeButton.AllInstances).FirstOrDefault((Func<NativeButton, bool>)((NativeButton b) => ((Object)b.gameObject).name == "CategoryBtn4")); if (val4 != null) { val4.SetToggleIndex((movementPermissions.WallJumpLeft && movementPermissions.WallJumpRight) ? 1 : 0); } NativeButton val5 = ((IEnumerable<NativeButton>)NativeButton.AllInstances).FirstOrDefault((Func<NativeButton, bool>)((NativeButton b) => ((Object)b.gameObject).name == "CategoryBtn5")); if (val5 != null) { val5.SetToggleIndex(movementPermissions.AllowHeal ? 1 : 0); } (bool, bool, bool) attackPermissions = StartingAbilityPickerAPI.GetAttackPermissions(); NativeButton val6 = ((IEnumerable<NativeButton>)NativeButton.AllInstances).FirstOrDefault((Func<NativeButton, bool>)((NativeButton b) => ((Object)b.gameObject).name == "CategoryBtn6")); if (val6 != null) { val6.SetToggleIndex((attackPermissions.Item1 && attackPermissions.Item2 && attackPermissions.Item3) ? 1 : 0); } } } private void UpdateTypeButtonColor(NativeButton btn, bool isEnabled) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) if (btn != null) { Text componentInChildren = btn.gameObject.GetComponentInChildren<Text>(); if ((Object)(object)componentInChildren != (Object)null) { ((Graphic)componentInChildren).color = (Color)(isEnabled ? Color.white : new Color(0.8f, 0.8f, 0.8f)); ((Graphic)componentInChildren).SetVerticesDirty(); } Canvas.ForceUpdateCanvases(); } } private void ApplyRoomSeed() { NativeInput val = ((IEnumerable<NativeInput>)NativeInput.AllInstances).FirstOrDefault((Func<NativeInput, bool>)((NativeInput i) => ((Object)i.gameObject).name == "RoomSeedInput")); if (val != null && int.TryParse(val.GetText(), out var result)) { HKSilksong_RandomizerAPI.RegenerateWithSeed(result); } } private void CollectCurrentSettingsToStore() { NativeButton val = ((IEnumerable<NativeButton>)NativeButton.AllInstances).FirstOrDefault((Func<NativeButton, bool>)((NativeButton b) => ((Object)b.gameObject).name == "UpBtn")); NativeButton val2 = ((IEnumerable<NativeButton>)NativeButton.AllInstances).FirstOrDefault((Func<NativeButton, bool>)((NativeButton b) => ((Object)b.gameObject).name == "LeftBtn")); NativeButton val3 = ((IEnumerable<NativeButton>)NativeButton.AllInstances).FirstOrDefault((Func<NativeButton, bool>)((NativeButton b) => ((Object)b.gameObject).name == "RightBtn")); PendingSettingsStore.allowUpward = ((val != null) ? val.GetTitle() : null) == "开"; PendingSettingsStore.allowLeft = ((val2 != null) ? val2.GetTitle() : null) == "开"; PendingSettingsStore.allowRight = ((val3 != null) ? val3.GetTitle() : null) == "开"; NativeOption val4 = ((IEnumerable<NativeOption>)NativeOption.AllInstances).FirstOrDefault((Func<NativeOption, bool>)((NativeOption o) => ((Object)o.gameObject).name == "SkillModeOption")); PendingSettingsStore.skillMode = ((val4 != null) ? val4.GetCurrentValue() : null) == "分类随机"; NativeSlider val5 = ((IEnumerable<NativeSlider>)NativeSlider.AllInstances).FirstOrDefault((Func<NativeSlider, bool>)((NativeSlider s) => ((Object)s.gameObject).name == "TotalSkillSlider")); if (val5 != null) { PendingSettingsStore.skillTotal = (int)val5.Value; } NativeSlider val6 = ((IEnumerable<NativeSlider>)NativeSlider.AllInstances).FirstOrDefault((Func<NativeSlider, bool>)((NativeSlider s) => ((Object)s.gameObject).name == "VSlider")); if (val6 != null) { PendingSettingsStore.skillV = (int)val6.Value; } NativeSlider val7 = ((IEnumerable<NativeSlider>)NativeSlider.AllInstances).FirstOrDefault((Func<NativeSlider, bool>)((NativeSlider s) => ((Object)s.gameObject).name == "HSlider")); if (val7 != null) { PendingSettingsStore.skillH = (int)val7.Value; } NativeSlider val8 = ((IEnumerable<NativeSlider>)NativeSlider.AllInstances).FirstOrDefault((Func<NativeSlider, bool>)((NativeSlider s) => ((Object)s.gameObject).name == "SSlider")); if (val8 != null) { PendingSettingsStore.skillS = (int)val8.Value; } NativeSlider val9 = ((IEnumerable<NativeSlider>)NativeSlider.AllInstances).FirstOrDefault((Func<NativeSlider, bool>)((NativeSlider s) => ((Object)s.gameObject).name == "ASlider")); if (val9 != null) { PendingSettingsStore.skillA = (int)val9.Value; } NativeSlider val10 = ((IEnumerable<NativeSlider>)NativeSlider.AllInstances).FirstOrDefault((Func<NativeSlider, bool>)((NativeSlider s) => ((Object)s.gameObject).name == "ItemCountSlider")); if (val10 != null) { PendingSettingsStore.itemCount = (int)val10.Value; } NativeInput val11 = ((IEnumerable<NativeInput>)NativeInput.AllInstances).FirstOrDefault((Func<NativeInput, bool>)((NativeInput i) => ((Object)i.gameObject).name == "SeedInput")); if (val11 != null) { PendingSettingsStore.seedInput = val11.GetText(); } NativeOption val12 = ((IEnumerable<NativeOption>)NativeOption.AllInstances).FirstOrDefault((Func<NativeOption, bool>)((NativeOption o) => ((Object)o.gameObject).name == "ResetOption")); PendingSettingsStore.resetPickups = ((val12 != null) ? val12.GetCurrentValue() : null) == "是"; PendingSettingsStore.fullRandomMode = IsFullRandomEnabled(); PendingSettingsStore.roomRandomMode = RoomRandomMode.IsPending; PendingSettingsStore.crestCurseEnabled = StartingAbilityPickerAPI.GetCrestCurseEnabled(); PendingSettingsStore.forceCompletionDisplay = StartingAbilityPickerAPI.GetForceCompletionDisplay(); NativeButton val13 = ((IEnumerable<NativeButton>)NativeButton.AllInstances).FirstOrDefault((Func<NativeButton, bool>)((NativeButton b) => ((Object)b.gameObject).name == "CategoryBtn1")); if (val13 != null) { PendingSettingsStore.allowDashRight = (PendingSettingsStore.allowDashLeft = val13.GetTitle() == "开"); } NativeButton val14 = ((IEnumerable<NativeButton>)NativeButton.AllInstances).FirstOrDefault((Func<NativeButton, bool>)((NativeButton b) => ((Object)b.gameObject).name == "CategoryBtn2")); if (val14 != null) { PendingSettingsStore.allowHarpoonRight = (PendingSettingsStore.allowHarpoonLeft = val14.GetTitle() == "开"); } NativeButton val15 = ((IEnumerable<NativeButton>)NativeButton.AllInstances).FirstOrDefault((Func<NativeButton, bool>)((NativeButton b) => ((Object)b.gameObject).name == "CategoryBtn3")); if (val15 != null) { PendingSettingsStore.allowFloatRight = (PendingSettingsStore.allowFloatLeft = val15.GetTitle() == "开"); } NativeButton val16 = ((IEnumerable<NativeButton>)NativeButton.AllInstances).FirstOrDefault((Func<NativeButton, bool>)((NativeButton b) => ((Object)b.gameObject).name == "CategoryBtn4")); if (val16 != null) { PendingSettingsStore.allowWallJumpRight = (PendingSettingsStore.allowWallJumpLeft = val16.GetTitle() == "开"); } NativeButton val17 = ((IEnumerable<NativeButton>)NativeButton.AllInstances).FirstOrDefault((Func<NativeButton, bool>)((NativeButton b) => ((Object)b.gameObject).name == "CategoryBtn5")); if (val17 != null) { PendingSettingsStore.allowHeal = val17.GetTitle() == "开"; } NativeButton val18 = ((IEnumerable<NativeButton>)NativeButton.AllInstances).FirstOrDefault((Func<NativeButton, bool>)((NativeButton b) => ((Object)b.gameObject).name == "CrestTypeBtn")); PendingSettingsStore.crestRandomEnabled = ((val18 != null) ? val18.GetTitle() : null) == "开"; NativeButton val19 = ((IEnumerable<NativeButton>)NativeButton.AllInstances).FirstOrDefault((Func<NativeButton, bool>)((NativeButton b) => ((Object)b.gameObject).name == "SkillTypeBtn")); PendingSettingsStore.skillItemRandomEnabled = ((val19 != null) ? val19.GetTitle() : null) == "开"; NativeButton val20 = ((IEnumerable<NativeButton>)NativeButton.AllInstances).FirstOrDefault((Func<NativeButton, bool>)((NativeButton b) => ((Object)b.gameObject).name == "RelicTypeBtn")); PendingSettingsStore.relicRandomEnabled = ((val20 != null) ? val20.GetTitle() : null) == "开"; NativeButton val21 = ((IEnumerable<NativeButton>)NativeButton.AllInstances).FirstOrDefault((Func<NativeButton, bool>)((NativeButton b) => ((Object)b.gameObject).name == "TrapBtn")); PendingSettingsStore.trapEnabled = ((val21 != null) ? val21.GetTitle() : null) == "开"; NativeButton val22 = ((IEnumerable<NativeButton>)NativeButton.AllInstances).FirstOrDefault((Func<NativeButton, bool>)((NativeButton b) => ((Object)b.gameObject).name == "TrapMovementBtn")); PendingSettingsStore.trapMovementEnabled = ((val22 != null) ? val22.GetTitle() : null) == "开"; NativeButton val23 = ((IEnumerable<NativeButton>)NativeButton.AllInstances).FirstOrDefault((Func<NativeButton, bool>)((NativeButton b) => ((Object)b.gameObject).name == "TrapDifficultyBtn")); if (val23 != null) { string title = val23.GetTitle(); PendingSettingsStore.trapDifficulty = ((!(title == "初猎")) ? ((title == "专注") ? 1 : 2) : 0); } NativeButton val24 = ((IEnumerable<NativeButton>)NativeButton.AllInstances).FirstOrDefault((Func<NativeButton, bool>)((NativeButton b) => ((Object)b.gameObject).name == "RoomBtn")); PendingSettingsStore.sceneRandomEnabled = ((val24 != null) ? val24.GetTitle() : null) == "开"; NativeButton val25 = ((IEnumerable<NativeButton>)NativeButton.AllInstances).FirstOrDefault((Func<NativeButton, bool>)((NativeButton b) => ((Object)b.gameObject).name == "ShowRoomNameBtn")); PendingSettingsStore.showSceneLabel = ((val25 != null) ? val25.GetTitle() : null) == "开"; NativeButton val26 = ((IEnumerable<NativeButton>)NativeButton.AllInstances).FirstOrDefault((Func<NativeButton, bool>)((NativeButton b) => ((Object)b.gameObject).name == "ShowRoomSeedBtn")); PendingSettingsStore.showSeedLabel = ((val26 != null) ? val26.GetTitle() : null) == "开"; NativeInput val27 = ((IEnumerable<NativeInput>)NativeInput.AllInstances).FirstOrDefault((Func<NativeInput, bool>)((NativeInput i) => ((Object)i.gameObject).name == "RoomSeedInput")); if (val27 != null && int.TryParse(val27.GetText(), out var result)) { PendingSettingsStore.roomSeed = result; } NativeInput val28 = ((IEnumerable<NativeInput>)NativeInput.AllInstances).FirstOrDefault((Func<NativeInput, bool>)((NativeInput i) => ((Object)i.gameObject).name == "CurrencyFirstThresholdInput")); if (val28 != null && int.TryParse(val28.GetText(), out var result2)) { PendingSettingsStore.currencyFirstThreshold = result2; } NativeInput val29 = ((IEnumerable<NativeInput>)NativeInput.AllInstances).FirstOrDefault((Func<NativeInput, bool>)((NativeInput i) => ((Object)i.gameObject).name == "CurrencySecondThresholdInput")); if (val29 != null && int.TryParse(val29.GetText(), out var result3)) { PendingSettingsStore.currencySecondThreshold = result3; } NativeInput val30 = ((IEnumerable<NativeInput>)NativeInput.AllInstances).FirstOrDefault((Func<NativeInput, bool>)((NativeInput i) => ((Object)i.gameObject).name == "SilkSpearPityInput")); if (val30 != null && int.TryParse(val30.GetText(), out var result4)) { PendingSettingsStore.silkSpearPityCount = result4; } NativeButton val31 = ((IEnumerable<NativeButton>)NativeButton.AllInstances).FirstOrDefault((Func<NativeButton, bool>)((NativeButton b) => ((Object)b.gameObject).name == "ItemBtn")); PendingSettingsStore.itemRandomEnabled = ((val31 != null) ? val31.GetTitle() : null) == "开"; PendingSettingsStore.MarkAsStored(); } private void Confirm() { CollectCurrentSettingsToStore(); SkipToFirstAct.EnableSkip(); UIManager.instance.StartNewGame(false, false); Hide(); } private void StartGame(bool permaDeath) { CollectCurrentSettingsToStore(); SkipToFirstAct.EnableSkip(); UIManager.instance.StartNewGame(permaDeath, false); Hide(); } private void UpdateSlidersVisibility() { bool flag = !StartingAbilityPickerAPI.GetSkillRandomMode(); NativeSlider val = ((IEnumerable<NativeSlider>)NativeSlider.AllInstances).FirstOrDefault((Func<NativeSlider, bool>)((NativeSlider s) => ((Object)s.gameObject).name == "TotalSkillSlider")); if (val != null) { val.gameObject.SetActive(flag); } NativeSlider val2 = ((IEnumerable<NativeSlider>)NativeSlider.AllInstances).FirstOrDefault((Func<NativeSlider, bool>)((NativeSlider s) => ((Object)s.gameObject).name == "VSlider")); NativeSlider val3 = ((IEnumerable<NativeSlider>)NativeSlider.AllInstances).FirstOrDefault((Func<NativeSlider, bool>)((NativeSlider s) => ((Object)s.gameObject).name == "HSlider")); NativeSlider val4 = ((IEnumerable<NativeSlider>)NativeSlider.AllInstances).FirstOrDefault((Func<NativeSlider, bool>)((NativeSlider s) => ((Object)s.gameObject).name == "SSlider")); NativeSlider val5 = ((IEnumerable<NativeSlider>)NativeSlider.AllInstances).FirstOrDefault((Func<NativeSlider, bool>)((NativeSlider s) => ((Object)s.gameObject).name == "ASlider")); bool active = !flag; if (val2 != null) { val2.gameObject.SetActive(active); } if (val3 != null) { val3.gameObject.SetActive(active); } if (val4 != null) { val4.gameObject.SetActive(active); } if (val5 != null) { val5.gameObject.SetActive(active); } } private void SetSliderValue(string sliderName, Func<float> getter) { NativeSlider val = ((IEnumerable<NativeSlider>)NativeSlider.AllInstances).FirstOrDefault((Func<NativeSlider, bool>)((NativeSlider s) => ((Object)s.gameObject).name == sliderName)); if (val != null) { val.Value = getter(); } } private void SetOptionValue(string optName, Func<int> getter) { NativeOption val = ((IEnumerable<NativeOption>)NativeOption.AllInstances).FirstOrDefault((Func<NativeOption, bool>)((NativeOption o) => ((Object)o.gameObject).name == optName)); if (val != null) { val.SetValueWithoutNotify(getter()); } } private void SyncButtonState(string buttonName, bool isEnabled) { NativeButton val = ((IEnumerable<NativeButton>)NativeButton.AllInstances).FirstOrDefault((Func<NativeButton, bool>)((NativeButton b) => ((Object)b.gameObject).name == buttonName)); if (val != null) { val.SetToggleIndex(isEnabled ? 1 : 0); } } public void RefreshAllValues() { SyncButtonState("RoomBtn", HKSilksong_RandomizerAPI.IsSceneRandomEnabled()); SyncButtonState("ItemBtn", SilksongItemRandomizerAPI.IsEnabled()); SyncButtonState("TrapBtn", SilksongItemRandomizerAPI.IsTrapEnabled()); SyncButtonState("CrestCurseBtn", StartingAbilityPickerAPI.GetCrestCurseEnabled()); SyncButtonState("FullRandomBtn", StartingAbilityPickerAPI.GetFullRandomMode()); SyncButtonState("TrapMovementBtn", SilksongItemRandomizerAPI.IsTrapMovementEnabled()); SyncButtonState("EnemyScaleRandomBtn", (bool)(Type.GetType("SilksongItemRandomizer.EnemyRandoAdjuster, SilksongItemRandomizer")?.GetProperty("ScaleRandomEnabled", BindingFlags.Static | BindingFlags.Public)?.GetValue(null) ?? ((object)false))); SyncButtonState("ShowRoomNameBtn", HKSilksong_RandomizerAPI.GetShowSceneLabel()); SyncButtonState("ShowRoomSeedBtn", HKSilksong_RandomizerAPI.GetShowSeedOnScreen()); SyncButtonState("CompletionBtn", StartingAbilityPickerAPI.GetForceCompletionDisplay()); SyncButtonState("CrestTypeBtn", SilksongItemRandomizerAPI.IsCrestRandomEnabled()); SyncButtonState("SkillTypeBtn", SilksongItemRandomizerAPI.IsSkillItemRandomEnabled()); SyncButtonState("RelicTypeBtn", SilksongItemRandomizerAPI.IsRelicRandomEnabled()); (bool, bool, bool) attackPermissions = StartingAbilityPickerAPI.GetAttackPermissions(); NativeButton val = ((IEnumerable<NativeButton>)NativeButton.AllInstances).FirstOrDefault((Func<NativeButton, bool>)((NativeButton b) => ((Object)b.gameObject).name == "UpBtn")); if (val != null) { val.SetToggleIndex(attackPermissions.Item1 ? 1 : 0); } NativeButton val2 = ((IEnumerable<NativeButton>)NativeButton.AllInstances).FirstOrDefault((Func<NativeButton, bool>)((NativeButton b) => ((Object)b.gameObject).name == "LeftBtn")); if (val2 != null) { val2.SetToggleIndex(attackPermissions.Item2 ? 1 : 0); } NativeButton val3 = ((IEnumerable<NativeButton>)NativeButton.AllInstances).FirstOrDefault((Func<NativeButton, bool>)((NativeButton b) => ((Object)b.gameObject).name == "RightBtn")); if (val3 != null) { val3.SetToggleIndex(attackPermissions.Item3 ? 1 : 0); } NativeButton val4 = ((IEnumerable<NativeButton>)NativeButton.AllInstances).FirstOrDefault((Func<NativeButton, bool>)((NativeButton b) => ((Object)b.gameObject).name == "SilkHeartBtn")); if (val4 != null) { val4.SetToggleIndex(RoomRandomMode.IsPending ? 1 : 0); } SetSliderValue("ItemCountSlider", () => StartingAbilityPickerAPI.GetStartingItemCount()); (int total, int v, int h, int s, int a) counts = StartingAbilityPickerAPI.GetSkillCounts(); SetSliderValue("TotalSkillSlider", () => counts.total); SetSliderValue("VSlider", () => counts.v); SetSliderValue("HSlider", () => counts.h); SetSliderValue("SSlider", () => counts.s); SetSliderValue("ASlider", () => counts.a); SetOptionValue("SkillModeOption", () => StartingAbilityPickerAPI.GetSkillRandomMode() ? 1 : 0); SetOptionValue("ResetOption", () => StartingAbilityPickerAPI.GetResetSeedWorld() ? 1 : 0); NativeInput val5 = ((IEnumerable<NativeInput>)NativeInput.AllInstances).FirstOrDefault((Func<NativeInput, bool>)((NativeInput i) => ((Object)i.gameObject).name == "SeedInput")); if (val5 != null) { val5.SetText(StartingAbilityPickerAPI.GetSeed().ToString()); } NativeInput val6 = ((IEnumerable<NativeInput>)NativeInput.AllInstances).FirstOrDefault((Func<NativeInput, bool>)((NativeInput i) => ((Object)i.gameObject).name == "RoomSeedInput")); if (val6 != null) { val6.SetText(HKSilksong_RandomizerAPI.GetCurrentRoomSeed().ToString()); } (int, int) currencyThresholds = SilksongItemRandomizerAPI.GetCurrencyThresholds(); NativeInput val7 = ((IEnumerable<NativeInput>)NativeInput.AllInstances).FirstOrDefault((Func<NativeInput, bool>)((NativeInput i) => ((Object)i.gameObject).name == "CurrencyFirstThresholdInput")); if (val7 != null) { val7.SetText(currencyThresholds.Item1.ToString()); } NativeInput val8 = ((IEnumerable<NativeInput>)NativeInput.AllInstances).FirstOrDefault((Func<NativeInput, bool>)((NativeInput i) => ((Object)i.gameObject).name == "CurrencySecondThresholdInput")); if (val8 != null) { val8.SetText(currencyThresholds.Item2.ToString()); } NativeInput val9 = ((IEnumerable<NativeInput>)NativeInput.AllInstances).FirstOrDefault((Func<NativeInput, bool>)((NativeInput i) => ((Object)i.gameObject).name == "SilkSpearPityInput")); if (val9 != null) { val9.SetText(SilksongItemRandomizerAPI.GetSilkSpearPityCount().ToString()); } NativeLabel val10 = ((IEnumerable<NativeLabel>)NativeLabel.AllInstances).FirstOrDefault((Func<NativeLabel, bool>)((NativeLabel l) => ((Object)l.gameObject).name == "CurrentSeedValue")); if (val10 != null) { val10.SetText(SilksongItemRandomizerAPI.GetSeed().ToString()); } NativeButton val11 = ((IEnumerable<NativeButton>)NativeButton.AllInstances).FirstOrDefault((Func<NativeButton, bool>)((NativeButton b) => ((Object)b.gameObject).name == "TrapDifficultyBtn")); if (val11 != null) { int trapDifficulty = SilksongItemRandomizerAPI.GetTrapDifficulty(); string[] array = new string[3] { "初猎", "专注", "满溢" }; if (trapDifficulty >= 0 && trapDifficulty < array.Length) { val11.SetTitle(array[trapDifficulty]); } } RefreshRepeatLimitInputs(); UpdateFullRandomUI(); UpdateCategoryButtonStates(); UpdateSlidersVisibility(); } public void RefreshPageList() { pageOrder = NativePage.AllInstances.Select((NativePage p) => ((Object)p.gameObject).name).ToList(); Debug.Log((object)("[NativeConfigPanel] 页面列表刷新: " + string.Join(", ", pageOrder))); } public void ShowPage(string pageName) { if (!string.IsNullOrEmpty(pageName)) { UIManagerEx.ShowPage(pageName); UpdatePageIndicator(); Canvas.ForceUpdateCanvases(); } } public void UpdatePageIndicator() { if (pageIndicator == null) { return; } NativePage? obj = ((IEnumerable<NativePage>)NativePage.AllInstances).FirstOrDefault((Func<NativePage, bool>)((NativePage p) => p.isShowing)); string text = ((obj != null) ? ((Object)obj.gameObject).name : null); if (!string.IsNullOrEmpty(text) && pageOrder.Count != 0) { int num = pageOrder.IndexOf(text); if (num >= 0) { pageIndicator.SetText($"{num + 1}/{pageOrder.Count}"); pageIndicator.gameObject.SetActive(pageOrder.Count > 1); } } } public void SwitchPage(int delta) { if (pageOrder.Count != 0) { NativePage? obj = ((IEnumerable<NativePage>)NativePage.AllInstances).FirstOrDefault((Func<NativePage, bool>)((NativePage p) => p.isShowing)); string text = ((obj != null) ? ((Object)obj.gameObject).name : null); if (!string.IsNullOrEmpty(text)) { int num = pageOrder.IndexOf(text); int index = (num + delta + pageOrder.Count) % pageOrder.Count; ShowPage(pageOrder[index]); } } } public void BindModeSelectButtons() { //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Expected O, but got Unknown //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Expected O, but got Unknown NativePage val = ((IEnumerable<NativePage>)NativePage.AllInstances).FirstOrDefault((Func<NativePage, bool>)((NativePage p) => ((Object)p.gameObject).name == "ModeSelect")); if (val == null) { return; } Transform transform = val.gameObject.transform; Transform obj = transform.Find("ClassicModeBtn"); NativeButton val2 = ((obj != null) ? ((Component)obj).GetComponent<NativeButton>() : null); Transform obj2 = transform.Find("SteelModeBtn"); NativeButton val3 = ((obj2 != null) ? ((Component)obj2).GetComponent<NativeButton>() : null); if (val2 != null) { val2.AddClickListener((UnityAction)delegate { StartGame(permaDeath: false); }); } if (val3 != null) { val3.AddClickListener((UnityAction)delegate { StartGame(permaDeath: true); }); } } public void Show(NativePage fromPage = null) { parentPage = fromPage; RefreshAllValues(); root.SetActive(true); ((MonoBehaviour)uiManager).StartCoroutine(FadeIn()); if (pageOrder.Contains("Main")) { ShowPage("Main"); } else if (pageOrder.Count > 0) { ShowPage(pageOrder[0]); } } public void Hide() { ((MonoBehaviour)uiManager).StartCoroutine(FadeOut()); } [IteratorStateMachine(typeof(<FadeIn>d__38))] private IEnumerator FadeIn() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <FadeIn>d__38(0) { <>4__this = this }; } [IteratorStateMachine(typeof(<FadeOut>d__39))] private IEnumerator FadeOut() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <FadeOut>d__39(0) { <>4__this = this }; } } public static class PendingSettingsStore { public static bool allowUpward; public static bool allowLeft; public static bool allowRight; public static bool skillMode; public static int skillTotal; public static int skillV; public static int skillH; public static int skillS; public static int skillA; public static int itemCount; public static string seedInput; public static bool resetPickups; public static bool fullRandomMode; public static bool roomRandomMode; public static bool crestCurseEnabled; public static bool forceCompletionDisplay; public static bool allowDashLeft; public static bool allowDashRight; public static bool allowHarpoonLeft; public static bool allowHarpoonRight; public static bool allowFloatLeft; public static bool allowFloatRight; public static bool allowWallJumpLeft; public static bool allowWallJumpRight; public static bool allowHeal; public static bool itemRandomEnabled; public static bool crestRandomEnabled; public static bool skillItemRandomEnabled; public static bool relicRandomEnabled; public static bool trapEnabled; public static bool trapMovementEnabled; public static int trapDifficulty; public static int currencyFirstThreshold; public static int currencySecondThreshold; public static int silkSpearPityCount; public static bool sceneRandomEnabled; public static bool showSceneLabel; public static bool showSeedLabel; public static int roomSeed; public static bool enemyRandomEnabled; public static bool skillTriggerEnabled; private static bool _hasPending; public static bool HasPending => _hasPending; public static void Clear() { _hasPending = false; } public static void MarkAsStored() { _hasPending = true; } } [HarmonyPatch] public static class SkipToFirstAct { [CompilerGenerated] private sealed class <SkipCutscenes>d__6 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; private GameManager <gm>5__1; private int <i>5__2; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <SkipCutscenes>d__6(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <gm>5__1 = null; <>1__state = -2; } private bool MoveNext() { //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = null; <>1__state = 1; return true; case 1: <>1__state = -1; <gm>5__1 = GameManager.instance; if ((Object)(object)<gm>5__1 == (Object)null) { Debug.LogError((object)"[SkipToFirstAct] GameManager 不可用"); return false; } <i>5__2 = 0; break; case 2: <>1__state = -1; <i>5__2++; break; } if (<i>5__2 < 5) { <gm>5__1.SkipCutscene(); Debug.Log((object)$"[SkipToFirstAct] 第 {<i>5__2 + 1} 次 SkipCutscene"); <>2__current = (object)new WaitForSeconds(0.2f); <>1__state = 2; return true; } Debug.Log((object)"[SkipToFirstAct] 跳过完成"); if (!string.IsNullOrEmpty(_targetScene)) { Debug.Log((object)("[SkipToFirstAct] 传送到 " + _targetScene)); HKSilksong_RandomizerAPI.TeleportToScene(_targetScene, (string)null); } else { Debug.Log((object)"[SkipToFirstAct] 未指定目标场景,使用默认开局"); } SceneManager.sceneLoaded -= OnSceneLoaded; return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private static bool _shouldSkip; private static bool _skipTriggered; private static string _targetScene; public static void EnableSkip() { if (!_shouldSkip) { _shouldSkip = true; _skipTriggered = false; SceneManager.sceneLoaded += OnSceneLoaded; Debug.Log((object)"[SkipToFirstAct] 已启用跳过开场模式"); } } public static void SetTargetScene(string sceneName) { _targetScene = sceneName; Debug.Log((object)("[SkipToFirstAct] 目标场景已设置为: " + _targetScene)); } private static void OnSceneLoaded(Scene scene, LoadSceneMode mode) { if (_shouldSkip && !_skipTriggered && ((Scene)(ref scene)).name == "Opening_Sequence") { _skipTriggered = true; Debug.Log((object)"[SkipToFirstAct] 检测到开场动画,开始跳过..."); ((MonoBehaviour)GameManager.instance).StartCoroutine(SkipCutscenes()); } } [IteratorStateMachine(typeof(<SkipCutscenes>d__6))] private static IEnumerator SkipCutscenes() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <SkipCutscenes>d__6(0); } [HarmonyPrefix] [HarmonyPatch(typeof(GameManager), "SkipCutscene")] private static void Prefix_SkipCutscene() { Debug.Log((object)"[SkipToFirstAct] 原生 SkipCutscene 被调用"); } } }
BepInEx/plugins/NativeUIMaker.dll
Decompiled 2 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using System.Threading; using BepInEx; using GlobalEnums; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.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 NativeUIMaker { [Serializable] public class UIControlConfig { public string name; public string type; public string page; public Vector2 position; public Vector2 size; public string title; public string description; public string[] toggleTexts; public int toggleIndex; public string labelText; public int fontSize; public Color color; public float minValue; public float maxValue; public float value; public bool wholeNumbers; public int optionIndex; public string[] options; public int direction; public bool playAnim; public bool clickable; public bool draggable; public string inputText; public string placeholderText; public int style; public Vector2 iconOffset; public Vector2 titleOffset; public Vector2 descOffset; public float sliderXOffset; public float sliderWidth; public float labelXOffset; public float valueXOffset; } [Serializable] public class ConfigData { public List<UIControlConfig> controls = new List<UIControlConfig>(); } public class DebugWindow : MonoBehaviour { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static Func<NativePage, bool> <>9__79_0; public static Func<string, string> <>9__82_0; public static UnityAction <>9__82_1; public static UnityAction <>9__87_0; public static Predicate<NativeButton> <>9__97_0; public static Predicate<NativeLabel> <>9__98_0; public static Predicate<NativeSlider> <>9__99_0; public static Predicate<NativeOption> <>9__100_0; public static Predicate<NativeArrow> <>9__101_0; public static Predicate<NativeInput> <>9__102_0; public static Func<string, string> <>9__104_0; public static Func<string, string> <>9__107_0; public static UnityAction <>9__108_0; public static UnityAction <>9__118_0; public static Predicate<NativeButton> <>9__120_0; public static Predicate<NativeLabel> <>9__120_1; public static Predicate<NativeSlider> <>9__120_2; public static Predicate<NativeOption> <>9__120_3; public static Predicate<NativeArrow> <>9__120_4; public static Predicate<NativeInput> <>9__120_5; public static Predicate<NativeButton> <>9__123_0; public static UnityAction <>9__126_7; internal bool <RefreshPageDropdownList>b__79_0(NativePage p) { return p != null; } internal string <DrawCreateButtonSection>b__82_0(string s) { return s.Trim(); } internal void <DrawCreateButtonSection>b__82_1() { Debug.Log((object)UILocale.Get("按钮被点击")); } internal void <CreateArrow>b__87_0() { Debug.Log((object)UILocale.Get("箭头被点击")); } internal bool <DrawExternalButtonsList>b__97_0(NativeButton b) { return b == null || (Object)(object)b.gameObject == (Object)null; } internal bool <DrawExternalLabelsList>b__98_0(NativeLabel l) { return l == null || (Object)(object)l.gameObject == (Object)null; } internal bool <DrawExternalSlidersList>b__99_0(NativeSlider s) { return s == null || (Object)(object)s.gameObject == (Object)null; } internal bool <DrawExternalOptionsList>b__100_0(NativeOption o) { return o == null || (Object)(object)o.gameObject == (Object)null; } internal bool <DrawExternalArrowsList>b__101_0(NativeArrow a) { return a == null || (Object)(object)a.gameObject == (Object)null; } internal bool <DrawExternalInputsList>b__102_0(NativeInput i) { return i == null || (Object)(object)i.gameObject == (Object)null; } internal string <DrawButtonEditor>b__104_0(string s) { return s.Trim(); } internal string <DrawOptionEditor>b__107_0(string s) { return s.Trim(); } internal void <DrawArrowEditor>b__108_0() { Debug.Log((object)UILocale.Get("箭头被点击")); } internal void <ApplyConfigToControlInPage>b__118_0() { Debug.Log((object)UILocale.Get("箭头被点击")); } internal bool <CleanInvalidControls>b__120_0(NativeButton b) { return b == null || (Object)(object)b.gameObject == (Object)null; } internal bool <CleanInvalidControls>b__120_1(NativeLabel l) { return l == null || (Object)(object)l.gameObject == (Object)null; } internal bool <CleanInvalidControls>b__120_2(NativeSlider s) { return s == null || (Object)(object)s.gameObject == (Object)null; } internal bool <CleanInvalidControls>b__120_3(NativeOption o) { return o == null || (Object)(object)o.gameObject == (Object)null; } internal bool <CleanInvalidControls>b__120_4(NativeArrow a) { return a == null || (Object)(object)a.gameObject == (Object)null; } internal bool <CleanInvalidControls>b__120_5(NativeInput i) { return i == null || (Object)(object)i.gameObject == (Object)null; } internal bool <SaveConfigToFile>b__123_0(NativeButton btn) { <>c__DisplayClass123_0 CS$<>8__locals0 = new <>c__DisplayClass123_0 { btn = btn }; return NativeArrow.AllInstances.Any((NativeArrow arr) => arr != null && (Object)(object)arr.gameObject == (Object)(object)CS$<>8__locals0.btn.gameObject); } internal void <LoadConfigFromFile>b__126_7() { Debug.Log((object)UILocale.Get("箭头被点击")); } } [CompilerGenerated] private sealed class <>c__DisplayClass123_0 { public NativeButton btn; internal bool <SaveConfigToFile>b__1(NativeArrow arr) { return arr != null && (Object)(object)arr.gameObject == (Object)(object)btn.gameObject; } } private static DebugWindow _instance; private Rect _windowRect = new Rect(50f, 50f, 800f, 1500f); private Vector2 _scrollPos; private bool _showWindow = true; private int _selectedTab = 0; private object _selectedControl = null; private string _editTitle = ""; private string _editDesc = ""; private Vector2 _editPos = Vector2.zero; private Vector2 _editSize = Vector2.zero; private string _editLabelText = ""; private int _editFontSize = 30; private Color _editColor = Color.white; private float _editSliderMin; private float _editSliderMax; private float _editSliderValue; private bool _editSliderWhole; private string _editSliderLabel = ""; private float _editSliderXOffset = 0f; private float _editSliderWidth = 0f; private float _editLabelXOffset = 0f; private float _editValueXOffset = 0f; private string _editOptionLabel = ""; private string _editOptionDesc = ""; private string[] _editOptionOptions; private int _editOptionIndex; private int _editArrowDirection; private bool _editArrowPlayAnim; private bool _editArrowClickable; private bool _editArrowDraggable; private string _editInputText = ""; private string _editInputPlaceholder = ""; private string _editToggleTextsInput = ""; private Vector2 _editIconOffset = Vector2.zero; private Vector2 _editTitleOffset = Vector2.zero; private Vector2 _editDescOffset = Vector2.zero; private List<NativeButton> _allButtons = new List<NativeButton>(); private List<NativeLabel> _allLabels = new List<NativeLabel>(); private List<NativeSlider> _allSliders = new List<NativeSlider>(); private List<NativeOption> _allOptions = new List<NativeOption>(); private List<NativeArrow> _allArrows = new List<NativeArrow>(); private List<NativeInput> _allInputs = new List<NativeInput>(); private ButtonStyle _selectedCreateStyle = ButtonStyle.IconButton; private string[] _styleNames = new string[3] { "图标按钮", "纯文字按钮", "小型按钮" }; private string _toggleTextsInput = "选项1,选项2,选项3"; private string _iconPathInput = ""; private NativePage _selectedCreateTargetPage = null; private string[] _pageNamesForDropdown = new string[0]; private int _selectedPageDropdownIndex = 0; private List<NativeButton> _externalButtons = new List<NativeButton>(); private List<NativeLabel> _externalLabels = new List<NativeLabel>(); private List<NativeSlider> _externalSliders = new List<NativeSlider>(); private List<NativeOption> _externalOptions = new List<NativeOption>(); private List<NativeArrow> _externalArrows = new List<NativeArrow>(); private List<NativeInput> _externalInputs = new List<NativeInput>(); private bool _externalScanned = false; private List<NativePage> _allPages = new List<NativePage>(); private NativePage _selectedPage = null; private List<UIControlConfig> _pageControlsCache = new List<UIControlConfig>(); private static bool _tempDragEnabled; private static GameObject _tempDragTarget; public static DebugWindow Instance => _instance; private string PluginDirectory => NativeUIMakerMod.PluginDirectory; public static GameObject CurrentlySelectedForDrag { get; private set; } public static bool TempDragEnabled => _tempDragEnabled; public static GameObject TempDragTarget => _tempDragTarget; public static void Create() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown if (!((Object)(object)_instance != (Object)null)) { GameObject val = new GameObject("DebugWindow"); _instance = val.AddComponent<DebugWindow>(); Object.DontDestroyOnLoad((Object)(object)val); } } public GameObject GetSelectedGameObject() { if (_selectedControl == null) { return null; } if (_selectedControl is NativeButton nativeButton) { return nativeButton.gameObject; } if (_selectedControl is NativeLabel nativeLabel) { return nativeLabel.gameObject; } if (_selectedControl is NativeSlider nativeSlider) { return nativeSlider.gameObject; } if (_selectedControl is NativeOption nativeOption) { return nativeOption.gameObject; } if (_selectedControl is NativeArrow nativeArrow) { return nativeArrow.gameObject; } if (_selectedControl is NativeInput nativeInput) { return nativeInput.gameObject; } return null; } public void RefreshEditFieldsForSelected() { if (_selectedControl != null) { UpdateEditFieldsFromControl(); } } private void OnGUI() { //IL_0017: 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_0037: Expected O, but got Unknown //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) if (_showWindow) { _windowRect = GUI.Window(123456, _windowRect, new WindowFunction(DrawWindow), UILocale.Get("NativeUIMaker 调试窗口")); } } private void DrawWindow(int id) { //IL_0157: 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) //IL_0170: Unknown result type (might be due to invalid IL or missing references) GUILayout.BeginVertical(Array.Empty<GUILayoutOption>()); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); if (GUILayout.Button("CN", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) })) { UILocale.SetForceChinese(true); } if (GUILayout.Button("EN", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) })) { UILocale.SetForceChinese(false); } if (GUILayout.Button(UILocale.Get("Auto"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) })) { UILocale.SetForceChinese(null); } GUILayout.EndHorizontal(); GUILayout.Space(10f); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); if (GUILayout.Button(UILocale.Get("本地控件"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) })) { _selectedTab = 0; } if (GUILayout.Button(UILocale.Get("外部控件"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) })) { _selectedTab = 1; } if (GUILayout.Button(UILocale.Get("页面管理"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) })) { _selectedTab = 2; } GUILayout.EndHorizontal(); _scrollPos = GUILayout.BeginScrollView(_scrollPos, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandHeight(true) }); if (_selectedTab == 0) { DrawLocalControlsTab(); } else if (_selectedTab == 1) { DrawExternalControlsTab(); } else { DrawPageManagementTab(); } GUILayout.EndScrollView(); DrawUnifiedEditor(); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); if (GUILayout.Button(UILocale.Get("隐藏窗口"), Array.Empty<GUILayoutOption>())) { _showWindow = false; } GUILayout.EndHorizontal(); GUILayout.EndVertical(); GUI.DragWindow(); } private void DrawLocalControlsTab() { DrawCreateTargetSelector(); GUILayout.Space(10f); DrawCreateButtonSection(); DrawLocalButtonsList(); GUILayout.Space(10f); DrawCreateLabelSection(); DrawLocalLabelsList(); GUILayout.Space(10f); DrawCreateSliderSection(); DrawLocalSlidersList(); GUILayout.Space(10f); DrawCreateOptionSection(); DrawLocalOptionsList(); GUILayout.Space(10f); DrawCreateArrowSection(); DrawLocalArrowsList(); GUILayout.Space(10f); DrawCreateInputSection(); DrawLocalInputsList(); } private void RefreshPageDropdownList() { List<NativePage> list = NativePage.AllInstances.Where((NativePage p) => p != null).ToList(); _pageNamesForDropdown = new string[list.Count + 1]; _pageNamesForDropdown[0] = UILocale.Get("全局画布 (独立于页面)"); for (int i = 0; i < list.Count; i++) { _pageNamesForDropdown[i + 1] = ((Object)list[i].gameObject).name; } if (_selectedCreateTargetPage != null) { int num = list.IndexOf(_selectedCreateTargetPage); if (num >= 0) { _selectedPageDropdownIndex = num + 1; return; } _selectedCreateTargetPage = null; _selectedPageDropdownIndex = 0; } else { _selectedPageDropdownIndex = 0; } } private void DrawCreateTargetSelector() { GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label(UILocale.Get("创建目标:"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(60f) }); RefreshPageDropdownList(); int num = GUILayout.SelectionGrid(_selectedPageDropdownIndex, _pageNamesForDropdown, 1, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(200f) }); if (num != _selectedPageDropdownIndex) { _selectedPageDropdownIndex = num; if (num == 0) { _selectedCreateTargetPage = null; } else { List<NativePage> list = NativePage.AllInstances.ToList(); if (num - 1 < list.Count) { _selectedCreateTargetPage = list[num - 1]; } else { _selectedCreateTargetPage = null; } } } if (_selectedCreateTargetPage != null) { GUILayout.Label(UILocale.Get("当前:") + " " + ((Object)_selectedCreateTargetPage.gameObject).name, Array.Empty<GUILayoutOption>()); } else { GUILayout.Label(UILocale.Get("当前:") + " " + UILocale.Get("全局画布"), Array.Empty<GUILayoutOption>()); } GUILayout.EndHorizontal(); } private RectTransform GetCurrentParent() { if (_selectedCreateTargetPage != null && (Object)(object)_selectedCreateTargetPage.rectTransform != (Object)null) { return _selectedCreateTargetPage.rectTransform; } return UIParent.GetDefaultParent(); } private void DrawCreateButtonSection() { //IL_0124: 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_0244: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Expected O, but got Unknown GUILayout.Label(UILocale.Get("=== 创建新按钮 ==="), Array.Empty<GUILayoutOption>()); GUILayout.Label(UILocale.Get("选择按钮样式:"), Array.Empty<GUILayoutOption>()); _selectedCreateStyle = (ButtonStyle)GUILayout.Toolbar((int)_selectedCreateStyle, new string[3] { UILocale.Get("图标按钮"), UILocale.Get("纯文字按钮"), UILocale.Get("小型按钮") }, Array.Empty<GUILayoutOption>()); if (_selectedCreateStyle == ButtonStyle.IconButton) { GUILayout.Label(UILocale.Get("图标文件路径 (绝对或相对路径,留空则不设置):"), Array.Empty<GUILayoutOption>()); _iconPathInput = GUILayout.TextField(_iconPathInput, Array.Empty<GUILayoutOption>()); } GUILayout.Label(UILocale.Get("切换文字序列(逗号分隔):"), Array.Empty<GUILayoutOption>()); _toggleTextsInput = GUILayout.TextField(_toggleTextsInput, Array.Empty<GUILayoutOption>()); if (!GUILayout.Button(string.Format(UILocale.Get("创建 {0}"), _styleNames[(int)_selectedCreateStyle]), Array.Empty<GUILayoutOption>())) { return; } RectTransform currentParent = GetCurrentParent(); NativeButton nativeButton = NativeButton.Create(currentParent, _selectedCreateStyle); if (nativeButton == null) { return; } nativeButton.SetPosition(Vector2.zero); nativeButton.SetSize(400f, 100f); nativeButton.SetTitle(UILocale.Get("新按钮")); nativeButton.SetDescription(UILocale.Get("可编辑描述")); if (_selectedCreateStyle == ButtonStyle.IconButton && !string.IsNullOrEmpty(_iconPathInput)) { Sprite val = NativeButton.LoadSpriteFromFile(_iconPathInput); if ((Object)(object)val != (Object)null) { nativeButton.SetIcon(val); } } string[] array = (from s in _toggleTextsInput.Split(new char[1] { ',' }) select s.Trim()).ToArray(); if (array.Length >= 2) { nativeButton.SetToggleTexts(array); } else if (array.Length == 1) { nativeButton.SetTitle(array[0]); nativeButton.SetDescription(array[0]); } else { object obj = <>c.<>9__82_1; if (obj == null) { UnityAction val2 = delegate { Debug.Log((object)UILocale.Get("按钮被点击")); }; <>c.<>9__82_1 = val2; obj = (object)val2; } nativeButton.AddClickListener((UnityAction)obj); } _allButtons.Add(nativeButton); _selectedControl = nativeButton; UpdateEditFieldsFromControl(); } private void DrawCreateLabelSection() { //IL_0047: Unknown result type (might be due to invalid IL or missing references) GUILayout.Label(UILocale.Get("=== 创建新标签 ==="), Array.Empty<GUILayoutOption>()); if (GUILayout.Button(UILocale.Get("创建文本标签 (StandardLabel)"), Array.Empty<GUILayoutOption>())) { RectTransform currentParent = GetCurrentParent(); NativeLabel nativeLabel = NativeLabel.Create(currentParent); if (nativeLabel != null) { nativeLabel.SetPosition(Vector2.zero); nativeLabel.SetSize(400f, 60f); nativeLabel.SetText(UILocale.Get("新标签")); _allLabels.Add(nativeLabel); _selectedControl = nativeLabel; UpdateEditFieldsFromControl(); } } } private void DrawCreateSliderSection() { //IL_004a: Unknown result type (might be due to invalid IL or missing references) GUILayout.Label(UILocale.Get("=== 创建新滑块 ==="), Array.Empty<GUILayoutOption>()); if (GUILayout.Button(UILocale.Get("创建滑块 (NativeSlider)"), Array.Empty<GUILayoutOption>())) { RectTransform currentParent = GetCurrentParent(); NativeSlider nativeSlider = NativeSlider.Create(currentParent); if (nativeSlider != null) { nativeSlider.SetPosition(Vector2.zero); nativeSlider.SetSize(600f, 60f); nativeSlider.SetLabel(UILocale.Get("新滑块")); nativeSlider.SetMinMax(0f, 100f); nativeSlider.Value = 50f; _allSliders.Add(nativeSlider); _selectedControl = nativeSlider; UpdateEditFieldsFromControl(); } } } private void DrawCreateOptionSection() { //IL_004d: Unknown result type (might be due to invalid IL or missing references) GUILayout.Label(UILocale.Get("=== 创建新选项行 (无滑块) ==="), Array.Empty<GUILayoutOption>()); if (GUILayout.Button(UILocale.Get("创建选项行 (NativeOption)"), Array.Empty<GUILayoutOption>())) { RectTransform currentParent = GetCurrentParent(); NativeOption nativeOption = NativeOption.Create(currentParent); if (nativeOption != null) { nativeOption.SetPosition(Vector2.zero); nativeOption.SetSize(600f, 80f); nativeOption.SetLabel(UILocale.Get("新选项")); nativeOption.SetDescription(UILocale.Get("这是描述文字")); nativeOption.SetOptions(new string[2] { UILocale.Get("选项1"), UILocale.Get("选项2") }); _allOptions.Add(nativeOption); _selectedControl = nativeOption; UpdateEditFieldsFromControl(); } } } private void DrawCreateArrowSection() { GUILayout.Label(UILocale.Get("=== 创建新箭头 ==="), Array.Empty<GUILayoutOption>()); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); if (GUILayout.Button(UILocale.Get("左箭头"), Array.Empty<GUILayoutOption>())) { CreateArrow(NativeArrow.Direction.Left); } if (GUILayout.Button(UILocale.Get("右箭头"), Array.Empty<GUILayoutOption>())) { CreateArrow(NativeArrow.Direction.Right); } if (GUILayout.Button(UILocale.Get("上箭头"), Array.Empty<GUILayoutOption>())) { CreateArrow(NativeArrow.Direction.Up); } if (GUILayout.Button(UILocale.Get("下箭头"), Array.Empty<GUILayoutOption>())) { CreateArrow(NativeArrow.Direction.Down); } GUILayout.EndHorizontal(); } private void CreateArrow(NativeArrow.Direction dir) { //IL_001a: 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_0057: Expected O, but got Unknown RectTransform currentParent = GetCurrentParent(); NativeArrow nativeArrow = NativeArrow.Create(currentParent, dir); if (nativeArrow == null) { return; } nativeArrow.SetPosition(Vector2.zero); nativeArrow.SetSize(80f, 80f); object obj = <>c.<>9__87_0; if (obj == null) { UnityAction val = delegate { Debug.Log((object)UILocale.Get("箭头被点击")); }; <>c.<>9__87_0 = val; obj = (object)val; } nativeArrow.SetClickable(clickable: true, (UnityAction)obj); _allArrows.Add(nativeArrow); _selectedControl = nativeArrow; UpdateEditFieldsFromControl(); } private void DrawCreateInputSection() { //IL_0047: Unknown result type (might be due to invalid IL or missing references) GUILayout.Label(UILocale.Get("=== 创建新输入框 ==="), Array.Empty<GUILayoutOption>()); if (GUILayout.Button(UILocale.Get("创建输入框"), Array.Empty<GUILayoutOption>())) { RectTransform currentParent = GetCurrentParent(); NativeInput nativeInput = NativeInput.Create(currentParent); if (nativeInput != null) { nativeInput.SetPosition(Vector2.zero); nativeInput.SetSize(300f, 60f); nativeInput.SetText(""); _allInputs.Add(nativeInput); _selectedControl = nativeInput; UpdateEditFieldsFromControl(); } } } private void DrawLocalButtonsList() { GUILayout.Label(UILocale.Get("=== 已创建的按钮 ==="), Array.Empty<GUILayoutOption>()); for (int i = 0; i < _allButtons.Count; i++) { NativeButton nativeButton = _allButtons[i]; if (nativeButton != null && !((Object)(object)nativeButton.gameObject == (Object)null) && GUILayout.Button(string.Format(UILocale.Get("按钮 {0}: {1}"), i, nativeButton.GetTitle()), Array.Empty<GUILayoutOption>())) { _selectedControl = nativeButton; UpdateEditFieldsFromControl(); } } } private void DrawLocalLabelsList() { GUILayout.Label(UILocale.Get("=== 已创建的标签 ==="), Array.Empty<GUILayoutOption>()); for (int i = 0; i < _allLabels.Count; i++) { NativeLabel nativeLabel = _allLabels[i]; if (nativeLabel != null && !((Object)(object)nativeLabel.gameObject == (Object)null) && GUILayout.Button(string.Format(UILocale.Get("标签 {0}: {1}"), i, nativeLabel.GetText()), Array.Empty<GUILayoutOption>())) { _selectedControl = nativeLabel; UpdateEditFieldsFromControl(); } } } private void DrawLocalSlidersList() { GUILayout.Label(UILocale.Get("=== 已创建的滑块 ==="), Array.Empty<GUILayoutOption>()); for (int i = 0; i < _allSliders.Count; i++) { NativeSlider nativeSlider = _allSliders[i]; if (nativeSlider != null && !((Object)(object)nativeSlider.gameObject == (Object)null) && GUILayout.Button(string.Format(UILocale.Get("滑块 {0}: {1} 当前值={2}"), i, nativeSlider.GetLabel(), nativeSlider.Value), Array.Empty<GUILayoutOption>())) { _selectedControl = nativeSlider; UpdateEditFieldsFromControl(); } } } private void DrawLocalOptionsList() { GUILayout.Label(UILocale.Get("=== 已创建的选项行 ==="), Array.Empty<GUILayoutOption>()); for (int i = 0; i < _allOptions.Count; i++) { NativeOption nativeOption = _allOptions[i]; if (nativeOption != null && !((Object)(object)nativeOption.gameObject == (Object)null) && GUILayout.Button(string.Format(UILocale.Get("选项 {0}: {1} 当前值={2}"), i, nativeOption.GetLabel(), nativeOption.GetCurrentValue()), Array.Empty<GUILayoutOption>())) { _selectedControl = nativeOption; UpdateEditFieldsFromControl(); } } } private void DrawLocalArrowsList() { //IL_005c: Unknown result type (might be due to invalid IL or missing references) GUILayout.Label(UILocale.Get("=== 已创建的箭头 ==="), Array.Empty<GUILayoutOption>()); for (int i = 0; i < _allArrows.Count; i++) { NativeArrow nativeArrow = _allArrows[i]; if (nativeArrow != null && !((Object)(object)nativeArrow.gameObject == (Object)null) && GUILayout.Button(string.Format(UILocale.Get("箭头 {0}: {1} 位置={2}"), i, nativeArrow.GetDirection(), nativeArrow.GetPosition()), Array.Empty<GUILayoutOption>())) { _selectedControl = nativeArrow; UpdateEditFieldsFromControl(); } } } private void DrawLocalInputsList() { GUILayout.Label(UILocale.Get("=== 已创建的输入框 ==="), Array.Empty<GUILayoutOption>()); for (int i = 0; i < _allInputs.Count; i++) { NativeInput nativeInput = _allInputs[i]; if (nativeInput != null && !((Object)(object)nativeInput.gameObject == (Object)null) && GUILayout.Button(string.Format(UILocale.Get("输入框 {0}: {1}"), i, nativeInput.GetText()), Array.Empty<GUILayoutOption>())) { _selectedControl = nativeInput; UpdateEditFieldsFromControl(); } } } private void DrawExternalControlsTab() { GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); if (GUILayout.Button(UILocale.Get("扫描外部控件"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) })) { ScanExternalControls(); _externalScanned = true; } if (GUILayout.Button(UILocale.Get("保存配置"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) })) { SaveConfigToFile(); } if (GUILayout.Button(UILocale.Get("加载配置"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) })) { LoadConfigFromFile(); } GUILayout.EndHorizontal(); if (!_externalScanned) { GUILayout.Label(UILocale.Get("点击“扫描外部控件”以发现其他模组创建的UI元素。"), Array.Empty<GUILayoutOption>()); return; } DrawExternalButtonsList(); GUILayout.Space(10f); DrawExternalLabelsList(); GUILayout.Space(10f); DrawExternalSlidersList(); GUILayout.Space(10f); DrawExternalOptionsList(); GUILayout.Space(10f); DrawExternalArrowsList(); GUILayout.Space(10f); DrawExternalInputsList(); } private void ScanExternalControls() { CleanInvalidControls(); _externalButtons.Clear(); _externalLabels.Clear(); _externalSliders.Clear(); _externalOptions.Clear(); _externalArrows.Clear(); _externalInputs.Clear(); foreach (NativeButton btn in NativeButton.AllInstances) { if (btn != null && !((Object)(object)btn.gameObject == (Object)null) && !NativeArrow.AllInstances.Any((NativeArrow arr) => arr != null && (Object)(object)arr.gameObject == (Object)(object)btn.gameObject) && !_allButtons.Contains(btn)) { _externalButtons.Add(btn); } } foreach (NativeLabel allInstance in NativeLabel.AllInstances) { if (allInstance != null && !((Object)(object)allInstance.gameObject == (Object)null) && !_allLabels.Contains(allInstance)) { _externalLabels.Add(allInstance); } } foreach (NativeSlider allInstance2 in NativeSlider.AllInstances) { if (allInstance2 != null && !((Object)(object)allInstance2.gameObject == (Object)null) && !_allSliders.Contains(allInstance2)) { _externalSliders.Add(allInstance2); } } foreach (NativeOption allInstance3 in NativeOption.AllInstances) { if (allInstance3 != null && !((Object)(object)allInstance3.gameObject == (Object)null) && !_allOptions.Contains(allInstance3)) { _externalOptions.Add(allInstance3); } } foreach (NativeArrow allInstance4 in NativeArrow.AllInstances) { if (allInstance4 != null && !((Object)(object)allInstance4.gameObject == (Object)null) && !_allArrows.Contains(allInstance4)) { _externalArrows.Add(allInstance4); } } foreach (NativeInput allInstance5 in NativeInput.AllInstances) { if (allInstance5 != null && !((Object)(object)allInstance5.gameObject == (Object)null) && !_allInputs.Contains(allInstance5)) { _externalInputs.Add(allInstance5); } } Debug.Log((object)$"扫描完成: 按钮={_externalButtons.Count}, 标签={_externalLabels.Count}, 滑块={_externalSliders.Count}, 选项={_externalOptions.Count}, 箭头={_externalArrows.Count}, 输入框={_externalInputs.Count}"); } private void DrawExternalButtonsList() { _externalButtons.RemoveAll((NativeButton b) => b == null || (Object)(object)b.gameObject == (Object)null); GUILayout.Label(string.Format("{0} ({1})", UILocale.Get("外部按钮"), _externalButtons.Count), Array.Empty<GUILayoutOption>()); for (int i = 0; i < _externalButtons.Count; i++) { NativeButton nativeButton = _externalButtons[i]; if (nativeButton != null && !((Object)(object)nativeButton.gameObject == (Object)null) && GUILayout.Button(string.Format(UILocale.Get("按钮 {0}: {1}"), i, nativeButton.GetTitle()), Array.Empty<GUILayoutOption>())) { _selectedControl = nativeButton; UpdateEditFieldsFromControl(); } } } private void DrawExternalLabelsList() { _externalLabels.RemoveAll((NativeLabel l) => l == null || (Object)(object)l.gameObject == (Object)null); GUILayout.Label(string.Format("{0} ({1})", UILocale.Get("外部标签"), _externalLabels.Count), Array.Empty<GUILayoutOption>()); for (int i = 0; i < _externalLabels.Count; i++) { NativeLabel nativeLabel = _externalLabels[i]; if (nativeLabel != null && !((Object)(object)nativeLabel.gameObject == (Object)null) && GUILayout.Button(string.Format(UILocale.Get("标签 {0}: {1}"), i, nativeLabel.GetText()), Array.Empty<GUILayoutOption>())) { _selectedControl = nativeLabel; UpdateEditFieldsFromControl(); } } } private void DrawExternalSlidersList() { _externalSliders.RemoveAll((NativeSlider s) => s == null || (Object)(object)s.gameObject == (Object)null); GUILayout.Label(string.Format("{0} ({1})", UILocale.Get("外部滑块"), _externalSliders.Count), Array.Empty<GUILayoutOption>()); for (int i = 0; i < _externalSliders.Count; i++) { NativeSlider nativeSlider = _externalSliders[i]; if (nativeSlider != null && !((Object)(object)nativeSlider.gameObject == (Object)null) && GUILayout.Button(string.Format(UILocale.Get("滑块 {0}: {1} 值={2}"), i, nativeSlider.GetLabel(), nativeSlider.Value), Array.Empty<GUILayoutOption>())) { _selectedControl = nativeSlider; UpdateEditFieldsFromControl(); } } } private void DrawExternalOptionsList() { _externalOptions.RemoveAll((NativeOption o) => o == null || (Object)(object)o.gameObject == (Object)null); GUILayout.Label(string.Format("{0} ({1})", UILocale.Get("外部选项行"), _externalOptions.Count), Array.Empty<GUILayoutOption>()); for (int i = 0; i < _externalOptions.Count; i++) { NativeOption nativeOption = _externalOptions[i]; if (nativeOption != null && !((Object)(object)nativeOption.gameObject == (Object)null) && GUILayout.Button(string.Format(UILocale.Get("选项 {0}: {1} 当前={2}"), i, nativeOption.GetLabel(), nativeOption.GetCurrentValue()), Array.Empty<GUILayoutOption>())) { _selectedControl = nativeOption; UpdateEditFieldsFromControl(); } } } private void DrawExternalArrowsList() { //IL_00a1: Unknown result type (might be due to invalid IL or missing references) _externalArrows.RemoveAll((NativeArrow a) => a == null || (Object)(object)a.gameObject == (Object)null); GUILayout.Label(string.Format("{0} ({1})", UILocale.Get("外部箭头"), _externalArrows.Count), Array.Empty<GUILayoutOption>()); for (int i = 0; i < _externalArrows.Count; i++) { NativeArrow nativeArrow = _externalArrows[i]; if (nativeArrow != null && !((Object)(object)nativeArrow.gameObject == (Object)null) && GUILayout.Button(string.Format(UILocale.Get("箭头 {0}: {1} 位置={2}"), i, nativeArrow.GetDirection(), nativeArrow.GetPosition()), Array.Empty<GUILayoutOption>())) { _selectedControl = nativeArrow; UpdateEditFieldsFromControl(); } } } private void DrawExternalInputsList() { _externalInputs.RemoveAll((NativeInput i) => i == null || (Object)(object)i.gameObject == (Object)null); GUILayout.Label(string.Format("{0} ({1})", UILocale.Get("外部输入框"), _externalInputs.Count), Array.Empty<GUILayoutOption>()); for (int j = 0; j < _externalInputs.Count; j++) { NativeInput nativeInput = _externalInputs[j]; if (nativeInput != null && !((Object)(object)nativeInput.gameObject == (Object)null) && GUILayout.Button(string.Format(UILocale.Get("输入框 {0}: {1}"), j, nativeInput.GetText()), Array.Empty<GUILayoutOption>())) { _selectedControl = nativeInput; UpdateEditFieldsFromControl(); } } } private void DrawUnifiedEditor() { if (_selectedControl == null) { GUILayout.Label(UILocale.Get("未选中任何控件"), Array.Empty<GUILayoutOption>()); return; } GameObject val = null; if (_selectedControl is NativeButton nativeButton) { val = nativeButton.gameObject; } else if (_selectedControl is NativeLabel nativeLabel) { val = nativeLabel.gameObject; } else if (_selectedControl is NativeSlider nativeSlider) { val = nativeSlider.gameObject; } else if (_selectedControl is NativeOption nativeOption) { val = nativeOption.gameObject; } else if (_selectedControl is NativeArrow nativeArrow) { val = nativeArrow.gameObject; } else if (_selectedControl is NativeInput nativeInput) { val = nativeInput.gameObject; } if ((Object)(object)val == (Object)null) { _selectedControl = null; CurrentlySelectedForDrag = null; GUILayout.Label(UILocale.Get("控件已被销毁"), Array.Empty<GUILayoutOption>()); return; } GUILayout.BeginVertical(GUIStyle.op_Implicit("box"), Array.Empty<GUILayoutOption>()); if (_selectedControl is NativeButton btn) { DrawButtonEditor(btn); } else if (_selectedControl is NativeLabel lbl) { DrawLabelEditor(lbl); } else if (_selectedControl is NativeSlider sld) { DrawSliderEditor(sld); } else if (_selectedControl is NativeOption opt) { DrawOptionEditor(opt); } else if (_selectedControl is NativeArrow arr) { DrawArrowEditor(arr); } else if (_selectedControl is NativeInput inp) { DrawInputEditor(inp); } GUILayout.Space(10f); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); if (GUILayout.Button(UILocale.Get("固定到当前页面"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) })) { PinSelectedControlToTargetPage(); } GUILayout.EndHorizontal(); GUILayout.EndVertical(); } private void DrawButtonEditor(NativeButton btn) { //IL_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_036a: Unknown result type (might be due to invalid IL or missing references) //IL_04ca: Unknown result type (might be due to invalid IL or missing references) //IL_050d: Unknown result type (might be due to invalid IL or missing references) //IL_051a: Unknown result type (might be due to invalid IL or missing references) //IL_0500: Unknown result type (might be due to invalid IL or missing references) if (btn == null || (Object)(object)btn.gameObject == (Object)null) { _selectedControl = null; CurrentlySelectedForDrag = null; GUILayout.Label(UILocale.Get("控件已被销毁"), Array.Empty<GUILayoutOption>()); return; } GUILayout.Label(string.Format(UILocale.Get("编辑按钮: {0}"), btn.GetTitle()), Array.Empty<GUILayoutOption>()); GUILayout.Label(UILocale.Get("标题:"), Array.Empty<GUILayoutOption>()); _editTitle = GUILayout.TextField(_editTitle, Array.Empty<GUILayoutOption>()); GUILayout.Label(UILocale.Get("描述:"), Array.Empty<GUILayoutOption>()); _editDesc = GUILayout.TextField(_editDesc, Array.Empty<GUILayoutOption>()); GUILayout.Label(UILocale.Get("位置 (x, y):"), Array.Empty<GUILayoutOption>()); string s2 = GUILayout.TextField(_editPos.x.ToString(), Array.Empty<GUILayoutOption>()); string s3 = GUILayout.TextField(_editPos.y.ToString(), Array.Empty<GUILayoutOption>()); float.TryParse(s2, out _editPos.x); float.TryParse(s3, out _editPos.y); GUILayout.Label(UILocale.Get("尺寸 (宽, 高):"), Array.Empty<GUILayoutOption>()); string s4 = GUILayout.TextField(_editSize.x.ToString(), Array.Empty<GUILayoutOption>()); string s5 = GUILayout.TextField(_editSize.y.ToString(), Array.Empty<GUILayoutOption>()); float.TryParse(s4, out _editSize.x); float.TryParse(s5, out _editSize.y); if (btn.HasIcon()) { GUILayout.Label(UILocale.Get("图标偏移 (x, y):"), Array.Empty<GUILayoutOption>()); string s6 = GUILayout.TextField(_editIconOffset.x.ToString(), Array.Empty<GUILayoutOption>()); string s7 = GUILayout.TextField(_editIconOffset.y.ToString(), Array.Empty<GUILayoutOption>()); float.TryParse(s6, out _editIconOffset.x); float.TryParse(s7, out _editIconOffset.y); if (GUILayout.Button(UILocale.Get("应用图标偏移"), Array.Empty<GUILayoutOption>())) { btn.SetIconOffset(_editIconOffset); } } GUILayout.Label(UILocale.Get("标题文字偏移 (x, y):"), Array.Empty<GUILayoutOption>()); string s8 = GUILayout.TextField(_editTitleOffset.x.ToString(), Array.Empty<GUILayoutOption>()); string s9 = GUILayout.TextField(_editTitleOffset.y.ToString(), Array.Empty<GUILayoutOption>()); float.TryParse(s8, out _editTitleOffset.x); float.TryParse(s9, out _editTitleOffset.y); if (GUILayout.Button(UILocale.Get("应用标题偏移"), Array.Empty<GUILayoutOption>())) { btn.SetTitleOffset(_editTitleOffset); } GUILayout.Label(UILocale.Get("描述文字偏移 (x, y):"), Array.Empty<GUILayoutOption>()); string s10 = GUILayout.TextField(_editDescOffset.x.ToString(), Array.Empty<GUILayoutOption>()); string s11 = GUILayout.TextField(_editDescOffset.y.ToString(), Array.Empty<GUILayoutOption>()); float.TryParse(s10, out _editDescOffset.x); float.TryParse(s11, out _editDescOffset.y); if (GUILayout.Button(UILocale.Get("应用描述偏移"), Array.Empty<GUILayoutOption>())) { btn.SetDescOffset(_editDescOffset); } bool flag = btn.IsDraggable(); bool flag2 = GUILayout.Toggle(flag, UILocale.Get("允许拖拽 (按住鼠标左键拖动)"), Array.Empty<GUILayoutOption>()); if (flag2 != flag) { btn.SetDraggable(flag2); } GUILayout.Label(UILocale.Get("设置切换文字序列(逗号分隔):"), Array.Empty<GUILayoutOption>()); _editToggleTextsInput = GUILayout.TextField(_editToggleTextsInput, Array.Empty<GUILayoutOption>()); if (GUILayout.Button(UILocale.Get("应用切换序列"), Array.Empty<GUILayoutOption>())) { string[] array = (from s in _editToggleTextsInput.Split(new char[1] { ',' }) select s.Trim()).ToArray(); if (array.Length >= 2) { btn.SetToggleTexts(array); UpdateEditFieldsFromControl(); } else if (array.Length == 1) { btn.SetTitle(array[0]); btn.SetDescription(array[0]); btn.SetToggleTexts(null); } else { btn.SetToggleTexts(null); } } if (GUILayout.Button(UILocale.Get("应用更改"), Array.Empty<GUILayoutOption>())) { btn.SetTitle(_editTitle); btn.SetDescription(_editDesc); btn.SetPosition(_editPos); btn.SetSize(_editSize.x, _editSize.y); if (btn.HasIcon()) { btn.SetIconOffset(_editIconOffset); } btn.SetTitleOffset(_editTitleOffset); btn.SetDescOffset(_editDescOffset); } if (GUILayout.Button(UILocale.Get("删除此控件"), Array.Empty<GUILayoutOption>())) { btn.Destroy(); RemoveFromList(btn); _selectedControl = null; CurrentlySelectedForDrag = null; } } private void DrawLabelEditor(NativeLabel lbl) { //IL_02c9: Unknown result type (might be due to invalid IL or missing references) //IL_0300: 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_0261: Unknown result type (might be due to invalid IL or missing references) if (lbl == null || (Object)(object)lbl.gameObject == (Object)null) { _selectedControl = null; CurrentlySelectedForDrag = null; GUILayout.Label(UILocale.Get("控件已被销毁"), Array.Empty<GUILayoutOption>()); return; } GUILayout.Label(string.Format(UILocale.Get("编辑标签: {0}"), lbl.GetText()), Array.Empty<GUILayoutOption>()); GUILayout.Label(UILocale.Get("文本:"), Array.Empty<GUILayoutOption>()); _editLabelText = GUILayout.TextField(_editLabelText, Array.Empty<GUILayoutOption>()); GUILayout.Label(UILocale.Get("位置 (x, y):"), Array.Empty<GUILayoutOption>()); string s = GUILayout.TextField(_editPos.x.ToString(), Array.Empty<GUILayoutOption>()); string s2 = GUILayout.TextField(_editPos.y.ToString(), Array.Empty<GUILayoutOption>()); float.TryParse(s, out _editPos.x); float.TryParse(s2, out _editPos.y); GUILayout.Label(UILocale.Get("尺寸 (宽, 高):"), Array.Empty<GUILayoutOption>()); string s3 = GUILayout.TextField(_editSize.x.ToString(), Array.Empty<GUILayoutOption>()); string s4 = GUILayout.TextField(_editSize.y.ToString(), Array.Empty<GUILayoutOption>()); float.TryParse(s3, out _editSize.x); float.TryParse(s4, out _editSize.y); GUILayout.Label(UILocale.Get("字体大小:"), Array.Empty<GUILayoutOption>()); string s5 = GUILayout.TextField(_editFontSize.ToString(), Array.Empty<GUILayoutOption>()); int.TryParse(s5, out _editFontSize); GUILayout.Label(UILocale.Get("颜色 (R,G,B):"), Array.Empty<GUILayoutOption>()); string text = GUILayout.TextField($"{_editColor.r:F2},{_editColor.g:F2},{_editColor.b:F2}", Array.Empty<GUILayoutOption>()); string[] array = text.Split(new char[1] { ',' }); if (array.Length == 3 && float.TryParse(array[0], out var result) && float.TryParse(array[1], out var result2) && float.TryParse(array[2], out var result3)) { _editColor = new Color(result, result2, result3, 1f); } bool flag = lbl.IsDraggable(); bool flag2 = GUILayout.Toggle(flag, UILocale.Get("允许拖拽 (按住鼠标左键拖动)"), Array.Empty<GUILayoutOption>()); if (flag2 != flag) { lbl.SetDraggable(flag2); } if (GUILayout.Button(UILocale.Get("应用更改"), Array.Empty<GUILayoutOption>())) { lbl.SetText(_editLabelText); lbl.SetPosition(_editPos); lbl.SetSize(_editSize.x, _editSize.y); lbl.SetFontSize(_editFontSize); lbl.SetColor(_editColor); } if (GUILayout.Button(UILocale.Get("删除此控件"), Array.Empty<GUILayoutOption>())) { lbl.Destroy(); RemoveFromList(lbl); _selectedControl = null; CurrentlySelectedForDrag = null; } } private void DrawSliderEditor(NativeSlider sld) { //IL_03a8: Unknown result type (might be due to invalid IL or missing references) //IL_03ad: Unknown result type (might be due to invalid IL or missing references) //IL_03b0: Unknown result type (might be due to invalid IL or missing references) //IL_03b5: Unknown result type (might be due to invalid IL or missing references) //IL_041f: Unknown result type (might be due to invalid IL or missing references) //IL_0428: Unknown result type (might be due to invalid IL or missing references) //IL_042f: Unknown result type (might be due to invalid IL or missing references) if (sld == null || (Object)(object)sld.gameObject == (Object)null) { _selectedControl = null; CurrentlySelectedForDrag = null; GUILayout.Label(UILocale.Get("控件已被销毁"), Array.Empty<GUILayoutOption>()); return; } GUILayout.Label(string.Format(UILocale.Get("编辑滑块: {0}"), sld.GetLabel()), Array.Empty<GUILayoutOption>()); GUILayout.Label(UILocale.Get("标签:"), Array.Empty<GUILayoutOption>()); _editSliderLabel = GUILayout.TextField(_editSliderLabel, Array.Empty<GUILayoutOption>()); GUILayout.Label(UILocale.Get("位置 (x, y):"), Array.Empty<GUILayoutOption>()); string s = GUILayout.TextField(_editPos.x.ToString(), Array.Empty<GUILayoutOption>()); string s2 = GUILayout.TextField(_editPos.y.ToString(), Array.Empty<GUILayoutOption>()); float.TryParse(s, out _editPos.x); float.TryParse(s2, out _editPos.y); GUILayout.Label(UILocale.Get("尺寸 (宽, 高):"), Array.Empty<GUILayoutOption>()); string s3 = GUILayout.TextField(_editSize.x.ToString(), Array.Empty<GUILayoutOption>()); string s4 = GUILayout.TextField(_editSize.y.ToString(), Array.Empty<GUILayoutOption>()); float.TryParse(s3, out _editSize.x); float.TryParse(s4, out _editSize.y); GUILayout.Label(UILocale.Get("滑块 X 偏移:"), Array.Empty<GUILayoutOption>()); string s5 = GUILayout.TextField(_editSliderXOffset.ToString(), Array.Empty<GUILayoutOption>()); float.TryParse(s5, out _editSliderXOffset); GUILayout.Label(UILocale.Get("滑块宽度 (0=原生):"), Array.Empty<GUILayoutOption>()); string s6 = GUILayout.TextField(_editSliderWidth.ToString(), Array.Empty<GUILayoutOption>()); float.TryParse(s6, out _editSliderWidth); GUILayout.Label(UILocale.Get("标签 X 偏移:"), Array.Empty<GUILayoutOption>()); string s7 = GUILayout.TextField(_editLabelXOffset.ToString(), Array.Empty<GUILayoutOption>()); float.TryParse(s7, out _editLabelXOffset); GUILayout.Label(UILocale.Get("数值 X 偏移:"), Array.Empty<GUILayoutOption>()); string s8 = GUILayout.TextField(_editValueXOffset.ToString(), Array.Empty<GUILayoutOption>()); float.TryParse(s8, out _editValueXOffset); GUILayout.Label(string.Format(UILocale.Get("最小值: {0}"), _editSliderMin), Array.Empty<GUILayoutOption>()); string s9 = GUILayout.TextField(_editSliderMin.ToString(), Array.Empty<GUILayoutOption>()); float.TryParse(s9, out _editSliderMin); GUILayout.Label(string.Format(UILocale.Get("最大值: {0}"), _editSliderMax), Array.Empty<GUILayoutOption>()); string s10 = GUILayout.TextField(_editSliderMax.ToString(), Array.Empty<GUILayoutOption>()); float.TryParse(s10, out _editSliderMax); GUILayout.Label(string.Format(UILocale.Get("当前值: {0}"), _editSliderValue), Array.Empty<GUILayoutOption>()); string s11 = GUILayout.TextField(_editSliderValue.ToString(), Array.Empty<GUILayoutOption>()); float.TryParse(s11, out _editSliderValue); _editSliderWhole = GUILayout.Toggle(_editSliderWhole, UILocale.Get("整数步进"), Array.Empty<GUILayoutOption>()); bool flag = sld.IsDraggable(); bool flag2 = GUILayout.Toggle(flag, UILocale.Get("允许拖拽 (按住鼠标左键拖动)"), Array.Empty<GUILayoutOption>()); if (flag2 != flag) { sld.SetDraggable(flag2); } if (GUILayout.Button(UILocale.Get("应用更改"), Array.Empty<GUILayoutOption>())) { Vector2 position = sld.GetPosition(); Vector2 size = sld.GetSize(); sld.SetLabel(_editSliderLabel); sld.SetSliderXOffset(_editSliderXOffset); sld.SetSliderWidth(_editSliderWidth); sld.SetLabelXOffset(_editLabelXOffset); sld.SetValueXOffset(_editValueXOffset); sld.SetMinMax(_editSliderMin, _editSliderMax, _editSliderWhole); sld.Value = _editSliderValue; sld.SetPosition(position); sld.SetSize(size.x, size.y); } if (GUILayout.Button(UILocale.Get("删除此控件"), Array.Empty<GUILayoutOption>())) { sld.Destroy(); RemoveFromList(sld); _selectedControl = null; CurrentlySelectedForDrag = null; } } private void DrawOptionEditor(NativeOption opt) { //IL_0383: Unknown result type (might be due to invalid IL or missing references) if (opt == null || (Object)(object)opt.gameObject == (Object)null) { _selectedControl = null; CurrentlySelectedForDrag = null; GUILayout.Label(UILocale.Get("控件已被销毁"), Array.Empty<GUILayoutOption>()); return; } GUILayout.Label(string.Format(UILocale.Get("编辑选项行: {0}"), opt.GetLabel()), Array.Empty<GUILayoutOption>()); GUILayout.Label(UILocale.Get("标签:"), Array.Empty<GUILayoutOption>()); _editOptionLabel = GUILayout.TextField(_editOptionLabel, Array.Empty<GUILayoutOption>()); GUILayout.Label(UILocale.Get("描述:"), Array.Empty<GUILayoutOption>()); _editOptionDesc = GUILayout.TextField(_editOptionDesc, Array.Empty<GUILayoutOption>()); GUILayout.Label(UILocale.Get("位置 (x, y):"), Array.Empty<GUILayoutOption>()); string s2 = GUILayout.TextField(_editPos.x.ToString(), Array.Empty<GUILayoutOption>()); string s3 = GUILayout.TextField(_editPos.y.ToString(), Array.Empty<GUILayoutOption>()); float.TryParse(s2, out _editPos.x); float.TryParse(s3, out _editPos.y); GUILayout.Label(UILocale.Get("尺寸 (宽, 高):"), Array.Empty<GUILayoutOption>()); string s4 = GUILayout.TextField(_editSize.x.ToString(), Array.Empty<GUILayoutOption>()); string s5 = GUILayout.TextField(_editSize.y.ToString(), Array.Empty<GUILayoutOption>()); float.TryParse(s4, out _editSize.x); float.TryParse(s5, out _editSize.y); GUILayout.Label(UILocale.Get("选项列表 (用逗号分隔):"), Array.Empty<GUILayoutOption>()); string text = ((_editOptionOptions != null) ? string.Join(",", _editOptionOptions) : ""); string text2 = GUILayout.TextField(text, Array.Empty<GUILayoutOption>()); if (text2 != text) { _editOptionOptions = (from s in text2.Split(new char[1] { ',' }) select s.Trim()).ToArray(); } if (_editOptionOptions != null && _editOptionOptions.Length != 0) { _editOptionIndex = Mathf.Clamp(_editOptionIndex, 0, _editOptionOptions.Length - 1); GUILayout.Label(string.Format(UILocale.Get("当前选中: {0} (索引 {1})"), _editOptionOptions[_editOptionIndex], _editOptionIndex), Array.Empty<GUILayoutOption>()); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); if (GUILayout.Button(UILocale.Get("上一个"), Array.Empty<GUILayoutOption>())) { _editOptionIndex = (_editOptionIndex - 1 + _editOptionOptions.Length) % _editOptionOptions.Length; } if (GUILayout.Button(UILocale.Get("下一个"), Array.Empty<GUILayoutOption>())) { _editOptionIndex = (_editOptionIndex + 1) % _editOptionOptions.Length; } GUILayout.EndHorizontal(); } bool flag = opt.IsDraggable(); bool flag2 = GUILayout.Toggle(flag, UILocale.Get("允许拖拽 (按住鼠标左键拖动)"), Array.Empty<GUILayoutOption>()); if (flag2 != flag) { opt.SetDraggable(flag2); } if (GUILayout.Button(UILocale.Get("应用更改"), Array.Empty<GUILayoutOption>())) { opt.SetLabel(_editOptionLabel); opt.SetDescription(_editOptionDesc); opt.SetPosition(_editPos); opt.SetSize(_editSize.x, _editSize.y); if (_editOptionOptions != null && _editOptionOptions.Length != 0) { opt.SetOptions(_editOptionOptions, _editOptionIndex); } } if (GUILayout.Button(UILocale.Get("删除此控件"), Array.Empty<GUILayoutOption>())) { opt.Destroy(); RemoveFromList(opt); _selectedControl = null; CurrentlySelectedForDrag = null; } } private void DrawArrowEditor(NativeArrow arr) { //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Expected O, but got Unknown if (arr == null || (Object)(object)arr.gameObject == (Object)null) { _selectedControl = null; CurrentlySelectedForDrag = null; GUILayout.Label(UILocale.Get("控件已被销毁"), Array.Empty<GUILayoutOption>()); return; } GUILayout.Label(string.Format(UILocale.Get("编辑箭头: {0}"), arr.GetDirection()), Array.Empty<GUILayoutOption>()); GUILayout.Label(UILocale.Get("位置 (x, y):"), Array.Empty<GUILayoutOption>()); string s = GUILayout.TextField(_editPos.x.ToString(), Array.Empty<GUILayoutOption>()); string s2 = GUILayout.TextField(_editPos.y.ToString(), Array.Empty<GUILayoutOption>()); float.TryParse(s, out _editPos.x); float.TryParse(s2, out _editPos.y); GUILayout.Label(UILocale.Get("尺寸 (宽, 高):"), Array.Empty<GUILayoutOption>()); string s3 = GUILayout.TextField(_editSize.x.ToString(), Array.Empty<GUILayoutOption>()); string s4 = GUILayout.TextField(_editSize.y.ToString(), Array.Empty<GUILayoutOption>()); float.TryParse(s3, out _editSize.x); float.TryParse(s4, out _editSize.y); _editArrowClickable = GUILayout.Toggle(_editArrowClickable, UILocale.Get("可点击 (添加按钮)"), Array.Empty<GUILayoutOption>()); _editArrowDraggable = GUILayout.Toggle(_editArrowDraggable, UILocale.Get("允许拖拽 (按住鼠标左键拖动)"), Array.Empty<GUILayoutOption>()); if (GUILayout.Button(UILocale.Get("应用更改"), Array.Empty<GUILayoutOption>())) { arr.SetPosition(_editPos); arr.SetSize(_editSize.x, _editSize.y); bool editArrowClickable = _editArrowClickable; object obj = <>c.<>9__108_0; if (obj == null) { UnityAction val = delegate { Debug.Log((object)UILocale.Get("箭头被点击")); }; <>c.<>9__108_0 = val; obj = (object)val; } arr.SetClickable(editArrowClickable, (UnityAction)obj); arr.SetDraggable(_editArrowDraggable); } if (GUILayout.Button(UILocale.Get("删除此控件"), Array.Empty<GUILayoutOption>())) { arr.Destroy(); RemoveFromList(arr); _selectedControl = null; CurrentlySelectedForDrag = null; } } private void DrawInputEditor(NativeInput inp) { //IL_021b: Unknown result type (might be due to invalid IL or missing references) if (inp == null || (Object)(object)inp.gameObject == (Object)null) { _selectedControl = null; CurrentlySelectedForDrag = null; GUILayout.Label(UILocale.Get("控件已被销毁"), Array.Empty<GUILayoutOption>()); return; } GUILayout.Label(UILocale.Get("编辑输入框"), Array.Empty<GUILayoutOption>()); GUILayout.Label(UILocale.Get("文本内容:"), Array.Empty<GUILayoutOption>()); _editInputText = GUILayout.TextField(_editInputText, Array.Empty<GUILayoutOption>()); GUILayout.Label(UILocale.Get("占位符:"), Array.Empty<GUILayoutOption>()); _editInputPlaceholder = GUILayout.TextField(_editInputPlaceholder, Array.Empty<GUILayoutOption>()); GUILayout.Label(UILocale.Get("位置 (x, y):"), Array.Empty<GUILayoutOption>()); string s = GUILayout.TextField(_editPos.x.ToString(), Array.Empty<GUILayoutOption>()); string s2 = GUILayout.TextField(_editPos.y.ToString(), Array.Empty<GUILayoutOption>()); float.TryParse(s, out _editPos.x); float.TryParse(s2, out _editPos.y); GUILayout.Label(UILocale.Get("尺寸 (宽, 高):"), Array.Empty<GUILayoutOption>()); string s3 = GUILayout.TextField(_editSize.x.ToString(), Array.Empty<GUILayoutOption>()); string s4 = GUILayout.TextField(_editSize.y.ToString(), Array.Empty<GUILayoutOption>()); float.TryParse(s3, out _editSize.x); float.TryParse(s4, out _editSize.y); bool flag = inp.IsDraggable(); bool flag2 = GUILayout.Toggle(flag, UILocale.Get("允许拖拽 (按住鼠标左键拖动)"), Array.Empty<GUILayoutOption>()); if (flag2 != flag) { inp.SetDraggable(flag2); } if (GUILayout.Button(UILocale.Get("应用更改"), Array.Empty<GUILayoutOption>())) { inp.SetText(_editInputText); Graphic placeholder = inp.inputField.placeholder; Text val = (Text)(object)((placeholder is Text) ? placeholder : null); if ((Object)(object)val != (Object)null) { val.text = _editInputPlaceholder; } inp.SetPosition(_editPos); inp.SetSize(_editSize.x, _editSize.y); } if (GUILayout.Button(UILocale.Get("删除此控件"), Array.Empty<GUILayoutOption>())) { inp.Destroy(); RemoveFromList(inp); _selectedControl = null; CurrentlySelectedForDrag = null; } } private void UpdateEditFieldsFromControl() { //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0168: 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_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0193: 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_020a: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_0371: Unknown result type (might be due to invalid IL or missing references) //IL_0376: 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_0383: Unknown result type (might be due to invalid IL or missing references) //IL_03c4: Unknown result type (might be due to invalid IL or missing references) //IL_03c9: Unknown result type (might be due to invalid IL or missing references) //IL_03d1: Unknown result type (might be due to invalid IL or missing references) //IL_03d6: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_042e: Unknown result type (might be due to invalid IL or missing references) //IL_0433: Unknown result type (might be due to invalid IL or missing references) //IL_043b: Unknown result type (might be due to invalid IL or missing references) //IL_0440: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) if (_tempDragEnabled) { _tempDragEnabled = false; _tempDragTarget = null; Debug.Log((object)"[DebugWindow] 由于选中新控件,临时拖拽模式已关闭"); } if (_selectedControl == null) { CurrentlySelectedForDrag = null; return; } GameObject val = null; if (_selectedControl is NativeButton nativeButton) { val = nativeButton.gameObject; } else if (_selectedControl is NativeLabel nativeLabel) { val = nativeLabel.gameObject; } else if (_selectedControl is NativeSlider nativeSlider) { val = nativeSlider.gameObject; } else if (_selectedControl is NativeOption nativeOption) { val = nativeOption.gameObject; } else if (_selectedControl is NativeArrow nativeArrow) { val = nativeArrow.gameObject; } else if (_selectedControl is NativeInput nativeInput) { val = nativeInput.gameObject; } if ((Object)(object)val == (Object)null) { _selectedControl = null; CurrentlySelectedForDrag = null; return; } if (_selectedControl is NativeButton nativeButton2) { _editTitle = nativeButton2.GetTitle(); _editDesc = nativeButton2.GetDescription(); _editPos = nativeButton2.GetPosition(); _editSize = nativeButton2.GetSize(); _editIconOffset = nativeButton2.GetIconOffset(); _editTitleOffset = nativeButton2.GetTitleOffset(); _editDescOffset = nativeButton2.GetDescOffset(); if (nativeButton2.toggleTexts != null && nativeButton2.toggleTexts.Length != 0) { _editToggleTextsInput = string.Join(",", nativeButton2.toggleTexts); } else { _editToggleTextsInput = ""; } } else if (_selectedControl is NativeLabel nativeLabel2) { _editLabelText = nativeLabel2.GetText(); _editPos = nativeLabel2.GetPosition(); _editSize = nativeLabel2.GetSize(); Text textComponent = nativeLabel2.textComponent; _editFontSize = ((textComponent != null) ? textComponent.fontSize : 30); Text textComponent2 = nativeLabel2.textComponent; _editColor = ((textComponent2 != null) ? ((Graphic)textComponent2).color : Color.white); } else if (_selectedControl is NativeSlider nativeSlider2) { _editSliderLabel = nativeSlider2.GetLabel(); _editPos = nativeSlider2.GetPosition(); _editSize = nativeSlider2.GetSize(); Slider slider = nativeSlider2.slider; _editSliderMin = ((slider != null) ? slider.minValue : 0f); Slider slider2 = nativeSlider2.slider; _editSliderMax = ((slider2 != null) ? slider2.maxValue : 100f); _editSliderValue = nativeSlider2.Value; Slider slider3 = nativeSlider2.slider; _editSliderWhole = slider3 == null || slider3.wholeNumbers; _editSliderXOffset = nativeSlider2.GetSliderXOffset(); _editSliderWidth = nativeSlider2.GetSliderWidth(); _editLabelXOffset = nativeSlider2.GetLabelXOffset(); _editValueXOffset = nativeSlider2.GetValueXOffset(); } else if (_selectedControl is NativeOption nativeOption2) { _editOptionLabel = nativeOption2.GetLabel(); _editOptionDesc = nativeOption2.GetDescription(); _editPos = nativeOption2.GetPosition(); _editSize = nativeOption2.GetSize(); _editOptionOptions = nativeOption2.GetOptions(); _editOptionIndex = nativeOption2.GetCurrentIndex(); } else if (_selectedControl is NativeArrow nativeArrow2) { _editPos = nativeArrow2.GetPosition(); _editSize = nativeArrow2.GetSize(); _editArrowDirection = (int)nativeArrow2.GetDirection(); _editArrowClickable = nativeArrow2.IsClickable(); _editArrowDraggable = nativeArrow2.IsDraggable(); } else if (_selectedControl is NativeInput nativeInput2) { _editInputText = nativeInput2.GetText(); _editPos = nativeInput2.GetPosition(); _editSize = nativeInput2.GetSize(); Graphic placeholder = nativeInput2.inputField.placeholder; Text val2 = (Text)(object)((placeholder is Text) ? placeholder : null); _editInputPlaceholder = (((Object)(object)val2 != (Object)null) ? val2.text : UILocale.Get("输入...")); } CurrentlySelectedForDrag = GetSelectedGameObject(); } private void RemoveFromList(object control) { if (control is NativeButton item) { _allButtons.Remove(item); } else if (control is NativeLabel item2) { _allLabels.Remove(item2); } else if (control is NativeSlider item3) { _allSliders.Remove(item3); } else if (control is NativeOption item4) { _allOptions.Remove(item4); } else if (control is NativeArrow item5) { _allArrows.Remove(item5); } else if (control is NativeInput item6) { _externalInputs.Remove(item6); _allInputs.Remove(item6); } } private void DrawPageManagementTab() { _allPages = NativePage.AllInstances.ToList(); GUILayout.Label(UILocale.Get("可用页面:"), Array.Empty<GUILayoutOption>()); for (int i = 0; i < _allPages.Count; i++) { NativePage nativePage = _allPages[i]; if (nativePage != null && GUILayout.Button(string.Format(UILocale.Get("页面 {0}: {1}"), i, ((Object)nativePage.gameObject).name), Array.Empty<GUILayoutOption>())) { _selectedPage = nativePage; RefreshPageControlsCache(); } } if (_selectedPage == null) { return; } GUILayout.Label(string.Format(UILocale.Get("当前页面: {0} 包含控件: {1}"), ((Object)_selectedPage.gameObject).name, _pageControlsCache.Count), Array.Empty<GUILayoutOption>()); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); if (GUILayout.Button(UILocale.Get("保存页面配置"), Array.Empty<GUILayoutOption>())) { SavePageConfig(); } if (GUILayout.Button(UILocale.Get("加载页面配置"), Array.Empty<GUILayoutOption>())) { LoadPageConfig(); } if (GUILayout.Button(UILocale.Get("刷新"), Array.Empty<GUILayoutOption>())) { RefreshPageControlsCache(); } GUILayout.EndHorizontal(); GUILayout.Label(UILocale.Get("页面内控件列表:"), Array.Empty<GUILayoutOption>()); foreach (UIControlConfig item in _pageControlsCache) { GUILayout.Label(string.Format(" {0}: {1} - {2}({3:F0},{4:F0})", item.type, item.name, UILocale.Get("位置"), item.position.x, item.position.y), Array.Empty<GUILayoutOption>()); } } private void RefreshPageControlsCache() { if (_selectedPage != null) { _pageControlsCache.Clear(); AddIfChild<NativeButton>(NativeButton.AllInstances); AddIfChild<NativeLabel>(NativeLabel.AllInstances); AddIfChild<NativeSlider>(NativeSlider.AllInstances); AddIfChild<NativeOption>(NativeOption.AllInstances); AddIfChild<NativeArrow>(NativeArrow.AllInstances); AddIfChild<NativeInput>(NativeInput.AllInstances); } void AddIfChild<T>(List<T> instances) where T : class { foreach (T instance in instances) { GameObject val = null; if (instance is NativeButton nativeButton) { val = nativeButton.gameObject; } else if (instance is NativeLabel nativeLabel) { val = nativeLabel.gameObject; } else if (instance is NativeSlider nativeSlider) { val = nativeSlider.gameObject; } else if (instance is NativeOption nativeOption) { val = nativeOption.gameObject; } else if (instance is NativeArrow nativeArrow) { val = nativeArrow.gameObject; } else if (instance is NativeInput nativeInput) { val = nativeInput.gameObject; } if ((Object)(object)val != (Object)null && IsChildOf(val.transform, _selectedPage.gameObject.transform)) { _pageControlsCache.Add(GetControlConfig(instance)); } } } } private bool IsChildOf(Transform child, Transform parent) { while ((Object)(object)child != (Object)null) { if ((Object)(object)child == (Object)(object)parent) { return true; } child = child.parent; } return false; } private UIControlConfig GetControlConfig(object ctrl) { //IL_0038: 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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008c: 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_0112: 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_011f: 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_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_0348: Unknown result type (might be due to invalid IL or missing references) //IL_034d: Unknown result type (might be due to invalid IL or missing references) //IL_0355: Unknown result type (might be due to invalid IL or missing references) //IL_035a: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_03c0: Unknown result type (might be due to invalid IL or missing references) //IL_03c5: Unknown result type (might be due to invalid IL or missing references) //IL_03d2: Unknown result type (might be due to invalid IL or missing references) //IL_03d7: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) UIControlConfig uIControlConfig = new UIControlConfig(); if (ctrl is NativeButton nativeButton) { uIControlConfig.type = "Button"; uIControlConfig.name = ((Object)nativeButton.gameObject).name; uIControlConfig.position = nativeButton.GetPosition(); uIControlConfig.size = nativeButton.GetSize(); uIControlConfig.title = nativeButton.GetTitle(); uIControlConfig.description = nativeButton.GetDescription(); uIControlConfig.draggable = nativeButton.IsDraggable(); uIControlConfig.iconOffset = nativeButton.GetIconOffset(); uIControlConfig.titleOffset = nativeButton.GetTitleOffset(); uIControlConfig.descOffset = nativeButton.GetDescOffset(); uIControlConfig.style = (int)nativeButton.Style; if (nativeButton.toggleTexts != null && nativeButton.toggleTexts.Length != 0) { uIControlConfig.toggleTexts = nativeButton.toggleTexts; uIControlConfig.toggleIndex = nativeButton.currentToggleIndex; } } else if (ctrl is NativeLabel nativeLabel) { uIControlConfig.type = "Label"; uIControlConfig.name = ((Object)nativeLabel.gameObject).name; uIControlConfig.position = nativeLabel.GetPosition(); uIControlConfig.size = nativeLabel.GetSize(); uIControlConfig.labelText = nativeLabel.GetText(); Text textComponent = nativeLabel.textComponent; uIControlConfig.fontSize = ((textComponent != null) ? textComponent.fontSize : 30); Text textComponent2 = nativeLabel.textComponent; uIControlConfig.color = ((textComponent2 != null) ? ((Graphic)textComponent2).color : Color.white); uIControlConfig.draggable = nativeLabel.IsDraggable(); } else if (ctrl is NativeSlider nativeSlider) { uIControlConfig.type = "Slider"; uIControlConfig.name = ((Object)nativeSlider.gameObject).name; uIControlConfig.position = nativeSlider.GetPosition(); uIControlConfig.size = nativeSlider.GetSize(); uIControlConfig.labelText = nativeSlider.GetLabel(); Slider slider = nativeSlider.slider; uIControlConfig.minValue = ((slider != null) ? slider.minValue : 0f); Slider slider2 = nativeSlider.slider; uIControlConfig.maxValue = ((slider2 != null) ? slider2.maxValue : 100f); uIControlConfig.value = nativeSlider.Value; Slider slider3 = nativeSlider.slider; uIControlConfig.wholeNumbers = slider3 == null || slider3.wholeNumbers; uIControlConfig.draggable = nativeSlider.IsDraggable(); uIControlConfig.sliderXOffset = nativeSlider.GetSliderXOffset(); uIControlConfig.sliderWidth = nativeSlider.GetSliderWidth(); uIControlConfig.labelXOffset = nativeSlider.GetLabelXOffset(); uIControlConfig.valueXOffset = nativeSlider.GetValueXOffset(); } else if (ctrl is NativeOption nativeOption) { uIControlConfig.type = "Option"; uIControlConfig.name = ((Object)nativeOption.gameObject).name; uIControlConfig.position = nativeOption.GetPosition(); uIControlConfig.size = nativeOption.GetSize(); uIControlConfig.labelText = nativeOption.GetLabel(); uIControlConfig.description = nativeOption.GetDescription(); uIControlConfig.options = nativeOption.GetOptions(); uIControlConfig.optionIndex = nativeOption.GetCurrentIndex(); uIControlConfig.draggable = nativeOption.IsDraggable(); } else if (ctrl is NativeArrow nativeArrow) { uIControlConfig.type = "Arrow"; uIControlConfig.name = ((Object)nativeArrow.gameObject).name; uIControlConfig.position = nativeArrow.GetPosition(); uIControlConfig.size = nativeArrow.GetSize(); uIControlConfig.direction = (int)nativeArrow.GetDirection(); uIControlConfig.clickable = nativeArrow.IsClickable(); uIControlConfig.draggable = nativeArrow.IsDraggable(); } else if (ctrl is NativeInput nativeInput) { uIControlConfig.type = "Input"; uIControlConfig.name = ((Object)nativeInput.gameObject).name; uIControlConfig.position = nativeInput.GetPosition(); uIControlConfig.size = nativeInput.rectTransform.sizeDelta; uIControlConfig.inputText = nativeInput.GetText(); Graphic placeholder = nativeInput.inputField.placeholder; Text val = (Text)(object)((placeholder is Text) ? placeholder : null); uIControlConfig.placeholderText = (((Object)(object)val != (Object)null) ? val.text : ""); } return uIControlConfig; } private void SavePageConfig() { if (_selectedPage != null) { RefreshPageControlsCache(); ConfigData configData = new ConfigData { controls = _pageControlsCache }; string text = ((Object)_selectedPage.gameObject).name.Replace(" ", "_"); string text2 = Path.Combine(PluginDirectory, "PageConfigs"); Directory.CreateDirectory(text2); string text3 = Path.Combine(text2, "PageConfig_" + text + ".json"); File.WriteAllText(text3, JsonConvert.SerializeObject((object)configData, (Formatting)1)); Debug.Log((object)("页面配置已保存至 " + text3)); } } private void LoadPageConfig() { if (_selectedPage == null) { return; } string text = ((Object)_selectedPage.gameObject).name.Replace(" ", "_"); string path = Path.Combine(PluginDirectory, "PageConfigs"); string text2 = Path.Combine(path, "PageConfig_" + text + ".json"); if (!File.Exists(text2)) { return; } ConfigData configData = JsonConvert.DeserializeObject<ConfigData>(File.ReadAllText(text2)); if (configData == null) { return; } foreach (UIControlConfig control in configData.controls) { ApplyConfigToControlInPage(control); } Canvas.ForceUpdateCanvases(); Debug.Log((object)("已加载页面配置 " + text2)); } private void ApplyConfigToControlInPage(UIControlConfig cfg) { //IL_01bd: 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_037a: Unknown result type (might be due to invalid IL or missing references) //IL_0316: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_011e: 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_0502: Unknown result type (might be due to invalid IL or missing references) //IL_04ab: Unknown result type (might be due to invalid IL or missing references) //IL_04b0: Unknown result type (might be due to invalid IL or missing references) //IL_04b6: Expected O, but got Unknown GameObject val = FindChildByName(_selectedPage.gameObject.transform, cfg.name); if ((Object)(object)val == (Object)null) { return; } if (cfg.type == "Button") { NativeButton component = val.GetComponent<NativeButton>(); if (component == null) { return; } if (component.Style != (ButtonStyle)cfg.style) { component.SetStyle((ButtonStyle)cfg.style); } component.SetPosition(cfg.position); component.SetSize(cfg.size.x, cfg.size.y); if (!string.IsNullOrEmpty(cfg.title)) { component.SetTitle(cfg.title.Trim()); } if (!string.IsNullOrEmpty(cfg.description)) { component.SetDescription(cfg.description.Trim()); } component.SetDraggable(cfg.draggable); component.SetIconOffset(cfg.iconOffset); component.SetTitleOffset(cfg.titleOffset); component.SetDescOffset(cfg.descOffset); if (cfg.toggleTexts != null && cfg.toggleTexts.Length != 0) { component.SetToggleTexts(cfg.toggleTexts); if (cfg.toggleIndex >= 0 && cfg.toggleIndex < cfg.toggleTexts.Length) { component.SetToggleIndex(cfg.toggleIndex); } } } else if (cfg.type == "Label") { NativeLabel component2 = val.GetComponent<NativeLabel>(); if (component2 != null) { component2.SetPosition(cfg.position); component2.SetSize(cfg.size.x, cfg.size.y); if (!string.IsNullOrEmpty(cfg.labelText)) { component2.SetText(cfg.labelText.Trim()); } if (cfg.fontSize > 0) { component2.SetFontSize(cfg.fontSize); } component2.SetColor(cfg.color); component2.SetDraggable(cfg.draggable); } } else if (cfg.type == "Slider") { NativeSlider component3 = val.GetComponent<NativeSlider>(); if (component3 != null) { if (!string.IsNullOrEmpty(cfg.labelText)) { component3.SetLabel(cfg.labelText.Trim()); } component3.SetMinMax(cfg.minValue, cfg.maxValue, cfg.wholeNumbers); component3.Value = cfg.value; component3.SetDraggable(cfg.draggable); component3.SetSliderXOffset(cfg.sliderXOffset); component3.SetSliderWidth(cfg.sliderWidth); component3.SetLabelXOffset(cfg.labelXOffset); component3.SetValueXOffset(cfg.valueXOffset); component3.SetPosition(cfg.position); component3.SetSize(cfg.size.x, cfg.size.y); } } else if (cfg.type == "Option") { NativeOption component4 = val.GetComponent<NativeOption>(); if (component4 != null) { component4.SetPosition(cfg.position); component4.SetSize(cfg.size.x, cfg.size.y); if (!string.IsNullOrEmpty(cfg.labelText)) { component4.SetLabel(cfg.labelText.Trim()); } if (!string.IsNullOrEmpty(cfg.description)) { component4.SetDescription(cfg.description.Trim()); } if (cfg.options != null && cfg.options.Length != 0) { component4.SetOptions(cfg.options, cfg.optionIndex); } component4.SetDraggable(cfg.draggable); } } else if (cfg.type == "Arrow") { NativeArrow component5 = val.GetComponent<NativeArrow>(); if (component5 == null) { return; } component5.SetPosition(cfg.position); component5.SetSize(cfg.size.x, cfg.size.y); bool clickable = cfg.clickable; object obj = <>c.<>9__118_0; if (obj == null) { UnityAction val2 = delegate { Debug.Log((object)UILocale.Get("箭头被点击")); }; <>c.<>9__118_0 = val2; obj = (object)val2; } component5.SetClickable(clickable, (UnityAction)obj); component5.SetDraggable(cfg.draggable); } else { if (!(cfg.type == "Input")) { return; } NativeInput component6 = val.GetComponent<NativeInput>(); if (component6 != null) { component6.SetPosition(cfg.position); component6.SetSize(cfg.size.x, cfg.size.y); component6.SetText(cfg.inputText); Graphic placeholder = component6.inputField.placeholder; Text val3 = (Text)(object)((placeholder is Text) ? placeholder : null); if ((Object)(object)val3 != (Object)null) { val3.text = cfg.placeholderText; } } } } private GameObject FindChildByName(Transform parent, string name) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown if (((Object)parent).name == name) { return ((Component)parent).gameObject; } foreach (Transform item in parent) { Transform parent2 = item; GameObject val = FindChildByName(parent2, name); if ((Object)(object)val != (Object)null) { return val; } } return null; } private void CleanInvalidControls() { _externalButtons.RemoveAll((NativeButton b) => b == null || (Object)(object)b.gameObject == (Object)null); _externalLabels.RemoveAll((NativeLabel l) => l == null || (Object)(object)l.gameObject == (Object)null); _externalSliders.RemoveAll((NativeSlider s) => s == null || (Object)(object)s.gameObject == (Object)null); _externalOptions.RemoveAll((NativeOption o) => o == null || (Object)(object)o.gameObject == (Object)null); _externalArrows.RemoveAll((NativeArrow a) => a == null || (Object)(object)a.gameObject == (Object)null); _externalInputs.RemoveAll((NativeInput i) => i == null || (Object)(object)i.gameObject == (Object)null); } private void EnsureUniqueNames() { EnsureUniqueNamesInList(_externalButtons); EnsureUniqueNamesInList(_externalLabels); EnsureUniqueNamesInList(_externalSliders); EnsureUniqueNamesInList(_externalOptions); EnsureUniqueNamesInList(_externalArrows); EnsureUniqueNamesInList(_externalInputs); } private void EnsureUniqueNamesInList<T>(List<T> list) where T : class { if (list == null) { return; } Dictionary<string, int> dictionary = new Dictionary<string, int>(); List<GameObject> list2 = new List<GameObject>(); foreach (T item in list) { GameObject val = null; if (item is NativeButton nativeButton) { val = nativeButton.gameObject; } else if (item is NativeLabel nativeLabel) { val = nativeLabel.gameObject; } else if (item is NativeSlider nativeSlider) { val = nativeSlider.gameObject; } else if (item is NativeOption nativeOption) { val = nativeOption.gameObject; } else if (item is NativeArrow nativeArrow) { val = nativeArrow.gameObject; } else if (item is NativeInput nativeInput) { val = nativeInput.gameObject; } if ((Object)(object)val != (Object)null) { list2.Add(val); } } foreach (GameObject item2 in list2) { string name = ((Object)item2).name; if (dictionary.ContainsKey(name)) { dictionary[name]++; } else { dictionary[name] = 1; } } Dictionary<string, int> dictionary2 = new Dictionary<string, int>(); foreach (GameObject item3 in list2) { string name2 = ((Object)item3).name; if (dictionary[name2] > 1) { if (!dictionary2.ContainsKey(name2)) { dictionary2[name2] = 1; } else { dictionary2[name2]++; } if (dictionary2[name2] > 1) { string text2 = (((Object)item3).name = $"{name2}_{dictionary2[name2]}"); Debug.Log((object)("[DebugWindow] 为避免重名,已将控件 " + name2 + " 重命名为 " + text2)); } } } } private void SaveConfigToFile() { CleanInvalidControls(); _externalButtons.RemoveAll((NativeButton btn) => NativeArrow.AllInstances.Any((NativeArrow arr) => arr != null && (Object)(object)arr.gameObject == (Object)(object)btn.gameObject)); EnsureUniqueNames(); string text = Path.Combine(PluginDirectory, "NativeUIMaker_Config.json"); ConfigData configData = new ConfigData(); CollectControls(_allButtons, "Button", configData); CollectControls(_allLabels, "Label", configData); CollectControls(_allSliders, "Slider", configData); CollectControls(_allOptions, "Option", configData); CollectControls(_allArrows, "Arrow", configData); CollectControls(_allInputs, "Input", configData); CollectControls(_externalButtons, "Button", configData); CollectControls(_externalLabels, "Label", configData); CollectControls(_externalSliders, "Slider", configData); CollectControls(_externalOptions, "Option", configData); CollectControls(_externalArrows, "Arrow", configData); CollectControls(_externalInputs, "Input", configData); File.WriteAllText(text, JsonConvert.SerializeObject((object)configData, (Formatting)1)); Debug.Log((object)$"配置已保存至 {text},共 {configData.controls.Count} 项"); } private string GetPageNameForControl(GameObject go) { Transform val = go.transform; while ((Object)(object)val != (Object)null) { foreach (NativePage allInstance in NativePage.AllInstances) { if ((Object)(object)allInstance.gameObject == (Object)(object)((Component)val).gameObject) { return ((Object)allInstance.gameObject).name; } } val = val.parent; } return null; } private void CollectControls<T>(List<T> list, string typeName, ConfigData data) where T : class { //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0239: 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_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0287: 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_02f9: Unknown result type (might be due to invalid IL or missing references) //IL_02fe: Unknown result type (might be due to invalid IL or missing references) //IL_0306: Unknown result type (might be due to invalid IL or missing references) //IL_030b: Unknown result type (might be due to invalid IL or missing references) //IL_0386: Unknown result type (might be due to invalid IL or missing references) //IL_038b: 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_0398: Unknown result type (might be due to invalid IL or missing references) //IL_046d: Unknown result type (might be due to invalid IL or missing references) //IL_0472: Unknown result type (might be due to invalid IL or missing references) //IL_047a: Unknown result type (might be due to invalid IL or missing references) //IL_047f: Unknown result type (might be due to invalid IL or missing references) //IL_04e7: Unknown result type (might be due to invalid IL or missing references) //IL_04ec: Unknown result type (might be due to invalid IL or missing references) //IL_04f4: Unknown result type (might be due to invalid IL or missing references) //IL_04f9: Unknown result type (might be due to invalid IL or missing references) //IL_034a: Unknown result type (might be due to invalid IL or missing references) //IL_0343: Unknown result type (might be due to invalid IL or missing references) //IL_0544: Unknown result type (might be due to invalid IL or missing references) //IL_0549: Unknown result type (might be due to invalid IL or missing references) //IL_0556: Unknown result type (might be due to invalid IL or missing references) //IL_055b: Unknown result type (might be due to invalid IL or missing references) //IL_034f: Unknown result type (might be due to invalid IL or missing references) foreach (T item in list) { if (item == null) { continue; } GameObject val = null; try { if (item is NativeButton nativeButton) { val = nativeButton.gameObject; } else if (item is NativeLabel nativeLabel) { val = nativeLabel.gameObject; } else if (item is NativeSlider nativeSlider) { val = nativeSlider.gameObject; } else if (item is NativeOption nativeOption) { val = nativeOption.gameObject; } else if (item is NativeArrow nativeArrow) { val = nativeArrow.gameObject; } else if (item is NativeInput nativeInput) { val = nativeInput.gameObject; } } catch { continue; } if ((Object)(object)val == (Object)null) { continue; } UIControlConfig uIControlConfig = new UIControlConfig(); if (item is NativeArrow) { uIControlConfig.type = "Arrow"; } else if (item is NativeButton) { uIControlConfig.type = "Button"; } else if (item is NativeLabel) { uIControlConfig.type = "Label"; } else if (item is NativeSlider) { uIControlConfig.type = "Slider"; } else if (item is NativeOption) { uIControlConfig.type = "Option"; } else if (item is NativeInput) { uIControlConfig.type = "Input"; } else { uIControlConfig.type = typeName; } uIControlConfig.name = ((Object)val).name; uIControlConfig.page = GetPageNameForControl(val); try { if (item is NativeButton nativeButton2) { uIControlConfig.position = nativeButton2.GetPosition(); uIControlConfig.size = nativeButton2.GetSize(); uIControlConfig.title = nativeButton2.GetTitle(); uIControlConfig.description = nativeButton2.GetDescription(); uIControlConfig.draggable = nativeButton2.IsDraggable(); uIControlConfig.iconOffset = nativeButton2.GetIconOffset(); uIControlConfig.titleOffset = nativeButton2.GetTitleOffset(); uIControlConfig.descOffset = nativeButton2.GetDescOffset(); uIControlConfig.style = (int)nativeButton2.Style; if (nativeButton2.toggleTexts != null && nativeButton2.toggleTexts.Length != 0) { uIControlConfig.toggleTexts = nativeButton2.toggleTexts; uIControlConfig.toggleIndex = nativeButton2.currentToggleIndex; } } else if (item is NativeLabel nativeLabel2) { uIControlConfig.position = nativeLabel2.GetPosition(); uIControlConfig.size = nativeLabel2.GetSize(); uIControlConfig.labelText = nativeLabel2.GetText(); Text textComponent = nativeLabel2.textComponent; uIControlConfig.fontSize = ((textComponent != null) ? textComponent.fontSize : 30); Text textComponent2 = nativeLabel2.textComponent; uIControlConfig.color = ((textComponent2 != null) ? ((Graphic)textComponent2).color : Color.white); uIControlConfig.draggable = nativeLabel2.IsDraggable(); } else if (item is NativeSlider nativeSlider2) { uIControlConfig.position = nativeSlider2.GetPosition(); uIControlConfig.size = nativeSlider2.GetSize(); uIControlConfig.labelText = nativeSlider2.GetLabel(); Slider slider = nativeSlider2.slider; uIControlConfig.minValue = ((slider != null) ? slider.minValue : 0f); Slider slider2 = nativeSlider2.slider; uIControlConfig.maxValue = ((slider2 != null) ? slider2.maxValue : 100f); uIControlConfig.value = nativeSlider2.Value; Slider slider3 = nativeSlider2.slider; uIControlConfig.wholeNumbers = slider3 == null || slider3.wholeNumbers; uIControlConfig.draggable = nativeSlider2.IsDraggable(); uIControlConfig.sliderXOffset = nativeSlider2.GetSliderXOffset(); uIControlConfig.sliderWidth = nativeSlider2.GetSliderWidth(); uIControlConfig.labelXOffset = nativeSlider2.GetLabelXOffset(); uIControlConfig.valueXOffset = nativeSlider2.GetValueXOffset(); } else if (item is NativeOption nativeOption2) { uIControlConfig.position = nativeOption2.GetPosition(); uIControlConfig.size = nativeOption2.GetSize(); uIControlConfig.labelText = nativeOption2.GetLabel(); uIControlConfig.description = nativeOption2.GetDescription(); uIControlConfig.options = nativeOption2.GetOptions(); uIControlConfig.optionIndex = nativeOption2.GetCurrentIndex(); uIControlConfig.draggable = nativeOption2.IsDraggable(); } else if (item is NativeArrow nativeArrow2) { uIControlConfig.position = nativeArrow2.GetPosition(); uIControlConfig.size = nativeArrow2.GetSize(); uIControlConfig.direction = (int)nativeArrow2.GetDirection(); uIControlConfig.clickable = nativeArrow2.IsClickable(); uIControlConfig.draggable = nativeArrow2.IsDraggable(); } else if (item is NativeInput nativeInput2) { uIControlConfig.position = nativeInput2.GetPosition(); uIControlConfig.size = nativeInput2.rectTransform.sizeDelta; uIControlConfig.inputText = nativeInput2.GetText(); Graphic placeholder = nativeInput2.inputField.placeholder; Text val2 = (Text)(object)((placeholder is Text) ? placeholder : null); uIControlConfig.placeholderText = (((Object)(object)val2 != (Object)null) ? val2.text : ""); } } catch (Exception ex) { Debug.LogError((object)("保存控件 " + uIControlConfig.name + " 时出错: " + ex.Message)); continue; } data.controls.Add(uIControlConfig); } } private void LoadConfigFromFile() { //IL_04ab: Unknown result type (might be due to invalid IL or missing references) //IL_0314: Unknown result type (might be due to invalid IL or missing references) //IL_06be: Unknown result type (might be due to invalid IL or missing references) //IL_0662: Unknown result type (might be due to invalid IL or missing references) //IL_0545: Unknown result type (might be due to invalid IL or missing references) //IL_03cc: 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_03f4: Unknown result type (might be due to invalid IL or missing references) //IL_07db: Unknown result type (might be due to invalid IL or missing references) //IL_087e: Unknown result type (might be due to invalid IL or missing references) //IL_0832: Unknown result type (might be due to invalid IL or missing references) //IL_0837: Unknown result type (might be due to invalid IL or missing references) //IL_083d: Expected O, but got Unknown string path = Path.Combine(PluginDirectory, "NativeUIMaker_Config.json"); if (!File.Exists(path)) { return; } ConfigData configData = JsonConvert.DeserializeObject<ConfigData>(File.ReadAllText(path)); if (configData == null) { return; } foreach (UIControlConfig control in configData.controls) { UILocale.TranslateControlConfig(control); } ScanExternalControls(); foreach (UIControlConfig cfg in configData.controls) { object obj = null; if (cfg.type == "Button") { obj = _externalButtons.Find((NativeButton b) => ((Object)b.gameObject).name == cfg.name); } else if (cfg.type == "Label") { obj = _externalLabels.Find((NativeLabel l) => ((Object)l.gameObject).name == cfg.name); } else if (cfg.type == "Slider") { obj = _externalSliders.Find((NativeSlider s) => ((Object)s.gameObject).name == cfg.name); } else if (cfg.type == "Option") { obj = _externalOptions.Find((NativeOption o) => ((Object)o.gameObject).name == cfg.name); } else if (cfg.type == "Arrow") { obj = _externalArrows.Find((NativeArrow a) => ((Object)a.gameObject).name == cfg.name); if (obj == null) { string baseName = Regex.Replace(cfg.name, "_\\d+$", ""); NativeArrow nativeArrow = _externalArrows.Find((NativeArrow a) => ((Object)a.gameObject).name == baseName); if (nativeArrow != null) { ((Object)nativeArrow.gameObject).name = cfg.name; obj = nativeArrow; Debug.Log((object)("[DebugWindow] 箭头名称不匹配,已将 " + baseName + " 重命名为 " + cfg.name)); } } } else if (cfg.type == "Input") { obj = _externalInputs.Find((NativeInput i) => ((Object)i.gameObject).name == cfg.name); } if (obj == null) { continue; } if (obj is NativeButton nativeButton) { if (nativeButton.Style != (ButtonStyle)cfg.style) { nativeButton.SetStyle((ButtonStyle)cfg.style); } nativeButton.SetPosition(cfg.position); nativeButton.SetSize(cfg.size.x, cfg.size.y); if (!string.IsNullOrEmpty(cfg.title)) { nativeButton.SetTitle(cfg.title.Trim()); } if (!string.IsNullOrEmpty(cfg.description)) { nativeButton.SetDescription(cfg.description.Trim()); } nativeButton.SetDraggable(cfg.draggable); nativeButton.SetIconOffset(cfg.iconOffset); nativeButton.SetTitleOffset(cfg.titleOffset); nativeButton.SetDescOffset(cfg.descOffset); if (cfg.toggleTexts != null && cfg.toggleTexts.Length != 0) { nativeButton.SetToggleTexts(cfg.toggleTexts); if (cfg.toggleIndex >= 0 && cfg.toggleIndex < cfg.toggleTexts.Length) { nativeButton.SetToggleIndex(cfg.toggleIndex); } } } else if (obj is NativeLabel nativeLabel) { nativeLabel.SetPosition(cfg.position); nativeLabel.SetSize(cfg.size.x, cfg.size.y); if (!string.IsNullOrEmpty(cfg.labelText)) { nativeLabel.SetText(cfg.labelText.Trim()); } if (cfg.fontSize > 0) { nativeLabel.SetFontSize(cfg.fontSize); } nativeLabel.SetColor(cfg.color); nativeLabel.SetDraggable(cfg.draggable); } else if (obj is NativeSlider nativeSlider) { if (!string.IsNullOrEmpty(cfg.labelText)) {
BepInEx/plugins/Newtonsoft.Json.dll
Decompiled 2 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Collections.Specialized; using System.ComponentModel; using System.Data; using System.Data.SqlTypes; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Dynamic; using System.Globalization; using System.IO; using System.Linq; using System.Linq.Expressions; using System.Numerics; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Runtime.Serialization.Formatters; using System.Runtime.Versioning; using System.Security; using System.Text; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; using System.Xml; using System.Xml.Linq; using Microsoft.CodeAnalysis; using Newtonsoft.Json.Bson; using Newtonsoft.Json.Converters; using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq.JsonPath; using Newtonsoft.Json.Schema; using Newtonsoft.Json.Serialization; using Newtonsoft.Json.Utilities; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AllowPartiallyTrustedCallers] [assembly: InternalsVisibleTo("Newtonsoft.Json.Schema, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f561df277c6c0b497d629032b410cdcf286e537c054724f7ffa0164345f62b3e642029d7a80cc351918955328c4adc8a048823ef90b0cf38ea7db0d729caf2b633c3babe08b0310198c1081995c19029bc675193744eab9d7345b8a67258ec17d112cebdbbb2a281487dceeafb9d83aa930f32103fbe1d2911425bc5744002c7")] [assembly: InternalsVisibleTo("Newtonsoft.Json.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f561df277c6c0b497d629032b410cdcf286e537c054724f7ffa0164345f62b3e642029d7a80cc351918955328c4adc8a048823ef90b0cf38ea7db0d729caf2b633c3babe08b0310198c1081995c19029bc675193744eab9d7345b8a67258ec17d112cebdbbb2a281487dceeafb9d83aa930f32103fbe1d2911425bc5744002c7")] [assembly: InternalsVisibleTo("Newtonsoft.Json.Dynamic, PublicKey=0024000004800000940000000602000000240000525341310004000001000100cbd8d53b9d7de30f1f1278f636ec462cf9c254991291e66ebb157a885638a517887633b898ccbcf0d5c5ff7be85a6abe9e765d0ac7cd33c68dac67e7e64530e8222101109f154ab14a941c490ac155cd1d4fcba0fabb49016b4ef28593b015cab5937da31172f03f67d09edda404b88a60023f062ae71d0b2e4438b74cc11dc9")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("9ca358aa-317b-4925-8ada-4a29e943a363")] [assembly: CLSCompliant(true)] [assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")] [assembly: AssemblyCompany("Newtonsoft")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyCopyright("Copyright © James Newton-King 2008")] [assembly: AssemblyDescription("Json.NET is a popular high-performance JSON framework for .NET")] [assembly: AssemblyFileVersion("13.0.4.30916")] [assembly: AssemblyInformationalVersion("13.0.4+4e13299d4b0ec96bd4df9954ef646bd2d1b5bf2a")] [assembly: AssemblyProduct("Json.NET")] [assembly: AssemblyTitle("Json.NET .NET Standard 2.0")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/JamesNK/Newtonsoft.Json")] [assembly: NeutralResourcesLanguage("en-US")] [assembly: AssemblyVersion("13.0.0.0")] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class IsReadOnlyAttribute : Attribute { } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace System.Diagnostics.CodeAnalysis { [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Interface | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, Inherited = false)] internal sealed class DynamicallyAccessedMembersAttribute : Attribute { public DynamicallyAccessedMemberTypes MemberTypes { get; } public DynamicallyAccessedMembersAttribute(DynamicallyAccessedMemberTypes memberTypes) { MemberTypes = memberTypes; } } [Flags] internal enum DynamicallyAccessedMemberTypes { None = 0, PublicParameterlessConstructor = 1, PublicConstructors = 3, NonPublicConstructors = 4, PublicMethods = 8, NonPublicMethods = 0x10, PublicFields = 0x20, NonPublicFields = 0x40, PublicNestedTypes = 0x80, NonPublicNestedTypes = 0x100, PublicProperties = 0x200, NonPublicProperties = 0x400, PublicEvents = 0x800, NonPublicEvents = 0x1000, Interfaces = 0x2000, All = -1 } [AttributeUsage(AttributeTargets.Property, Inherited = false, AllowMultiple = true)] internal sealed class FeatureGuardAttribute : Attribute { public Type FeatureType { get; } public FeatureGuardAttribute(Type featureType) { FeatureType = featureType; } } [AttributeUsage(AttributeTargets.Property, Inherited = false)] internal sealed class FeatureSwitchDefinitionAttribute : Attribute { public string SwitchName { get; } public FeatureSwitchDefinitionAttribute(string switchName) { SwitchName = switchName; } } [AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple = true)] internal sealed class NotNullAttribute : Attribute { } [AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false)] internal sealed class NotNullWhenAttribute : Attribute { public bool ReturnValue { get; } public NotNullWhenAttribute(bool returnValue) { ReturnValue = returnValue; } } [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, Inherited = false)] internal sealed class MaybeNullAttribute : Attribute { } [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)] internal sealed class AllowNullAttribute : Attribute { } [AttributeUsage(AttributeTargets.Parameter, Inherited = false)] internal class DoesNotReturnIfAttribute : Attribute { public bool ParameterValue { get; } public DoesNotReturnIfAttribute(bool parameterValue) { ParameterValue = parameterValue; } } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Method, Inherited = false)] internal sealed class RequiresDynamicCodeAttribute : Attribute { public string Message { get; } public string? Url { get; set; } public RequiresDynamicCodeAttribute(string message) { Message = message; } } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Method, Inherited = false)] internal sealed class RequiresUnreferencedCodeAttribute : Attribute { public string Message { get; } public string? Url { get; set; } public RequiresUnreferencedCodeAttribute(string message) { Message = message; } } [AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)] internal sealed class UnconditionalSuppressMessageAttribute : Attribute { public string Category { get; } public string CheckId { get; } public string? Scope { get; set; } public string? Target { get; set; } public string? MessageId { get; set; } public string? Justification { get; set; } public UnconditionalSuppressMessageAttribute(string category, string checkId) { Category = category; CheckId = checkId; } } } namespace Newtonsoft.Json { public enum ConstructorHandling { Default, AllowNonPublicDefaultConstructor } public enum DateFormatHandling { IsoDateFormat, MicrosoftDateFormat } public enum DateParseHandling { None, DateTime, DateTimeOffset } public enum DateTimeZoneHandling { Local, Utc, Unspecified, RoundtripKind } public class DefaultJsonNameTable : JsonNameTable { private class Entry { internal readonly string Value; internal readonly int HashCode; internal Entry Next; internal Entry(string value, int hashCode, Entry next) { Value = value; HashCode = hashCode; Next = next; } } private static readonly int HashCodeRandomizer; private int _count; private Entry[] _entries; private int _mask = 31; static DefaultJsonNameTable() { HashCodeRandomizer = Environment.TickCount; } public DefaultJsonNameTable() { _entries = new Entry[_mask + 1]; } public override string? Get(char[] key, int start, int length) { if (length == 0) { return string.Empty; } int num = length + HashCodeRandomizer; num += (num << 7) ^ key[start]; int num2 = start + length; for (int i = start + 1; i < num2; i++) { num += (num << 7) ^ key[i]; } num -= num >> 17; num -= num >> 11; num -= num >> 5; int num3 = Volatile.Read(ref _mask); int num4 = num & num3; for (Entry entry = _entries[num4]; entry != null; entry = entry.Next) { if (entry.HashCode == num && TextEquals(entry.Value, key, start, length)) { return entry.Value; } } return null; } public string Add(string key) { if (key == null) { throw new ArgumentNullException("key"); } int length = key.Length; if (length == 0) { return string.Empty; } int num = length + HashCodeRandomizer; for (int i = 0; i < key.Length; i++) { num += (num << 7) ^ key[i]; } num -= num >> 17; num -= num >> 11; num -= num >> 5; for (Entry entry = _entries[num & _mask]; entry != null; entry = entry.Next) { if (entry.HashCode == num && entry.Value.Equals(key, StringComparison.Ordinal)) { return entry.Value; } } return AddEntry(key, num); } private string AddEntry(string str, int hashCode) { int num = hashCode & _mask; Entry entry = new Entry(str, hashCode, _entries[num]); _entries[num] = entry; if (_count++ == _mask) { Grow(); } return entry.Value; } private void Grow() { Entry[] entries = _entries; int num = _mask * 2 + 1; Entry[] array = new Entry[num + 1]; for (int i = 0; i < entries.Length; i++) { Entry entry = entries[i]; while (entry != null) { int num2 = entry.HashCode & num; Entry next = entry.Next; entry.Next = array[num2]; array[num2] = entry; entry = next; } } _entries = array; Volatile.Write(ref _mask, num); } private static bool TextEquals(string str1, char[] str2, int str2Start, int str2Length) { if (str1.Length != str2Length) { return false; } for (int i = 0; i < str1.Length; i++) { if (str1[i] != str2[str2Start + i]) { return false; } } return true; } } [Flags] public enum DefaultValueHandling { Include = 0, Ignore = 1, Populate = 2, IgnoreAndPopulate = 3 } public enum FloatFormatHandling { String, Symbol, DefaultValue } public enum FloatParseHandling { Double, Decimal } public enum Formatting { None, Indented } public interface IArrayPool<T> { T[] Rent(int minimumLength); void Return(T[]? array); } public interface IJsonLineInfo { int LineNumber { get; } int LinePosition { get; } bool HasLineInfo(); } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = false)] public sealed class JsonArrayAttribute : JsonContainerAttribute { private bool _allowNullItems; public bool AllowNullItems { get { return _allowNullItems; } set { _allowNullItems = value; } } public JsonArrayAttribute() { } public JsonArrayAttribute(bool allowNullItems) { _allowNullItems = allowNullItems; } public JsonArrayAttribute(string id) : base(id) { } } [AttributeUsage(AttributeTargets.Constructor, AllowMultiple = false)] public sealed class JsonConstructorAttribute : Attribute { } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = false)] public abstract class JsonContainerAttribute : Attribute { internal bool? _isReference; internal bool? _itemIsReference; internal ReferenceLoopHandling? _itemReferenceLoopHandling; internal TypeNameHandling? _itemTypeNameHandling; private Type? _namingStrategyType; private object[]? _namingStrategyParameters; public string? Id { get; set; } public string? Title { get; set; } public string? Description { get; set; } public Type? ItemConverterType { get; set; } public object[]? ItemConverterParameters { get; set; } public Type? NamingStrategyType { get { return _namingStrategyType; } set { _namingStrategyType = value; NamingStrategyInstance = null; } } public object[]? NamingStrategyParameters { get { return _namingStrategyParameters; } set { _namingStrategyParameters = value; NamingStrategyInstance = null; } } internal NamingStrategy? NamingStrategyInstance { get; set; } public bool IsReference { get { return _isReference.GetValueOrDefault(); } set { _isReference = value; } } public bool ItemIsReference { get { return _itemIsReference.GetValueOrDefault(); } set { _itemIsReference = value; } } public ReferenceLoopHandling ItemReferenceLoopHandling { get { return _itemReferenceLoopHandling.GetValueOrDefault(); } set { _itemReferenceLoopHandling = value; } } public TypeNameHandling ItemTypeNameHandling { get { return _itemTypeNameHandling.GetValueOrDefault(); } set { _itemTypeNameHandling = value; } } protected JsonContainerAttribute() { } protected JsonContainerAttribute(string id) { Id = id; } } public static class JsonConvert { public static readonly string True = "true"; public static readonly string False = "false"; public static readonly string Null = "null"; public static readonly string Undefined = "undefined"; public static readonly string PositiveInfinity = "Infinity"; public static readonly string NegativeInfinity = "-Infinity"; public static readonly string NaN = "NaN"; public static Func<JsonSerializerSettings>? DefaultSettings { get; set; } public static string ToString(DateTime value) { return ToString(value, DateFormatHandling.IsoDateFormat, DateTimeZoneHandling.RoundtripKind); } public static string ToString(DateTime value, DateFormatHandling format, DateTimeZoneHandling timeZoneHandling) { DateTime value2 = DateTimeUtils.EnsureDateTime(value, timeZoneHandling); using StringWriter stringWriter = StringUtils.CreateStringWriter(64); stringWriter.Write('"'); DateTimeUtils.WriteDateTimeString(stringWriter, value2, format, null, CultureInfo.InvariantCulture); stringWriter.Write('"'); return stringWriter.ToString(); } public static string ToString(DateTimeOffset value) { return ToString(value, DateFormatHandling.IsoDateFormat); } public static string ToString(DateTimeOffset value, DateFormatHandling format) { using StringWriter stringWriter = StringUtils.CreateStringWriter(64); stringWriter.Write('"'); DateTimeUtils.WriteDateTimeOffsetString(stringWriter, value, format, null, CultureInfo.InvariantCulture); stringWriter.Write('"'); return stringWriter.ToString(); } public static string ToString(bool value) { if (!value) { return False; } return True; } public static string ToString(char value) { return ToString(char.ToString(value)); } public static string ToString(Enum value) { return value.ToString("D"); } public static string ToString(int value) { return value.ToString(null, CultureInfo.InvariantCulture); } public static string ToString(short value) { return value.ToString(null, CultureInfo.InvariantCulture); } [CLSCompliant(false)] public static string ToString(ushort value) { return value.ToString(null, CultureInfo.InvariantCulture); } [CLSCompliant(false)] public static string ToString(uint value) { return value.ToString(null, CultureInfo.InvariantCulture); } public static string ToString(long value) { return value.ToString(null, CultureInfo.InvariantCulture); } private static string ToStringInternal(BigInteger value) { return value.ToString(null, CultureInfo.InvariantCulture); } [CLSCompliant(false)] public static string ToString(ulong value) { return value.ToString(null, CultureInfo.InvariantCulture); } public static string ToString(float value) { return EnsureDecimalPlace(value, value.ToString("R", CultureInfo.InvariantCulture)); } internal static string ToString(float value, FloatFormatHandling floatFormatHandling, char quoteChar, bool nullable) { return EnsureFloatFormat(value, EnsureDecimalPlace(value, value.ToString("R", CultureInfo.InvariantCulture)), floatFormatHandling, quoteChar, nullable); } private static string EnsureFloatFormat(double value, string text, FloatFormatHandling floatFormatHandling, char quoteChar, bool nullable) { if (floatFormatHandling == FloatFormatHandling.Symbol || (!double.IsInfinity(value) && !double.IsNaN(value))) { return text; } if (floatFormatHandling == FloatFormatHandling.DefaultValue) { if (nullable) { return Null; } return "0.0"; } return quoteChar + text + quoteChar; } public static string ToString(double value) { return EnsureDecimalPlace(value, value.ToString("R", CultureInfo.InvariantCulture)); } internal static string ToString(double value, FloatFormatHandling floatFormatHandling, char quoteChar, bool nullable) { return EnsureFloatFormat(value, EnsureDecimalPlace(value, value.ToString("R", CultureInfo.InvariantCulture)), floatFormatHandling, quoteChar, nullable); } private static string EnsureDecimalPlace(double value, string text) { if (double.IsNaN(value) || double.IsInfinity(value) || StringUtils.IndexOf(text, '.') != -1 || StringUtils.IndexOf(text, 'E') != -1 || StringUtils.IndexOf(text, 'e') != -1) { return text; } return text + ".0"; } private static string EnsureDecimalPlace(string text) { if (StringUtils.IndexOf(text, '.') != -1) { return text; } return text + ".0"; } public static string ToString(byte value) { return value.ToString(null, CultureInfo.InvariantCulture); } [CLSCompliant(false)] public static string ToString(sbyte value) { return value.ToString(null, CultureInfo.InvariantCulture); } public static string ToString(decimal value) { return EnsureDecimalPlace(value.ToString(null, CultureInfo.InvariantCulture)); } public static string ToString(Guid value) { return ToString(value, '"'); } internal static string ToString(Guid value, char quoteChar) { string text = value.ToString("D", CultureInfo.InvariantCulture); string text2 = quoteChar.ToString(CultureInfo.InvariantCulture); return text2 + text + text2; } public static string ToString(TimeSpan value) { return ToString(value, '"'); } internal static string ToString(TimeSpan value, char quoteChar) { return ToString(value.ToString(), quoteChar); } public static string ToString(Uri? value) { if (value == null) { return Null; } return ToString(value, '"'); } internal static string ToString(Uri value, char quoteChar) { return ToString(value.OriginalString, quoteChar); } public static string ToString(string? value) { return ToString(value, '"'); } public static string ToString(string? value, char delimiter) { return ToString(value, delimiter, StringEscapeHandling.Default); } public static string ToString(string? value, char delimiter, StringEscapeHandling stringEscapeHandling) { if (delimiter != '"' && delimiter != '\'') { throw new ArgumentException("Delimiter must be a single or double quote.", "delimiter"); } return JavaScriptUtils.ToEscapedJavaScriptString(value, delimiter, appendDelimiters: true, stringEscapeHandling); } public static string ToString(object? value) { if (value == null) { return Null; } return ConvertUtils.GetTypeCode(value.GetType()) switch { PrimitiveTypeCode.String => ToString((string)value), PrimitiveTypeCode.Char => ToString((char)value), PrimitiveTypeCode.Boolean => ToString((bool)value), PrimitiveTypeCode.SByte => ToString((sbyte)value), PrimitiveTypeCode.Int16 => ToString((short)value), PrimitiveTypeCode.UInt16 => ToString((ushort)value), PrimitiveTypeCode.Int32 => ToString((int)value), PrimitiveTypeCode.Byte => ToString((byte)value), PrimitiveTypeCode.UInt32 => ToString((uint)value), PrimitiveTypeCode.Int64 => ToString((long)value), PrimitiveTypeCode.UInt64 => ToString((ulong)value), PrimitiveTypeCode.Single => ToString((float)value), PrimitiveTypeCode.Double => ToString((double)value), PrimitiveTypeCode.DateTime => ToString((DateTime)value), PrimitiveTypeCode.Decimal => ToString((decimal)value), PrimitiveTypeCode.DBNull => Null, PrimitiveTypeCode.DateTimeOffset => ToString((DateTimeOffset)value), PrimitiveTypeCode.Guid => ToString((Guid)value), PrimitiveTypeCode.Uri => ToString((Uri)value), PrimitiveTypeCode.TimeSpan => ToString((TimeSpan)value), PrimitiveTypeCode.BigInteger => ToStringInternal((BigInteger)value), _ => throw new ArgumentException("Unsupported type: {0}. Use the JsonSerializer class to get the object's JSON representation.".FormatWith(CultureInfo.InvariantCulture, value.GetType())), }; } [DebuggerStepThrough] [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static string SerializeObject(object? value) { return SerializeObject(value, (Type?)null, (JsonSerializerSettings?)null); } [DebuggerStepThrough] [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static string SerializeObject(object? value, Formatting formatting) { return SerializeObject(value, formatting, (JsonSerializerSettings?)null); } [DebuggerStepThrough] [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static string SerializeObject(object? value, params JsonConverter[] converters) { JsonSerializerSettings settings = ((converters != null && converters.Length != 0) ? new JsonSerializerSettings { Converters = converters } : null); return SerializeObject(value, null, settings); } [DebuggerStepThrough] [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static string SerializeObject(object? value, Formatting formatting, params JsonConverter[] converters) { JsonSerializerSettings settings = ((converters != null && converters.Length != 0) ? new JsonSerializerSettings { Converters = converters } : null); return SerializeObject(value, null, formatting, settings); } [DebuggerStepThrough] [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static string SerializeObject(object? value, JsonSerializerSettings? settings) { return SerializeObject(value, null, settings); } [DebuggerStepThrough] [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static string SerializeObject(object? value, Type? type, JsonSerializerSettings? settings) { JsonSerializer jsonSerializer = JsonSerializer.CreateDefault(settings); return SerializeObjectInternal(value, type, jsonSerializer); } [DebuggerStepThrough] [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static string SerializeObject(object? value, Formatting formatting, JsonSerializerSettings? settings) { return SerializeObject(value, null, formatting, settings); } [DebuggerStepThrough] [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static string SerializeObject(object? value, Type? type, Formatting formatting, JsonSerializerSettings? settings) { JsonSerializer jsonSerializer = JsonSerializer.CreateDefault(settings); jsonSerializer.Formatting = formatting; return SerializeObjectInternal(value, type, jsonSerializer); } [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] private static string SerializeObjectInternal(object? value, Type? type, JsonSerializer jsonSerializer) { StringWriter stringWriter = new StringWriter(new StringBuilder(256), CultureInfo.InvariantCulture); using (JsonTextWriter jsonTextWriter = new JsonTextWriter(stringWriter)) { jsonTextWriter.Formatting = jsonSerializer.Formatting; jsonSerializer.Serialize(jsonTextWriter, value, type); } return stringWriter.ToString(); } [DebuggerStepThrough] [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static object? DeserializeObject(string value) { return DeserializeObject(value, (Type?)null, (JsonSerializerSettings?)null); } [DebuggerStepThrough] [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static object? DeserializeObject(string value, JsonSerializerSettings settings) { return DeserializeObject(value, null, settings); } [DebuggerStepThrough] [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static object? DeserializeObject(string value, Type type) { return DeserializeObject(value, type, (JsonSerializerSettings?)null); } [DebuggerStepThrough] [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static T? DeserializeObject<T>(string value) { return JsonConvert.DeserializeObject<T>(value, (JsonSerializerSettings?)null); } [DebuggerStepThrough] [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static T? DeserializeAnonymousType<T>(string value, T anonymousTypeObject) { return DeserializeObject<T>(value); } [DebuggerStepThrough] [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static T? DeserializeAnonymousType<T>(string value, T anonymousTypeObject, JsonSerializerSettings settings) { return DeserializeObject<T>(value, settings); } [DebuggerStepThrough] [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static T? DeserializeObject<T>(string value, params JsonConverter[] converters) { return (T)DeserializeObject(value, typeof(T), converters); } [DebuggerStepThrough] [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static T? DeserializeObject<T>(string value, JsonSerializerSettings? settings) { return (T)DeserializeObject(value, typeof(T), settings); } [DebuggerStepThrough] [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static object? DeserializeObject(string value, Type type, params JsonConverter[] converters) { JsonSerializerSettings settings = ((converters != null && converters.Length != 0) ? new JsonSerializerSettings { Converters = converters } : null); return DeserializeObject(value, type, settings); } [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static object? DeserializeObject(string value, Type? type, JsonSerializerSettings? settings) { ValidationUtils.ArgumentNotNull(value, "value"); JsonSerializer jsonSerializer = JsonSerializer.CreateDefault(settings); if (!jsonSerializer.IsCheckAdditionalContentSet()) { jsonSerializer.CheckAdditionalContent = true; } using JsonTextReader reader = new JsonTextReader(new StringReader(value)); return jsonSerializer.Deserialize(reader, type); } [DebuggerStepThrough] [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static void PopulateObject(string value, object target) { PopulateObject(value, target, null); } [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static void PopulateObject(string value, object target, JsonSerializerSettings? settings) { JsonSerializer jsonSerializer = JsonSerializer.CreateDefault(settings); using JsonReader jsonReader = new JsonTextReader(new StringReader(value)); jsonSerializer.Populate(jsonReader, target); if (settings == null || !settings.CheckAdditionalContent) { return; } while (jsonReader.Read()) { if (jsonReader.TokenType != JsonToken.Comment) { throw JsonSerializationException.Create(jsonReader, "Additional text found in JSON string after finishing deserializing object."); } } } [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static string SerializeXmlNode(XmlNode? node) { return SerializeXmlNode(node, Formatting.None); } [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static string SerializeXmlNode(XmlNode? node, Formatting formatting) { XmlNodeConverter xmlNodeConverter = new XmlNodeConverter(); return SerializeObject(node, formatting, xmlNodeConverter); } [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static string SerializeXmlNode(XmlNode? node, Formatting formatting, bool omitRootObject) { XmlNodeConverter xmlNodeConverter = new XmlNodeConverter { OmitRootObject = omitRootObject }; return SerializeObject(node, formatting, xmlNodeConverter); } [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static XmlDocument? DeserializeXmlNode(string value) { return DeserializeXmlNode(value, null); } [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static XmlDocument? DeserializeXmlNode(string value, string? deserializeRootElementName) { return DeserializeXmlNode(value, deserializeRootElementName, writeArrayAttribute: false); } [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static XmlDocument? DeserializeXmlNode(string value, string? deserializeRootElementName, bool writeArrayAttribute) { return DeserializeXmlNode(value, deserializeRootElementName, writeArrayAttribute, encodeSpecialCharacters: false); } [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static XmlDocument? DeserializeXmlNode(string value, string? deserializeRootElementName, bool writeArrayAttribute, bool encodeSpecialCharacters) { XmlNodeConverter xmlNodeConverter = new XmlNodeConverter(); xmlNodeConverter.DeserializeRootElementName = deserializeRootElementName; xmlNodeConverter.WriteArrayAttribute = writeArrayAttribute; xmlNodeConverter.EncodeSpecialCharacters = encodeSpecialCharacters; return (XmlDocument)DeserializeObject(value, typeof(XmlDocument), xmlNodeConverter); } [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static string SerializeXNode(XObject? node) { return SerializeXNode(node, Formatting.None); } [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static string SerializeXNode(XObject? node, Formatting formatting) { return SerializeXNode(node, formatting, omitRootObject: false); } [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static string SerializeXNode(XObject? node, Formatting formatting, bool omitRootObject) { XmlNodeConverter xmlNodeConverter = new XmlNodeConverter { OmitRootObject = omitRootObject }; return SerializeObject(node, formatting, xmlNodeConverter); } [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static XDocument? DeserializeXNode(string value) { return DeserializeXNode(value, null); } [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static XDocument? DeserializeXNode(string value, string? deserializeRootElementName) { return DeserializeXNode(value, deserializeRootElementName, writeArrayAttribute: false); } [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static XDocument? DeserializeXNode(string value, string? deserializeRootElementName, bool writeArrayAttribute) { return DeserializeXNode(value, deserializeRootElementName, writeArrayAttribute, encodeSpecialCharacters: false); } [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static XDocument? DeserializeXNode(string value, string? deserializeRootElementName, bool writeArrayAttribute, bool encodeSpecialCharacters) { XmlNodeConverter xmlNodeConverter = new XmlNodeConverter(); xmlNodeConverter.DeserializeRootElementName = deserializeRootElementName; xmlNodeConverter.WriteArrayAttribute = writeArrayAttribute; xmlNodeConverter.EncodeSpecialCharacters = encodeSpecialCharacters; return (XDocument)DeserializeObject(value, typeof(XDocument), xmlNodeConverter); } } public abstract class JsonConverter { public virtual bool CanRead => true; public virtual bool CanWrite => true; public abstract void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer); public abstract object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer); public abstract bool CanConvert(Type objectType); } public abstract class JsonConverter<T> : JsonConverter { public sealed override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer) { if (!((value != null) ? (value is T) : ReflectionUtils.IsNullable(typeof(T)))) { throw new JsonSerializationException("Converter cannot write specified value to JSON. {0} is required.".FormatWith(CultureInfo.InvariantCulture, typeof(T))); } WriteJson(writer, (T)value, serializer); } public abstract void WriteJson(JsonWriter writer, T? value, JsonSerializer serializer); public sealed override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer) { bool flag = existingValue == null; if (!flag && !(existingValue is T)) { throw new JsonSerializationException("Converter cannot read JSON with the specified existing value. {0} is required.".FormatWith(CultureInfo.InvariantCulture, typeof(T))); } return ReadJson(reader, objectType, flag ? default(T) : ((T)existingValue), !flag, serializer); } public abstract T? ReadJson(JsonReader reader, Type objectType, T? existingValue, bool hasExistingValue, JsonSerializer serializer); public sealed override bool CanConvert(Type objectType) { return typeof(T).IsAssignableFrom(objectType); } } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Interface | AttributeTargets.Parameter, AllowMultiple = false)] public sealed class JsonConverterAttribute : Attribute { private readonly Type _converterType; public Type ConverterType => _converterType; public object[]? ConverterParameters { get; } public JsonConverterAttribute(Type converterType) { if (converterType == null) { throw new ArgumentNullException("converterType"); } _converterType = converterType; } public JsonConverterAttribute(Type converterType, params object[] converterParameters) : this(converterType) { ConverterParameters = converterParameters; } } public class JsonConverterCollection : Collection<JsonConverter> { } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = false)] public sealed class JsonDictionaryAttribute : JsonContainerAttribute { public JsonDictionaryAttribute() { } public JsonDictionaryAttribute(string id) : base(id) { } } [Serializable] public class JsonException : Exception { public JsonException() { } public JsonException(string message) : base(message) { } public JsonException(string message, Exception? innerException) : base(message, innerException) { } public JsonException(SerializationInfo info, StreamingContext context) : base(info, context) { } internal static JsonException Create(IJsonLineInfo lineInfo, string path, string message) { message = JsonPosition.FormatMessage(lineInfo, path, message); return new JsonException(message); } } [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)] public class JsonExtensionDataAttribute : Attribute { public bool WriteData { get; set; } public bool ReadData { get; set; } public JsonExtensionDataAttribute() { WriteData = true; ReadData = true; } } [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)] public sealed class JsonIgnoreAttribute : Attribute { } public abstract class JsonNameTable { public abstract string? Get(char[] key, int start, int length); } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface, AllowMultiple = false)] public sealed class JsonObjectAttribute : JsonContainerAttribute { private MemberSerialization _memberSerialization; internal MissingMemberHandling? _missingMemberHandling; internal Required? _itemRequired; internal NullValueHandling? _itemNullValueHandling; public MemberSerialization MemberSerialization { get { return _memberSerialization; } set { _memberSerialization = value; } } public MissingMemberHandling MissingMemberHandling { get { return _missingMemberHandling.GetValueOrDefault(); } set { _missingMemberHandling = value; } } public NullValueHandling ItemNullValueHandling { get { return _itemNullValueHandling.GetValueOrDefault(); } set { _itemNullValueHandling = value; } } public Required ItemRequired { get { return _itemRequired.GetValueOrDefault(); } set { _itemRequired = value; } } public JsonObjectAttribute() { } public JsonObjectAttribute(MemberSerialization memberSerialization) { MemberSerialization = memberSerialization; } public JsonObjectAttribute(string id) : base(id) { } } internal enum JsonContainerType { None, Object, Array, Constructor } internal struct JsonPosition { private static readonly char[] SpecialCharacters = new char[18] { '.', ' ', '\'', '/', '"', '[', ']', '(', ')', '\t', '\n', '\r', '\f', '\b', '\\', '\u0085', '\u2028', '\u2029' }; internal JsonContainerType Type; internal int Position; internal string? PropertyName; internal bool HasIndex; public JsonPosition(JsonContainerType type) { Type = type; HasIndex = TypeHasIndex(type); Position = -1; PropertyName = null; } internal int CalculateLength() { switch (Type) { case JsonContainerType.Object: return PropertyName.Length + 5; case JsonContainerType.Array: case JsonContainerType.Constructor: return MathUtils.IntLength((ulong)Position) + 2; default: throw new ArgumentOutOfRangeException("Type"); } } internal void WriteTo(StringBuilder sb, ref StringWriter? writer, ref char[]? buffer) { switch (Type) { case JsonContainerType.Object: { string propertyName = PropertyName; if (propertyName.IndexOfAny(SpecialCharacters) != -1) { sb.Append("['"); if (writer == null) { writer = new StringWriter(sb); } JavaScriptUtils.WriteEscapedJavaScriptString(writer, propertyName, '\'', appendDelimiters: false, JavaScriptUtils.SingleQuoteCharEscapeFlags, StringEscapeHandling.Default, null, ref buffer); sb.Append("']"); } else { if (sb.Length > 0) { sb.Append('.'); } sb.Append(propertyName); } break; } case JsonContainerType.Array: case JsonContainerType.Constructor: sb.Append('['); sb.Append(Position); sb.Append(']'); break; } } internal static bool TypeHasIndex(JsonContainerType type) { if (type != JsonContainerType.Array) { return type == JsonContainerType.Constructor; } return true; } internal static string BuildPath(List<JsonPosition> positions, JsonPosition? currentPosition) { int num = 0; if (positions != null) { for (int i = 0; i < positions.Count; i++) { num += positions[i].CalculateLength(); } } if (currentPosition.HasValue) { num += currentPosition.GetValueOrDefault().CalculateLength(); } StringBuilder stringBuilder = new StringBuilder(num); StringWriter writer = null; char[] buffer = null; if (positions != null) { foreach (JsonPosition position in positions) { position.WriteTo(stringBuilder, ref writer, ref buffer); } } currentPosition?.WriteTo(stringBuilder, ref writer, ref buffer); return stringBuilder.ToString(); } internal static string FormatMessage(IJsonLineInfo? lineInfo, string path, string message) { if (!message.EndsWith(Environment.NewLine, StringComparison.Ordinal)) { message = message.Trim(); if (!StringUtils.EndsWith(message, '.')) { message += "."; } message += " "; } message += "Path '{0}'".FormatWith(CultureInfo.InvariantCulture, path); if (lineInfo != null && lineInfo.HasLineInfo()) { message += ", line {0}, position {1}".FormatWith(CultureInfo.InvariantCulture, lineInfo.LineNumber, lineInfo.LinePosition); } message += "."; return message; } } [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false)] public sealed class JsonPropertyAttribute : Attribute { internal NullValueHandling? _nullValueHandling; internal DefaultValueHandling? _defaultValueHandling; internal ReferenceLoopHandling? _referenceLoopHandling; internal ObjectCreationHandling? _objectCreationHandling; internal TypeNameHandling? _typeNameHandling; internal bool? _isReference; internal int? _order; internal Required? _required; internal bool? _itemIsReference; internal ReferenceLoopHandling? _itemReferenceLoopHandling; internal TypeNameHandling? _itemTypeNameHandling; public Type? ItemConverterType { get; set; } public object[]? ItemConverterParameters { get; set; } public Type? NamingStrategyType { get; set; } public object[]? NamingStrategyParameters { get; set; } public NullValueHandling NullValueHandling { get { return _nullValueHandling.GetValueOrDefault(); } set { _nullValueHandling = value; } } public DefaultValueHandling DefaultValueHandling { get { return _defaultValueHandling.GetValueOrDefault(); } set { _defaultValueHandling = value; } } public ReferenceLoopHandling ReferenceLoopHandling { get { return _referenceLoopHandling.GetValueOrDefault(); } set { _referenceLoopHandling = value; } } public ObjectCreationHandling ObjectCreationHandling { get { return _objectCreationHandling.GetValueOrDefault(); } set { _objectCreationHandling = value; } } public TypeNameHandling TypeNameHandling { get { return _typeNameHandling.GetValueOrDefault(); } set { _typeNameHandling = value; } } public bool IsReference { get { return _isReference.GetValueOrDefault(); } set { _isReference = value; } } public int Order { get { return _order.GetValueOrDefault(); } set { _order = value; } } public Required Required { get { return _required.GetValueOrDefault(); } set { _required = value; } } public string? PropertyName { get; set; } public ReferenceLoopHandling ItemReferenceLoopHandling { get { return _itemReferenceLoopHandling.GetValueOrDefault(); } set { _itemReferenceLoopHandling = value; } } public TypeNameHandling ItemTypeNameHandling { get { return _itemTypeNameHandling.GetValueOrDefault(); } set { _itemTypeNameHandling = value; } } public bool ItemIsReference { get { return _itemIsReference.GetValueOrDefault(); } set { _itemIsReference = value; } } public JsonPropertyAttribute() { } public JsonPropertyAttribute(string propertyName) { PropertyName = propertyName; } } public abstract class JsonReader : IDisposable { protected internal enum State { Start, Complete, Property, ObjectStart, Object, ArrayStart, Array, Closed, PostValue, ConstructorStart, Constructor, Error, Finished } private JsonToken _tokenType; private object? _value; internal char _quoteChar; internal State _currentState; private JsonPosition _currentPosition; private CultureInfo? _culture; private DateTimeZoneHandling _dateTimeZoneHandling; private int? _maxDepth; private bool _hasExceededMaxDepth; internal DateParseHandling _dateParseHandling; internal FloatParseHandling _floatParseHandling; private string? _dateFormatString; private List<JsonPosition>? _stack; protected State CurrentState => _currentState; public bool CloseInput { get; set; } public bool SupportMultipleContent { get; set; } public virtual char QuoteChar { get { return _quoteChar; } protected internal set { _quoteChar = value; } } public DateTimeZoneHandling DateTimeZoneHandling { get { return _dateTimeZoneHandling; } set { if (value < DateTimeZoneHandling.Local || value > DateTimeZoneHandling.RoundtripKind) { throw new ArgumentOutOfRangeException("value"); } _dateTimeZoneHandling = value; } } public DateParseHandling DateParseHandling { get { return _dateParseHandling; } set { if (value < DateParseHandling.None || value > DateParseHandling.DateTimeOffset) { throw new ArgumentOutOfRangeException("value"); } _dateParseHandling = value; } } public FloatParseHandling FloatParseHandling { get { return _floatParseHandling; } set { if (value < FloatParseHandling.Double || value > FloatParseHandling.Decimal) { throw new ArgumentOutOfRangeException("value"); } _floatParseHandling = value; } } public string? DateFormatString { get { return _dateFormatString; } set { _dateFormatString = value; } } public int? MaxDepth { get { return _maxDepth; } set { if (value <= 0) { throw new ArgumentException("Value must be positive.", "value"); } _maxDepth = value; } } public virtual JsonToken TokenType => _tokenType; public virtual object? Value => _value; public virtual Type? ValueType => _value?.GetType(); public virtual int Depth { get { int num = _stack?.Count ?? 0; if (JsonTokenUtils.IsStartToken(TokenType) || _currentPosition.Type == JsonContainerType.None) { return num; } return num + 1; } } public virtual string Path { get { if (_currentPosition.Type == JsonContainerType.None) { return string.Empty; } JsonPosition? currentPosition = ((_currentState != State.ArrayStart && _currentState != State.ConstructorStart && _currentState != State.ObjectStart) ? new JsonPosition?(_currentPosition) : null); return JsonPosition.BuildPath(_stack, currentPosition); } } public CultureInfo Culture { get { return _culture ?? CultureInfo.InvariantCulture; } set { _culture = value; } } public virtual Task<bool> ReadAsync(CancellationToken cancellationToken = default(CancellationToken)) { return cancellationToken.CancelIfRequestedAsync<bool>() ?? Read().ToAsync(); } public async Task SkipAsync(CancellationToken cancellationToken = default(CancellationToken)) { if (TokenType == JsonToken.PropertyName) { await ReadAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false); } if (JsonTokenUtils.IsStartToken(TokenType)) { int depth = Depth; while (await ReadAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false) && depth < Depth) { } } } internal async Task ReaderReadAndAssertAsync(CancellationToken cancellationToken) { if (!(await ReadAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false))) { throw CreateUnexpectedEndException(); } } public virtual Task<bool?> ReadAsBooleanAsync(CancellationToken cancellationToken = default(CancellationToken)) { return cancellationToken.CancelIfRequestedAsync<bool?>() ?? Task.FromResult(ReadAsBoolean()); } public virtual Task<byte[]?> ReadAsBytesAsync(CancellationToken cancellationToken = default(CancellationToken)) { return cancellationToken.CancelIfRequestedAsync<byte[]>() ?? Task.FromResult(ReadAsBytes()); } internal async Task<byte[]?> ReadArrayIntoByteArrayAsync(CancellationToken cancellationToken) { List<byte> buffer = new List<byte>(); do { if (!(await ReadAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false))) { SetToken(JsonToken.None); } } while (!ReadArrayElementIntoByteArrayReportDone(buffer)); byte[] array = buffer.ToArray(); SetToken(JsonToken.Bytes, array, updateIndex: false); return array; } public virtual Task<DateTime?> ReadAsDateTimeAsync(CancellationToken cancellationToken = default(CancellationToken)) { return cancellationToken.CancelIfRequestedAsync<DateTime?>() ?? Task.FromResult(ReadAsDateTime()); } public virtual Task<DateTimeOffset?> ReadAsDateTimeOffsetAsync(CancellationToken cancellationToken = default(CancellationToken)) { return cancellationToken.CancelIfRequestedAsync<DateTimeOffset?>() ?? Task.FromResult(ReadAsDateTimeOffset()); } public virtual Task<decimal?> ReadAsDecimalAsync(CancellationToken cancellationToken = default(CancellationToken)) { return cancellationToken.CancelIfRequestedAsync<decimal?>() ?? Task.FromResult(ReadAsDecimal()); } public virtual Task<double?> ReadAsDoubleAsync(CancellationToken cancellationToken = default(CancellationToken)) { return Task.FromResult(ReadAsDouble()); } public virtual Task<int?> ReadAsInt32Async(CancellationToken cancellationToken = default(CancellationToken)) { return cancellationToken.CancelIfRequestedAsync<int?>() ?? Task.FromResult(ReadAsInt32()); } public virtual Task<string?> ReadAsStringAsync(CancellationToken cancellationToken = default(CancellationToken)) { return cancellationToken.CancelIfRequestedAsync<string>() ?? Task.FromResult(ReadAsString()); } internal async Task<bool> ReadAndMoveToContentAsync(CancellationToken cancellationToken) { bool flag = await ReadAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false); if (flag) { flag = await MoveToContentAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false); } return flag; } internal Task<bool> MoveToContentAsync(CancellationToken cancellationToken) { JsonToken tokenType = TokenType; if (tokenType == JsonToken.None || tokenType == JsonToken.Comment) { return MoveToContentFromNonContentAsync(cancellationToken); } return AsyncUtils.True; } private async Task<bool> MoveToContentFromNonContentAsync(CancellationToken cancellationToken) { JsonToken tokenType; do { if (!(await ReadAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false))) { return false; } tokenType = TokenType; } while (tokenType == JsonToken.None || tokenType == JsonToken.Comment); return true; } internal JsonPosition GetPosition(int depth) { if (_stack != null && depth < _stack.Count) { return _stack[depth]; } return _currentPosition; } protected JsonReader() { _currentState = State.Start; _dateTimeZoneHandling = DateTimeZoneHandling.RoundtripKind; _dateParseHandling = DateParseHandling.DateTime; _floatParseHandling = FloatParseHandling.Double; _maxDepth = 64; CloseInput = true; } private void Push(JsonContainerType value) { UpdateScopeWithFinishedValue(); if (_currentPosition.Type == JsonContainerType.None) { _currentPosition = new JsonPosition(value); return; } if (_stack == null) { _stack = new List<JsonPosition>(); } _stack.Add(_currentPosition); _currentPosition = new JsonPosition(value); if (!_maxDepth.HasValue || !(Depth + 1 > _maxDepth) || _hasExceededMaxDepth) { return; } _hasExceededMaxDepth = true; throw JsonReaderException.Create(this, "The reader's MaxDepth of {0} has been exceeded.".FormatWith(CultureInfo.InvariantCulture, _maxDepth)); } private JsonContainerType Pop() { JsonPosition currentPosition; if (_stack != null && _stack.Count > 0) { currentPosition = _currentPosition; _currentPosition = _stack[_stack.Count - 1]; _stack.RemoveAt(_stack.Count - 1); } else { currentPosition = _currentPosition; _currentPosition = default(JsonPosition); } if (_maxDepth.HasValue && Depth <= _maxDepth) { _hasExceededMaxDepth = false; } return currentPosition.Type; } private JsonContainerType Peek() { return _currentPosition.Type; } public abstract bool Read(); public virtual int? ReadAsInt32() { JsonToken contentToken = GetContentToken(); switch (contentToken) { case JsonToken.None: case JsonToken.Null: case JsonToken.EndArray: return null; case JsonToken.Integer: case JsonToken.Float: { object value = Value; if (value is int) { return (int)value; } int num; if (value is BigInteger bigInteger) { num = (int)bigInteger; } else { try { num = Convert.ToInt32(value, CultureInfo.InvariantCulture); } catch (Exception ex) { throw JsonReaderException.Create(this, "Could not convert to integer: {0}.".FormatWith(CultureInfo.InvariantCulture, value), ex); } } SetToken(JsonToken.Integer, num, updateIndex: false); return num; } case JsonToken.String: { string s = (string)Value; return ReadInt32String(s); } default: throw JsonReaderException.Create(this, "Error reading integer. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, contentToken)); } } internal int? ReadInt32String(string? s) { if (StringUtils.IsNullOrEmpty(s)) { SetToken(JsonToken.Null, null, updateIndex: false); return null; } if (int.TryParse(s, NumberStyles.Integer, Culture, out var result)) { SetToken(JsonToken.Integer, result, updateIndex: false); return result; } SetToken(JsonToken.String, s, updateIndex: false); throw JsonReaderException.Create(this, "Could not convert string to integer: {0}.".FormatWith(CultureInfo.InvariantCulture, s)); } public virtual string? ReadAsString() { JsonToken contentToken = GetContentToken(); switch (contentToken) { case JsonToken.None: case JsonToken.Null: case JsonToken.EndArray: return null; case JsonToken.String: return (string)Value; default: if (JsonTokenUtils.IsPrimitiveToken(contentToken)) { object value = Value; if (value != null) { string text = ((!(value is IFormattable formattable)) ? ((value is Uri uri) ? uri.OriginalString : value.ToString()) : formattable.ToString(null, Culture)); SetToken(JsonToken.String, text, updateIndex: false); return text; } } throw JsonReaderException.Create(this, "Error reading string. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, contentToken)); } } public virtual byte[]? ReadAsBytes() { JsonToken contentToken = GetContentToken(); switch (contentToken) { case JsonToken.StartObject: { ReadIntoWrappedTypeObject(); byte[] array2 = ReadAsBytes(); ReaderReadAndAssert(); if (TokenType != JsonToken.EndObject) { throw JsonReaderException.Create(this, "Error reading bytes. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, TokenType)); } SetToken(JsonToken.Bytes, array2, updateIndex: false); return array2; } case JsonToken.String: { string text = (string)Value; Guid g; byte[] array3 = ((text.Length == 0) ? CollectionUtils.ArrayEmpty<byte>() : ((!ConvertUtils.TryConvertGuid(text, out g)) ? Convert.FromBase64String(text) : g.ToByteArray())); SetToken(JsonToken.Bytes, array3, updateIndex: false); return array3; } case JsonToken.None: case JsonToken.Null: case JsonToken.EndArray: return null; case JsonToken.Bytes: if (Value is Guid guid) { byte[] array = guid.ToByteArray(); SetToken(JsonToken.Bytes, array, updateIndex: false); return array; } return (byte[])Value; case JsonToken.StartArray: return ReadArrayIntoByteArray(); default: throw JsonReaderException.Create(this, "Error reading bytes. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, contentToken)); } } internal byte[] ReadArrayIntoByteArray() { List<byte> list = new List<byte>(); do { if (!Read()) { SetToken(JsonToken.None); } } while (!ReadArrayElementIntoByteArrayReportDone(list)); byte[] array = list.ToArray(); SetToken(JsonToken.Bytes, array, updateIndex: false); return array; } private bool ReadArrayElementIntoByteArrayReportDone(List<byte> buffer) { switch (TokenType) { case JsonToken.None: throw JsonReaderException.Create(this, "Unexpected end when reading bytes."); case JsonToken.Integer: buffer.Add(Convert.ToByte(Value, CultureInfo.InvariantCulture)); return false; case JsonToken.EndArray: return true; case JsonToken.Comment: return false; default: throw JsonReaderException.Create(this, "Unexpected token when reading bytes: {0}.".FormatWith(CultureInfo.InvariantCulture, TokenType)); } } public virtual double? ReadAsDouble() { JsonToken contentToken = GetContentToken(); switch (contentToken) { case JsonToken.None: case JsonToken.Null: case JsonToken.EndArray: return null; case JsonToken.Integer: case JsonToken.Float: { object value = Value; if (value is double) { return (double)value; } double num = ((!(value is BigInteger bigInteger)) ? Convert.ToDouble(value, CultureInfo.InvariantCulture) : ((double)bigInteger)); SetToken(JsonToken.Float, num, updateIndex: false); return num; } case JsonToken.String: return ReadDoubleString((string)Value); default: throw JsonReaderException.Create(this, "Error reading double. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, contentToken)); } } internal double? ReadDoubleString(string? s) { if (StringUtils.IsNullOrEmpty(s)) { SetToken(JsonToken.Null, null, updateIndex: false); return null; } if (double.TryParse(s, NumberStyles.Float | NumberStyles.AllowThousands, Culture, out var result)) { SetToken(JsonToken.Float, result, updateIndex: false); return result; } SetToken(JsonToken.String, s, updateIndex: false); throw JsonReaderException.Create(this, "Could not convert string to double: {0}.".FormatWith(CultureInfo.InvariantCulture, s)); } public virtual bool? ReadAsBoolean() { JsonToken contentToken = GetContentToken(); switch (contentToken) { case JsonToken.None: case JsonToken.Null: case JsonToken.EndArray: return null; case JsonToken.Integer: case JsonToken.Float: { bool flag = ((!(Value is BigInteger bigInteger)) ? Convert.ToBoolean(Value, CultureInfo.InvariantCulture) : (bigInteger != 0L)); SetToken(JsonToken.Boolean, flag, updateIndex: false); return flag; } case JsonToken.String: return ReadBooleanString((string)Value); case JsonToken.Boolean: return (bool)Value; default: throw JsonReaderException.Create(this, "Error reading boolean. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, contentToken)); } } internal bool? ReadBooleanString(string? s) { if (StringUtils.IsNullOrEmpty(s)) { SetToken(JsonToken.Null, null, updateIndex: false); return null; } if (bool.TryParse(s, out var result)) { SetToken(JsonToken.Boolean, result, updateIndex: false); return result; } SetToken(JsonToken.String, s, updateIndex: false); throw JsonReaderException.Create(this, "Could not convert string to boolean: {0}.".FormatWith(CultureInfo.InvariantCulture, s)); } public virtual decimal? ReadAsDecimal() { JsonToken contentToken = GetContentToken(); switch (contentToken) { case JsonToken.None: case JsonToken.Null: case JsonToken.EndArray: return null; case JsonToken.Integer: case JsonToken.Float: { object value = Value; if (value is decimal) { return (decimal)value; } decimal num; if (value is BigInteger bigInteger) { num = (decimal)bigInteger; } else { try { num = Convert.ToDecimal(value, CultureInfo.InvariantCulture); } catch (Exception ex) { throw JsonReaderException.Create(this, "Could not convert to decimal: {0}.".FormatWith(CultureInfo.InvariantCulture, value), ex); } } SetToken(JsonToken.Float, num, updateIndex: false); return num; } case JsonToken.String: return ReadDecimalString((string)Value); default: throw JsonReaderException.Create(this, "Error reading decimal. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, contentToken)); } } internal decimal? ReadDecimalString(string? s) { if (StringUtils.IsNullOrEmpty(s)) { SetToken(JsonToken.Null, null, updateIndex: false); return null; } if (decimal.TryParse(s, NumberStyles.Number, Culture, out var result)) { SetToken(JsonToken.Float, result, updateIndex: false); return result; } if (ConvertUtils.DecimalTryParse(s.ToCharArray(), 0, s.Length, out result) == ParseResult.Success) { SetToken(JsonToken.Float, result, updateIndex: false); return result; } SetToken(JsonToken.String, s, updateIndex: false); throw JsonReaderException.Create(this, "Could not convert string to decimal: {0}.".FormatWith(CultureInfo.InvariantCulture, s)); } public virtual DateTime? ReadAsDateTime() { switch (GetContentToken()) { case JsonToken.None: case JsonToken.Null: case JsonToken.EndArray: return null; case JsonToken.Date: if (Value is DateTimeOffset dateTimeOffset) { SetToken(JsonToken.Date, dateTimeOffset.DateTime, updateIndex: false); } return (DateTime)Value; case JsonToken.String: return ReadDateTimeString((string)Value); default: throw JsonReaderException.Create(this, "Error reading date. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, TokenType)); } } internal DateTime? ReadDateTimeString(string? s) { if (StringUtils.IsNullOrEmpty(s)) { SetToken(JsonToken.Null, null, updateIndex: false); return null; } if (DateTimeUtils.TryParseDateTime(s, DateTimeZoneHandling, _dateFormatString, Culture, out var dt)) { dt = DateTimeUtils.EnsureDateTime(dt, DateTimeZoneHandling); SetToken(JsonToken.Date, dt, updateIndex: false); return dt; } if (DateTime.TryParse(s, Culture, DateTimeStyles.RoundtripKind, out dt)) { dt = DateTimeUtils.EnsureDateTime(dt, DateTimeZoneHandling); SetToken(JsonToken.Date, dt, updateIndex: false); return dt; } throw JsonReaderException.Create(this, "Could not convert string to DateTime: {0}.".FormatWith(CultureInfo.InvariantCulture, s)); } public virtual DateTimeOffset? ReadAsDateTimeOffset() { JsonToken contentToken = GetContentToken(); switch (contentToken) { case JsonToken.None: case JsonToken.Null: case JsonToken.EndArray: return null; case JsonToken.Date: if (Value is DateTime dateTime) { SetToken(JsonToken.Date, new DateTimeOffset(dateTime), updateIndex: false); } return (DateTimeOffset)Value; case JsonToken.String: { string s = (string)Value; return ReadDateTimeOffsetString(s); } default: throw JsonReaderException.Create(this, "Error reading date. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, contentToken)); } } internal DateTimeOffset? ReadDateTimeOffsetString(string? s) { if (StringUtils.IsNullOrEmpty(s)) { SetToken(JsonToken.Null, null, updateIndex: false); return null; } if (DateTimeUtils.TryParseDateTimeOffset(s, _dateFormatString, Culture, out var dt)) { SetToken(JsonToken.Date, dt, updateIndex: false); return dt; } if (DateTimeOffset.TryParse(s, Culture, DateTimeStyles.RoundtripKind, out dt)) { SetToken(JsonToken.Date, dt, updateIndex: false); return dt; } SetToken(JsonToken.String, s, updateIndex: false); throw JsonReaderException.Create(this, "Could not convert string to DateTimeOffset: {0}.".FormatWith(CultureInfo.InvariantCulture, s)); } internal void ReaderReadAndAssert() { if (!Read()) { throw CreateUnexpectedEndException(); } } internal JsonReaderException CreateUnexpectedEndException() { return JsonReaderException.Create(this, "Unexpected end when reading JSON."); } internal void ReadIntoWrappedTypeObject() { ReaderReadAndAssert(); if (Value != null && Value.ToString() == "$type") { ReaderReadAndAssert(); if (Value != null && Value.ToString().StartsWith("System.Byte[]", StringComparison.Ordinal)) { ReaderReadAndAssert(); if (Value.ToString() == "$value") { return; } } } throw JsonReaderException.Create(this, "Error reading bytes. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, JsonToken.StartObject)); } public void Skip() { if (TokenType == JsonToken.PropertyName) { Read(); } if (JsonTokenUtils.IsStartToken(TokenType)) { int depth = Depth; while (Read() && depth < Depth) { } } } protected void SetToken(JsonToken newToken) { SetToken(newToken, null, updateIndex: true); } protected void SetToken(JsonToken newToken, object? value) { SetToken(newToken, value, updateIndex: true); } protected void SetToken(JsonToken newToken, object? value, bool updateIndex) { _tokenType = newToken; _value = value; switch (newToken) { case JsonToken.StartObject: _currentState = State.ObjectStart; Push(JsonContainerType.Object); break; case JsonToken.StartArray: _currentState = State.ArrayStart; Push(JsonContainerType.Array); break; case JsonToken.StartConstructor: _currentState = State.ConstructorStart; Push(JsonContainerType.Constructor); break; case JsonToken.EndObject: ValidateEnd(JsonToken.EndObject); break; case JsonToken.EndArray: ValidateEnd(JsonToken.EndArray); break; case JsonToken.EndConstructor: ValidateEnd(JsonToken.EndConstructor); break; case JsonToken.PropertyName: _currentState = State.Property; _currentPosition.PropertyName = (string)value; break; case JsonToken.Raw: case JsonToken.Integer: case JsonToken.Float: case JsonToken.String: case JsonToken.Boolean: case JsonToken.Null: case JsonToken.Undefined: case JsonToken.Date: case JsonToken.Bytes: SetPostValueState(updateIndex); break; case JsonToken.Comment: break; } } internal void SetPostValueState(bool updateIndex) { if (Peek() != 0 || SupportMultipleContent) { _currentState = State.PostValue; } else { SetFinished(); } if (updateIndex) { UpdateScopeWithFinishedValue(); } } private void UpdateScopeWithFinishedValue() { if (_currentPosition.HasIndex) { _currentPosition.Position++; } } private void ValidateEnd(JsonToken endToken) { JsonContainerType jsonContainerType = Pop(); if (GetTypeForCloseToken(endToken) != jsonContainerType) { throw JsonReaderException.Create(this, "JsonToken {0} is not valid for closing JsonType {1}.".FormatWith(CultureInfo.InvariantCulture, endToken, jsonContainerType)); } if (Peek() != 0 || SupportMultipleContent) { _currentState = State.PostValue; } else { SetFinished(); } } protected void SetStateBasedOnCurrent() { JsonContainerType jsonContainerType = Peek(); switch (jsonContainerType) { case JsonContainerType.Object: _currentState = State.Object; break; case JsonContainerType.Array: _currentState = State.Array; break; case JsonContainerType.Constructor: _currentState = State.Constructor; break; case JsonContainerType.None: SetFinished(); break; default: throw JsonReaderException.Create(this, "While setting the reader state back to current object an unexpected JsonType was encountered: {0}".FormatWith(CultureInfo.InvariantCulture, jsonContainerType)); } } private void SetFinished() { _currentState = ((!SupportMultipleContent) ? State.Finished : State.Start); } private JsonContainerType GetTypeForCloseToken(JsonToken token) { return token switch { JsonToken.EndObject => JsonContainerType.Object, JsonToken.EndArray => JsonContainerType.Array, JsonToken.EndConstructor => JsonContainerType.Constructor, _ => throw JsonReaderException.Create(this, "Not a valid close JsonToken: {0}".FormatWith(CultureInfo.InvariantCulture, token)), }; } void IDisposable.Dispose() { Dispose(disposing: true); GC.SuppressFinalize(this); } protected virtual void Dispose(bool disposing) { if (_currentState != State.Closed && disposing) { Close(); } } public virtual void Close() { _currentState = State.Closed; _tokenType = JsonToken.None; _value = null; } internal void ReadAndAssert() { if (!Read()) { throw JsonSerializationException.Create(this, "Unexpected end when reading JSON."); } } internal void ReadForTypeAndAssert(JsonContract? contract, bool hasConverter) { if (!ReadForType(contract, hasConverter)) { throw JsonSerializationException.Create(this, "Unexpected end when reading JSON."); } } internal bool ReadForType(JsonContract? contract, bool hasConverter) { if (hasConverter) { return Read(); } switch (contract?.InternalReadType ?? ReadType.Read) { case ReadType.Read: return ReadAndMoveToContent(); case ReadType.ReadAsInt32: ReadAsInt32(); break; case ReadType.ReadAsInt64: { bool result = ReadAndMoveToContent(); if (TokenType == JsonToken.Undefined) { throw JsonReaderException.Create(this, "An undefined token is not a valid {0}.".FormatWith(CultureInfo.InvariantCulture, contract?.UnderlyingType ?? typeof(long))); } return result; } case ReadType.ReadAsDecimal: ReadAsDecimal(); break; case ReadType.ReadAsDouble: ReadAsDouble(); break; case ReadType.ReadAsBytes: ReadAsBytes(); break; case ReadType.ReadAsBoolean: ReadAsBoolean(); break; case ReadType.ReadAsString: ReadAsString(); break; case ReadType.ReadAsDateTime: ReadAsDateTime(); break; case ReadType.ReadAsDateTimeOffset: ReadAsDateTimeOffset(); break; default: throw new ArgumentOutOfRangeException(); } return TokenType != JsonToken.None; } internal bool ReadAndMoveToContent() { if (Read()) { return MoveToContent(); } return false; } internal bool MoveToContent() { JsonToken tokenType = TokenType; while (tokenType == JsonToken.None || tokenType == JsonToken.Comment) { if (!Read()) { return false; } tokenType = TokenType; } return true; } private JsonToken GetContentToken() { JsonToken tokenType; do { if (!Read()) { SetToken(JsonToken.None); return JsonToken.None; } tokenType = TokenType; } while (tokenType == JsonToken.Comment); return tokenType; } } [Serializable] public class JsonReaderException : JsonException { public int LineNumber { get; } public int LinePosition { get; } public string? Path { get; } public JsonReaderException() { } public JsonReaderException(string message) : base(message) { } public JsonReaderException(string message, Exception innerException) : base(message, innerException) { } public JsonReaderException(SerializationInfo info, StreamingContext context) : base(info, context) { } public JsonReaderException(string message, string path, int lineNumber, int linePosition, Exception? innerException) : base(message, innerException) { Path = path; LineNumber = lineNumber; LinePosition = linePosition; } internal static JsonReaderException Create(JsonReader reader, string message) { return Create(reader, message, null); } internal static JsonReaderException Create(JsonReader reader, string message, Exception? ex) { return Create(reader as IJsonLineInfo, reader.Path, message, ex); } internal static JsonReaderException Create(IJsonLineInfo? lineInfo, string path, string message, Exception? ex) { message = JsonPosition.FormatMessage(lineInfo, path, message); int lineNumber; int linePosition; if (lineInfo != null && lineInfo.HasLineInfo()) { lineNumber = lineInfo.LineNumber; linePosition = lineInfo.LinePosition; } else { lineNumber = 0; linePosition = 0; } return new JsonReaderException(message, path, lineNumber, linePosition, ex); } } [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)] public sealed class JsonRequiredAttribute : Attribute { } [Serializable] public class JsonSerializationException : JsonException { public int LineNumber { get; } public int LinePosition { get; } public string? Path { get; } public JsonSerializationException() { } public JsonSerializationException(string message) : base(message) { } public JsonSerializationException(string message, Exception innerException) : base(message, innerException) { } public JsonSerializationException(SerializationInfo info, StreamingContext context) : base(info, context) { } public JsonSerializationException(string message, string path, int lineNumber, int linePosition, Exception? innerException) : base(message, innerException) { Path = path; LineNumber = lineNumber; LinePosition = linePosition; } internal static JsonSerializationException Create(JsonReader reader, string message) { return Create(reader, message, null); } internal static JsonSerializationException Create(JsonReader reader, string message, Exception? ex) { return Create(reader as IJsonLineInfo, reader.Path, message, ex); } internal static JsonSerializationException Create(IJsonLineInfo? lineInfo, string path, string message, Exception? ex) { message = JsonPosition.FormatMessage(lineInfo, path, message); int lineNumber; int linePosition; if (lineInfo != null && lineInfo.HasLineInfo()) { lineNumber = lineInfo.LineNumber; linePosition = lineInfo.LinePosition; } else { lineNumber = 0; linePosition = 0; } return new JsonSerializationException(message, path, lineNumber, linePosition, ex); } } [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public class JsonSerializer { internal TypeNameHandling _typeNameHandling; internal TypeNameAssemblyFormatHandling _typeNameAssemblyFormatHandling; internal PreserveReferencesHandling _preserveReferencesHandling; internal ReferenceLoopHandling _referenceLoopHandling; internal MissingMemberHandling _missingMemberHandling; internal ObjectCreationHandling _objectCreationHandling; internal NullValueHandling _nullValueHandling; internal DefaultValueHandling _defaultValueHandling; internal ConstructorHandling _constructorHandling; internal MetadataPropertyHandling _metadataPropertyHandling; internal JsonConverterCollection? _converters; internal IContractResolver _contractResolver; internal ITraceWriter? _traceWriter; internal IEqualityComparer? _equalityComparer; internal ISerializationBinder _serializationBinder; internal StreamingContext _context; private IReferenceResolver? _referenceResolver; private Formatting? _formatting; private DateFormatHandling? _dateFormatHandling; private DateTimeZoneHandling? _dateTimeZoneHandling; private DateParseHandling? _dateParseHandling; private FloatFormatHandling? _floatFormatHandling; private FloatParseHandling? _floatParseHandling; private StringEscapeHandling? _stringEscapeHandling; private CultureInfo _culture; private int? _maxDepth; private bool _maxDepthSet; private bool? _checkAdditionalContent; private string? _dateFormatString; private bool _dateFormatStringSet; public virtual IReferenceResolver? ReferenceResolver { get { return GetReferenceResolver(); } set { if (value == null) { throw new ArgumentNullException("value", "Reference resolver cannot be null."); } _referenceResolver = value; } } [Obsolete("Binder is obsolete. Use SerializationBinder instead.")] public virtual SerializationBinder Binder { get { if (_serializationBinder is SerializationBinder result) { return result; } if (_serializationBinder is SerializationBinderAdapter serializationBinderAdapter) { return serializationBinderAdapter.SerializationBinder; } throw new InvalidOperationException("Cannot get SerializationBinder because an ISerializationBinder was previously set."); } set { if (value == null) { throw new ArgumentNullException("value", "Serialization binder cannot be null."); } _serializationBinder = (value as ISerializationBinder) ?? new SerializationBinderAdapter(value); } } public virtual ISerializationBinder SerializationBinder { get { return _serializationBinder; } set { if (value == null) { throw new ArgumentNullException("value", "Serialization binder cannot be null."); } _serializationBinder = value; } } public virtual ITraceWriter? TraceWriter { get { return _traceWriter; } set { _traceWriter = value; } } public virtual IEqualityComparer? EqualityComparer { get { return _equalityComparer; } set { _equalityComparer = value; } } public virtual TypeNameHandling TypeNameHandling { get { return _typeNameHandling; } set { if (value < TypeNameHandling.None || value > TypeNameHandling.Auto) { throw new ArgumentOutOfRangeException("value"); } _typeNameHandling = value; } } [Obsolete("TypeNameAssemblyFormat is obsolete. Use TypeNameAssemblyFormatHandling instead.")] public virtual FormatterAssemblyStyle TypeNameAssemblyFormat { get { return (FormatterAssemblyStyle)_typeNameAssemblyFormatHandling; } set { if (value < FormatterAssemblyStyle.Simple || value > FormatterAssemblyStyle.Full) { throw new ArgumentOutOfRangeException("value"); } _typeNameAssemblyFormatHandling = (TypeNameAssemblyFormatHandling)value; } } public virtual TypeNameAssemblyFormatHandling TypeNameAssemblyFormatHandling { get { return _typeNameAssemblyFormatHandling; } set { if (value < TypeNameAssemblyFormatHandling.Simple || value > TypeNameAssemblyFormatHandling.Full) { throw new ArgumentOutOfRangeException("value"); } _typeNameAssemblyFormatHandling = value; } } public virtual PreserveReferencesHandling PreserveReferencesHandling { get { return _preserveReferencesHandling; } set { if (value < PreserveReferencesHandling.None || value > PreserveReferencesHandling.All) { throw new ArgumentOutOfRangeException("value"); } _preserveReferencesHandling = value; } } public virtual ReferenceLoopHandling ReferenceLoopHandling { get { return _referenceLoopHandling; } set { if (value < ReferenceLoopHandling.Error || value > ReferenceLoopHandling.Serialize) { throw new ArgumentOutOfRangeException("value"); } _referenceLoopHandling = value; } } public virtual MissingMemberHandling MissingMemberHandling { get { return _missingMemberHandling; } set { if (value < MissingMemberHandling.Ignore || value > MissingMemberHandling.Error) { throw new ArgumentOutOfRangeException("value"); } _missingMemberHandling = value; } } public virtual NullValueHandling NullValueHandling { get { return _nullValueHandling; } set { if (value < NullValueHandling.Include || value > NullValueHandling.Ignore) { throw new ArgumentOutOfRangeException("value"); } _nullValueHandling = value; } } public virtual DefaultValueHandling DefaultValueHandling { get { return _defaultValueHandling; } set { if (value < DefaultValueHandling.Include || value > DefaultValueHandling.IgnoreAndPopulate) { throw new ArgumentOutOfRangeException("value"); } _defaultValueHandling = value; } } public virtual ObjectCreationHandling ObjectCreationHandling { get { return _objectCreationHandling; } set { if (value < ObjectCreationHandling.Auto || value > ObjectCreationHandling.Replace) { throw new ArgumentOutOfRangeException("value"); } _objectCreationHandling = value; } } public virtual ConstructorHandling ConstructorHandling { get { return _constructorHandling; } set { if (value < ConstructorHandling.Default || value > ConstructorHandling.AllowNonPublicDefaultConstructor) { throw new ArgumentOutOfRangeException("value"); } _constructorHandling = value; } } public virtual MetadataPropertyHandling MetadataPropertyHandling { get { return _metadataPropertyHandling; } set { if (value < MetadataPropertyHandling.Default || value > MetadataPropertyHandling.Ignore) { throw new ArgumentOutOfRangeException("value"); } _metadataPropertyHandling = value; } } public virtual JsonConverterCollection Converters { get { if (_converters == null) { _converters = new JsonConverterCollection(); } return _converters; } } public virtual IContractResolver ContractResolver { get { return _contractResolver; } set { _contractResolver = value ?? DefaultContractResolver.Instance; } } public virtual StreamingContext Context { get { return _context; } set { _context = value; } } public virtual Formatting Formatting { get { return _formatting.GetValueOrDefault(); } set { _formatting = value; } } public virtual DateFormatHandling DateFormatHandling { get { return _dateFormatHandling.GetValueOrDefault(); } set { _dateFormatHandling = value; } } public virtual DateTimeZoneHandling DateTimeZoneHandling { get { return _dateTimeZoneHandling.GetValueOrDefault(DateTimeZoneHandling.RoundtripKind); } set { _dateTimeZoneHandling = value; } } public virtual DateParseHandling DateParseHandling { get { return _dateParseHandling.GetValueOrDefault(DateParseHandling.DateTime); } set { _dateParseHandling = value; } } public virtual FloatParseHandling FloatParseHandling { get { return _floatParseHandling.GetValueOrDefault(); } set { _floatParseHandling = value; } } public virtual FloatFormatHandling FloatFormatHandling { get { return _floatFormatHandling.GetValueOrDefault(); } set { _floatFormatHandling = value; } } public virtual StringEscapeHandling StringEscapeHandling { get { return _stringEscapeHandling.GetValueOrDefault(); } set { _stringEscapeHandling = value; } } public virtual string DateFormatString { get { return _dateFormatString ?? "yyyy'-'MM'-'dd'T'HH':'mm':'ss.FFFFFFFK"; } set { _dateFormatString = value; _dateFormatStringSet = true; } } public virtual CultureInfo Culture { get { return _culture ?? JsonSerializerSettings.DefaultCulture; } set { _culture = value; } } public virtual int? MaxDepth { get { return _maxDepth; } set { if (value <= 0) { throw new ArgumentException("Value must be positive.", "value"); } _maxDepth = value; _maxDepthSet = true; } } public virtual bool CheckAdditionalContent { get { return _checkAdditionalContent.GetValueOrDefault(); } set { _checkAdditionalContent = value; } } public virtual event EventHandler<Newtonsoft.Json.Serialization.ErrorEventArgs>? Error; internal bool IsCheckAdditionalContentSet() { return _checkAdditionalContent.HasValue; } public JsonSerializer() { _referenceLoopHandling = ReferenceLoopHandling.Error; _missingMemberHandling = MissingMemberHandling.Ignore; _nullValueHandling = NullValueHandling.Include; _defaultValueHandling = DefaultValueHandling.Include; _objectCreationHandling = ObjectCreationHandling.Auto; _preserveReferencesHandling = PreserveReferencesHandling.None; _constructorHandling = ConstructorHandling.Default; _typeNameHandling = TypeNameHandling.None; _metadataPropertyHandling = MetadataPropertyHandling.Default; _context = JsonSerializerSettings.DefaultContext; _serializationBinder = DefaultSerializationBinder.Instance; _culture = JsonSerializerSettings.DefaultCulture; _contractResolver = DefaultContractResolver.Instance; } public static JsonSerializer Create() { return new JsonSerializer(); } public static JsonSerializer Create(JsonSerializerSettings? settings) { JsonSerializer jsonSerializer = Create(); if (settings != null) { ApplySerializerSettings(jsonSerializer, settings); } return jsonSerializer; } public static JsonSerializer CreateDefault() { return Create(JsonConvert.DefaultSettings?.Invoke()); } public static JsonSerializer CreateDefault(JsonSerializerSettings? settings) { JsonSerializer jsonSerializer = CreateDefault(); if (settings != null) { ApplySerializerSettings(jsonSerializer, settings); } return jsonSerializer; } private static void ApplySerializerSettings(JsonSerializer serializer, JsonSerializerSettings settings) { if (!CollectionUtils.IsNullOrEmpty(settings.Converters)) { for (int i = 0; i < settings.Converters.Count; i++) { serializer.Converters.Insert(i, settings.Converters[i]); } } if (settings._typeNameHandling.HasValue) { serializer.TypeNameHandling = settings.TypeNameHandling; } if (settings._metadataPropertyHandling.HasValue) { serializer.MetadataPropertyHandling = settings.MetadataPropertyHandling; } if (settings._typeNameAssemblyFormatHandling.HasValue) { serializer.TypeNameAssemblyFormatHandling = settings.TypeNameAssemblyFormatHandling; } if (settings._preserveReferencesHandling.HasValue) { serializer.PreserveReferencesHandling = settings.PreserveReferencesHandling; } if (settings._referenceLoopHandling.HasValue) { serializer.ReferenceLoopHandling = settings.ReferenceLoopHandling; } if (settings._missingMemberHandling.HasValue) { serializer.MissingMemberHandling = settings.MissingMemberHandling; } if (settings._objectCreationHandling.HasValue) { serializer.ObjectCreationHandling = settings.ObjectCreationHandling; } if (settings._nullValueHandling.HasValue) { serializer.NullValueHandling = settings.NullValueHandling; } if (settings._defaultValueHandling.HasValue) { serializer.DefaultValueHandling = settings.DefaultValueHandling; } if (settings._constructorHandling.HasValue) { serializer.ConstructorHandling = settings.ConstructorHandling; } if (settings._context.HasValue) { serializer.Context = settings.Context; } if (settings._checkAdditionalContent.HasValue) { serializer._checkAdditionalContent = settings._checkAdditionalContent; } if (settings.Error != null) { serializer.Error += settings.Error; } if (settings.ContractResolver != null) { serializer.ContractResolver = settings.ContractResolver; } if (settings.ReferenceResolverProvider != null) { serializer.ReferenceResolver = settings.ReferenceResolverProvider(); } if (settings.TraceWriter != null) { serializer.TraceWriter = settings.TraceWriter; } if (settings.EqualityComparer != null) { serializer.EqualityComparer = settings.EqualityComparer; } if (settings.SerializationBinder != null) { serializer.SerializationBinder = settings.SerializationBinder; } if (settings._formatting.HasValue) { serializer._formatting = settings._formatting; } if (settings._dateFormatHandling.HasValue) { serializer._dateFormatHandling = settings._dateFormatHandling; } if (settings._dateTimeZoneHandling.HasValue) { serializer._dateTimeZoneHandling = settings._dateTimeZoneHandling; } if (settings._dateParseHandling.HasValue) { serializer._dateParseHandling = settings._dateParseHandling; } if (settings._dateFormatStringSet) { serializer._dateFormatString = settings._dateFormatString; serializer._dateFormatStringSet = settings._dateFormatStringSet; } if (settings._floatFormatHandling.HasValue) { serializer._floatFormatHandling = settings._floatFormatHandling; } if (settings._floatParseHandling.HasValue) { serializer._floatParseHandling = settings._floatParseHandling; } if (settings._stringEscapeHandling.HasValue) { serializer._stringEscapeHandling = settings._stringEscapeHandling; } if (settings._culture != null) { serializer._culture = settings._culture; } if (settings._maxDepthSet) { serializer._maxDepth = settings._maxDepth; serializer._maxDepthSet = settings._maxDepthSet; } } [DebuggerStepThrough] public void Populate(TextReader reader, object target) { Populate(new JsonTextReader(reader), target); } [DebuggerStepThrough] public void Populate(JsonReader reader, object target) { PopulateInternal(reader, target); } internal virtual void PopulateInternal(JsonReader reader, object target) { ValidationUtils.ArgumentNotNull(reader, "reader"); ValidationUtils.ArgumentNotNull(target, "target"); SetupReader(reader, out CultureInfo previousCulture, out DateTimeZoneHandling? previousDateTimeZoneHandling, out DateParseHandling? previousDateParseHandling, out FloatParseHandling? previousFloatParseHandling, out int? previousMaxDepth, out string previousDateFormatString); TraceJsonReader traceJsonReader = ((TraceWriter != null && TraceWriter.LevelFilter >= TraceLevel.Verbose) ? CreateTraceJsonReader(reader) : null); new JsonSerializerInternalReader(this).Populate(traceJsonReader ?? reader, target); if (traceJsonReader != null) { TraceWriter.Trace(TraceLevel.Verbose, traceJsonReader.GetDeserializedJsonMessage(), null); } ResetReader(reader, previousCulture, previousDateTimeZoneHandling, previousDateParseHandling, previousFloatParseHandling, previousMaxDepth, previousDateFormatString); } [DebuggerStepThrough] public object? Deserialize(JsonReader reader) { return Deserialize(reader, null); } [DebuggerStepThrough] public object? Deserialize(TextReader reader, Type objectType) { return Deserialize(new JsonTextReader(reader), objectType); } [DebuggerStepThrough] public T? Deserialize<T>(JsonReader reader) { return (T)Deserialize(reader, typeof(T)); } [DebuggerStepThrough] public object? Deserialize(JsonReader reader, Type? objectType) { return DeserializeInternal(reader, objectType); } internal virtual object? DeserializeInternal(JsonReader reader, Type? objectType) { ValidationUtils.ArgumentNotNull(reader, "reader"); SetupReader(reader, out CultureInfo previousCulture, out DateTimeZoneHandling? previousDateTimeZoneHandling, out DateParseHandling? previousDateParseHandling, out FloatParseHandling? previousFloatParseHandling, out int? previousMaxDepth, out string previousDateFormatString); TraceJsonReader traceJsonReader = ((TraceWriter != null && TraceWriter.LevelFilter >= TraceLevel.Verbose) ? CreateTraceJsonReader(reader) : null); object? result = new JsonSerializerInternalReader(this).Deserialize(traceJsonReader ?? reader, objectType, CheckAdditionalContent); if (traceJsonReader != null) { TraceWriter.Trace(TraceLevel.Verbose, traceJsonReader.GetDeserializedJsonMessage(), null); } ResetReader(reader, previousCulture, previousDateTimeZoneHandling, previousDateParseHandling, previousFloatParseHandling, previousMaxDepth, previousDateFormatString); return result; } internal void SetupReader(JsonReader reader, out CultureInfo? previousCulture, out DateTimeZoneHandling? previousDateTimeZoneHandling, out DateParseHandling? previousDateParseHandling, out FloatParseHandling? previousFloatParseHandling, out int? previousMaxDepth, out string? previousDateFormatString) { if (_culture != null && !_culture.Equals(reader.Culture)) { previousCulture = reader.Culture; reader.Culture = _culture; } else { previousCulture = null; } if (_dateTimeZoneHandling.HasValue && reader.DateTimeZoneHandling != _dateTimeZoneHandling) { previousDateTimeZoneHandling
BepInEx/plugins/SilksongItemRandomizer.dll
Decompiled 2 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GlobalEnums; using GlobalSettings; using HarmonyLib; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using SilksongItemRandomizer; using StartingAbilityPicker; using TeamCherry.Localization; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyCompany("SilksongItemRandomizer")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("0.1.0.0")] [assembly: AssemblyInformationalVersion("0.1.0")] [assembly: AssemblyProduct("SilksongItemRandomizer")] [assembly: AssemblyTitle("SilksongItemRandomizer")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/YourGitHubUsername/SilksongItemRandomizer")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.1.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.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; } } } public class HotkeyHandler : MonoBehaviour { private GUIStyle _tipStyle; private static bool _isChineseCache; private void Update() { if (Input.GetKeyDown((KeyCode)286)) { TestUnlockEvaHeal(); } if (Input.GetKeyDown((KeyCode)287)) { WarpToLastBench(); } if (Input.GetKeyDown((KeyCode)289)) { ToggleRecentItemsUI(); } if (Input.GetKeyDown((KeyCode)290)) { Plugin.Instance?.DumpAllMappings(); } if (Input.GetKeyDown((KeyCode)27)) { Plugin.Instance?.RefreshBenchwarpUI(); } } private void TestUnlockEvaHeal() { //IL_011f: 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_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) PlayerData instance = PlayerData.instance; if (instance == null) { Plugin.Log.LogError((object)"PlayerData 不可用"); return; } Plugin.Log.LogInfo((object)"=== 开始尝试所有方式解锁 EvaHeal(风铃摇)==="); instance.HasSeenEvaHeal = true; Plugin.Log.LogInfo((object)"1. HasSeenEvaHeal = true"); instance.HasBoundCrestUpgrader = true; Plugin.Log.LogInfo((object)"2. HasBoundCrestUpgrader = true"); instance.CrestUpgraderOfferedFinal = true; instance.CrestPreUpgradeTalked = true; instance.CrestTalkedPurpose = true; instance.CrestUpgraderTalkedSnare = true; Plugin.Log.LogInfo((object)"3. 设置纹章升级相关标志: CrestUpgraderOfferedFinal, CrestPreUpgradeTalked, CrestTalkedPurpose, CrestUpgraderTalkedSnare = true"); instance.chapelClosed_reaper = true; instance.chapelClosed_wanderer = true; instance.chapelClosed_beast = true; instance.chapelClosed_witch = true; instance.chapelClosed_toolmaster = true; instance.chapelClosed_shaman = true; Plugin.Log.LogInfo((object)"4. 设置所有 chapelClosed 标志 = true"); instance.completedMemory_reaper = true; instance.completedMemory_wanderer = true; instance.completedMemory_beast = true; instance.completedMemory_witch = true; instance.completedMemory_toolmaster = true; instance.completedMemory_shaman = true; Plugin.Log.LogInfo((object)"5. 设置所有 completedMemory 标志 = true"); string[] array = new string[3] { "EvaHeal", "Sylphsong", "Slythsong" }; foreach (string text in array) { try { Data data = ((SerializableNamedList<Data, NamedData>)(object)instance.Tools).GetData(text); data.IsUnlocked = true; data.AmountLeft = 1; ((SerializableNamedList<Data, NamedData>)(object)instance.Tools).SetData(text, data); Plugin.Log.LogInfo((object)("6. 已解锁工具 " + text)); } catch (Exception ex) { Plugin.Log.LogWarning((object)("6. 工具 " + text + " 不存在或无法修改: " + ex.Message)); } } try { Data data2 = ((SerializableNamedList<Data, NamedData>)(object)instance.Collectables).GetData("EvaHeal"); data2.Amount = 1; ((SerializableNamedList<Data, NamedData>)(object)instance.Collectables).SetData("EvaHeal", data2); Plugin.Log.LogInfo((object)"7. 已设置 Collectables[EvaHeal].Amount = 1"); } catch (Exception ex2) { Plugin.Log.LogWarning((object)("7. 设置 Collectables 失败: " + ex2.Message)); } try { MethodInfo methodInfo = Type.GetType("AutoSaveManager, Assembly-CSharp")?.GetMethod("Save", new Type[1] { typeof(Enum) }); FieldInfo fieldInfo = Type.GetType("AutoSaveName, Assembly-CSharp")?.GetField("GAINED_SLYTHSONG"); if (methodInfo != null && fieldInfo != null) { methodInfo.Invoke(null, new object[1] { fieldInfo.GetValue(null) }); Plugin.Log.LogInfo((object)"8. 已触发 GAINED_SLYTHSONG 自动存档"); } else { Plugin.Log.LogWarning((object)"8. 未找到 AutoSaveManager.Save 方法或 GAINED_SLYTHSONG 枚举"); } } catch (Exception ex3) { Plugin.Log.LogWarning((object)("8. 触发自动存档失败: " + ex3.Message)); } try { Type type = Type.GetType("InventoryCollectableItemSelectionHelper, Assembly-CSharp"); if (type != null) { PropertyInfo property = type.GetProperty("LastSelectionUpdate", BindingFlags.Static | BindingFlags.Public); if (property != null) { Type nestedType = type.GetNestedType("SelectionType"); if (nestedType != null) { object value = Enum.Parse(nestedType, "EvaHeal"); property.SetValue(null, value); Plugin.Log.LogInfo((object)"9. 已触发 InventoryCollectableItemSelectionHelper.SelectionType.EvaHeal"); } } } } catch (Exception ex4) { Plugin.Log.LogWarning((object)("9. 触发物品栏选择失败: " + ex4.Message)); } try { HeroController instance2 = HeroController.instance; if ((Object)(object)instance2 != (Object)null) { instance2.AddSilk(1, true); Plugin.Log.LogInfo((object)"10. 已添加 1 丝线(测试用)"); } } catch (Exception ex5) { Plugin.Log.LogWarning((object)("10. 添加丝线失败: " + ex5.Message)); } Plugin.Log.LogInfo((object)"=== 解锁尝试完成,请坐椅子并观察丝线是否自动恢复 ==="); Plugin.Log.LogInfo((object)"如果仍未恢复,请将日志提交给开发者分析。"); } private void WarpToLastBench() { try { PlayerData instance = PlayerData.instance; if (instance == null) { Plugin.Log.LogError((object)"[HotkeyHandler] PlayerData 不可用"); return; } string respawnScene = instance.respawnScene; if (string.IsNullOrEmpty(respawnScene)) { Plugin.Log.LogWarning((object)"[HotkeyHandler] 重生点场景为空,请先坐一次椅子"); return; } Plugin.Log.LogInfo((object)("[HotkeyHandler] 传送至重生点: " + respawnScene + " / " + instance.respawnMarkerName)); GameManager gm = GameManager.instance; gm.SaveGame((Action<bool>)delegate(bool success) { if (!success) { Plugin.Log.LogError((object)"[HotkeyHandler] 保存游戏失败"); } else { gm.LoadGameFromUI(gm.profileID); } }); } catch (Exception ex) { Plugin.Log.LogError((object)("[HotkeyHandler] 传送异常: " + ex.Message)); } } private static void ToggleRecentItemsUI() { RecentItemsUI.Toggle(); Plugin.Log.LogInfo((object)("最近获得物品UI " + (RecentItemsUI.IsVisible ? "显示" : "隐藏"))); } private void OnGUI() { //IL_007d: 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_0024: 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_0033: 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) //IL_0048: Expected O, but got Unknown try { if (IsBenchwarpMenuVisible()) { if (_tipStyle == null) { GUIStyle val = new GUIStyle(GUI.skin.label) { fontSize = 48, alignment = (TextAnchor)4 }; val.normal.textColor = Color.red; _tipStyle = val; } string text = Locale.Get("按 F6 可直接传送"); float num = ((float)Screen.width - 600f) / 2f; float num2 = (float)Screen.height * 0.66f; GUI.Label(new Rect(num, num2, 600f, 80f), text, _tipStyle); } } catch { } } private static bool IsBenchwarpMenuVisible() { try { Type type = Type.GetType("Benchwarp.Components.GUIController, Benchwarp"); if (type == null) { GameObject val = GameObject.Find("WarpMenu") ?? GameObject.Find("BenchwarpMenu"); return (Object)(object)val != (Object)null && val.activeInHierarchy; } PropertyInfo property = type.GetProperty("Instance", BindingFlags.Static | BindingFlags.Public); if (property == null) { return false; } object value = property.GetValue(null); if (value != null) { PropertyInfo property2 = type.GetProperty("IsDisplaying"); if (property2 != null && (bool)property2.GetValue(value)) { return true; } } GameObject val2 = GameObject.Find("WarpMenu") ?? GameObject.Find("BenchwarpMenu"); return (Object)(object)val2 != (Object)null && val2.activeInHierarchy; } catch { return false; } } } namespace SilksongItemRandomizer { [HarmonyPatch(typeof(HeroController), "SetBenchRespawn", new Type[] { typeof(RespawnMarker), typeof(string), typeof(int) })] public static class BenchRespawnPatch { public interface IBenchRespawnSaveDataAccessor { string GetLastUnlockedCrest(); } [CompilerGenerated] private sealed class <DelayedReplace>d__7 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public string originalCrestId; public HeroController hero; private string <targetCrest>5__2; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <DelayedReplace>d__7(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <targetCrest>5__2 = null; <>1__state = -2; } private bool MoveNext() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(7f); <>1__state = 1; return true; case 1: { <>1__state = -1; _activeCoroutine = null; <targetCrest>5__2 = _saveData?.GetLastUnlockedCrest() ?? ""; if (string.IsNullOrEmpty(<targetCrest>5__2)) { Plugin.Log.LogInfo((object)"纹章随机总开关关闭或无最后解锁记录,跳过重生替换"); return false; } Plugin.Log.LogInfo((object)("重生强制替换: " + originalCrestId + " -> " + <targetCrest>5__2)); typeof(ToolItemManager).GetMethod("SetEquippedCrest", new Type[1] { typeof(string) })?.Invoke(null, new object[1] { <targetCrest>5__2 }); HeroController obj = hero; if (obj != null) { obj.ResetAllCrestState(); } <>2__current = null; <>1__state = 2; return true; } case 2: <>1__state = -1; ToolItemManager.SendEquippedChangedEvent(true); _lastExecutionTime = Time.time; Plugin.Log.LogInfo((object)("替换完成,当前装备: " + <targetCrest>5__2)); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private static IBenchRespawnSaveDataAccessor _saveData; private static Coroutine _activeCoroutine; private static float _lastExecutionTime; private const float MinInterval = 10f; public static void Initialize(IBenchRespawnSaveDataAccessor accessor) { _saveData = accessor; } [HarmonyPostfix] private static void Postfix(HeroController __instance) { try { if (!((Object)(object)__instance == (Object)null) && PlayerData.instance != null && _activeCoroutine == null && !(Time.time - _lastExecutionTime < 10f)) { string currentCrestID = PlayerData.instance.CurrentCrestID; if (!string.IsNullOrEmpty(currentCrestID)) { Plugin.Log.LogInfo((object)("重生触发: 延迟7秒处理纹章 " + currentCrestID)); _activeCoroutine = ((MonoBehaviour)Plugin.Instance).StartCoroutine(DelayedReplace(currentCrestID, __instance)); } } } catch (Exception arg) { Plugin.Log.LogError((object)$"BenchRespawnPatch异常: {arg}"); } } [IteratorStateMachine(typeof(<DelayedReplace>d__7))] private static IEnumerator DelayedReplace(string originalCrestId, HeroController hero) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <DelayedReplace>d__7(0) { originalCrestId = originalCrestId, hero = hero }; } public static void ResetCooldown() { if (_activeCoroutine != null) { _activeCoroutine = null; } _lastExecutionTime = 0f; } } [HarmonyPatch] public static class BenchwarpTranslator { private static readonly Dictionary<string, string> ChineseMap = new Dictionary<string, string>(); private static bool DetectChinese() { try { Type type = Type.GetType("FontManager, Assembly-CSharp"); if (type != null) { FieldInfo field = type.GetField("_currentLanguage", BindingFlags.Static | BindingFlags.NonPublic); if (field != null) { object value = field.GetValue(null); if (value != null) { string text = value.ToString().ToUpper(); if (text == "ZH" || text == "ZH_TW") { return true; } } } } } catch { } try { GameSettings val = GameManager.instance?.gameSettings; if (val != null) { FieldInfo field2 = ((object)val).GetType().GetField("language", BindingFlags.Instance | BindingFlags.Public); if (field2 != null) { object value2 = field2.GetValue(val); if (value2 != null) { string text2 = value2.ToString().ToUpper(); if (text2 == "ZH" || text2 == "ZH_TW") { return true; } } } } } catch { } return false; } private static MethodBase TargetMethod() { return Type.GetType("Benchwarp.Util.Localization, Benchwarp")?.GetMethod("GetLanguageString", BindingFlags.Static | BindingFlags.Public); } [HarmonyPrefix] private static bool Prefix(string key, ref string __result) { if (DetectChinese() && ChineseMap.TryGetValue(key, out var value)) { __result = value; return false; } return true; } public static void RefreshUI() { GameObject val = GameObject.Find("WarpMenu") ?? GameObject.Find("BenchwarpMenu"); if ((Object)(object)val != (Object)null && val.activeInHierarchy) { val.SetActive(false); val.SetActive(true); Debug.Log((object)"[Benchwarp] UI refreshed."); } } } public interface ICrestSaveDataAccessor { Dictionary<string, string> GetCrestMappings(); void SaveCrestMappings(Dictionary<string, string> mappings); HashSet<string> GetUnlockedCrests(); void SaveUnlockedCrests(HashSet<string> unlockedCrests); string GetLastUnlockedCrest(); void SetLastUnlockedCrest(string crestName); } public static class CrestRandomizer { private static bool _initialized = false; private static List<ToolCrest> _allCrests; private static ICrestSaveDataAccessor _saveData; private static Random _rng; private static int _seed; private static bool _enabled = true; private static bool _temporaryDisable = false; public static readonly HashSet<string> ExcludeFromPool = new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "Hunter", "Hunter_v2", "Hunter_v3", "Witch_v2", "Cursed", "Cloakless" }; public static bool IsEnabled { get { if (_enabled) { return !_temporaryDisable; } return false; } } public static List<ToolCrest> CrestList => _allCrests; public static IReadOnlyDictionary<string, string> CrestMappings => new Dictionary<string, string>(_saveData.GetCrestMappings()); public static IEnumerable<string> UnlockedCrests => _saveData.GetUnlockedCrests().ToList(); public static string LastUnlockedCrest { get { if (!IsEnabled) { return ""; } return _saveData.GetLastUnlockedCrest(); } private set { _saveData.SetLastUnlockedCrest(value); } } public static void Initialize(int seed, bool enabled, ICrestSaveDataAccessor saveDataAccessor) { _seed = seed; _rng = ((seed == 0) ? new Random() : new Random(seed)); _enabled = enabled; _saveData = saveDataAccessor; _allCrests = Resources.FindObjectsOfTypeAll<ToolCrest>().ToList(); EnsureInitialCrests(); _initialized = true; Plugin.Log.LogInfo((object)$"纹章随机初始化完成,已有 {_saveData.GetCrestMappings().Count} 个映射,已解锁 {_saveData.GetUnlockedCrests().Count} 个纹章"); } public static void SetEnabled(bool enabled) { _enabled = enabled; Plugin.Log.LogInfo((object)("纹章随机开关: " + (_enabled ? "启用" : "禁用"))); } public static void DisableRandom() { _temporaryDisable = true; } public static void EnableRandom() { _temporaryDisable = false; } private static void EnsureInitialCrests() { HashSet<string> unlockedCrests = _saveData.GetUnlockedCrests(); if (unlockedCrests.Count == 0) { unlockedCrests.Add("Hunter"); _saveData.SaveUnlockedCrests(unlockedCrests); LastUnlockedCrest = "Hunter"; } foreach (string crestName in unlockedCrests) { ToolCrest val = ((IEnumerable<ToolCrest>)_allCrests).FirstOrDefault((Func<ToolCrest, bool>)((ToolCrest c) => c.name == crestName)); if ((Object)(object)val != (Object)null && !val.IsUnlocked) { UnlockCrestDirectly(val); } } } private static void UnlockCrestDirectly(ToolCrest crest) { //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) //IL_0010: Unknown result type (might be due to invalid IL or missing references) Data saveData = crest.SaveData; saveData.IsUnlocked = true; crest.SaveData = saveData; } public static void AddUnlockedCrest(string crestName) { HashSet<string> unlockedCrests = _saveData.GetUnlockedCrests(); if (unlockedCrests.Add(crestName)) { _saveData.SaveUnlockedCrests(unlockedCrests); ToolCrest val = ((IEnumerable<ToolCrest>)_allCrests).FirstOrDefault((Func<ToolCrest, bool>)((ToolCrest c) => c.name == crestName)); if ((Object)(object)val != (Object)null && !val.IsUnlocked) { UnlockCrestDirectly(val); } LastUnlockedCrest = crestName; Plugin.Log.LogInfo((object)("记录最后解锁纹章: " + LastUnlockedCrest)); } } public static string GetMappedCrestName(string sourceCrestName) { if (!IsEnabled) { return sourceCrestName; } if (_saveData.GetUnlockedCrests().Contains(sourceCrestName)) { return sourceCrestName; } Dictionary<string, string> crestMappings = _saveData.GetCrestMappings(); if (crestMappings.TryGetValue(sourceCrestName, out var value)) { return value; } List<string> list = (from c in _allCrests where !ExcludeFromPool.Contains(c.name) && !c.name.Contains("_v") && c.name != sourceCrestName select c.name).ToList(); string text; if (list.Count == 0) { text = sourceCrestName; } else { Random random = new Random(_seed ^ sourceCrestName.GetHashCode()); text = list[random.Next(list.Count)]; } crestMappings[sourceCrestName] = text; _saveData.SaveCrestMappings(crestMappings); Plugin.Log.LogInfo((object)("新映射: " + sourceCrestName + " -> " + text)); return text; } public static string GetMappedCrestNameForRespawn(string sourceCrestName) { return GetMappedCrestName(sourceCrestName); } public static void ResetMappings() { _saveData.GetCrestMappings().Clear(); _saveData.SaveCrestMappings(new Dictionary<string, string>()); _saveData.GetUnlockedCrests().Clear(); EnsureInitialCrests(); Plugin.Log.LogInfo((object)"纹章映射已重置"); } public static void ResetUnlockedCrests() { _saveData.GetUnlockedCrests().Clear(); EnsureInitialCrests(); Plugin.Log.LogInfo((object)"纹章解锁记录已重置"); } public static string GetSourceCrestByTarget(string targetCrestName) { foreach (KeyValuePair<string, string> crestMapping in _saveData.GetCrestMappings()) { if (crestMapping.Value == targetCrestName) { return crestMapping.Key; } } return null; } } [HarmonyPatch(typeof(ToolCrest), "Unlock")] public static class CrestRandomizePatch { public interface ICrestPatchSaveDataAccessor { HashSet<string> GetDisabledChapels(); void SaveDisabledChapels(HashSet<string> disabledChapels); } private static ICrestPatchSaveDataAccessor _saveData; private static List<ToolCrest> _allCrests; private static readonly HashSet<int> ProcessedInstanceIds = new HashSet<int>(); private static readonly string[] DisableKeywords = new string[23] { "shrine", "crest", "church", "chapel", "door", "gate", "altar", "pedestal", "weaver", "bell", "bind", "orb", "rune", "memory", "statue", "pillar", "candle", "bench", "lever", "switch", "transition", "entrance", "exit" }; public static void Initialize(ICrestPatchSaveDataAccessor accessor) { _saveData = accessor; _allCrests = Resources.FindObjectsOfTypeAll<ToolCrest>().ToList(); } public static void ResetProcessedIds() { ProcessedInstanceIds.Clear(); } public static void ResetPersistentData() { if (_saveData != null) { _saveData.GetDisabledChapels().Clear(); _saveData.SaveDisabledChapels(_saveData.GetDisabledChapels()); } Plugin.Log.LogInfo((object)"已清除教堂禁用持久化数据"); } public static void OnSceneLoaded(Scene scene, LoadSceneMode mode) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (CrestRandomizer.IsEnabled) { DisableChurchObjectsInScene(scene); } } private static void DisableChurchObjectsInScene(Scene scene) { if (_saveData == null || !_saveData.GetDisabledChapels().Contains(((Scene)(ref scene)).name)) { return; } Plugin.Log.LogInfo((object)("禁用场景 '" + ((Scene)(ref scene)).name + "' 中的教堂相关物体")); int num = 0; GameObject[] rootGameObjects = ((Scene)(ref scene)).GetRootGameObjects(); for (int i = 0; i < rootGameObjects.Length; i++) { Transform[] componentsInChildren = rootGameObjects[i].GetComponentsInChildren<Transform>(true); foreach (Transform val in componentsInChildren) { string name = ((Object)((Component)val).gameObject).name.ToLower(); if (DisableKeywords.Any((string kw) => name.Contains(kw))) { Collider2D[] components = ((Component)val).GetComponents<Collider2D>(); for (int k = 0; k < components.Length; k++) { ((Behaviour)components[k]).enabled = false; } Collider[] components2 = ((Component)val).GetComponents<Collider>(); for (int k = 0; k < components2.Length; k++) { components2[k].enabled = false; } PlayMakerFSM[] components3 = ((Component)val).GetComponents<PlayMakerFSM>(); for (int k = 0; k < components3.Length; k++) { ((Behaviour)components3[k]).enabled = false; } Animator[] components4 = ((Component)val).GetComponents<Animator>(); for (int k = 0; k < components4.Length; k++) { ((Behaviour)components4[k]).enabled = false; } Renderer[] components5 = ((Component)val).GetComponents<Renderer>(); for (int k = 0; k < components5.Length; k++) { components5[k].enabled = false; } num++; Plugin.Log.LogInfo((object)(" 已禁用: " + ((Object)((Component)val).gameObject).name)); } } } Plugin.Log.LogInfo((object)$"共禁用 {num} 个物体"); } [HarmonyPrefix] private static bool Prefix(ToolCrest __instance) { //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) if (!CrestRandomizer.IsEnabled) { Plugin.Log.LogInfo((object)("[CrestRandomizePatch] 纹章随机总开关关闭,放行原纹章: " + __instance.name)); return true; } try { int instanceID = ((Object)__instance).GetInstanceID(); if (ProcessedInstanceIds.Contains(instanceID)) { return true; } ProcessedInstanceIds.Add(instanceID); string name = __instance.name; string targetName = CrestRandomizer.GetMappedCrestName(name); if (string.IsNullOrEmpty(targetName) || targetName == name) { Plugin.Log.LogInfo((object)("纹章 " + name + " 映射到自身,放行原解锁")); return true; } if (_allCrests == null || _allCrests.Count == 0) { _allCrests = Resources.FindObjectsOfTypeAll<ToolCrest>().ToList(); } ToolCrest val = ((IEnumerable<ToolCrest>)_allCrests).FirstOrDefault((Func<ToolCrest, bool>)((ToolCrest c) => c.name == targetName)); if ((Object)(object)val == (Object)null) { Plugin.Log.LogWarning((object)("无法找到目标纹章 " + targetName + ",放行原解锁")); return true; } CrestRandomizer.AddUnlockedCrest(targetName); CrestRandomizer.DisableRandom(); val.Unlock(); CrestRandomizer.EnableRandom(); Scene activeScene = SceneManager.GetActiveScene(); string name2 = ((Scene)(ref activeScene)).name; if (name2.Contains("Chapel") && _saveData != null && !_saveData.GetDisabledChapels().Contains(name2)) { _saveData.GetDisabledChapels().Add(name2); _saveData.SaveDisabledChapels(_saveData.GetDisabledChapels()); Plugin.Log.LogInfo((object)("标记教堂场景 '" + name2 + "',下次进入时将禁用所有教堂物体")); } Plugin.Log.LogInfo((object)("纹章替换: " + name + " -> " + targetName)); return false; } catch (Exception arg) { Plugin.Log.LogError((object)$"CrestRandomizePatch异常: {arg}"); return true; } } } [HarmonyPatch(typeof(CurrencyObjectBase), "Collect")] public static class CurrencyCollectPatch { public interface ICurrencySaveDataAccessor { int GetTotalCollectCount(); void SetTotalCollectCount(int count); bool GetFirstKeyGiven(); void SetFirstKeyGiven(bool given); bool GetSecondKeyGiven(); void SetSecondKeyGiven(bool given); int GetFirstThreshold(); void SetFirstThreshold(int threshold); int GetSecondThreshold(); void SetSecondThreshold(int threshold); } private static ICurrencySaveDataAccessor _saveData; private const string KeyName = "Simple Key"; public static void Initialize(ICurrencySaveDataAccessor saveDataAccessor) { _saveData = saveDataAccessor; } public static void ResetCounters() { if (_saveData != null) { _saveData.SetTotalCollectCount(0); _saveData.SetFirstKeyGiven(given: false); _saveData.SetSecondKeyGiven(given: false); } Plugin.Log.LogInfo((object)"货币保底计数器已重置"); } public static void ResetKeyState() { ResetCounters(); } [HarmonyPostfix] private static void Postfix(bool __result) { if (__result && _saveData != null) { int num = _saveData.GetTotalCollectCount() + 1; _saveData.SetTotalCollectCount(num); int firstThreshold = _saveData.GetFirstThreshold(); int secondThreshold = _saveData.GetSecondThreshold(); if (!_saveData.GetFirstKeyGiven() && num >= firstThreshold) { GiveKey(); _saveData.SetFirstKeyGiven(given: true); Plugin.Log.LogInfo((object)$"第一次钥匙保底触发,当前货币收集次数: {num}"); } else if (!_saveData.GetSecondKeyGiven() && num >= secondThreshold) { GiveKey(); _saveData.SetSecondKeyGiven(given: true); Plugin.Log.LogInfo((object)$"第二次钥匙保底触发,当前货币收集次数: {num}"); } } } private static void GiveKey() { SavedItem val = ((IEnumerable<SavedItem>)Resources.FindObjectsOfTypeAll<SavedItem>()).FirstOrDefault((Func<SavedItem, bool>)((SavedItem i) => ((Object)i).name == "Simple Key")); if ((Object)(object)val != (Object)null) { TryGetPatch.BypassRandom = true; try { val.TryGet(false, true); return; } finally { TryGetPatch.BypassRandom = false; } } Plugin.Log.LogError((object)"钥匙保底失败:找不到物品 Simple Key"); } } public static class EnemyRandoAdjuster { private static bool _patched; private static object _originalEnemyRandoType; private static object _originalBossRandoType; private static object _originalMiscRandoType; private static Type _randoTypeEnum; private static Type _settingsType; private static FieldInfo _enemyRandoTypeField; private static FieldInfo _bossRandoTypeField; private static FieldInfo _miscRandoTypeField; private static Type _replacedEnemyType; private static Type _replacementEnemyType; private static FieldInfo _replacementsField; private static bool _enabled; public static bool Enabled { get { return _enabled; } set { if (_enabled != value) { _enabled = value; SetEnemyRandoConfig(value); if (!value) { RestoreAllReplacedEnemies(); } } } } public static bool ScaleRandomEnabled { get; set; } public static float ScaleMin { get; set; } public static float ScaleMax { get; set; } static EnemyRandoAdjuster() { _patched = false; _enabled = true; ScaleRandomEnabled = true; ScaleMin = 0.5f; ScaleMax = 2f; _settingsType = Type.GetType("EnemyRando.Settings, EnemyRando"); if (_settingsType != null) { _enemyRandoTypeField = _settingsType.GetField("EnemyRandoType", BindingFlags.Static | BindingFlags.Public); _bossRandoTypeField = _settingsType.GetField("BossRandoType", BindingFlags.Static | BindingFlags.Public); _miscRandoTypeField = _settingsType.GetField("MiscRandoType", BindingFlags.Static | BindingFlags.Public); _randoTypeEnum = Type.GetType("EnemyRando.Settings+RandoType, EnemyRando"); } _replacedEnemyType = Type.GetType("EnemyRando.ReplacedEnemy, EnemyRando"); _replacementEnemyType = Type.GetType("EnemyRando.ReplacementEnemy, EnemyRando"); if (_replacedEnemyType != null) { _replacementsField = _replacedEnemyType.GetField("replacements", BindingFlags.Instance | BindingFlags.Public); } } public static void TryPatch(Harmony harmony) { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown if (_patched) { return; } Type type = Type.GetType("EnemyRando.Randomiser, EnemyRando"); if (type == null) { Plugin.Log.LogInfo((object)"[EnemyRandoAdjuster] EnemyRando not found, skip patch."); return; } MethodInfo method = type.GetMethod("SpawnRandomEnemy", BindingFlags.Static | BindingFlags.NonPublic); if (method == null) { Plugin.Log.LogWarning((object)"[EnemyRandoAdjuster] SpawnRandomEnemy method not found."); return; } HarmonyMethod val = new HarmonyMethod(typeof(EnemyRandoAdjuster).GetMethod("Prefix", BindingFlags.Static | BindingFlags.NonPublic)); HarmonyMethod val2 = new HarmonyMethod(typeof(EnemyRandoAdjuster).GetMethod("Postfix", BindingFlags.Static | BindingFlags.NonPublic)); harmony.Patch((MethodBase)method, val, val2, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); _patched = true; Plugin.Log.LogInfo((object)"[EnemyRandoAdjuster] Patch applied successfully."); SaveOriginalConfig(); } private static void SaveOriginalConfig() { if (_settingsType == null) { return; } try { if (_enemyRandoTypeField != null) { _originalEnemyRandoType = _enemyRandoTypeField.GetValue(null); } if (_bossRandoTypeField != null) { _originalBossRandoType = _bossRandoTypeField.GetValue(null); } if (_miscRandoTypeField != null) { _originalMiscRandoType = _miscRandoTypeField.GetValue(null); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("保存 EnemyRando 原始配置失败: " + ex.Message)); } } private static void SetEnemyRandoConfig(bool enabled) { if (_settingsType == null || _randoTypeEnum == null) { return; } try { object value = Enum.Parse(_randoTypeEnum, "Disabled"); object obj = Enum.Parse(_randoTypeEnum, "Any"); if (enabled) { _enemyRandoTypeField?.SetValue(null, _originalEnemyRandoType ?? obj); _bossRandoTypeField?.SetValue(null, _originalBossRandoType ?? obj); _miscRandoTypeField?.SetValue(null, _originalMiscRandoType ?? obj); } else { _enemyRandoTypeField?.SetValue(null, value); _bossRandoTypeField?.SetValue(null, value); _miscRandoTypeField?.SetValue(null, value); } Plugin.Log.LogInfo((object)("[EnemyRandoAdjuster] 设置随机配置: " + (enabled ? "开启" : "关闭"))); } catch (Exception arg) { Plugin.Log.LogError((object)$"设置 EnemyRando 配置失败: {arg}"); } } private static void RestoreAllReplacedEnemies() { if (_replacedEnemyType == null) { return; } Object[] array = Resources.FindObjectsOfTypeAll(_replacedEnemyType); foreach (Object val in array) { Object obj = ((val is Component) ? val : null); GameObject val2 = ((obj != null) ? ((Component)obj).gameObject : null); if ((Object)(object)val2 == (Object)null || !(_replacementsField?.GetValue(val) is IList list) || list.Count == 0) { continue; } HealthManager component = val2.GetComponent<HealthManager>(); if ((Object)(object)component == (Object)null) { continue; } val2.SetActive(true); component.isDead = false; foreach (object item in list) { if (item != null) { object obj2 = ((item is Component) ? item : null); Object.Destroy((Object)(object)((obj2 != null) ? ((Component)obj2).gameObject : null)); } } (_replacementsField.GetValue(val) as IList)?.Clear(); Object.Destroy((val is Component) ? val : null); } Plugin.Log.LogInfo((object)"[EnemyRandoAdjuster] 已恢复所有被替换的敌人"); } private static bool Prefix(HealthManager source, int hp) { if (!_enabled) { if (!((Component)source).gameObject.activeSelf) { ((Component)source).gameObject.SetActive(true); } source.hp = hp; if (_replacedEnemyType != null) { Component component = ((Component)source).GetComponent(_replacedEnemyType); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } } Plugin.Log.LogInfo((object)$"[EnemyRandoAdjuster] Disabled, restored {((Object)source).name} hp to {hp}"); return false; } return true; } private static void Postfix(bool __result, HealthManager source, int hp) { //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: 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) if (!_enabled || !__result || (Object)(object)source == (Object)null || _replacedEnemyType == null) { return; } Component component = ((Component)source).GetComponent(_replacedEnemyType); if ((Object)(object)component == (Object)null || _replacementsField == null || !(_replacementsField.GetValue(component) is IList list) || list.Count == 0) { return; } foreach (object item in list) { object obj = ((item is Component) ? item : null); HealthManager val = ((obj != null) ? ((Component)obj).GetComponent<HealthManager>() : null); if (!((Object)(object)val == (Object)null)) { val.hp = hp; if (ScaleRandomEnabled && Random.value < 0.2f) { float num = 1f - Mathf.Sin(Random.value * (float)Math.PI); float num2 = ScaleMin + (ScaleMax - ScaleMin) * num; ((Component)val).transform.localScale = Vector3.Scale(((Component)val).transform.localScale, new Vector3(num2, num2, num2)); } } } } } [HarmonyPatch] public static class Extracurrencypickup { public interface IExtraPickupSaveDataAccessor { HashSet<string> GetPickedPositions(); void SavePickedPositions(HashSet<string> positions); } [CompilerGenerated] private sealed class <DelayedSpawn>d__9 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public Vector3 position; public string itemId; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <DelayedSpawn>d__9(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(0.2f); <>1__state = 1; return true; case 1: <>1__state = -1; SpawnPickupAt(position, itemId); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private static IExtraPickupSaveDataAccessor _saveData; private static bool _isInitialized = false; private static readonly Dictionary<string, List<(Vector3 pos, string itemId)>> pickupTable = new Dictionary<string, List<(Vector3, string)>> { ["Tut_01"] = new List<(Vector3, string)> { (new Vector3(26f, 77f, 0f), "Simple Key") }, ["Bonetown"] = new List<(Vector3, string)> { (new Vector3(224f, 80f, 0f), "Simple Key"), (new Vector3(151f, 69f, 0f), "Simple Key") }, ["Bone_01c"] = new List<(Vector3, string)> { (new Vector3(176f, 58f, 0f), "Simple Key"), (new Vector3(139f, 7.5f, 0f), "Simple Key") }, ["Bone_01"] = new List<(Vector3, string)> { (new Vector3(118f, 7.5f, 0f), "Simple Key") }, ["Bone_04"] = new List<(Vector3, string)> { (new Vector3(204f, 5.5f, 0f), "Simple Key") }, ["Mosstown_01"] = new List<(Vector3, string)> { (new Vector3(48f, 23.5f, 0f), "Simple Key") }, ["Mosstown_02"] = new List<(Vector3, string)> { (new Vector3(154f, 55.5f, 0f), "Simple Key") }, ["Bone_14"] = new List<(Vector3, string)> { (new Vector3(129f, 8.5f, 0f), "Simple Key") }, ["Bone_19"] = new List<(Vector3, string)> { (new Vector3(28f, 13.5f, 0f), "Simple Key") }, ["Belltown_basement_03"] = new List<(Vector3, string)> { (new Vector3(65.5f, 5.5f, 0f), "Simple Key"), (new Vector3(71f, 116.5f, 0f), "Simple Key") }, ["Bone_08"] = new List<(Vector3, string)> { (new Vector3(30.5f, 47.5f, 0f), "Simple Key") }, ["Bone_09"] = new List<(Vector3, string)> { (new Vector3(6.5f, 36.5f, 0f), "Simple Key") }, ["Bone_East_03"] = new List<(Vector3, string)> { (new Vector3(153f, 22.5f, 0f), "Simple Key") }, ["Ant_04_left"] = new List<(Vector3, string)> { (new Vector3(7f, 29f, 0f), "Simple Key") }, ["Ant_21"] = new List<(Vector3, string)> { (new Vector3(48.5f, 74f, 0f), "Simple Key") }, ["Dock_06_Church"] = new List<(Vector3, string)> { (new Vector3(11f, 21.5f, 0f), "Simple Key") }, ["Bone_10"] = new List<(Vector3, string)> { (new Vector3(8f, 43.5f, 0f), "Simple Key"), (new Vector3(112.5f, 66.5f, 0f), "Simple Key"), (new Vector3(30f, 45.5f, 0f), "Simple Key") }, ["Bone_11"] = new List<(Vector3, string)> { (new Vector3(8f, 9.5f, 0f), "Simple Key") }, ["Aspid_01"] = new List<(Vector3, string)> { (new Vector3(10.5f, 7.5f, 0f), "Simple Key") }, ["Bonegrave"] = new List<(Vector3, string)> { (new Vector3(270.5f, 72.5f, 0f), "Simple Key") }, ["Chapel_Wanderer"] = new List<(Vector3, string)> { (new Vector3(79.5f, 106.4f, 0f), "Simple Key") }, ["Shellwood_26"] = new List<(Vector3, string)> { (new Vector3(98.5f, 75.5f, 0f), "Simple Key") }, ["Belltown_04"] = new List<(Vector3, string)> { (new Vector3(77f, 48.5f, 0f), "Simple Key"), (new Vector3(63f, 19.5f, 0f), "Simple Key") }, ["Bone_East_17"] = new List<(Vector3, string)> { (new Vector3(7f, 84.5f, 0f), "Simple Key"), (new Vector3(42f, 96.5f, 0f), "Simple Key") }, ["Bone_East_17b"] = new List<(Vector3, string)> { (new Vector3(12f, 31.5f, 0f), "Simple Key") }, ["Bone_East_16"] = new List<(Vector3, string)> { (new Vector3(11f, 16.5f, 0f), "Simple Key") }, ["Bone_East_08"] = new List<(Vector3, string)> { (new Vector3(59f, 21.5f, 0f), "Simple Key") }, ["Bone_East_14"] = new List<(Vector3, string)> { (new Vector3(88f, 40.5f, 0f), "Simple Key") }, ["Bone_East_14b"] = new List<(Vector3, string)> { (new Vector3(250f, 52.5f, 0f), "Simple Key") }, ["Bone_East_07"] = new List<(Vector3, string)> { (new Vector3(10f, 165.5f, 0f), "Simple Key") }, ["Bone_East_09b"] = new List<(Vector3, string)> { (new Vector3(61f, 141.5f, 0f), "Simple Key") }, ["Greymoor_15"] = new List<(Vector3, string)> { (new Vector3(57.3f, 74.5f, 0f), "Simple Key") }, ["Greymoor_15b"] = new List<(Vector3, string)> { (new Vector3(205f, 61.5f, 0f), "Simple Key"), (new Vector3(198f, 41.5f, 0f), "Simple Key") }, ["Greymoor_22"] = new List<(Vector3, string)> { (new Vector3(88f, 25.5f, 0f), "Simple Key") }, ["Greymoor_02"] = new List<(Vector3, string)> { (new Vector3(52f, 90.5f, 0f), "Simple Key") }, ["Greymoor_01"] = new List<(Vector3, string)> { (new Vector3(8.61f, 17.5f, 0f), "Simple Key") }, ["Greymoor_04"] = new List<(Vector3, string)> { (new Vector3(32f, 36.5f, 0f), "Simple Key") }, ["Greymoor_05"] = new List<(Vector3, string)> { (new Vector3(95f, 62.5f, 0f), "Simple Key"), (new Vector3(7f, 19f, 0f), "Simple Key") }, ["Greymoor_06"] = new List<(Vector3, string)> { (new Vector3(6f, 79.5f, 0f), "Simple Key") }, ["Greymoor_07"] = new List<(Vector3, string)> { (new Vector3(28f, 10.5f, 0f), "Simple Key") }, ["Greymoor_08"] = new List<(Vector3, string)> { (new Vector3(140f, 30.5f, 0f), "Simple Key") }, ["Shellwood_11"] = new List<(Vector3, string)> { (new Vector3(59f, 21.5f, 0f), "Simple Key") }, ["Coral_12"] = new List<(Vector3, string)> { (new Vector3(87f, 34.5f, 0f), "Simple Key") }, ["Song_01"] = new List<(Vector3, string)> { (new Vector3(19.5f, 80.5f, 0f), "Simple Key"), (new Vector3(109f, 129.5f, 0f), "Simple Key") }, ["Song_11"] = new List<(Vector3, string)> { (new Vector3(44f, 44.5f, 0f), "Simple Key") }, ["Song_03"] = new List<(Vector3, string)> { (new Vector3(130f, 4.5f, 0f), "Simple Key") }, ["Song_15"] = new List<(Vector3, string)> { (new Vector3(6.5f, 6.5f, 0f), "Simple Key") }, ["Song_17"] = new List<(Vector3, string)> { (new Vector3(34.5f, 100.5f, 0f), "Simple Key") }, ["Hang_08"] = new List<(Vector3, string)> { (new Vector3(19.5f, 195f, 0f), "Simple Key") }, ["Library_04"] = new List<(Vector3, string)> { (new Vector3(51f, 77f, 0f), "Simple Key") }, ["Library_06"] = new List<(Vector3, string)> { (new Vector3(36.5f, 63f, 0f), "Simple Key") }, ["Library_07"] = new List<(Vector3, string)> { (new Vector3(39f, 139.5f, 0f), "Simple Key") }, ["Dock_02"] = new List<(Vector3, string)> { (new Vector3(103f, 51.5f, 0f), "Simple Key") }, ["Bone_East_24"] = new List<(Vector3, string)> { (new Vector3(246f, 65.5f, 0f), "Simple Key") }, ["Bone_East_18"] = new List<(Vector3, string)> { (new Vector3(139f, 36.5f, 0f), "Simple Key") }, ["Bone_East_18b"] = new List<(Vector3, string)> { (new Vector3(133f, 6.5f, 0f), "Simple Key") }, ["Bone_01b"] = new List<(Vector3, string)> { (new Vector3(7f, 85.5f, 0f), "Simple Key") }, ["Bone_East_15"] = new List<(Vector3, string)> { (new Vector3(47f, 8.5f, 0f), "Simple Key") }, ["Song_09"] = new List<(Vector3, string)> { (new Vector3(11f, 56.5f, 0f), "Simple Key") } }; public static void Initialize(IExtraPickupSaveDataAccessor saveDataAccessor) { _saveData = saveDataAccessor; _isInitialized = true; Plugin.Log.LogInfo((object)"[Extracurrencypickup] 初始化完成"); } public static void RegisterAll() { Plugin.Log.LogInfo((object)"[Extracurrencypickup] 已注册 Harmony 补丁(由 API 管理)"); } public static void ResetAll() { if (_saveData != null) { _saveData.GetPickedPositions().Clear(); } Plugin.SaveGlobalData(); Plugin.Log.LogInfo((object)"[Extracurrencypickup] 所有坐标记录已重置"); } private static bool IsPositionPicked(string sceneName, Vector3 pos, float tolerance = 2f) { //IL_00a6: 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_00da: 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) if (_saveData == null) { return false; } foreach (string pickedPosition in _saveData.GetPickedPositions()) { if (!pickedPosition.StartsWith(sceneName + "_")) { continue; } string text = pickedPosition.Substring(sceneName.Length + 1); int num = text.IndexOf('_'); if (num >= 0) { string s = text.Substring(0, num); string text2 = text.Substring(num + 1); int num2 = text2.IndexOf('_'); string s2 = ((num2 >= 0) ? text2.Substring(0, num2) : text2); if (float.TryParse(s, out var result) && float.TryParse(s2, out var result2) && Mathf.Abs(pos.x - result) <= tolerance && Mathf.Abs(pos.y - result2) <= tolerance) { Plugin.Log.LogInfo((object)$"[Extracurrencypickup] 坐标 ({pos.x:F2},{pos.y:F2}) 匹配已记录 ({result:F2},{result2:F2}),跳过生成"); return true; } } } return false; } public static void SpawnPickupsForScene(Scene scene) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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_005e: Unknown result type (might be due to invalid IL or missing references) if (!SilksongItemRandomizerAPI.IsEnabled()) { return; } string name = ((Scene)(ref scene)).name; if (!pickupTable.TryGetValue(name, out List<(Vector3, string)> value)) { return; } foreach (var (val, itemId) in value) { if (!IsPositionPicked(name, val) && (Object)(object)Plugin.Instance != (Object)null) { ((MonoBehaviour)Plugin.Instance).StartCoroutine(DelayedSpawn(val, itemId)); } } } [IteratorStateMachine(typeof(<DelayedSpawn>d__9))] private static IEnumerator DelayedSpawn(Vector3 position, string itemId) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <DelayedSpawn>d__9(0) { position = position, itemId = itemId }; } private static void SpawnPickupAt(Vector3 position, string itemId) { //IL_006a: 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_0118: Unknown result type (might be due to invalid IL or missing references) CollectableItemPickup val = Gameplay.CollectableItemPickupPrefab; if ((Object)(object)val == (Object)null) { CollectableItemPickup val2 = ((IEnumerable<CollectableItemPickup>)Resources.FindObjectsOfTypeAll<CollectableItemPickup>()).FirstOrDefault((Func<CollectableItemPickup, bool>)delegate(CollectableItemPickup p) { //IL_0006: 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) Scene scene = ((Component)p).gameObject.scene; return ((Scene)(ref scene)).isLoaded; }); if ((Object)(object)val2 == (Object)null) { Plugin.Log.LogError((object)"[Extracurrencypickup] No pickup prefab found."); return; } val = val2; } GameObject val3 = Object.Instantiate<GameObject>(((Component)val).gameObject, position, Quaternion.identity); CollectableItemPickup component = val3.GetComponent<CollectableItemPickup>(); if ((Object)(object)component == (Object)null) { Plugin.Log.LogError((object)"[Extracurrencypickup] Instantiated object has no CollectableItemPickup."); Object.Destroy((Object)(object)val3); return; } SavedItem val4 = ((IEnumerable<SavedItem>)Resources.FindObjectsOfTypeAll<SavedItem>()).FirstOrDefault((Func<SavedItem, bool>)((SavedItem i) => ((Object)i).name == itemId)); if ((Object)(object)val4 == (Object)null) { Plugin.Log.LogError((object)("[Extracurrencypickup] Item '" + itemId + "' not found.")); Object.Destroy((Object)(object)val3); return; } component.SetItem(val4, false); PersistentBoolItem component2 = ((Component)component).GetComponent<PersistentBoolItem>(); if ((Object)(object)component2 != (Object)null) { ((Behaviour)component2).enabled = false; } val3.SetActive(true); Plugin.Log.LogInfo((object)$"[Extracurrencypickup] Spawned pickup at {position}, item {itemId}"); } [HarmonyPatch(typeof(SavedItem), "TryGet")] [HarmonyPostfix] public static void OnItemTryGet(SavedItem __instance, bool __result) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0053: 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) if (!__result || _saveData == null) { return; } HeroController instance = HeroController.instance; if (!((Object)(object)instance == (Object)null)) { Scene activeScene = SceneManager.GetActiveScene(); Vector3 position = ((Component)instance).transform.position; string text = $"{((Scene)(ref activeScene)).name}_{position.x:F2}_{position.y:F2}_{position.z:F2}"; if (_saveData.GetPickedPositions().Add(text)) { _saveData.SavePickedPositions(_saveData.GetPickedPositions()); Plugin.Log.LogInfo((object)("[Extracurrencypickup] 记录物品获得坐标: " + text)); } } } } [Serializable] public class GlobalSaveData { public int Version = 2; public Dictionary<string, string> CrestMappings = new Dictionary<string, string>(); public HashSet<string> UnlockedCrests = new HashSet<string>(); public string LastUnlockedCrest = ""; public HashSet<string> DisabledChapels = new HashSet<string>(); public HashSet<string> PickedPositions = new HashSet<string>(); public HashSet<string> PickedPickupKeys = new HashSet<string>(); public int CurrencyTotalCollectCount; public bool CurrencyFirstKeyGiven; public bool CurrencySecondKeyGiven; public int CurrencyFirstThreshold = 30; public int CurrencySecondThreshold = 1000; public Dictionary<string, int> ShopSlotCounts = new Dictionary<string, int>(); public Dictionary<string, int> ItemGivenCounts = new Dictionary<string, int>(); public Dictionary<string, string> TotalMappings = new Dictionary<string, string>(); public float VirtualUnlimitedProbability = 0.1f; public float CrestUnlockerProbability = 0.1f; public float NormalLimitedProbability = 0.8f; public int MaxGivenPerItem = 2; public HashSet<string> DestroyedPickupKeys = new HashSet<string>(); public int SilkSpearTryGetCount; public bool SilkSpearGiven; public int SilkSpearPityCount = 10; public bool TrapEnabled; public string TrapDifficulty = "Beginner"; public bool TrapMovementEnabled = true; public HashSet<string> TrapFrostBannedScenes = new HashSet<string>(); public Dictionary<string, Dictionary<string, float>> CrestEffects = new Dictionary<string, Dictionary<string, float>>(); public HashSet<string> ShopAssignedItemIds = new HashSet<string>(); } [Serializable] public class CurrencyState { public int TotalCollectCount; public bool FirstKeyGiven; public bool SecondKeyGiven; } [HarmonyPatch(typeof(HeroController))] public static class HeroRespawnReset { [CompilerGenerated] private sealed class <ClearInvincibleAfterDelay>d__3 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public float duration; public HeroController hero; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <ClearInvincibleAfterDelay>d__3(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(duration); <>1__state = 1; return true; case 1: <>1__state = -1; if ((Object)(object)hero != (Object)null) { hero.cState.invulnerable = false; } return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private const float ProtectionDuration = 4f; private static float _protectionEndTime; [HarmonyPatch("FinishedEnteringScene", new Type[] { typeof(bool), typeof(bool) })] [HarmonyPostfix] private static void FinishedEnteringScenePostfix(HeroController __instance) { //IL_00ca: Unknown result type (might be due to invalid IL or missing references) __instance.controlReqlinquished = false; __instance.cState.recoiling = false; __instance.cState.recoilingLeft = false; __instance.cState.recoilingRight = false; __instance.cState.floating = false; typeof(HeroController).GetField("acceptingInput", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(__instance, true); object obj = typeof(HeroController).GetField("inputHandler", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(__instance); if (obj != null) { object obj2 = obj.GetType().GetProperty("inputActions")?.GetValue(obj); (obj2?.GetType().GetMethod("ClearInputState"))?.Invoke(obj2, null); } __instance.damageMode = (DamageMode)0; __instance.AffectedByGravity(true); _protectionEndTime = Time.time + 4f; __instance.cState.invulnerable = true; ((MonoBehaviour)__instance).StartCoroutine(ClearInvincibleAfterDelay(__instance, 4f)); } [IteratorStateMachine(typeof(<ClearInvincibleAfterDelay>d__3))] private static IEnumerator ClearInvincibleAfterDelay(HeroController hero, float duration) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <ClearInvincibleAfterDelay>d__3(0) { hero = hero, duration = duration }; } [HarmonyPatch("TakeDamage", new Type[] { typeof(GameObject), typeof(CollisionSide), typeof(int), typeof(HazardType), typeof(DamagePropertyFlags) })] [HarmonyPrefix] private static bool TakeDamagePrefix(HeroController __instance) { return Time.time >= _protectionEndTime; } } public static class ItemLimitConfig { public static int LimitSkillItem { get; set; } = 2; public static int LimitRelic { get; set; } = 2; public static int LimitOtherItem { get; set; } = 2; public static int LimitUpSlash { get; set; } = 1; public static int LimitLeftSlash { get; set; } = 1; public static int LimitRightSlash { get; set; } = 1; public static int LimitDashLeft { get; set; } = 1; public static int LimitDashRight { get; set; } = 1; public static int LimitHarpoonLeft { get; set; } = 1; public static int LimitHarpoonRight { get; set; } = 1; public static int LimitFloatLeft { get; set; } = 1; public static int LimitFloatRight { get; set; } = 1; public static int LimitWallJumpLeft { get; set; } = 1; public static int LimitWallJumpRight { get; set; } = 1; public static int LimitHeal { get; set; } = 1; public static int LimitNeedleThrow { get; set; } = 1; public static int LimitThreadSphere { get; set; } = 1; public static int LimitHarpoonDash { get; set; } = 1; public static int LimitSilkCharge { get; set; } = 1; public static int LimitSilkBomb { get; set; } = 1; public static int LimitSilkBossNeedle { get; set; } = 1; public static int LimitNeedolin { get; set; } = 1; public static int LimitParry { get; set; } = 1; public static int LimitNeedolinMemory { get; set; } = 1; public static int LimitFastTravel { get; set; } = 1; public static int LimitEvaHeal { get; set; } = 1; public static int LimitDash { get; set; } = 1; public static int LimitBrolly { get; set; } = 1; public static int LimitDoubleJump { get; set; } = 1; public static int LimitSuperJump { get; set; } = 1; public static int LimitWallJump { get; set; } = 1; public static int LimitChargeSlash { get; set; } = 1; public static int LimitHeartPiece { get; set; } = 2; public static int LimitSpoolPart { get; set; } = 2; public static int LimitMaxSilkRegenUp { get; set; } = 2; public static int LimitUnlockCrestSlot { get; set; } = 2; public static bool EnableInfSilk { get; private set; } = true; public static bool EnableInfFullRestore { get; private set; } = true; public static bool EnableInfBlueHealth { get; private set; } = true; public static bool EnableInfGeo300 { get; private set; } = true; public static bool EnableInfShards300 { get; private set; } = true; public static bool EnableInfSilkParts { get; private set; } = true; public static void Init(ConfigFile config) { Func<string, string, int, int> func = (string section, string key, int defaultValue) => config.Bind<int>(section, key, defaultValue, (ConfigDescription)null).Value; Func<string, string, bool, bool> obj = (string section, string key, bool defaultValue) => config.Bind<bool>(section, key, defaultValue, (ConfigDescription)null).Value; LimitSkillItem = func("Limits", "SkillItem", 2); LimitRelic = func("Limits", "Relic", 2); LimitOtherItem = func("Limits", "OtherItem", 2); LimitUpSlash = func("Limits", "UpSlash", 1); LimitLeftSlash = func("Limits", "LeftSlash", 1); LimitRightSlash = func("Limits", "RightSlash", 1); LimitDashLeft = func("Limits", "DashLeft", 1); LimitDashRight = func("Limits", "DashRight", 1); LimitHarpoonLeft = func("Limits", "HarpoonLeft", 1); LimitHarpoonRight = func("Limits", "HarpoonRight", 1); LimitFloatLeft = func("Limits", "FloatLeft", 1); LimitFloatRight = func("Limits", "FloatRight", 1); LimitWallJumpLeft = func("Limits", "WallJumpLeft", 1); LimitWallJumpRight = func("Limits", "WallJumpRight", 1); LimitHeal = func("Limits", "Heal", 1); LimitNeedleThrow = func("Limits", "NeedleThrow", 1); LimitThreadSphere = func("Limits", "ThreadSphere", 1); LimitHarpoonDash = func("Limits", "HarpoonDash", 1); LimitSilkCharge = func("Limits", "SilkCharge", 1); LimitSilkBomb = func("Limits", "SilkBomb", 1); LimitSilkBossNeedle = func("Limits", "SilkBossNeedle", 1); LimitNeedolin = func("Limits", "Needolin", 1); LimitParry = func("Limits", "Parry", 1); LimitNeedolinMemory = func("Limits", "NeedolinMemory", 1); LimitFastTravel = func("Limits", "FastTravel", 1); LimitEvaHeal = func("Limits", "EvaHeal", 1); LimitDash = func("Limits", "Dash", 1); LimitBrolly = func("Limits", "Brolly", 1); LimitDoubleJump = func("Limits", "DoubleJump", 1); LimitSuperJump = func("Limits", "SuperJump", 1); LimitWallJump = func("Limits", "WallJump", 1); LimitChargeSlash = func("Limits", "ChargeSlash", 1); LimitHeartPiece = func("Limits", "HeartPiece", 2); LimitSpoolPart = func("Limits", "SpoolPart", 2); LimitMaxSilkRegenUp = func("Limits", "MaxSilkRegenUp", 2); LimitUnlockCrestSlot = func("Limits", "UnlockCrestSlot", 2); EnableInfSilk = obj("Limits", "EnableInfSilk", arg3: true); EnableInfFullRestore = obj("Limits", "EnableInfFullRestore", arg3: true); EnableInfBlueHealth = obj("Limits", "EnableInfBlueHealth", arg3: true); EnableInfGeo300 = obj("Limits", "EnableInfGeo300", arg3: true); EnableInfShards300 = obj("Limits", "EnableInfShards300", arg3: true); EnableInfSilkParts = obj("Limits", "EnableInfSilkParts", arg3: true); } public static void Apply(ItemLimitSettings settings) { if (settings != null) { LimitSkillItem = settings.SkillItem; LimitRelic = settings.Relic; LimitOtherItem = settings.OtherItem; LimitUpSlash = settings.UpSlash; LimitLeftSlash = settings.LeftSlash; LimitRightSlash = settings.RightSlash; LimitDashLeft = settings.DashLeft; LimitDashRight = settings.DashRight; LimitHarpoonLeft = settings.HarpoonLeft; LimitHarpoonRight = settings.HarpoonRight; LimitFloatLeft = settings.FloatLeft; LimitFloatRight = settings.FloatRight; LimitWallJumpLeft = settings.WallJumpLeft; LimitWallJumpRight = settings.WallJumpRight; LimitHeal = settings.Heal; LimitNeedleThrow = settings.NeedleThrow; LimitThreadSphere = settings.ThreadSphere; LimitHarpoonDash = settings.HarpoonDash; LimitSilkCharge = settings.SilkCharge; LimitSilkBomb = settings.SilkBomb; LimitSilkBossNeedle = settings.SilkBossNeedle; LimitNeedolin = settings.Needolin; LimitParry = settings.Parry; LimitNeedolinMemory = settings.NeedolinMemory; LimitFastTravel = settings.FastTravel; LimitEvaHeal = settings.EvaHeal; LimitDash = settings.Dash; LimitBrolly = settings.Brolly; LimitDoubleJump = settings.DoubleJump; LimitSuperJump = settings.SuperJump; LimitWallJump = settings.WallJump; LimitChargeSlash = settings.ChargeSlash; LimitHeartPiece = settings.HeartPiece; LimitSpoolPart = settings.SpoolPart; LimitMaxSilkRegenUp = settings.MaxSilkRegenUp; LimitUnlockCrestSlot = settings.UnlockCrestSlot; } } public static void ApplyInfinitePoolSettings(InfinitePoolSettings settings) { if (settings != null) { EnableInfSilk = settings.Silk; EnableInfFullRestore = settings.FullRestore; EnableInfBlueHealth = settings.BlueHealth; EnableInfGeo300 = settings.Geo300; EnableInfShards300 = settings.Shards300; EnableInfSilkParts = settings.SilkParts; } } public static int GetAbilityLimit(string abilityId) { return abilityId switch { "hasNeedleThrow" => LimitNeedleThrow, "hasThreadSphere" => LimitThreadSphere, "hasHarpoonDash" => LimitHarpoonDash, "hasSilkCharge" => LimitSilkCharge, "hasSilkBomb" => LimitSilkBomb, "hasSilkBossNeedle" => LimitSilkBossNeedle, "hasNeedolin" => LimitNeedolin, "hasParry" => LimitParry, "hasNeedolinMemoryPowerup" => LimitNeedolinMemory, "hasFastTravelTeleport" => LimitFastTravel, "HasSeenEvaHeal" => LimitEvaHeal, "hasDash" => LimitDash, "hasBrolly" => LimitBrolly, "hasDoubleJump" => LimitDoubleJump, "hasSuperJump" => LimitSuperJump, "hasWalljump" => LimitWallJump, "hasChargeSlash" => LimitChargeSlash, _ => 1, }; } public static int GetDirectionLimit(string id) { return id switch { "perm:upward" => LimitUpSlash, "perm:left" => LimitLeftSlash, "perm:right" => LimitRightSlash, "perm:hasDash_L" => LimitDashLeft, "perm:hasDash_R" => LimitDashRight, "perm:hasHarpoonDash_L" => LimitHarpoonLeft, "perm:hasHarpoonDash_R" => LimitHarpoonRight, "perm:hasBrolly_L" => LimitFloatLeft, "perm:hasBrolly_R" => LimitFloatRight, "perm:hasWalljump_L" => LimitWallJumpLeft, "perm:hasWalljump_R" => LimitWallJumpRight, "perm:heal" => LimitHeal, _ => 1, }; } public static int GetPreciousLimit(string id) { return id switch { "virt:HeartPiece" => LimitHeartPiece, "virt:SpoolPart" => LimitSpoolPart, "virt:MaxSilkRegenUp" => LimitMaxSilkRegenUp, "virt:UnlockCrestSlot" => LimitUnlockCrestSlot, _ => 2, }; } public static int GetItemTypeLimit(SavedItem item) { if ((Object)(object)item == (Object)null) { return 2; } Type type = ((object)item).GetType(); if (type == typeof(ToolItemSkill) || type.IsSubclassOf(typeof(ToolItemSkill)) || item is ToolItemSkill) { return LimitSkillItem; } if (typeof(CollectableRelic).IsAssignableFrom(type)) { return LimitRelic; } return LimitOtherItem; } } public static class ItemLocalizationRegistrar { public const string CustomSheetName = "SilksongItemRandomizer"; private static readonly HashSet<string> _registeredKeys = new HashSet<string>(); private static Dictionary<string, Dictionary<string, string>> _localizationDict; private static bool EnsureLocalizationDict() { if (_localizationDict != null) { return true; } FieldInfo field = typeof(Language).GetField("_currentEntrySheets", BindingFlags.Static | BindingFlags.NonPublic); if (field == null) { Plugin.Log.LogError((object)"[ItemLocalization] 无法获取 Language._currentEntrySheets 字段"); return false; } _localizationDict = field.GetValue(null) as Dictionary<string, Dictionary<string, string>>; if (_localizationDict == null) { Plugin.Log.LogError((object)"[ItemLocalization] Language._currentEntrySheets 字段不是预期类型"); return false; } return true; } public static bool RegisterItemName(string key, string displayName) { if (!EnsureLocalizationDict()) { return false; } if (string.IsNullOrEmpty(key) || string.IsNullOrEmpty(displayName)) { return false; } if (_registeredKeys.Contains(key)) { return true; } if (!_localizationDict.TryGetValue("SilksongItemRandomizer", out var value)) { value = new Dictionary<string, string>(); _localizationDict["SilksongItemRandomizer"] = value; } value[key] = displayName; _registeredKeys.Add(key); Plugin.Log.LogDebug((object)("[ItemLocalization] 注册物品名称: " + key + " -> " + displayName)); return true; } public static string GetLocalizationKey(string itemInternalName) { return "item_" + itemInternalName; } public static LocalisedString GetLocalisedString(string itemInternalName) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) return new LocalisedString("SilksongItemRandomizer", GetLocalizationKey(itemInternalName)); } public static void RegisterAllKnownItems() { if (!EnsureLocalizationDict()) { return; } SavedItem[] array = Resources.FindObjectsOfTypeAll<SavedItem>(); int num = 0; SavedItem[] array2 = array; foreach (SavedItem val in array2) { if (!((Object)(object)val == (Object)null)) { string name = ((Object)val).name; string itemDisplayNameSafe = GetItemDisplayNameSafe(val); if (!string.IsNullOrEmpty(itemDisplayNameSafe) && RegisterItemName(GetLocalizationKey(name), itemDisplayNameSafe)) { num++; } } } Plugin.Log.LogInfo((object)$"[ItemLocalization] 已注册 {num} 个物品的本地化名称"); } private static string GetItemDisplayNameSafe(SavedItem item) { if (typeof(SavedItem).GetMethod("GetPopupName", BindingFlags.Instance | BindingFlags.Public) != null) { MethodInfo method = ((object)item).GetType().GetMethod("GetPopupName", BindingFlags.Instance | BindingFlags.Public); if (method != null && method.DeclaringType == typeof(SavedItem)) { return ((Object)item).name; } } try { return item.GetPopupName(); } catch { return ((Object)item).name; } } public static void Reset() { if (EnsureLocalizationDict()) { if (_localizationDict.ContainsKey("SilksongItemRandomizer")) { _localizationDict["SilksongItemRandomizer"].Clear(); } _registeredKeys.Clear(); Plugin.Log.LogInfo((object)"[ItemLocalization] 已清空所有自定义本地化条目"); } } } public interface ISaveDataAccessor { Dictionary<string, int> GetItemGivenCounts(); Dictionary<string, string> GetTotalMappings(); void SaveItemGivenCounts(Dictionary<string, int> counts); void SaveTotalMappings(Dictionary<string, string> mappings); } public static class ItemRandomizer { [CompilerGenerated] private sealed class <AddBlueHealthCoroutine>d__23 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public int times; public float interval; private int <i>5__2; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <AddBlueHealthCoroutine>d__23(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown int num = <>1__state; if (num != 0) { if (num != 1) { return false; } <>1__state = -1; goto IL_005c; } <>1__state = -1; <i>5__2 = 0; goto IL_006c; IL_005c: <i>5__2++; goto IL_006c; IL_006c: if (<i>5__2 < times) { EventRegister.SendEvent(EventRegisterEvents.AddBlueHealth, (GameObject)null); if (<i>5__2 < times - 1) { <>2__current = (object)new WaitForSeconds(interval); <>1__state = 1; return true; } goto IL_005c; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <WaitForSystemMenuThenGive>d__26 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public string skillField; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <WaitForSystemMenuThenGive>d__26(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; goto IL_003b; case 1: <>1__state = -1; goto IL_003b; case 2: { <>1__state = -1; StartingAbilityPickerAPI.GiveSkill(skillField); return false; } IL_003b: if (IsSystemMenuOpen()) { <>2__current = null; <>1__state = 1; return true; } <>2__current = null; <>1__state = 2; return true; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private static List<IRandomReward> _unlimitedRewards = new List<IRandomReward>(); private static List<IRandomReward> _limitedRewards = new List<IRandomReward>(); private static IRandomReward _cachedCrestUnlocker; private static Random _globalRng; private static int _seed; private static ISaveDataAccessor _saveData; private static float _virtualUnlimitedProbability = 0.1f; private static float _crestUnlockerProbability = 0.1f; private static float _normalLimitedProbability = 0.8f; private static bool _fullRandomModeActive = false; public static readonly HashSet<string> ExcludedNames = new HashSet<string> { "Steel Spines", "Common Spine", "Plasmium", "Sliver Bell", "Seared Organ", "Shredded Organ", "Skewered Organ", "Ragpelt", "Invalid Item Template" }; public static Random Rng => _globalRng; public static bool IsInitialized { get; private set; } = false; public static ToolItemType? LastUnlockedSlotType { get; private set; } public static void Initialize(int seed, ItemRandomizerConfig config, ISaveDataAccessor saveDataAccessor, bool fullRandomMode) { _seed = seed; _globalRng = ((seed == 0) ? new Random() : new Random(seed)); _saveData = saveDataAccessor; _fullRandomModeActive = fullRandomMode; if (config != null) { _virtualUnlimitedProbability = config.VirtualUnlimitedProbability; _crestUnlockerProbability = config.CrestUnlockerProbability; _normalLimitedProbability = config.NormalLimitedProbability; } BuildRewardPools(config, fullRandomMode); IsInitialized = true; } public static void RefreshPool() { if (IsInitialized) { BuildRewardPools(null, _fullRandomModeActive); } } private static void BuildRewardPools(ItemRandomizerConfig config, bool fullRandomMode) { _limitedRewards.Clear(); _unlimitedRewards.Clear(); SavedItem[] array = Resources.FindObjectsOfTypeAll<SavedItem>(); List<SavedItem> list = new List<SavedItem>(); SavedItem[] array2 = array; foreach (SavedItem val in array2) { if (!((Object)(object)val == (Object)null) && !ExcludedNames.Contains(((Object)val).name)) { Type type = ((object)val).GetType(); if (!(val is EnemyJournalRecord) && !type.Name.StartsWith("QuestTarget") && !(type == typeof(Quest)) && !(type == typeof(MainQuest)) && !(type == typeof(SubQuest)) && !(type == typeof(QuestRumour)) && !(type == typeof(FullQuestBase)) && !(type == typeof(BasicQuestBase)) && !(type == typeof(QuestGroup)) && !(type == typeof(QuestGroupBase)) && IsValidItem(val)) { list.Add(val); } } } HashSet<string> hashSet = new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "Swift Step", "Harpoon Dash", "Drifter's Cloak", "Cling Grip", "EvaHeal" }; foreach (SavedItem item in list) { if (!fullRandomMode || !hashSet.Contains(((Object)item).name)) { _limitedRewards.Add(new SavedItemReward(item)); } } BuildAbilityVirtualRewards(fullRandomMode); if (fullRandomMode) { AddDirectionPermissionRewards(); } BuildUnlimitedVirtualRewards(); BuildPreciousVirtualRewards(); _cachedCrestUnlocker = _limitedRewards.FirstOrDefault((IRandomReward r) => r.Id == "virt:UnlockCrestSlot"); Plugin.Log.LogInfo((object)$"随机奖励池构建完成:无限类 {_unlimitedRewards.Count} 个,有限类 {_limitedRewards.Count} 个"); } private static void BuildAbilityVirtualRewards(bool fullRandomMode) { string[] array = new string[17] { "hasNeedleThrow", "hasThreadSphere", "hasSilkCharge", "hasSilkBomb", "hasSilkBossNeedle", "hasParry", "hasHarpoonDash", "hasNeedolin", "hasDash", "hasBrolly", "hasDoubleJump", "hasChargeSlash", "hasSuperJump", "hasWalljump", "HasSeenEvaHeal", "hasNeedolinMemoryPowerup", "hasFastTravelTeleport" }; foreach (string field in array) { if (!fullRandomMode || !IsDirectionSkillField(field)) { var (text, val) = GetAbilityInfo(field); if ((Object)(object)val == (Object)null) { val = GetFallbackIcon(); } if (string.IsNullOrEmpty(text)) { text = field; } VirtualReward item = new VirtualReward(field, text, val, delegate { GiveSkillWithMenuCheck(field); }, () => GetGivenCount(field) >= ItemLimitConfig.GetAbilityLimit(field)); _limitedRewards.Add(item); } } } private static void AddDirectionPermissionRewards() { _limitedRewards.Add(new DirectionPermissionReward(Locale.Get("冲刺左"), "hasDash", allowRight: false, allowLeft: true)); _limitedRewards.Add(new DirectionPermissionReward(Locale.Get("冲刺右"), "hasDash", allowRight: true, allowLeft: false)); _limitedRewards.Add(new DirectionPermissionReward(Locale.Get("飞针左"), "hasHarpoonDash", allowRight: false, allowLeft: true)); _limitedRewards.Add(new DirectionPermissionReward(Locale.Get("飞针右"), "hasHarpoonDash", allowRight: true, allowLeft: false)); _limitedRewards.Add(new DirectionPermissionReward(Locale.Get("漂浮左"), "hasBrolly", allowRight: false, allowLeft: true)); _limitedRewards.Add(new DirectionPermissionReward(Locale.Get("漂浮右"), "hasBrolly", allowRight: true, allowLeft: false)); _limitedRewards.Add(new DirectionPermissionReward(Locale.Get("壁跳左"), "hasWalljump", allowRight: false, allowLeft: true)); _limitedRewards.Add(new DirectionPermissionReward(Locale.Get("壁跳右"), "hasWalljump", allowRight: true, allowLeft: false)); _limitedRewards.Add(new DirectionPermissionReward(Locale.Get("上劈权限"), "upward", allowRight: true, allowLeft: false, isAttack: true)); _limitedRewards.Add(new DirectionPermissionReward(Locale.Get("左劈权限"), "left", allowRight: true, allowLeft: false, isAttack: true)); _limitedRewards.Add(new DirectionPermissionReward(Locale.Get("右劈权限"), "right", allowRight: true, allowLeft: false, isAttack: true)); _limitedRewards.Add(new DirectionPermissionReward(Locale.Get("回血权限"), "heal", allowRight: true, allowLeft: false, isAttack: false, isHeal: true)); } private static void BuildUnlimitedVirtualRewards() { if (ItemLimitConfig.EnableInfSilk) { _unlimitedRewards.Add(new VirtualReward("virt:Silk_9", Locale.Get("灵丝"), null, delegate { HeroController instance7 = HeroController.instance; if ((Object)(object)instance7 != (Object)null) { for (int k = 0; k < 9; k++) { instance7.AddSilk(1, false); } } }, () => false)); } if (ItemLimitConfig.EnableInfFullRestore) { _unlimitedRewards.Add(new VirtualReward("virt:FullRestore", Locale.Get("完全恢复"), null, delegate { HeroController instance5 = HeroController.instance; PlayerData instance6 = PlayerData.instance; if (!((Object)(object)instance5 == (Object)null) && instance6 != null) { int num = instance6.CurrentMaxHealth - instance6.health; for (int i = 0; i < num; i++) { instance5.AddHealth(1); } int num2 = instance6.CurrentSilkMax - instance6.silk; for (int j = 0; j < num2; j++) { instance5.AddSilk(1, false); } } }, () => false)); } if (ItemLimitConfig.EnableInfBlueHealth) { _unlimitedRewards.Add(new VirtualReward("virt:BlueHealth_5", Locale.Get("蓝血"), null, delegate { Plugin instance4 = Plugin.Instance; if (instance4 != null) { ((MonoBehaviour)instance4).StartCoroutine(AddBlueHealthCoroutine(5, 1f)); } }, () => false)); } if (ItemLimitConfig.EnableInfGeo300) { _unlimitedRewards.Add(new VirtualReward("virt:Geo_300", Locale.Get("念珠"), null, delegate { HeroController instance3 = HeroController.instance; if (instance3 != null) { instance3.AddGeo(300); } }, () => false)); } if (ItemLimitConfig.EnableInfShards300) { _unlimitedRewards.Add(new VirtualReward("virt:Shards_300", Locale.Get("甲壳"), null, delegate { HeroController instance2 = HeroController.instance; if (instance2 != null) { instance2.AddShards(300); } }, () => false)); } if (!ItemLimitConfig.EnableInfSilkParts) { return; } _unlimitedRewards.Add(new VirtualReward("virt:SilkParts_3", Locale.Get("大灵丝碎片"), null, delegate { HeroController instance = HeroController.instance; if (instance != null) { instance.AddSilkParts(3); } }, () => false)); } private static void BuildPreciousVirtualRewards() { _limitedRewards.Add(new VirtualReward("virt:HeartPiece", Locale.Get("面具碎片"), null, delegate { PlayerData instance4 = PlayerData.instance; if (instance4 != null) { instance4.heartPieces++; } EventRegister.SendEvent(EventRegisterEvents.EquipsChangedEvent, (GameObject)null); }, () => GetGivenCount("virt:HeartPiece") >= ItemLimitConfig.GetPreciousLimit("virt:HeartPiece"))); _limitedRewards.Add(new VirtualReward("virt:SpoolPart", Locale.Get("丝轴碎片"), null, delegate { PlayerData instance2 = PlayerData.instance; if (instance2 != null) { instance2.silkSpoolParts++; } GameCameras instance3 = GameCameras.instance; if (instance3 != null) { SilkSpool silkSpool = instance3.silkSpool; if (silkSpool != null) { silkSpool.RefreshSilk(); } } EventRegister.SendEvent(EventRegisterEvents.EquipsChangedEvent, (GameObject)null); }, () => GetGivenCount("virt:SpoolPart") >= ItemLimitConfig.GetPreciousLimit("virt:SpoolPart"))); _limitedRewards.Add(new VirtualReward("virt:MaxSilkRegenUp", Locale.Get("丝线恢复上限 +1"), null, delegate { HeroController instance = HeroController.instance; if (instance != null) { instance.AddToMaxSilkRegen(1); } }, () => GetGivenCount("virt:MaxSilkRegenUp") >= ItemLimitConfig.GetPreciousLimit("virt:MaxSilkRegenUp"))); _limitedRewards.Add(new VirtualReward("virt:UnlockCrestSlot", Locale.Get("纹章槽位解锁器"), null, delegate { TryUnlockCrestSlot(); }, () => GetGivenCount("virt:UnlockCrestSlot") >= ItemLimitConfig.GetPreciousLimit("virt:UnlockCrestSlot"))); } [IteratorStateMachine(typeof(<AddBlueHealthCoroutine>d__23))] private static IEnumerator AddBlueHealthCoroutine(int times, float interval) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <AddBlueHealthCoroutine>d__23(0) { times = times, interval = interval }; } private static bool IsDirectionSkillField(string field) { switch (field) { default: return field == "HasSeenEvaHeal"; case "hasDash": case "hasHarpoonDash": case "hasBrolly": case "hasWalljump": return true; } } private static bool IsSystemMenuOpen() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Invalid comparison between Unknown and I4 try { if ((Object)(object)UIManager.instance != (Object)null && (int)UIManager.instance.uiState == 5) { return true; } GameObject obj = GameObject.Find("PauseMenu"); if (obj != null && obj.activeInHierarchy) { return true; } } catch { } return false; } [IteratorStateMachine(typeof(<WaitForSystemMenuThenGive>d__26))] private static IEnumerator WaitForSystemMenuThenGive(string skillField) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <WaitForSystemMenuThenGive>d__26(0) { skillField = skillField }; } private static void GiveSkillWithMenuCheck(string skillField) { EnsureSpellSlotsUnlocked(); if (IsSystemMenuOpen()) { ((MonoBehaviour)Plugin.Instance).StartCoroutine(WaitForSystemMenuThenGive(skillField)); } else { StartingAbilityPickerAPI.GiveSkill(skillField); } } private static void EnsureSpellSlotsUnlocked() { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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_008a: 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_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_0156: 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) //IL_0105: 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) //IL_0119: 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) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) try { PlayerData instance = PlayerData.instance; if (instance == null) { return; } string crestId = instance.CurrentCrestID; if (string.IsNullOrEmpty(crestId)) { crestId = "Hunter"; } ToolCrest val = ((IEnumerable<ToolCrest>)Resources.FindObjectsOfTypeAll<ToolCrest>()).FirstOrDefault((Func<ToolCrest, bool>)((ToolCrest c) => c.name == crestId)); if ((Object)(object)val == (Object)null) { return; } Data saveData = val.SaveData; if (saveData.Slots == null || saveData.Slots.Count == 0) { saveData.Slots = new List<SlotData>(); for (int i = 0; i < val.Slots.Length; i++) { saveData.Slots.Add(new SlotData { IsUnlocked = !val.Slots[i].IsLocked }); } val.SaveData = saveData; } bool flag = false; for (int j = 0; j < val.Slots.Length && j < saveData.Slots.Count; j++) { if (((object)(ToolItemType)(ref val.Slots[j].Type)).ToString().Contains("Spell") && !saveData.Slots[j].IsUnlocked) { SlotData value = saveData.Slots[j]; value.IsUnlocked = true; saveData.Slots[j] = value; flag = true; } } if (flag) { val.SaveData = saveData; Plugin.Log.LogInfo((object)("[ItemRandomizer] 已为纹章 " + crestId + " 解锁法术槽")); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("[ItemRandomizer] 解锁法术槽失败: " + ex.Message)); } } private static (string displayName, Sprite icon) GetAbilityInfo(string abilityField) { try { string displayName = StartingAbilityPickerAPI.GetDisplayName(abilityField); Sprite icon = StartingAbilityPickerAPI.GetIcon(abilityField); if (!string.IsNullOrEmpty(displayName) && (Object)(object)icon != (Object)null) { return (displayName, icon); } } catch { } object item = abilityField switch { "hasDash" => Locale.Get("疾风步"), "hasBrolly" => Locale.Get("流浪者披风"), "hasDoubleJump" => Locale.Get("雪绒披风"), "hasSuperJump" => Locale.Get("灵丝升腾"), "hasWalljump" => Locale.Get("蛛攀术"), "HasSeenEvaHeal" => Locale.Get("风铃摇"), _ => abilityField, }; Sprite fallbackIcon = GetFallbackIcon(); return ((string)item, fallbackIcon); } private static Sprite GetFallbackIcon() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0014: 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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown Texture2D val = new Texture2D(1, 1); val.SetPixel(0, 0, Color.white); val.Apply(); return Sprite.Create(val, new Rect(0f, 0f, 1f, 1f), Vector2.zero); } private static Dictionary<string, int> GetGivenCountsDict() { return _saveData?.GetItemGivenCounts() ?? new Dictionary<string, int>(); } private static Dictionary<string, string> GetTotalMappingsDict() { return _saveData?.GetTotalMappings() ?? new Dictionary<string, string>(); } private static void SaveGivenCounts() { _saveData?.SaveItemGivenCounts(GetGivenCountsDict()); } private static void SaveTotalMappings() { _saveData?.SaveTotalMappings(GetTotalMappingsDict()); } public static int GetGivenCount(string id) { if (!GetGivenCountsDict().TryGetValue(id, out var value)) { return 0; } return value; } public static void AddGivenCount(string id) { Dictionary<string, int> givenCountsDict = GetGivenCountsDict(); if (givenCountsDict.ContainsKey(id)) { givenCountsDict[id]++; } else { givenCountsDict[id] = 1; } SaveGivenCounts(); } public static void RecordMapping(string sourceKey, string targetKey) { Dictionary<string, string> totalMappingsDict = GetTotalMappingsDict(); if (!totalMappingsDict.TryGetValue(sourceKey, out var value) || !(value == targetKey)) { totalMappingsDict[sourceKey] = targetKey; SaveTotalMappings(); } } public static string GetMapping(string sourceKey) { GetTotalMappingsDict().TryGetValue(sourceKey, out var value); return value; } public static IRandomReward GetRandomReward() { double num = _globalRng.NextDouble(); float virtualUnlimitedProbability = _virtualUnlimitedProbability; float crestUnlockerProbability = _crestUnlockerProbability; _ = _normalLimitedProbability; if (num < (double)virtualUnlimitedProbability) { if (_unlimitedRewards.Count > 0) { return _unlimitedRewards[_globalRng.Next(_unlimitedRewards.Count)]; } num = (double)virtualUnlimitedProbability + 0.01; } if (num < (double)(virtualUnlimitedProbability + crestUnlockerProbability)) { if (_cachedCrestUnlocker != null && !_cachedCrestUnlocker.IsAtMax()) { return _cachedCrestUnlocker; } num = (double)(virtualUnlimitedProbability + crestUnlockerProbability) + 0.01; } List<IRandomReward> list = _limitedRewards.Where((IRandomReward r) => r != _cachedCrestUnlocker && !r.IsAtMax()).ToList(); if (list.Count > 0) { return list[_globalRng.Next(list.Count)]; } if (_unlimitedRewards.Count > 0) { return _unlimitedRewards[_globalRng.Next(_unlimitedRewards.Count)]; } return new VirtualReward("virt:FallbackGeo", Locale.Get("保底念珠"), null, delegate { HeroController instance = HeroController.instance; if (instance != null) { instance.AddGeo(10); } }, () => false); } public static SavedItem GetRandomItem() { List<IRandomReward> list = _limitedRewards.Where((IRandomReward r) => !r.IsAtMax()).ToList(); if (list.Count == 0) { return null; } IRandomReward randomReward = list[_globalRng.Next(list.Count)]; if (randomReward is SavedItemReward savedItemReward) { return savedItemReward.Item; } ProxySavedItem proxySavedItem = new ProxySavedItem(); proxySavedItem.Init(randomReward); return (SavedItem)(object)proxySavedItem; } public static SavedItem PeekRandomItem(Random externalRng) { List<SavedItemReward> list = _limitedRewards.OfType<SavedItemReward>().ToList(); if (list.Count == 0) { return null; } return list[externalRng.Next(list.Count)].Item; } public static List<SavedItem> GetAllItems() { return (from r in _limitedRewards.OfType<SavedItemReward>() select r.Item into i where (Object)(object)i != (Object)null select i).ToList(); } public static bool GiveRandomReward() { IRandomReward randomReward = GetRandomReward(); if (randomReward == null) { return false; } randomReward.Give(); AddGivenCount(randomReward.Id); return true; } public static void ResetAllData() { GetGivenCountsDict().Clear(); GetTotalMappingsDict().Clear(); SaveGivenCounts(); SaveTotalMappings(); Plugin.Log.LogInfo((object)"所有随机奖励次数和映射表已重置"); } public static string GetSlotTypeName(ToolItemType type) { if (((object)(ToolItemType)(ref type)).ToString().Contains("Attack")) { return Locale.Get("攻击槽"); } if (((object)(ToolItemType)(ref type)).ToString().Contains("Tool") || ((object)(ToolItemType)(ref type)).ToString().Contains("Item")) { return Locale.Get("工具槽"); } if (((object)(ToolItemType)(ref type)).ToString().Contains("Spell")) { return Locale.Get("法术槽"); } return ((object)(ToolItemType)(ref type)).ToString(); } public static void TryUnlockCrestSlot() { //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_00db: 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_005e: 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_0109: Unknown result type (might be due to invalid IL or missing references) //IL_012b: 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_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_021b: 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_022b: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) LastUnlockedSlotType = null; PlayerData instance = PlayerData.instance; if (instance == null) { return; } string crestId = instance.CurrentCrestID; if (string.IsNullOrEmpty(crestId)) { List<string> list = new List<string>(); foreach (KeyValuePair<string, Data> item in ((SerializableNamedList<Data, NamedData>)(object)instance.ToolEquips).Enumerate()) { if (item.Value.IsUnlocked) { list.Add(item.Key); } } if (list.Count == 0) { return; } crestId = list[Random.Range(0, list.Count)]; } ToolCrest val = ((IEnumerable<ToolCrest>)Resources.FindObjectsOfTypeAll<ToolCrest>()).FirstOrDefault((Func<ToolCrest, bool>)((ToolCrest c) => c.name == crestId)); if ((Object)(object)val == (Object)null) { return; } Data saveData = val.SaveData; if (saveData.Slots == null || saveData.Slots.Count == 0) { saveData.Slots = new List<SlotData>(); for (int i = 0; i < val.Slots.Length; i++) { saveData.Slots.Add(new SlotData { IsUnlocked = !val.Slots[i].IsLocked }); } val.SaveData = saveData; } int num = -1; ToolItemType? lastUnlockedSlotType = null; for (int j = 0; j < saveData.Slots.Count && j < val.Slots.Length; j++) { if (!saveData.Slots[j].IsUnlocked && !((object)(ToolItemType)(ref val.Slots[j].Type)).ToString().Contains("Spell")) { num = j; lastUnlockedSlotType = val.Slots[j].Type; break; } } if (num == -1) { HeroController instance2 = HeroController.instance; if (instance2 != null) { instance2.AddGeo(100); } Plugin.ShowNotification(Locale.Get("纹章槽位已满,获得 100 念珠"), 2f); } else { SlotData value = saveData.Slots[num]; value.IsUnlocked = true; saveData.Slots[num] = value; val.SaveData = saveData; LastUnlockedSlotType = lastUnlockedSlotType; EventRegister.SendEvent(EventRegisterEvents.EquipsChangedEvent, (GameObject)null); string arg = (lastUnlockedSlotType.HasValue ? GetSlotTypeName(lastUnlockedSlotType.Value) : Locale.Get("未知")); Plugin.ShowNotification(string.Format(Locale.Get("纹章槽位 {0} ({1}) 已解锁!"), num + 1, arg)); } } public static bool IsAllCrestSlotsUnlocked() { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0055: 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_00b8: 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_00a2: Unknown result type (might be due to invalid IL or missing references) PlayerData instance = PlayerData.instance; if (instance == null) { return true; } string crestId = instance.CurrentCrestID; if (string.IsNullOrEmpty(crestId)) { return false; } ToolCrest val = ((IEnumerable<ToolCrest>)Resources.FindObjectsOfTypeAll<ToolCrest>()).FirstOrDefault((Func<ToolCrest, bool>)((ToolCrest c) => c.name == crestId)); if ((Object)(object)val == (Object)null) { return false; } Data saveData = val.SaveData; if (saveData.Slots == null || saveData.Slots.Count == 0) { return false; } for (int i = 0; i < saveData.Slots.Count && i < val.Slots.Length; i++) { if (!((object)(ToolItemType)(ref val.Slots[i].Type)).ToString().Contains("Spell") && !saveData.Slots[i].IsUnlocked) { return false; } } return true; } private static bool IsValidItem(SavedItem item) { if (!((Object)(object)item == (Object)null) && !string.IsNullOrEmpty(((Object)item).name)) { return !ExcludedNames.Contains(((Object)item).name); } return false; } } public static class ItemTypeRandomFilter { public static bool EnableCrestRandom { get; private set; } = true; public static bool EnableSkillItemRandom { get; private set; } = true; public static bool EnableRelicRandom { get; private set; } =
BepInEx/plugins/SkillRandomizerMod.dll
Decompiled 2 weeks agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using StartingAbilityPicker; using UnityEngine; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyCompany("SkillRandomizerMod")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("0.1.0.0")] [assembly: AssemblyInformationalVersion("0.1.0")] [assembly: AssemblyProduct("SkillRandomizerMod")] [assembly: AssemblyTitle("SkillRandomizerMod")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/YourName/SkillRandomizerMod")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.1.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.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 SkillTriggerMod { [Serializable] public class TriggerPosition { public string sceneName; public Vector3 position; public int index; public TriggerPosition() { } public TriggerPosition(string scene, float x, float y, float z, int idx = -1) { //IL_0012: 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) sceneName = scene; position = new Vector3(x, y, z); index = idx; } } public class SkillTriggerConfig { public int Seed; public bool Enabled = true; public List<TriggerPosition> TriggerPositions = new List<TriggerPosition>(); public bool AutoDisableShrines = true; } public static class SkillTriggerAPI { private static SkillTriggerConfig _cachedConfig; private static bool _pendingChanges = false; private static bool _isGameReady = false; private static bool _initialized = false; private static HashSet<string> _triggeredRecords = new HashSet<string>(); private static List<GameObject> _activeTriggers = new List<GameObject>(); private static bool _eventsSubscribed = false; private static string TriggerRecordsPath => Path.Combine(Paths.ConfigPath, "SkillTriggerMod", "trigger_records.json"); public static void Initialize(SkillTriggerConfig config) { if (!_initialized) { _cachedConfig = config ?? new SkillTriggerConfig(); _initialized = true; _pendingChanges = true; LoadTriggerRecords(); } } public static void MarkGameReady() { _isGameReady = true; if (_pendingChanges) { ApplyPending(); } } public static void SetEnabled(bool enabled) { _cachedConfig.Enabled = enabled; MarkPendingAndApply(); } public static void SetSeed(int seed) { _cachedConfig.Seed = seed; MarkPendingAndApply(); } public static void SetTriggerPositions(List<TriggerPosition> positions) { _cachedConfig.TriggerPositions = positions; MarkPendingAndApply(); } public static void SetAutoDisableShrines(bool auto) { _cachedConfig.AutoDisableShrines = auto; MarkPendingAndApply(); } public static void ApplyNow() { if (_isGameReady || _initialized) { ApplyPending(); } } public static bool IsEnabled() { return _cachedConfig.Enabled; } public static int GetSeed() { return _cachedConfig.Seed; } public static List<TriggerPosition> GetTriggerPositions() { return new List<TriggerPosition>(_cachedConfig.TriggerPositions); } public static bool IsAutoDisableShrines() { return _cachedConfig.AutoDisableShrines; } public static void ResetAllRecords() { _triggeredRecords.Clear(); SaveTriggerRecords(); } private static void MarkPendingAndApply() { _pendingChanges = true; if (_isGameReady) { ApplyPending(); } } private static void ApplyPending() { //IL_00aa: 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_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) if (!_isGameReady && !_pendingChanges) { return; } SkillRandomizer.SetSeed(_cachedConfig.Seed); ClearAllTriggers(); if (_cachedConfig.Enabled && !_eventsSubscribed) { SceneManager.sceneLoaded += OnSceneLoaded; _eventsSubscribed = true; } else if (!_cachedConfig.Enabled && _eventsSubscribed) { SceneManager.sceneLoaded -= OnSceneLoaded; _eventsSubscribed = false; } if (_cachedConfig.Enabled && _isGameReady) { Scene activeScene = SceneManager.GetActiveScene(); if (((Scene)(ref activeScene)).isLoaded) { if (_cachedConfig.AutoDisableShrines && IsItemRandomEnabled()) { DisableShrinesInScene(activeScene); } CreateTriggersForScene(activeScene); } } _pendingChanges = false; } private static void ClearAllTriggers() { foreach (GameObject activeTrigger in _activeTriggers) { if ((Object)(object)activeTrigger != (Object)null) { Object.Destroy((Object)(object)activeTrigger); } } _activeTriggers.Clear(); } private static void OnSceneLoaded(Scene scene, LoadSceneMode mode) { //IL_0026: 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) if (_cachedConfig.Enabled) { if (_cachedConfig.AutoDisableShrines && IsItemRandomEnabled()) { DisableShrinesInScene(scene); } CreateTriggersForScene(scene); } } private static void DisableShrinesInScene(Scene scene) { string[] array = new string[5] { "bind orb", "shrine weaver ability", "weaver_shrine", "bellshrine", "dash shrine" }; GameObject[] rootGameObjects = ((Scene)(ref scene)).GetRootGameObjects(); for (int i = 0; i < rootGameObjects.Length; i++) { Transform[] componentsInChildren = rootGameObjects[i].GetComponentsInChildren<Transform>(true); foreach (Transform val in componentsInChildren) { string text = ((Object)((Component)val).gameObject).name.ToLower(); string[] array2 = array; foreach (string value in array2) { if (text.Contains(value)) { Collider2D[] components = ((Component)val).GetComponents<Collider2D>(); for (int l = 0; l < components.Length; l++) { ((Behaviour)components[l]).enabled = false; } Collider[] components2 = ((Component)val).GetComponents<Collider>(); for (int l = 0; l < components2.Length; l++) { components2[l].enabled = false; } PlayMakerFSM[] components3 = ((Component)val).GetComponents<PlayMakerFSM>(); for (int l = 0; l < components3.Length; l++) { ((Behaviour)components3[l]).enabled = false; } break; } } } } } private static void CreateTriggersForScene(Scene scene) { //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Expected O, but got Unknown //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < _cachedConfig.TriggerPositions.Count; i++) { TriggerPosition triggerPosition = _cachedConfig.TriggerPositions[i]; if (!(triggerPosition.sceneName != ((Scene)(ref scene)).name)) { int num = ((triggerPosition.index >= 0) ? triggerPosition.index : i); string text = $"SkillTriggered_{((Scene)(ref scene)).name}_{num}"; if (!_triggeredRecords.Contains(text)) { GameObject val = new GameObject($"SkillTrigger_{((Scene)(ref scene)).name}_{num}"); val.transform.position = triggerPosition.position; BoxCollider2D obj = val.AddComponent<BoxCollider2D>(); ((Collider2D)obj).isTrigger = true; obj.size = new Vector2(8f, 8f); val.AddComponent<SkillTrigger>().SetInfo(((Scene)(ref scene)).name, num, text); SceneManager.MoveGameObjectToScene(val, scene); _activeTriggers.Add(val); Plugin.Log.LogInfo((object)$"触发器创建: {((Scene)(ref scene)).name} 索引 {num}"); } } } } private static bool IsItemRandomEnabled() { try { PropertyInfo propertyInfo = Type.GetType("SilksongItemRandomizer.Plugin, SilksongItemRandomizer")?.GetProperty("PublicItemRandomEnabled", BindingFlags.Static | BindingFlags.Public); if (propertyInfo != null) { return (bool)propertyInfo.GetValue(null); } } catch { } return false; } private static void LoadTriggerRecords() { try { if (File.Exists(TriggerRecordsPath)) { _triggeredRecords = JsonConvert.DeserializeObject<HashSet<string>>(File.ReadAllText(TriggerRecordsPath)) ?? new HashSet<string>(); } else { _triggeredRecords.Clear(); } } catch { _triggeredRecords.Clear(); } } private static void SaveTriggerRecords() { try { string directoryName = Path.GetDirectoryName(TriggerRecordsPath); if (!Directory.Exists(directoryName)) { Directory.CreateDirectory(directoryName); } string contents = JsonConvert.SerializeObject((object)_triggeredRecords, (Formatting)1); File.WriteAllText(TriggerRecordsPath, contents); } catch { } } internal static void RecordTriggered(string key) { if (_triggeredRecords.Add(key)) { SaveTriggerRecords(); } } } [BepInPlugin("YourName.SkillTriggerMod", "Skill Trigger Mod", "1.0.0.0")] public class Plugin : BaseUnityPlugin { [CompilerGenerated] private sealed class <WaitForGameReady>d__18 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <WaitForGameReady>d__18(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; goto IL_003f; case 1: <>1__state = -1; goto IL_003f; case 2: <>1__state = -1; goto IL_0065; case 3: { <>1__state = -1; SkillTriggerAPI.MarkGameReady(); return false; } IL_003f: if ((Object)(object)GameManager.instance == (Object)null) { <>2__current = null; <>1__state = 1; return true; } goto IL_0065; IL_0065: if (string.IsNullOrEmpty(GameManager.instance.sceneName)) { <>2__current = null; <>1__state = 2; return true; } <>2__current = null; <>1__state = 3; return true; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } internal static ManualLogSource Log; internal static Plugin Instance { get; private set; } public static ConfigEntry<int> RandomSeed { get; private set; } public static ConfigEntry<bool> ModEnabled { get; private set; } public static ConfigEntry<string> CustomPositionsJson { get; private set; } private void Awake() { Instance = this; Log = ((BaseUnityPlugin)this).Logger; RandomSeed = ((BaseUnityPlugin)this).Config.Bind<int>("General", "RandomSeed", 0, "随机种子 (0 表示随机)"); ModEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ModEnabled", true, "启用技能触发器模组"); CustomPositionsJson = ((BaseUnityPlugin)this).Config.Bind<string>("General", "CustomPositionsJson", "", "自定义触发器坐标 JSON(高级)"); SkillTriggerAPI.Initialize(new SkillTriggerConfig { Seed = RandomSeed.Value, Enabled = ModEnabled.Value, AutoDisableShrines = true, TriggerPositions = ParseTriggerPositions() }); ModEnabled.SettingChanged += delegate { SkillTriggerAPI.SetEnabled(ModEnabled.Value); }; RandomSeed.SettingChanged += delegate { SkillTriggerAPI.SetSeed(RandomSeed.Value); }; CustomPositionsJson.SettingChanged += delegate { SkillTriggerAPI.SetTriggerPositions(ParseTriggerPositions()); }; ((MonoBehaviour)this).StartCoroutine(WaitForGameReady()); } [IteratorStateMachine(typeof(<WaitForGameReady>d__18))] private IEnumerator WaitForGameReady() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <WaitForGameReady>d__18(0); } private List<TriggerPosition> ParseTriggerPositions() { List<TriggerPosition> result = new List<TriggerPosition> { new TriggerPosition("Mosstown_02", 86.922f, 52.568f, 0.004f, 0), new TriggerPosition("Crawl_05", 23.032f, 16.568f, 0.004f, 1), new TriggerPosition("Shellwood_10", 40.643f, 79.57f, 0.004f, 2), new TriggerPosition("Greymoor_22", 39.783f, 36.826f, 0.004f, 3), new TriggerPosition("Bone_East_05", 100.062f, 13.568f, 0.004f, 4), new TriggerPosition("Under_18", 26f, 13f, 0.004f, 5) }; string text = CustomPositionsJson.Value?.Trim(); if (string.IsNullOrEmpty(text)) { return result; } try { List<TriggerPosition> list = JsonConvert.DeserializeObject<List<TriggerPosition>>(text); if (list != null && list.Count > 0) { return list; } } catch (Exception ex) { Log.LogError((object)("解析自定义坐标失败: " + ex.Message)); } return result; } public static void ResetAllRecords() { SkillTriggerAPI.ResetAllRecords(); } } public class SkillTrigger : MonoBehaviour { private bool _triggered; private string _sceneName; private int _index; private string _recordKey; public void SetInfo(string sceneName, int index, string recordKey) { _sceneName = sceneName; _index = index; _recordKey = recordKey; } private void OnTriggerEnter2D(Collider2D other) { if (!_triggered && !((Object)(object)((Component)other).GetComponent<HeroController>() == (Object)null)) { _triggered = true; if (_sceneName == "Shellwood_10") { SkillRandomizer.GiveWallJump(); } else if (_sceneName == "Under_18") { SkillRandomizer.GiveHarpoonDash(); } else { SkillRandomizer.GiveRandomSkill(); } SkillTriggerAPI.RecordTriggered(_recordKey); Object.Destroy((Object)(object)((Component)this).gameObject); } } } public static class SkillRandomizer { private static readonly Dictionary<string, string> DisplayNames = new Dictionary<string, string> { { "hasNeedleThrow", "丝之矛" }, { "hasThreadSphere", "灵丝风暴" }, { "hasHarpoonDash", "飞针" }, { "hasSilkCharge", "丝刃标" }, { "hasSilkBomb", "符文之怒" }, { "hasSilkBossNeedle", "苍白之爪" }, { "hasNeedolin", "丝忆弦针" }, { "hasDash", "疾风步" }, { "hasBrolly", "流浪者披风" }, { "hasDoubleJump", "雪绒披风" }, { "hasChargeSlash", "蓄力斩" }, { "hasSuperJump", "灵丝升腾" }, { "hasWallJump", "蛛攀术" } }; private static readonly List<string> AllFields = DisplayNames.Keys.ToList(); private static Random _rng; private static int _seed; private static Dictionary<string, Sprite> _icons = new Dictionary<string, Sprite>(); private static Sprite _fallback; private static bool _cacheBuilt; private static readonly Dictionary<string, string> BestPickNames = new Dictionary<string, string> { { "hasNeedleThrow", "Silk Spear" }, { "hasThreadSphere", "Thread Sphere" }, { "hasHarpoonDash", "prompt_hornet_silk_dash" }, { "hasSilkCharge", "Silk Charge" }, { "hasSilkBomb", "Silk Bomb" }, { "hasSilkBossNeedle", "Silk Boss Needle" }, { "hasNeedolin", "Needolin_Prompt" }, { "hasDash", "prompt_swiftstep" }, { "hasBrolly", "prompt_hornet_umbrella" }, { "hasDoubleJump", "Hornet_Double_Jump_Prompt" }, { "hasChargeSlash", "charge_dash_slash" }, { "hasSuperJump", "prompt_super_jump" }, { "hasWallJump", "Wall_Jump_Prompt" } }; private static readonly Dictionary<string, string[]> FallbackKeywords = new Dictionary<string, string[]> { { "hasNeedleThrow", new string[5] { "Silk Spear", "SilkSpear", "NeedleThrow", "needle", "spear" } }, { "hasThreadSphere", new string[6] { "Thread Storm", "ThreadStorm", "ThreadSphere", "thread", "storm", "sphere" } }, { "hasHarpoonDash", new string[5] { "Clawline", "Harpoon Dash", "HarpoonDash", "harpoon", "dash" } }, { "hasSilkCharge", new string[5] { "Sharpdart", "Silk Charge", "SilkCharge", "sharpdart", "silk charge" } }, { "hasSilkBomb", new string[7] { "Rune Rage", "RuneRage", "Silk Bomb", "SilkBomb", "rune", "rage", "silk bomb" } }, { "hasSilkBossNeedle", new string[8] { "Pale Nails", "PaleNails", "Silk Boss Needle", "SilkBossNeedle", "pale", "nail", "needle", "boss" } }, { "hasNeedolin", new string[2] { "Needolin", "needolin" } }, { "hasDash", new string[6] { "Swift Step", "SwiftStep", "Dash", "dash", "swift", "step" } }, { "hasBrolly", new string[8] { "Drifter's Cloak", "DriftersCloak", "Drifter", "Brolly", "Umbrella", "brolly", "drifter", "cloak" } }, { "hasDoubleJump", new string[7] { "Faydown Cloak", "FaydownCloak", "Double Jump", "DoubleJump", "faydown", "double", "jump" } }, { "hasChargeSlash", new string[7] { "Needle Strike", "NeedleStrike", "Charge Slash", "ChargeSlash", "needle strike", "charge", "slash" } }, { "hasSuperJump", new string[7] { "Silk Soar", "SilkSoar", "Super Jump", "SuperJump", "silk soar", "super", "jump" } }, { "hasWallJump", new string[8] { "Cling Grip", "ClingGrip", "Wall Jump", "WallJump", "cling", "grip", "wall", "jump" } } }; public static void SetSeed(int seed) { _seed = seed; _rng = ((seed == 0) ? new Random() : new Random(seed)); _cacheBuilt = false; } private static void BuildIconCache() { if (_cacheBuilt) { return; } _cacheBuilt = true; _icons.Clear(); SavedItem[] source = Resources.FindObjectsOfTypeAll<SavedItem>(); Sprite[] source2 = Resources.FindObjectsOfTypeAll<Sprite>(); foreach (string allField in AllFields) { bool flag = false; if (BestPickNames.TryGetValue(allField, out var bestName)) { SavedItem val = ((IEnumerable<SavedItem>)source).FirstOrDefault((Func<SavedItem, bool>)((SavedItem i) => Object.op_Implicit((Object)(object)i) && string.Equals(((Object)i).name, bestName, StringComparison.OrdinalIgnoreCase))); if ((Object)(object)val != (Object)null) { try { Sprite popupIcon = val.GetPopupIcon(); if (Object.op_Implicit((Object)(object)popupIcon)) { _icons[allField] = popupIcon; flag = true; } } catch { } } if (!flag) { Sprite val2 = ((IEnumerable<Sprite>)source2).FirstOrDefault((Func<Sprite, bool>)((Sprite s) => Object.op_Implicit((Object)(object)s) && string.Equals(((Object)s).name, bestName, StringComparison.OrdinalIgnoreCase))); if ((Object)(object)val2 != (Object)null) { _icons[allField] = val2; flag = true; } } } if (!flag && FallbackKeywords.TryGetValue(allField, out var keywords)) { SavedItem val3 = ((IEnumerable<SavedItem>)source).FirstOrDefault((Func<SavedItem, bool>)((SavedItem i) => Object.op_Implicit((Object)(object)i) && !string.IsNullOrEmpty(((Object)i).name) && keywords.Any((string k) => ((Object)i).name.ToLower().Contains(k.ToLower())))); if ((Object)(object)val3 != (Object)null) { try { Sprite popupIcon2 = val3.GetPopupIcon(); if (Object.op_Implicit((Object)(object)popupIcon2)) { _icons[allField] = popupIcon2; flag = true; } } catch { } } if (!flag) { Sprite val4 = ((IEnumerable<Sprite>)source2).FirstOrDefault((Func<Sprite, bool>)((Sprite s) => Object.op_Implicit((Object)(object)s) && !string.IsNullOrEmpty(((Object)s).name) && keywords.Any((string k) => ((Object)s).name.ToLower().Contains(k.ToLower())))); if ((Object)(object)val4 != (Object)null) { _icons[allField] = val4; flag = true; } } } if (!flag) { Plugin.Log.LogWarning((object)("✗ " + allField + " 未找到图标")); } } if (!((Object)(object)_fallback == (Object)null)) { return; } SavedItem val5 = ((IEnumerable<SavedItem>)source).FirstOrDefault((Func<SavedItem, bool>)((SavedItem i) => Object.op_Implicit((Object)(object)i) && ((Object)i).name.Contains("Rosary"))); if (Object.op_Implicit((Object)(object)val5)) { try { _fallback = val5.GetPopupIcon(); } catch { } } if ((Object)(object)_fallback == (Object)null) { _fallback = ((IEnumerable<Sprite>)source2).FirstOrDefault((Func<Sprite, bool>)((Sprite s) => Object.op_Implicit((Object)(object)s) && ((Object)s).name.Contains("Rosary"))); } } private static Sprite GetIcon(string field) { BuildIconCache(); if (!_icons.TryGetValue(field, out var value)) { return _fallback; } return value; } public static void GiveRandomSkill() { try { PlayerData instance = PlayerData.instance; if (instance == null) { return; } List<string> list = new List<string>(); foreach (string allField in AllFields) { FieldInfo field = typeof(PlayerData).GetField(allField, BindingFlags.Instance | BindingFlags.Public); if (field != null && field.FieldType == typeof(bool) && !(bool)field.GetValue(instance)) { list.Add(allField); } } if (list.Count == 0) { GiveWallJump(); } else { SkillRandomizer.GiveSkill(list[(_rng ?? (_rng = new Random())).Next(list.Count)]); } } catch (Exception arg) { Plugin.Log.LogError((object)$"GiveRandomSkill 异常: {arg}"); } } public static void GiveWallJump() { try { string text = "hasWallJump"; PlayerData instance = PlayerData.instance; FieldInfo field = typeof(PlayerData).GetField(text, BindingFlags.Instance | BindingFlags.Public); if (!(field == null) && !(bool)field.GetValue(instance)) { SkillRandomizer.GiveSkill(text); } } catch (Exception arg) { Plugin.Log.LogError((object)$"GiveWallJump 异常: {arg}"); } } public static void GiveHarpoonDash() { try { string text = "hasHarpoonDash"; PlayerData instance = PlayerData.instance; FieldInfo field = typeof(PlayerData).GetField(text, BindingFlags.Instance | BindingFlags.Public); if (!(field == null) && !(bool)field.GetValue(instance)) { SkillRandomizer.GiveSkill(text); } } catch (Exception arg) { Plugin.Log.LogError((object)$"GiveHarpoonDash 异常: {arg}"); } } } }
BepInEx/plugins/StartingAbilityPicker.dll
Decompiled 2 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HKSilksong_Randomizer; using HarmonyLib; using HutongGames.PlayMaker; using HutongGames.PlayMaker.Actions; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using SilksongItemRandomizer; using TeamCherry.Localization; using UnityEngine; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyCompany("StartingAbilityPicker")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("0.1.0.0")] [assembly: AssemblyInformationalVersion("0.1.0")] [assembly: AssemblyProduct("StartingAbilityPicker")] [assembly: AssemblyTitle("StartingAbilityPicker")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/YourGitHubUsername/StartingAbilityPicker")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.1.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.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 StartingAbilityPicker { public static class CrazyRandomizer { private static readonly Random GlobalRng = new Random(); public static void Apply(Plugin plugin) { Plugin.allowUpward = GlobalRng.Next(2) == 1; Plugin.allowLeft = GlobalRng.Next(2) == 1; Plugin.allowRight = GlobalRng.Next(2) == 1; Plugin.skillMode = true; Plugin.skillV = WeightedRandom(5, GlobalRng); Plugin.skillH = WeightedRandom(4, GlobalRng); Plugin.skillS = WeightedRandom(4, GlobalRng); Plugin.skillA = WeightedRandom(5, GlobalRng); if (Plugin.skillV == 0) { Plugin.skillV = 1; } if (Plugin.skillH == 0) { Plugin.skillH = 1; } Plugin.itemCount = WeightedRandom(10, GlobalRng); Plugin.seedInput = GlobalRng.Next(1, int.MaxValue).ToString(); } private static int WeightedRandom(int max, Random rng) { if (max <= 0) { return 0; } int num = 0; for (int i = 0; i <= max; i++) { int num2 = max - i + 1; num += num2 * num2; } int num3 = rng.Next(num); int num4 = 0; for (int j = 0; j <= max; j++) { int num5 = max - j + 1; num4 += num5 * num5; if (num3 < num4) { return j; } } return 0; } } public static class Locale { private static bool? _forceChinese; private static Dictionary<string, string> _externalTranslations; private static string _languageFolderPath; private static bool _isLoaded; private static readonly Dictionary<string, string> FallbackEnglish = new Dictionary<string, string> { { "开局选项 & 场景随机", "Startup Options & Scene Randomizer" }, { "当前存档开局设置:", "Current Save Startup Settings:" }, { "(此存档已设置过,只能查看)", "(This save has been configured, view only)" }, { "重置本存档设置", "Reset This Save's Settings" }, { "攻击方向选择:", "Attack Direction Selection:" }, { "下劈 (默认)", "Down Slash (Default)" }, { "上劈", "Up Slash" }, { "左劈", "Left Slash" }, { "右劈", "Right Slash" }, { "技能随机模式:", "Skill Random Mode:" }, { "总随机", "Total Mode" }, { "分类随机", "Type Mode" }, { "开局随机技能总数量:", "Total Random Skills:" }, { "分类随机数量:", "Category Random Count:" }, { "垂直技能", "Vertical Skills" }, { "水平技能", "Horizontal Skills" }, { "特殊技能", "Special Skills" }, { "攻击技能", "Attack Skills" }, { "开局随机物品数量:", "Starting Random Item Count:" }, { "种子", "Seed" }, { "重置种子世界(含技能触发器)", "Reset Seed World (incl. Skill Triggers)" }, { "警告:重置后当前种子世界将重新生成,所有拾取点会重生,技能触发器也会重置。", "Warning: This will regenerate the seed world, respawn all pickups, and reset skill triggers." }, { "确认", "Confirm" }, { "关闭", "Close" }, { "提示: 按 F7 呼出此窗口", "Tip: Press F7 to open this window" }, { "彻底疯狂", "Crazy Mode" }, { "纹章诅咒", "Crest Curse" }, { "启用纹章诅咒(每个纹章带有偏科效果)", "Enable Crest Curse (each crest has specialized effects)" }, { "丝之心、疾跑和上冲", "Silk Heart, Dash & Super Jump" }, { "[开]", "[ON]" }, { "[关]", "[OFF]" }, { "启用物品随机", "Enable Item Randomizer" }, { "场景随机未加载", "Scene Randomizer Not Loaded" }, { "场景随机设置", "Scene Randomizer" }, { "启用场景随机", "Enable Randomizer" }, { "启用陷阱随机", "Enable Trap Randomizer" }, { "陷阱、房间随机建议丝之心,疾跑和上冲", "Trap & Room Randomizer: Silk Heart, Dash & Super Jump recommended" }, { "陷阱难度:", "Trap Difficulty:" }, { "初猎", "Beginner" }, { "专注", "Focused" }, { "满溢", "Overflow" }, { "当前种子", "Current Seed" }, { "当前场景", "Current Scene" }, { "修改种子:", "Modify Seed:" }, { "应用种子", "Apply Seed" }, { "场景传送:", "Teleport:" }, { "传送", "Teleport" }, { "稍后传送至", "Teleporting to " }, { "场景连接已重新生成", "Regenerated" }, { "显示选项:", "Display:" }, { "显示当前场景名", "Show Scene Name" }, { "显示当前种子", "Show Seed" }, { "陷阱生命化", "Trap Life" }, { "完成度", "Completion" }, { "直接应用可随机", "Apply directly to randomize" }, { "启用怪物随机", "Enable Enemy Randomizer" }, { "面板背景", "Panel Background" }, { "全随机模式", "Full Random Mode" }, { "CN", "CN" }, { "EN", "EN" }, { "Auto", "Auto" }, { "Current Seed: ", "Current Seed: " }, { "Seed: ", "Seed: " }, { "Scene: ", "Scene: " }, { "正在传送到 ", "Teleporting to " }, { "纹章槽位已满,获得 100 念珠", "Crest slots full, gained 100 Geo" }, { "纹章槽位 {0} ({1}) 已解锁!", "Crest slot {0} ({1}) unlocked!" }, { "纹章槽位解锁器", "Crest Slot Unlocker" }, { "小生命", "Small Health" }, { "中灵丝", "Medium Silk" }, { "大念珠", "Large Geo" }, { "完全恢复", "Full Restore" }, { "面具碎片", "Mask Shard" }, { "丝轴碎片", "Spool Part" }, { "丝线恢复上限 +1", "Max Silk Regen +1" }, { "随机念珠", "Random Geo" }, { "随机蓝血", "Random Blue Health" }, { "丝之矛", "Silk Spear" }, { "灵丝风暴", "Thread Sphere" }, { "飞针", "Harpoon Dash" }, { "丝刃标", "Silk Charge" }, { "符文之怒", "Silk Bomb" }, { "苍白之爪", "Silk Boss Needle" }, { "丝忆弦针", "Needolin" }, { "疾风步", "Swift Step" }, { "流浪者披风", "Drifter's Cloak" }, { "雪绒披风", "Faydown Cloak" }, { "蓄力斩", "Charge Slash" }, { "灵丝升腾", "Silk Soar" }, { "蛛攀术", "Cling Grip" }, { "风铃摇", "EvaHeal" }, { "格挡", "Cross Stitch" }, { "深邃挽歌", "Deep Elegy" }, { "幻兽歌", "Beast Song" }, { "最近获得物品", "Recent Items" }, { "按 F6 可直接传送", "Press F6 to warp directly" }, { "攻击槽", "Attack Slot" }, { "工具槽", "Tool Slot" }, { "法术槽", "Spell Slot" }, { "未知", "Unknown" }, { "保底念珠", "Fallback Geo" }, { "灵丝", "Silk" }, { "蓝血", "Blue Health" }, { "念珠", "Geo" }, { "甲壳", "Shell" }, { "大灵丝碎片", "Large Silk Part" }, { "小念珠", "Small Geo" }, { "灵丝碎片", "Silk Fragment" }, { "生命", "Health" }, { "丝线恢复上限", "Max Silk Regen" } }; public static bool IsChinese { get { if (_forceChinese.HasValue) { return _forceChinese.Value; } return DetectChinese(); } } public static void SetLanguageFolder(string path) { if (!string.IsNullOrEmpty(path) && Directory.Exists(path)) { _languageFolderPath = path; _isLoaded = false; } } public static void SetForceChinese(bool? force) { _forceChinese = force; } public static void Reload() { _isLoaded = false; _externalTranslations = null; } public static string Get(string chineseText) { if (string.IsNullOrEmpty(chineseText)) { return chineseText; } EnsureLoaded(); if (_externalTranslations != null && _externalTranslations.TryGetValue(chineseText, out var value)) { return value; } if (IsChinese) { return chineseText; } if (FallbackEnglish.TryGetValue(chineseText, out var value2)) { return value2; } return chineseText; } private static void EnsureLoaded() { if (_isLoaded) { return; } _externalTranslations = null; _isLoaded = true; string text = _languageFolderPath; if (string.IsNullOrEmpty(text)) { text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "language"); } if (!Directory.Exists(text)) { Debug.LogWarning((object)("[Locale] Language folder not found: " + text)); return; } List<string> list = (from f in Directory.GetFiles(text, "*.json") orderby Path.GetFileName(f) select f).ToList(); if (list.Count == 0) { Debug.LogWarning((object)("[Locale] No JSON files found in " + text)); return; } Dictionary<string, string> dictionary = new Dictionary<string, string>(); foreach (string item in list) { try { Dictionary<string, string> dictionary2 = JsonConvert.DeserializeObject<Dictionary<string, string>>(File.ReadAllText(item)); if (dictionary2 == null) { continue; } foreach (KeyValuePair<string, string> item2 in dictionary2) { dictionary[item2.Key] = item2.Value; } Debug.Log((object)$"[Locale] Loaded {dictionary2.Count} entries from {Path.GetFileName(item)}"); } catch (Exception ex) { Debug.LogError((object)("[Locale] Failed to load " + item + ": " + ex.Message)); } } if (dictionary.Count > 0) { _externalTranslations = dictionary; Debug.Log((object)$"[Locale] Total external translations: {_externalTranslations.Count}"); } } private static bool DetectChinese() { try { Type type = Type.GetType("FontManager, Assembly-CSharp"); if (type != null) { FieldInfo field = type.GetField("_currentLanguage", BindingFlags.Static | BindingFlags.NonPublic); if (field != null) { object value = field.GetValue(null); if (value != null) { string text = value.ToString().ToUpper(); if (text == "ZH" || text == "ZH_TW") { return true; } } } } } catch { } try { GameSettings val = GameManager.instance?.gameSettings; if (val != null) { FieldInfo field2 = ((object)val).GetType().GetField("language", BindingFlags.Instance | BindingFlags.Public); if (field2 != null) { object value2 = field2.GetValue(val); if (value2 != null) { string text2 = value2.ToString().ToUpper(); if (text2 == "ZH" || text2 == "ZH_TW") { return true; } } } } } catch { } return false; } } public static class PanelRenderer { private static readonly Color BrightWhite = new Color(0.95f, 0.97f, 1f); private static GUIStyle _titleStyle; private static GUIStyle _statusStyle; private static GUIStyle _diffTitleStyle; private static GUIStyle _diffStatusStyle; private static Vector2 _skillScrollPos; private static void EnsureStyles() { //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_0020: 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_002f: 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_0044: Expected O, but got Unknown //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown //IL_0081: 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_008d: 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_009c: 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_00b1: Expected O, but got Unknown //IL_00bb: 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_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: 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_00e4: Expected O, but got Unknown if (_titleStyle == null) { GUIStyle val = new GUIStyle(GUI.skin.label) { alignment = (TextAnchor)1, fontSize = 14, fontStyle = (FontStyle)1 }; val.normal.textColor = BrightWhite; _titleStyle = val; GUIStyle val2 = new GUIStyle(GUI.skin.label) { alignment = (TextAnchor)7, fontSize = 11 }; val2.normal.textColor = BrightWhite; _statusStyle = val2; GUIStyle val3 = new GUIStyle(GUI.skin.label) { alignment = (TextAnchor)1, fontSize = 18, fontStyle = (FontStyle)1 }; val3.normal.textColor = BrightWhite; _diffTitleStyle = val3; GUIStyle val4 = new GUIStyle(GUI.skin.label) { alignment = (TextAnchor)7, fontSize = 15 }; val4.normal.textColor = BrightWhite; _diffStatusStyle = val4; } } public static void DrawLeftPanel(Plugin p) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_006f: 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_025c: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_0275: 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_020e: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: Unknown result type (might be due to invalid IL or missing references) //IL_031b: Unknown result type (might be due to invalid IL or missing references) //IL_0344: Unknown result type (might be due to invalid IL or missing references) //IL_0359: Unknown result type (might be due to invalid IL or missing references) //IL_036e: Unknown result type (might be due to invalid IL or missing references) //IL_0383: Unknown result type (might be due to invalid IL or missing references) //IL_0398: Unknown result type (might be due to invalid IL or missing references) Color textColor = GUI.skin.label.normal.textColor; GUI.skin.label.normal.textColor = BrightWhite; GUI.skin.toggle.normal.textColor = BrightWhite; GUI.skin.button.normal.textColor = BrightWhite; GUI.skin.horizontalSlider.normal.textColor = BrightWhite; GUI.skin.textField.normal.textColor = BrightWhite; GUI.skin.label.fontSize = 20; GUI.skin.toggle.fontSize = 20; GUI.skin.button.fontSize = 24; GUI.skin.horizontalSlider.fontSize = 18; GUI.skin.textField.fontSize = 18; GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label(Locale.Get("当前存档开局设置:"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(40f) }); DrawBackgroundToggle(p); GUILayout.EndHorizontal(); GUILayout.Space(15f); bool flag = IsAlreadyChosen(p); if (flag) { GUILayout.Label(Locale.Get("(此存档已设置过,只能查看)"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(35f) }); GUI.backgroundColor = new Color(0.8f, 0.5f, 0.2f); if (GUILayout.Button(Locale.Get("重置本存档设置"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(45f) })) { ResetProfile(p); GUI.backgroundColor = Color.white; GUI.skin.label.normal.textColor = textColor; GUI.skin.toggle.normal.textColor = textColor; GUI.skin.button.normal.textColor = textColor; GUI.skin.horizontalSlider.normal.textColor = textColor; GUI.skin.textField.normal.textColor = textColor; return; } GUI.backgroundColor = Color.white; } GUILayout.Space(20f); DrawAttackDirection(p, flag); GUILayout.Space(20f); DrawSkillModeButtons(p, flag); GUILayout.Space(10f); GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(200f) }); _skillScrollPos = GUILayout.BeginScrollView(_skillScrollPos, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandHeight(true) }); if (!StartingAbilityPickerAPI.GetSkillRandomMode()) { DrawTotalSlider(p, flag); } else { DrawCategorySliders(p, flag); } GUILayout.EndScrollView(); GUILayout.EndVertical(); GUILayout.Space(15f); DrawItemSlider(p, flag); GUILayout.Space(25f); DrawSeedInput(p, flag); DrawConfirmAndClose(p, flag); GUILayout.Space(15f); int fontSize = GUI.skin.label.fontSize; GUI.skin.label.fontSize = 26; GUI.color = Color.yellow; GUILayout.Label(Locale.Get("提示: 按 F7 呼出此窗口"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(40f) }); GUI.color = BrightWhite; GUI.skin.label.fontSize = fontSize; GUI.skin.label.normal.textColor = textColor; GUI.skin.toggle.normal.textColor = textColor; GUI.skin.button.normal.textColor = textColor; GUI.skin.horizontalSlider.normal.textColor = textColor; GUI.skin.textField.normal.textColor = textColor; } public static void DrawScenePanel(Plugin p) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_0099: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Unknown result type (might be due to invalid IL or missing references) Color textColor = GUI.skin.label.normal.textColor; GUI.skin.label.normal.textColor = BrightWhite; GUI.skin.button.normal.textColor = BrightWhite; GUI.skin.toggle.normal.textColor = BrightWhite; if (!p.SceneRandomAvailable) { GUILayout.Label(Locale.Get("场景随机未加载"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) }); GUI.skin.label.normal.textColor = textColor; return; } GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); if (GUILayout.Button("CN", (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Height(20f), GUILayout.Width(60f) })) { Locale.SetForceChinese(true); } if (GUILayout.Button("EN", (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Height(20f), GUILayout.Width(60f) })) { Locale.SetForceChinese(false); } if (GUILayout.Button("Auto", (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Height(20f), GUILayout.Width(60f) })) { Locale.SetForceChinese(null); } GUILayout.EndHorizontal(); GUILayout.Space(8f); GUILayout.Label(Locale.Get("场景随机设置"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) }); GUILayout.Space(12f); DrawItemRandomToggle(p); DrawSceneToggle(p); DrawEnemyRandoAdjustToggle(p); DrawTrapToggle(p); DrawTrapDifficulty(p); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); DrawTrapMovementToggle(p); GUILayout.Space(12f); int currentRoomSeed = StartingAbilityPickerAPI.GetCurrentRoomSeed(); GUILayout.Label(string.Format("{0}: {1}", Locale.Get("当前种子"), currentRoomSeed), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) }); GUILayout.Space(8f); string currentRoomScene = StartingAbilityPickerAPI.GetCurrentRoomScene(); GUILayout.Label(Locale.Get("当前场景") + ": " + currentRoomScene, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) }); GUILayout.Space(18f); DrawSeedChanger(p); GUILayout.Space(20f); DrawTeleporter(p); GUILayout.Space(20f); DrawDisplayToggles(p); GUI.skin.label.normal.textColor = textColor; GUI.skin.button.normal.textColor = textColor; GUI.skin.toggle.normal.textColor = textColor; } private static bool IsAlreadyChosen(Plugin p) { int item = GameManager.instance?.profileID ?? (-1); if (typeof(Plugin).GetField("chosenProfileSet", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(p) is HashSet<int> hashSet) { return hashSet.Contains(item); } return false; } private static void ResetProfile(Plugin p) { int item = GameManager.instance?.profileID ?? (-1); (typeof(Plugin).GetField("chosenProfileSet", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(p) as HashSet<int>)?.Remove(item); typeof(Plugin).GetMethod("SaveChosenProfiles", BindingFlags.Instance | BindingFlags.NonPublic)?.Invoke(p, null); StartingAbilityPickerAPI.SetAttackPermissions(up: false, left: false, right: false); StartingAbilityPickerAPI.SetStartingItemCount(0); StartingAbilityPickerAPI.SetResetSeedWorld(reset: false); StartingAbilityPickerAPI.SetSkillRandomMode(useTypeMode: false); StartingAbilityPickerAPI.SetSkillCounts(0, 0, 0, 0, 0); RoomRandomMode.ResetPending(); } private static void DrawAttackDirection(Plugin p, bool alreadyChosen) { GUILayout.Label(Locale.Get("攻击方向选择:"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(35f) }); GUILayout.Space(5f); GUI.enabled = false; DrawModeButton("下劈 (默认)", true, 18, GUILayout.Width(220f), GUILayout.Height(60f)); GUI.enabled = !alreadyChosen && !StartingAbilityPickerAPI.GetFullRandomMode(); bool item = StartingAbilityPickerAPI.GetAttackPermissions().up; bool flag = DrawModeButton(Locale.Get("上劈"), item, 18, GUILayout.Width(220f), GUILayout.Height(60f)); if (flag != item && !alreadyChosen) { StartingAbilityPickerAPI.SetAttackPermissions(flag, StartingAbilityPickerAPI.GetAttackPermissions().left, StartingAbilityPickerAPI.GetAttackPermissions().right); } bool item2 = StartingAbilityPickerAPI.GetAttackPermissions().left; bool flag2 = DrawModeButton(Locale.Get("左劈"), item2, 18, GUILayout.Width(220f), GUILayout.Height(60f)); if (flag2 != item2 && !alreadyChosen) { StartingAbilityPickerAPI.SetAttackPermissions(StartingAbilityPickerAPI.GetAttackPermissions().up, flag2, StartingAbilityPickerAPI.GetAttackPermissions().right); } bool item3 = StartingAbilityPickerAPI.GetAttackPermissions().right; bool flag3 = DrawModeButton(Locale.Get("右劈"), item3, 18, GUILayout.Width(220f), GUILayout.Height(60f)); if (flag3 != item3 && !alreadyChosen) { StartingAbilityPickerAPI.SetAttackPermissions(StartingAbilityPickerAPI.GetAttackPermissions().up, StartingAbilityPickerAPI.GetAttackPermissions().left, flag3); } GUI.enabled = true; } private static void DrawSkillModeButtons(Plugin p, bool alreadyChosen) { //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02ca: Unknown result type (might be due to invalid IL or missing references) GUILayout.Label(Locale.Get("技能随机模式:"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(35f) }); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); bool flag = !StartingAbilityPickerAPI.GetSkillRandomMode(); if (DrawModeButton(Locale.Get("总随机"), flag, 18, GUILayout.Width(130f), GUILayout.Height(60f)) != flag && !alreadyChosen) { StartingAbilityPickerAPI.SetSkillRandomMode(useTypeMode: false); } bool skillRandomMode = StartingAbilityPickerAPI.GetSkillRandomMode(); if (DrawModeButton(Locale.Get("分类随机"), skillRandomMode, 18, GUILayout.Width(130f), GUILayout.Height(60f)) != skillRandomMode && !alreadyChosen) { StartingAbilityPickerAPI.SetSkillRandomMode(useTypeMode: true); } GUI.enabled = !alreadyChosen && !StartingAbilityPickerAPI.GetFullRandomMode(); if (DrawModeButton(Locale.Get("彻底疯狂"), false, 18, GUILayout.Width(160f), GUILayout.Height(60f)) && !alreadyChosen) { CrazyRandomizer.Apply(p); } GUI.enabled = true; bool isPending = RoomRandomMode.IsPending; if (DrawModeButton(Locale.Get("丝之心、疾跑和上冲"), isPending, 14, GUILayout.Width(160f), GUILayout.Height(60f)) != isPending && !alreadyChosen) { RoomRandomMode.Toggle(); } GUILayout.EndHorizontal(); GUILayout.Space(8f); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.FlexibleSpace(); GUI.enabled = !alreadyChosen; bool fullRandomMode = StartingAbilityPickerAPI.GetFullRandomMode(); bool flag2 = DrawModeButton(Locale.Get("全随机模式"), fullRandomMode, 18, GUILayout.Width(260f), GUILayout.Height(60f)); if (flag2 != fullRandomMode && !alreadyChosen) { StartingAbilityPickerAPI.SetFullRandomMode(flag2); } GUI.enabled = true; GUILayout.EndHorizontal(); GUILayout.Space(10f); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.FlexibleSpace(); bool crestCurseEnabled = StartingAbilityPickerAPI.GetCrestCurseEnabled(); GUI.enabled = !alreadyChosen; bool flag3 = DrawModeButton(Locale.Get("纹章诅咒"), crestCurseEnabled, 18, GUILayout.Width(160f), GUILayout.Height(60f)); if (flag3 != crestCurseEnabled && !alreadyChosen) { StartingAbilityPickerAPI.SetCrestCurseEnabled(flag3); } bool forceCompletionDisplay = StartingAbilityPickerAPI.GetForceCompletionDisplay(); bool flag4 = DrawModeButton(Locale.Get("完成度"), forceCompletionDisplay, 18, GUILayout.Width(160f), GUILayout.Height(60f)); if (flag4 != forceCompletionDisplay && !alreadyChosen) { StartingAbilityPickerAPI.SetForceCompletionDisplay(flag4); } GUI.enabled = true; GUILayout.EndHorizontal(); if (crestCurseEnabled) { GUILayout.Space(5f); GUI.color = Color.yellow; GUILayout.Label(Locale.Get("启用纹章诅咒(每个纹章带有偏科效果)"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) }); GUI.color = BrightWhite; } } private static void DrawTotalSlider(Plugin p, bool alreadyChosen) { GUILayout.Label(Locale.Get("开局随机技能总数量:"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(35f) }); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); int item = StartingAbilityPickerAPI.GetSkillCounts().total; GUILayout.Label(item.ToString(), (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(35f), GUILayout.Height(40f) }); int num = (int)GUILayout.HorizontalSlider((float)item, 0f, 13f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(220f) }); if (num != item && !alreadyChosen) { StartingAbilityPickerAPI.SetSkillCounts(num, StartingAbilityPickerAPI.GetSkillCounts().v, StartingAbilityPickerAPI.GetSkillCounts().h, StartingAbilityPickerAPI.GetSkillCounts().s, StartingAbilityPickerAPI.GetSkillCounts().a); } GUILayout.EndHorizontal(); GUILayout.Space(10f); } private static void DrawCategorySliders(Plugin p, bool alreadyChosen) { GUILayout.Label(Locale.Get("分类随机数量:"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(35f) }); (int, int, int, int, int) skillCounts = StartingAbilityPickerAPI.GetSkillCounts(); DrawOneSlider(Locale.Get("垂直技能"), ref skillCounts.Item2, Plugin.MaxVerticalDynamic, alreadyChosen); DrawOneSlider(Locale.Get("水平技能"), ref skillCounts.Item3, Plugin.MaxHorizontalDynamic, alreadyChosen); DrawOneSlider(Locale.Get("特殊技能"), ref skillCounts.Item4, Plugin.MaxSpecialDynamic, alreadyChosen); DrawOneSlider(Locale.Get("攻击技能"), ref skillCounts.Item5, Plugin.MaxAttackDynamic, alreadyChosen); StartingAbilityPickerAPI.SetSkillCounts(skillCounts.Item1, skillCounts.Item2, skillCounts.Item3, skillCounts.Item4, skillCounts.Item5); } private static void DrawOneSlider(string label, ref int value, int max, bool disabled) { GUILayout.Label($"{label} (0-{max})", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) }); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label(value.ToString(), (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(35f), GUILayout.Height(40f) }); int num = (int)GUILayout.HorizontalSlider((float)value, 0f, (float)max, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(220f) }); if (num != value && !disabled) { value = num; } GUILayout.EndHorizontal(); } private static void DrawItemSlider(Plugin p, bool alreadyChosen) { GUILayout.Label(Locale.Get("开局随机物品数量:"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(35f) }); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); int startingItemCount = StartingAbilityPickerAPI.GetStartingItemCount(); GUILayout.Label(startingItemCount.ToString(), (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(35f), GUILayout.Height(40f) }); int num = (int)GUILayout.HorizontalSlider((float)startingItemCount, 0f, 10f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(220f) }); if (num != startingItemCount && !alreadyChosen) { StartingAbilityPickerAPI.SetStartingItemCount(num); } GUILayout.EndHorizontal(); } private static void DrawSeedInput(Plugin p, bool alreadyChosen) { //IL_00aa: 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_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: 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) GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label(Locale.Get("种子"), (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(60f), GUILayout.Height(40f) }); string text = StartingAbilityPickerAPI.GetSeed().ToString(); string text2 = GUILayout.TextField(text, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(160f), GUILayout.Height(40f) }); if (text2 != text && !alreadyChosen && int.TryParse(text2, out var result)) { StartingAbilityPickerAPI.SetSeed(result); } GUILayout.EndHorizontal(); GUILayout.Space(5f); bool resetSeedWorld = StartingAbilityPickerAPI.GetResetSeedWorld(); GUI.color = (resetSeedWorld ? Color.red : BrightWhite); bool flag = GUILayout.Toggle(resetSeedWorld, Locale.Get("重置种子世界(含技能触发器)"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(40f) }); if (flag != resetSeedWorld && !alreadyChosen) { StartingAbilityPickerAPI.SetResetSeedWorld(flag); } GUI.color = BrightWhite; if (resetSeedWorld) { GUI.color = Color.yellow; GUILayout.Label(Locale.Get("警告:重置后当前种子世界将重新生成,所有拾取点会重生,技能触发器也会重置。"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(70f) }); GUI.color = BrightWhite; } GUILayout.Space(35f); } private static void DrawConfirmAndClose(Plugin p, bool alreadyChosen) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0082: 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) GUI.enabled = !alreadyChosen; GUI.backgroundColor = Color.green; if (GUILayout.Button(Locale.Get("确认"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(50f) }) && !alreadyChosen) { StartingAbilityPickerAPI.ApplyPending(); typeof(Plugin).GetMethod("ApplySettings", BindingFlags.Instance | BindingFlags.NonPublic)?.Invoke(p, null); } GUI.backgroundColor = Color.white; GUI.enabled = true; GUI.backgroundColor = new Color(0.8f, 0.2f, 0.2f); if (GUILayout.Button(Locale.Get("关闭"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(40f) })) { p.ShowUI = false; } GUI.backgroundColor = Color.white; } private static void DrawSceneToggle(Plugin p) { bool flag = StartingAbilityPickerAPI.IsRoomRandomizationEnabled(); bool flag2 = DrawModeButton(Locale.Get("启用场景随机"), flag, 18, GUILayout.Width(260f), GUILayout.Height(60f)); if (flag2 != flag) { StartingAbilityPickerAPI.SetRoomRandomizationEnabled(flag2); } } private static void DrawTrapToggle(Plugin p) { bool trapEnabled = GetTrapEnabled(); bool flag = DrawModeButton(Locale.Get("启用陷阱随机"), trapEnabled, 18, GUILayout.Width(260f), GUILayout.Height(60f)); if (flag != trapEnabled) { SetTrapEnabled(flag); if (flag) { TriggerTrapSpawn(); } else { TriggerTrapClear(); } } } private static void DrawItemRandomToggle(Plugin p) { bool itemRandomEnabled = p.GetItemRandomEnabled(); bool flag = DrawModeButton(Locale.Get("启用物品随机"), itemRandomEnabled, 18, GUILayout.Width(260f), GUILayout.Height(60f)); if (flag != itemRandomEnabled) { p.SetItemRandomEnabled(flag); } } private static void DrawTrapDifficulty(Plugin p) { //IL_0094: 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_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_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0138: 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_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0150: 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_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: 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_021d: Unknown result type (might be due to invalid IL or missing references) GUILayout.Label(Locale.Get("陷阱难度:"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(25f) }); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); Sprite[] array = (Sprite[])(object)new Sprite[3] { Plugin.BeginnerIcon, Plugin.FocusedIcon, Plugin.OverflowIcon }; string[] array2 = new string[3] { "初猎", "专注", "满溢" }; float num = 50f; Rect rect; if ((Object)(object)Plugin.OverflowIcon != (Object)null && (Object)(object)Plugin.OverflowIcon.texture != (Object)null) { rect = Plugin.OverflowIcon.rect; float width = ((Rect)(ref rect)).width; rect = Plugin.OverflowIcon.rect; float height = ((Rect)(ref rect)).height; num = 90f * (height / width); } EnsureStyles(); Rect val2 = default(Rect); for (int i = 0; i < 3; i++) { bool flag = GetTrapDifficulty() == i; Sprite val = array[i]; Rect rect2 = GUILayoutUtility.GetRect(90f, num, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(90f), GUILayout.Height(num) }); Color backgroundColor = (flag ? new Color(0.2f, 1f, 0.2f) : new Color(0.6f, 0.6f, 0.6f)); Color backgroundColor2 = GUI.backgroundColor; GUI.backgroundColor = backgroundColor; GUI.Box(rect2, ""); GUI.backgroundColor = backgroundColor2; if ((Object)(object)((val != null) ? val.texture : null) != (Object)null) { rect = val.rect; float width2 = ((Rect)(ref rect)).width; rect = val.rect; float height2 = ((Rect)(ref rect)).height; float num2; float num3; float num4; float num5; if (i == 0) { num2 = ((Rect)(ref rect2)).height; num3 = num2 * (width2 / height2); num4 = ((Rect)(ref rect2)).x + (((Rect)(ref rect2)).width - num3) / 2f; num5 = ((Rect)(ref rect2)).y; } else { num3 = 90f; num2 = num3 * (height2 / width2); num4 = ((Rect)(ref rect2)).x + (((Rect)(ref rect2)).width - num3) / 2f; num5 = ((Rect)(ref rect2)).y + (((Rect)(ref rect2)).height - num2) / 2f; } GUI.DrawTexture(new Rect(num4, num5, num3, num2), (Texture)(object)val.texture, (ScaleMode)0); } if (GUI.Button(rect2, "", GUIStyle.none)) { SetTrapDifficulty(i); if (GetTrapEnabled()) { TriggerTrapClear(); TriggerTrapSpawn(); } } ((Rect)(ref val2))..ctor(((Rect)(ref rect2)).x, ((Rect)(ref rect2)).y, ((Rect)(ref rect2)).width, ((Rect)(ref rect2)).height / 2f); Rect val3 = new Rect(((Rect)(ref rect2)).x, ((Rect)(ref rect2)).y + ((Rect)(ref rect2)).height / 2f, ((Rect)(ref rect2)).width, ((Rect)(ref rect2)).height / 2f); GUI.Label(val2, Locale.Get(array2[i]), _diffTitleStyle); GUI.Label(val3, flag ? Locale.Get("[开]") : Locale.Get("[关]"), _diffStatusStyle); } GUILayout.EndHorizontal(); GUILayout.Space(5f); } private static void DrawTrapMovementToggle(Plugin p) { bool trapMovementEnabled = GetTrapMovementEnabled(); bool flag = DrawModeButton(Locale.Get("陷阱生命化"), trapMovementEnabled, 18, GUILayout.Width(260f), GUILayout.Height(60f)); if (flag != trapMovementEnabled) { SetTrapMovementEnabled(flag); if (GetTrapEnabled()) { TriggerTrapClear(); TriggerTrapSpawn(); } } } private static void DrawEnemyRandoAdjustToggle(Plugin p) { bool value = Plugin.EnemyRandoAdjustEnabled.Value; bool flag = DrawModeButton(Locale.Get("启用怪物随机"), value, 18, GUILayout.Width(260f), GUILayout.Height(60f)); if (flag != value) { p.SetEnemyRandoAdjustEnabled(flag); } } private static void DrawBackgroundToggle(Plugin p) { bool value = Plugin.PanelBackgroundEnabled.Value; bool flag = DrawModeButton(Locale.Get("面板背景"), value, 18, GUILayout.Width(260f), GUILayout.Height(60f)); if (flag != value) { p.SetPanelBackgroundEnabled(flag); } } private static void DrawSeedChanger(Plugin p) { //IL_022f: 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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_009c: 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_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Expected O, but got Unknown //IL_00b5: Unknown result type (might be due to invalid IL or missing references) GUILayout.Label(Locale.Get("修改种子:"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(25f) }); string text = GUILayout.TextField(p.SceneSeedInput, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(260f), GUILayout.Height(30f) }); if (string.IsNullOrEmpty(text) && GUI.GetNameOfFocusedControl() != "SeedTextField") { Rect lastRect = GUILayoutUtility.GetLastRect(); GUI.SetNextControlName("SeedTextField"); Color color = GUI.color; GUI.color = Color.yellow; GUIStyle val = new GUIStyle(GUI.skin.label) { alignment = (TextAnchor)4, fontSize = 14 }; val.normal.textColor = GUI.color; GUIStyle val2 = val; GUI.Label(lastRect, Locale.Get("直接应用可随机"), val2); GUI.color = color; } else { GUI.SetNextControlName("SeedTextField"); } p.SceneSeedInput = text; GUILayout.Space(4f); GUI.backgroundColor = Color.green; if (GUILayout.Button(Locale.Get("应用种子"), (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Height(32f), GUILayout.Width(260f) })) { string text2 = p.SceneSeedInput.Trim(); int result; if (string.IsNullOrEmpty(text2)) { result = new Random().Next(1, int.MaxValue); } else if (!int.TryParse(text2, out result)) { return; } try { object seedManager = p.SeedManager; object obj = seedManager.GetType().GetField("cfgNewSeed", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(seedManager); object obj2 = seedManager.GetType().GetField("cfgRegenerateTrigger", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(seedManager); obj.GetType().GetProperty("Value").SetValue(obj, result, null); obj2.GetType().GetProperty("Value").SetValue(obj2, true, null); Plugin.ShowNotification(Locale.Get("场景连接已重新生成")); if (GetTrapEnabled()) { TriggerTrapClear(); SetTrapSeed(result); TriggerTrapSpawn(); } } catch (Exception arg) { Plugin.Log.LogError((object)$"场景种子更新失败: {arg}"); } } GUI.backgroundColor = Color.white; } private static void DrawTeleporter(Plugin p) { //IL_005d: 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) GUILayout.Label(Locale.Get("场景传送:"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(25f) }); p.SceneTeleportInput = GUILayout.TextField(p.SceneTeleportInput, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(260f), GUILayout.Height(30f) }); GUILayout.Space(4f); GUI.backgroundColor = Color.green; if (GUILayout.Button(Locale.Get("传送"), (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Height(32f), GUILayout.Width(260f) }) && !string.IsNullOrWhiteSpace(p.SceneTeleportInput)) { p.PendingTeleport = true; p.PendingTeleportScene = p.SceneTeleportInput; p.ShowUI = false; Plugin.ShowNotification(Locale.Get("稍后传送至") + p.SceneTeleportInput + " ..."); } GUI.backgroundColor = Color.white; } private static void DrawDisplayToggles(Plugin p) { //IL_0044: 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_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: 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) bool showSceneLabel = p.GetShowSceneLabel(); bool showSeedLabel = p.GetShowSeedLabel(); GUILayout.Label(Locale.Get("显示选项:"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(25f) }); GUILayout.Space(4f); GUI.color = (showSceneLabel ? Color.green : BrightWhite); if (GUILayout.Toggle(showSceneLabel, Locale.Get("显示当前场景名"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) })) { if (!showSceneLabel) { p.SetShowSceneLabel(value: true); } } else if (showSceneLabel) { p.SetShowSceneLabel(value: false); } GUI.color = BrightWhite; GUILayout.Space(6f); GUI.color = (showSeedLabel ? Color.green : BrightWhite); if (GUILayout.Toggle(showSeedLabel, Locale.Get("显示当前种子"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) })) { if (!showSeedLabel) { p.SetShowSceneLabel(value: true, isSeed: true); } } else if (showSeedLabel) { p.SetShowSceneLabel(value: false, isSeed: true); } GUI.color = BrightWhite; } private static bool DrawModeButton(string label, bool isOn, int titleFontSize = 18, params GUILayoutOption[] options) { //IL_0042: 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_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_005d: 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_006d: 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_007a: Expected O, but got Unknown //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_008f: Expected O, but got Unknown //IL_00b1: 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_00fa: Unknown result type (might be due to invalid IL or missing references) string text = (isOn ? Locale.Get("[开]") : Locale.Get("[关]")); Color backgroundColor = (isOn ? new Color(0.2f, 1f, 0.2f) : new Color(0.6f, 0.6f, 0.6f)); Color backgroundColor2 = GUI.backgroundColor; GUI.backgroundColor = backgroundColor; bool num = GUILayout.Button("", options); Rect lastRect = GUILayoutUtility.GetLastRect(); EnsureStyles(); GUIStyle val = new GUIStyle(_titleStyle) { fontSize = titleFontSize }; GUIStyle val2 = new GUIStyle(_statusStyle) { fontSize = titleFontSize - 3 }; GUI.Label(new Rect(((Rect)(ref lastRect)).x, ((Rect)(ref lastRect)).y, ((Rect)(ref lastRect)).width, ((Rect)(ref lastRect)).height / 2f), label, val); GUI.Label(new Rect(((Rect)(ref lastRect)).x, ((Rect)(ref lastRect)).y + ((Rect)(ref lastRect)).height / 2f, ((Rect)(ref lastRect)).width, ((Rect)(ref lastRect)).height / 2f), text, val2); GUI.backgroundColor = backgroundColor2; if (!num) { return isOn; } return !isOn; } private static bool GetTrapEnabled() { return SilksongItemRandomizerAPI.IsTrapEnabled(); } private static void SetTrapEnabled(bool enabled) { SilksongItemRandomizerAPI.SetTrapEnabled(enabled); } private static void SetTrapSeed(int seed) { SilksongItemRandomizerAPI.SetSeed(seed); } private static void TriggerTrapSpawn() { SilksongItemRandomizerAPI.RegenerateTrapsNow(); } private static void TriggerTrapClear() { bool trapEnabled = GetTrapEnabled(); SilksongItemRandomizerAPI.SetTrapEnabled(false); if (trapEnabled) { SilksongItemRandomizerAPI.SetTrapEnabled(true); } } private static int GetTrapDifficulty() { return SilksongItemRandomizerAPI.GetTrapDifficulty(); } private static void SetTrapDifficulty(int difficultyIndex) { SilksongItemRandomizerAPI.SetTrapDifficulty(difficultyIndex); } private static bool GetTrapMovementEnabled() { return SilksongItemRandomizerAPI.IsTrapMovementEnabled(); } private static void SetTrapMovementEnabled(bool value) { SilksongItemRandomizerAPI.SetTrapMovementEnabled(value); } } [BepInPlugin("YourName.StartingAbilityPicker", "Starting Ability Picker", "1.0.0.0")] public class Plugin : BaseUnityPlugin { [CompilerGenerated] private sealed class <DelayedGiveAfterSceneLoad>d__184 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public Plugin <>4__this; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <DelayedGiveAfterSceneLoad>d__184(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown int num = <>1__state; Plugin plugin = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(0.5f); <>1__state = 1; return true; case 1: <>1__state = -1; <>2__current = null; <>1__state = 2; return true; case 2: <>1__state = -1; plugin.GivePendingSkillsAndItems(); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <DelayedTeleport>d__193 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public Plugin <>4__this; public string sceneName; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <DelayedTeleport>d__193(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown int num = <>1__state; Plugin plugin = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(0.5f); <>1__state = 1; return true; case 1: <>1__state = -1; try { if (plugin._sceneLoader == null) { return false; } object obj = plugin._sceneLoader.GetType().GetField("cfgTeleportScene", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(plugin._sceneLoader); object obj2 = plugin._sceneLoader.GetType().GetField("cfgTeleportConfirm", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(plugin._sceneLoader); obj?.GetType().GetProperty("Value")?.SetValue(obj, sceneName, null); obj2?.GetType().GetProperty("Value")?.SetValue(obj2, true, null); ShowNotification(Locale.Get("正在传送到 ") + sceneName + " ..."); } catch (Exception arg) { Log.LogError((object)$"传送失败: {arg}"); } return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <LoadAllImages>d__176 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; private string <folder>5__2; private string[] <iconFiles>5__3; private WWW <www>5__4; private int <i>5__5; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <LoadAllImages>d__176(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { switch (<>1__state) { case -3: case 1: try { } finally { <>m__Finally1(); } break; case -4: case 2: try { } finally { <>m__Finally2(); } break; } <folder>5__2 = null; <iconFiles>5__3 = null; <www>5__4 = null; <>1__state = -2; } private bool MoveNext() { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Expected O, but got Unknown //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0108: 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_0229: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Expected O, but got Unknown try { switch (<>1__state) { default: return false; case 0: { <>1__state = -1; <folder>5__2 = Path.Combine(Paths.PluginPath, "elesanren-Hard_Item_Randomizer", "nandu"); string text = Path.Combine(<folder>5__2, "4.png"); if (File.Exists(text)) { <www>5__4 = new WWW("file://" + text); <>1__state = -3; <>2__current = <www>5__4; <>1__state = 1; return true; } goto IL_0124; } case 1: <>1__state = -3; if (string.IsNullOrEmpty(<www>5__4.error) && (Object)(object)<www>5__4.texture != (Object)null) { _backgroundSprite = Sprite.Create(<www>5__4.texture, new Rect(0f, 0f, (float)((Texture)<www>5__4.texture).width, (float)((Texture)<www>5__4.texture).height), new Vector2(0.5f, 0.5f)); } <>m__Finally1(); <www>5__4 = null; goto IL_0124; case 2: { <>1__state = -4; if (string.IsNullOrEmpty(<www>5__4.error) && (Object)(object)<www>5__4.texture != (Object)null) { Sprite val = Sprite.Create(<www>5__4.texture, new Rect(0f, 0f, (float)((Texture)<www>5__4.texture).width, (float)((Texture)<www>5__4.texture).height), new Vector2(0.5f, 0.5f)); switch (<i>5__5) { case 0: _beginnerIcon = val; break; case 1: _focusedIcon = val; break; case 2: _overflowIcon = val; break; } } <>m__Finally2(); <www>5__4 = null; goto IL_0278; } IL_0278: <i>5__5++; goto IL_028a; IL_0124: <iconFiles>5__3 = new string[3] { "1.png", "2.png", "3.png" }; <i>5__5 = 0; goto IL_028a; IL_028a: if (<i>5__5 < 3) { string text2 = Path.Combine(<folder>5__2, <iconFiles>5__3[<i>5__5]); if (File.Exists(text2)) { <www>5__4 = new WWW("file://" + text2); <>1__state = -4; <>2__current = <www>5__4; <>1__state = 2; return true; } goto IL_0278; } _bgLoaded = true; return false; } } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<www>5__4 != null) { ((IDisposable)<www>5__4).Dispose(); } } private void <>m__Finally2() { <>1__state = -1; if (<www>5__4 != null) { ((IDisposable)<www>5__4).Dispose(); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <ProcessPopupQueue>d__169 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <ProcessPopupQueue>d__169(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; break; case 1: <>1__state = -1; break; } if (_popupQueue.Count > 0) { _isShowingPopup = true; (Sprite icon, string text) tuple = _popupQueue.Dequeue(); Sprite item = tuple.icon; string item2 = tuple.text; _currentPopupSprite = item; _currentPopupText = item2; _popupStartTime = Time.time; _popupEndTime = Time.time + 8f; <>2__current = (object)new WaitForSeconds(8f); <>1__state = 1; return true; } _isShowingPopup = false; return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <ShowUIAuto>d__189 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public Plugin <>4__this; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <ShowUIAuto>d__189(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { int num = <>1__state; Plugin plugin = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; <>2__current = null; <>1__state = 1; return true; case 1: <>1__state = -1; if (plugin.currentProfileID != -1) { allowUpward = AllowUpwardAttack; allowLeft = AllowLeftAttack; allowRight = AllowRightAttack; itemCount = StartingItemCount.Value; resetPickups = false; seedInput = RandomSeed.Value.ToString(); plugin.showUI = true; } return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } internal static ManualLogSource Log; public static bool AllowLeftAttack = false; public static bool AllowRightAttack = false; public static bool AllowUpwardAttack = false; public static bool DirectionEnabled = true; public static bool AllowDashLeft = false; public static bool AllowDashRight = false; public static bool AllowHarpoonLeft = false; public static bool AllowHarpoonRight = false; public static bool AllowFloatLeft = false; public static bool AllowFloatRight = false; public static bool AllowWallJumpLeft = false; public static bool AllowWallJumpRight = false; public static bool AllowHeal = true; private static Dictionary<string, string> _abilityConfig = new Dictionary<string, string>(); public static bool skillMode = false; public static int skillTotal = 0; public static int skillV = 0; public static int skillH = 0; public static int skillS = 0; public static int skillA = 0; public const int MaxVertical = 5; public const int MaxHorizontal = 4; public const int MaxSpecial = 4; public const int MaxAttack = 5; private bool _lastSceneWasMenu = true; private bool showUI; public static bool allowUpward = false; public static bool allowLeft = false; public static bool allowRight = false; public static int itemCount = 0; public static bool resetPickups = false; public static string seedInput = ""; private static HashSet<int> chosenProfileSet = new HashSet<int>(); private static string _notificationMessage = null; private static float _notificationEndTime = 0f; private static GUIStyle _notificationStyle; private static Sprite _backgroundSprite; private static Sprite _beginnerIcon; private static Sprite _focusedIcon; private static Sprite _overflowIcon; private static bool _bgLoaded = false; private static Rect _windowRect; private static float _lastScreenHeight; public static bool crestCurseEnabled = false; public static ConfigEntry<bool> CfgAllowDashLeft; public static ConfigEntry<bool> CfgAllowDashRight; public static ConfigEntry<bool> CfgAllowHarpoonLeft; public static ConfigEntry<bool> CfgAllowHarpoonRight; public static ConfigEntry<bool> CfgAllowFloatLeft; public static ConfigEntry<bool> CfgAllowFloatRight; public static ConfigEntry<bool> CfgAllowWallJumpLeft; public static ConfigEntry<bool> CfgAllowWallJumpRight; public static ConfigEntry<bool> CfgAllowHeal; private static readonly string CompletionConfigPath = Path.Combine(Paths.ConfigPath, "StartingAbilityPicker", "completion_per_profile.json"); private static Dictionary<int, bool> _profileCompletionDisplay = new Dictionary<int, bool>(); private static Queue<(Sprite icon, string text)> _popupQueue = new Queue<(Sprite, string)>(); private static bool _isShowingPopup = false; private static Sprite _currentPopupSprite; private static string _currentPopupText; private static float _popupStartTime; private static float _popupEndTime; private const float PopupDuration = 8f; private static GUIStyle _popupTextStyle; private bool _pendingApply; private int _pendingSkillTotal; private int _pendingSkillV; private int _pendingSkillH; private int _pendingSkillS; private int _pendingSkillA; private bool _pendingSkillMode; private int _pendingItemCount; private bool _sceneRandomAvailable; private Type _sceneLoaderType; private Type _roomRandoType; private Type _seedManagerType; private object _sceneLoader; private object _roomRando; private object _seedManager; private PropertyInfo _cfgShowSceneLabelProp; private FieldInfo _currentSceneNameField; private MethodInfo _getSeedMethod; private string sceneSeedInput = ""; private string sceneTeleportInput = ""; private bool _pendingTeleport; private string _pendingTeleportScene = ""; private bool _apiInitialized; public static Plugin Instance { get; private set; } public static ConfigEntry<bool> UseNativeSkillGiving { get; private set; } public static ConfigEntry<string> ChosenProfiles { get; private set; } public static ConfigEntry<int> StartingSkillCount { get; private set; } public static ConfigEntry<int> StartingItemCount { get; private set; } public static ConfigEntry<int> RandomSeed { get; private set; } public static ConfigEntry<bool> CfgCrestCurseEnabled { get; private set; } public static ConfigEntry<bool> EnemyRandoAdjustEnabled { get; private set; } public static ConfigEntry<bool> PanelBackgroundEnabled { get; private set; } public static ConfigEntry<bool> CfgDirectionEnabled { get; private set; } public static ConfigEntry<bool> CfgFullRandomMode { get; private set; } public bool ShowUI { get { return showUI; } set { showUI = value; } } public string SceneSeedInput { get { return sceneSeedInput; } set { sceneSeedInput = value; } } public string SceneTeleportInput { get { return sceneTeleportInput; } set { sceneTeleportInput = value; } } public bool PendingTeleport { get { return _pendingTeleport; } set { _pendingTeleport = value; } } public string PendingTeleportScene { get { return _pendingTeleportScene; } set { _pendingTeleportScene = value; } } public object SeedManager => _seedManager; public bool SceneRandomAvailable => _sceneRandomAvailable; public static int MaxVerticalDynamic => 5; public static int MaxHorizontalDynamic => 4; public static int MaxSpecialDynamic => 4; public static int MaxAttackDynamic => 5; public static Sprite BeginnerIcon => _beginnerIcon; public static Sprite FocusedIcon => _focusedIcon; public static Sprite OverflowIcon => _overflowIcon; public static bool FullRandomModeEnabled { get { return DirectionPatch.FullRandomMode; } set { DirectionPatch.FullRandomMode = value; } } private string AbilityConfigPath => Path.Combine(Paths.ConfigPath, "StartingAbilityPicker", "ability_config.json"); private int currentProfileID => PlayerData.instance?.profileID ?? (-1); public static void ShowNotification(string message, float duration = 3f) { _notificationMessage = message; _notificationEndTime = Time.time + duration; } public static void ShowSkillPopup(Sprite icon, string text) { _popupQueue.Enqueue((icon, text)); if (!_isShowingPopup) { ((MonoBehaviour)Instance).StartCoroutine(Instance.ProcessPopupQueue()); } } [IteratorStateMachine(typeof(<ProcessPopupQueue>d__169))] private IEnumerator ProcessPopupQueue() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <ProcessPopupQueue>d__169(0); } private Texture2D MakeTexture(int width, int height, Color col) { //IL_000f: 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_0021: 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown Color[] array = (Color[])(object)new Color[width * height]; for (int i = 0; i < array.Length; i++) { array[i] = col; } Texture2D val = new Texture2D(width, height); val.SetPixels(array); val.Apply(); return val; } public static bool GetCrestCurseEnabled() { return crestCurseEnabled; } public static void SetCrestCurseEnabled(bool value) { crestCurseEnabled = value; CfgCrestCurseEnabled.Value = value; try { Type.GetType("SilksongItemRandomizer.ToolEffectRandomizer, SilksongItemRandomizer")?.GetMethod("SetEnabled", BindingFlags.Static | BindingFlags.Public)?.Invoke(null, new object[1] { value }); } catch { } Log.LogInfo((object)("纹章诅咒开关: " + (value ? "启用" : "禁用"))); } public static void SetFullRandomMode(bool enabled) { DirectionPatch.FullRandomMode = enabled; CfgFullRandomMode.Value = enabled; ((BaseUnityPlugin)Instance).Config.Save(); } public void SetForceCompletionDisplay(bool value) { int num = currentProfileID; if (num == -1 || GetForceCompletionDisplay() == value) { return; } _profileCompletionDisplay[num] = value; SaveCompletionConfig(); Log.LogInfo((object)string.Format("强制完成度显示开关 (存档 {0}): {1}", num, value ? "启用(显示)" : "禁用(隐藏)")); PlayerData instance = PlayerData.instance; if (instance != null) { if (value) { instance.ConstructedFarsight = true; RefreshCompletionUI(forceShow: true); } else { ClearFsmCompletionVariables(); } } } private void Awake() { Instance = this; Log = ((BaseUnityPlugin)this).Logger; Log.LogInfo((object)"StartingAbilityPicker loaded! Press F7 to open starting options."); ChosenProfiles = ((BaseUnityPlugin)this).Config.Bind<string>("General", "ChosenProfiles", "", "已选择过开局选项的存档ID列表"); StartingSkillCount = ((BaseUnityPlugin)this).Config.Bind<int>("General", "StartingSkillCount", 0, "开局随机技能数量 (0-5)"); StartingItemCount = ((BaseUnityPlugin)this).Config.Bind<int>("General", "StartingItemCount", 0, "开局随机物品数量 (0-5)"); RandomSeed = ((BaseUnityPlugin)this).Config.Bind<int>("General", "RandomSeed", 0, "随机种子 (0 表示随机)"); CfgCrestCurseEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "CrestCurseEnabled", false, "启用纹章诅咒"); crestCurseEnabled = CfgCrestCurseEnabled.Value; try { Type.GetType("SilksongItemRandomizer.ToolEffectRandomizer, SilksongItemRandomizer")?.GetMethod("SetEnabled", BindingFlags.Static | BindingFlags.Public)?.Invoke(null, new object[1] { crestCurseEnabled }); } catch { } EnemyRandoAdjustEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnemyRandoAdjustEnabled", true, "启用怪物随机调整"); try { Type type = Type.GetType("SilksongItemRandomizer.EnemyRandoAdjuster, SilksongItemRandomizer"); if (type != null) { PropertyInfo property = type.GetProperty("Enabled", BindingFlags.Static | BindingFlags.Public); if (property != null) { property.SetValue(null, EnemyRandoAdjustEnabled.Value); } } } catch (Exception arg) { Log.LogError((object)$"同步怪物调整开关失败: {arg}"); } PanelBackgroundEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("UI", "PanelBackgroundEnabled", true, "显示开局选项面板背景图片"); UseNativeSkillGiving = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "UseNativeSkillGiving", true, "技能给予使用原生物品获得动画"); SkillRandomizer.UseNativeItemGiving = UseNativeSkillGiving.Value; CfgDirectionEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Direction", "Enabled", true, "启用方向分裂系统"); DirectionEnabled = CfgDirectionEnabled.Value; CfgAllowDashLeft = ((BaseUnityPlugin)this).Config.Bind<bool>("Direction", "DashLeft", false, "允许向左冲刺"); CfgAllowDashRight = ((BaseUnityPlugin)this).Config.Bind<bool>("Direction", "DashRight", false, "允许向右冲刺"); CfgAllowHarpoonLeft = ((BaseUnityPlugin)this).Config.Bind<bool>("Direction", "HarpoonLeft", false, "允许向左飞针"); CfgAllowHarpoonRight = ((BaseUnityPlugin)this).Config.Bind<bool>("Direction", "HarpoonRight", false, "允许向右飞针"); CfgAllowFloatLeft = ((BaseUnityPlugin)this).Config.Bind<bool>("Direction", "FloatLeft", false, "允许向左漂浮"); CfgAllowFloatRight = ((BaseUnityPlugin)this).Config.Bind<bool>("Direction", "FloatRight", false, "允许向右漂浮"); CfgAllowWallJumpLeft = ((BaseUnityPlugin)this).Config.Bind<bool>("Direction", "WallJumpLeft", false, "允许向左壁跳"); CfgAllowWallJumpRight = ((BaseUnityPlugin)this).Config.Bind<bool>("Direction", "WallJumpRight", false, "允许向右壁跳"); CfgAllowHeal = ((BaseUnityPlugin)this).Config.Bind<bool>("Direction", "Heal", true, "允许回血"); AllowDashLeft = CfgAllowDashLeft.Value; AllowDashRight = CfgAllowDashRight.Value; AllowHarpoonLeft = CfgAllowHarpoonLeft.Value; AllowHarpoonRight = CfgAllowHarpoonRight.Value; AllowFloatLeft = CfgAllowFloatLeft.Value; AllowFloatRight = CfgAllowFloatRight.Value; AllowWallJumpLeft = CfgAllowWallJumpLeft.Value; AllowWallJumpRight = CfgAllowWallJumpRight.Value; AllowHeal = CfgAllowHeal.Value; CfgFullRandomMode = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "FullRandomMode", false, "全随机模式:开启后只允许下劈,所有其他方向动作全部禁用"); DirectionPatch.FullRandomMode = CfgFullRandomMode.Value; LoadCompletionConfig(); LoadChosenProfiles(); EnsureRandomSeed(); LoadAbilityConfig(); SceneManager.sceneLoaded += OnSceneLoaded; Harmony.CreateAndPatchAll(typeof(DirectionPatch), (string)null); Harmony.CreateAndPatchAll(typeof(SaveStats_GetCompletionPercentage_Patch), (string)null); Harmony.CreateAndPatchAll(typeof(SaveStats_UnlockedCompletionRate_Patch), (string)null); Harmony.CreateAndPatchAll(typeof(PlayerData_CountGameCompletion_Patch), (string)null); Harmony.CreateAndPatchAll(typeof(ConvertFloatToString_Patch), (string)null); Harmony.CreateAndPatchAll(typeof(BuildString_Patch), (string)null); ((MonoBehaviour)this).StartCoroutine(LoadAllImages()); InitSceneRandomRefs(); StartingAbilityPickerAPI.Initialize(new StartingAbilityPickerConfig { Seed = RandomSeed.Value, FullRandomMode = CfgFullRandomMode.Value, MovementPermissions = new DirectionPermissions { DashLeft = AllowDashLeft, DashRight = AllowDashRight, HarpoonLeft = AllowHarpoonLeft, HarpoonRight = AllowHarpoonRight, FloatLeft = AllowFloatLeft, FloatRight = AllowFloatRight, WallJumpLeft = AllowWallJumpLeft, WallJumpRight = AllowWallJumpRight, AllowHeal = AllowHeal }, CrestCurseEnabled = crestCurseEnabled, ForceCompletionDisplay = GetForceCompletionDisplay(), UseNativeSkillGiving = UseNativeSkillGiving.Value, PanelBackgroundEnabled = PanelBackgroundEnabled.Value, DefaultStartingItemCount = StartingItemCount.Value, DefaultSkillTotal = StartingSkillCount.Value, DefaultSkillV = 0, DefaultSkillH = 0, DefaultSkillS = 0, DefaultSkillA = 0, DefaultSkillTypeMode = false, DefaultResetPickups = false, DefaultAttackPermissions = (AllowUpwardAttack, AllowLeftAttack, AllowRightAttack), DisableBuiltinShortcut = false }); _apiInitialized = true; } [IteratorStateMachine(typeof(<LoadAllImages>d__176))] private IEnumerator LoadAllImages() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <LoadAllImages>d__176(0); } private void LoadAbilityConfig() { try { if (File.Exists(AbilityConfigPath)) { _abilityConfig = JsonConvert.DeserializeObject<Dictionary<string, string>>(File.ReadAllText(AbilityConfigPath)) ?? new Dictionary<string, string>(); } else { _abilityConfig.Clear(); } AllowUpwardAttack = _abilityConfig.TryGetValue("AllowUpwardAttack", out var value) && string.Equals(value, "true", StringComparison.OrdinalIgnoreCase); AllowLeftAttack = _abilityConfig.TryGetValue("AllowLeftAttack", out var value2) && string.Equals(value2, "true", StringComparison.OrdinalIgnoreCase); AllowRightAttack = _abilityConfig.TryGetValue("AllowRightAttack", out var value3) && string.Equals(value3, "true", StringComparison.OrdinalIgnoreCase); PlayerData instance = PlayerData.instance; if (instance != null) { if (instance.GetBool("AllowUpwardAttack")) { AllowUpwardAttack = true; } if (instance.GetBool("AllowLeftAttack")) { AllowLeftAttack = true; } if (instance.GetBool("AllowRightAttack")) { AllowRightAttack = true; } } } catch (Exception arg) { Log.LogError((object)$"加载配置失败: {arg}"); } } private void SaveAbilityConfig() { try { _abilityConfig["AllowUpwardAttack"] = AllowUpwardAttack.ToString(); _abilityConfig["AllowLeftAttack"] = AllowLeftAttack.ToString(); _abilityConfig["AllowRightAttack"] = AllowRightAttack.ToString(); string directoryName = Path.GetDirectoryName(AbilityConfigPath); if (!Directory.Exists(directoryName)) { Directory.CreateDirectory(directoryName); } File.WriteAllText(AbilityConfigPath, JsonConvert.SerializeObject((object)_abilityConfig, (Formatting)1)); } catch (Exception arg) { Log.LogError((object)$"保存配置失败: {arg}"); } } public static void SaveAttackDirections() { try { PlayerData instance = PlayerData.instance; if (instance != null) { instance.SetBool("AllowUpwardAttack", AllowUpwardAttack); instance.SetBool("AllowLeftAttack", AllowLeftAttack); instance.SetBool("AllowRightAttack", AllowRightAttack); } Instance.SaveAbilityConfig(); ((BaseUnityPlugin)Instance).Config.Save(); Log.LogInfo((object)"攻击方向配置已完整保存"); } catch (Exception arg) { Log.LogError((object)$"SaveAttackDirections 失败: {arg}"); } } public static void SaveDirectionSettings() { CfgAllowDashLeft.Value = AllowDashLeft; CfgAllowDashRight.Value = AllowDashRight; CfgAllowHarpoonLeft.Value = AllowHarpoonLeft; CfgAllowHarpoonRight.Value = AllowHarpoonRight; CfgAllowFloatLeft.Value = AllowFloatLeft; CfgAllowFloatRight.Value = AllowFloatRight; CfgAllowWallJumpLeft.Value = AllowWallJumpLeft; CfgAllowWallJumpRight.Value = AllowWallJumpRight; CfgAllowHeal.Value = AllowHeal; CfgDirectionEnabled.Value = DirectionEnabled; ((BaseUnityPlugin)Instance).Config.Save(); Log.LogInfo((object)"方向分裂设置已保存"); } private void EnsureRandomSeed() { if (RandomSeed.Value == 0) { int value = new Random().Next(1, int.MaxValue); RandomSeed.Value = value; ((BaseUnityPlugin)Instance).Config.Save(); } } private void OnDestroy() { SceneManager.sceneLoaded -= OnSceneLoaded; } private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { if (((Scene)(ref scene)).name != "Menu_Title" && ((Scene)(ref scene)).name != "Menu" && ((Scene)(ref scene)).name != "Loading" && (Object)(object)HeroController.instance != (Object)null) { LoadAbilityConfig(); LoadPlayerDataSettings(); InitSceneRandomInstances(); if (GetForceCompletionDisplay()) { PlayerData instance = PlayerData.instance; if (instance != null && !instance.ConstructedFarsight) { instance.ConstructedFarsight = true; Log.LogInfo((object)$"已强制解锁完成度显示 (ConstructedFarsight) for profile {currentProfileID}"); } RefreshCompletionUI(forceShow: true); } if (_pendingApply) { ((MonoBehaviour)this).StartCoroutine(DelayedGiveAfterSceneLoad()); } if (_apiInitialized) { StartingAbilityPickerAPI.MarkGameReady(); } } else if (((Scene)(ref scene)).name == "Menu_Title" || ((Scene)(ref scene)).name == "Menu") { _lastSceneWasMenu = true; } if (!GetForceCompletionDisplay()) { ClearFsmCompletionVariables(); } } [IteratorStateMachine(typeof(<DelayedGiveAfterSceneLoad>d__184))] private IEnumerator DelayedGiveAfterSceneLoad() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <DelayedGiveAfterSceneLoad>d__184(0) { <>4__this = this }; } private void GivePendingSkillsAndItems() { Log.LogInfo((object)"开始给予技能和物品(场景加载完成后)"); if (!_pendingSkillMode) { for (int i = 0; i < _pendingSkillTotal; i++) { SkillRandomizer.GiveRandomSkill(); } } else { for (int j = 0; j < _pendingSkillV; j++) { SkillRandomizer.GiveRandomSkillFromCategory(SkillRandomizer.VerticalSkills); } for (int k = 0; k < _pendingSkillH; k++) { SkillRandomizer.GiveRandomSkillFromCategory(SkillRandomizer.HorizontalSkills); } for (int l = 0; l < _pendingSkillS; l++) { SkillRandomizer.GiveRandomSkillFromCategory(SkillRandomizer.SpecialSkills); } for (int m = 0; m < _pendingSkillA; m++) { SkillRandomizer.GiveRandomSkillFromCategory(SkillRandomizer.AttackSkills); } } for (int n = 0; n < _pendingItemCount; n++) { SavedItem randomItem = ItemRandomizer.GetRandomItem(); if ((Object)(object)randomItem != (Object)null) { randomItem.TryGet(false, true); } } RoomRandomMode.TryApply(); _pendingApply = false; showUI = false; Log.LogInfo((object)"技能和物品给予完成"); } private void LoadPlayerDataSettings() { try { PlayerData instance = PlayerData.instance; if (instance != null) { skillMode = instance.GetBool("SkillRandomMode"); skillTotal = instance.GetInt("SkillTotalCount"); skillV = instance.GetInt("SkillVerticalCount"); skillH = instance.GetInt("SkillHorizontalCount"); skillS = instance.GetInt("SkillSpecialCount"); skillA = instance.GetInt("SkillAttackCount"); if (!skillMode && skillTotal == 0) { skillTotal = StartingSkillCount.Value; } } } catch (Exception arg) { Log.LogError((object)$"加载技能随机设置失败: {arg}"); } } private void InitSceneRandomRefs() { _sceneRandomAvailable = false; try { _sceneLoaderType = Type.GetType("HKSilksong_Randomizer.RandomSceneLoader, HKSilksong_SceneRandomizer"); _roomRandoType = Type.GetType("HKSilksong_Randomizer.RoomRando, HKSilksong_SceneRandomizer"); _seedManagerType = Type.GetType("HKSilksong_Randomizer.SeedManager, HKSilksong_SceneRandomizer"); if (_sceneLoaderType == null || _roomRandoType == null || _seedManagerType == null) { Log.LogWarning((object)"场景随机模块类型未找到,右侧面板将不可用"); return; } PropertyInfo property = _sceneLoaderType.GetProperty("cfgShowSceneLabel", BindingFlags.Instance | BindingFlags.NonPublic); _cfgShowSceneLabelProp = property; FieldInfo field = _sceneLoaderType.GetField("currentSceneName", BindingFlags.Instance | BindingFlags.NonPublic); _currentSceneNameField = field; MethodInfo method = _roomRandoType.GetMethod("GetGenerationSeed"); _getSeedMethod = method; _sceneRandomAvailable = true; Log.LogInfo((object)"场景随机模块可用(静态接口)"); } catch (Exception ex) { Log.LogWarning((object)("场景随机模块初始化失败: " + ex.Message)); } } private void InitSceneRandomInstances() { try { GameObject val = GameObject.Find("__RoomRando"); GameObject val2 = GameObject.Find("__SeedManager"); if ((Object)(object)val != (Object)null) { _roomRando = val.GetComponent(_roomRandoType); } if ((Object)(object)val2 != (Object)null) { _seedManager = val2.GetComponent(_seedManagerType); } if (_seedManager != null) { _sceneLoader = _seedManager.GetType().GetField("sceneLoader", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(_seedManager); } } catch (Exception ex) { Log.LogWarning((object)("获取场景随机实例失败: " + ex.Message)); } } [IteratorStateMachine(typeof(<ShowUIAuto>d__189))] private IEnumerator ShowUIAuto() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <ShowUIAuto>d__189(0) { <>4__this = this }; } private void LoadChosenProfiles() { chosenProfileSet.Clear(); string[] array = ChosenProfiles.Value.Split(new char[1] { ',' }); for (int i = 0; i < array.Length; i++) { if (int.TryParse(array[i].Trim(), out var result)) { chosenProfileSet.Add(result); } } } private void SaveChosenProfiles() { ChosenProfiles.Value = string.Join(",", chosenProfileSet); ((BaseUnityPlugin)Instance).Config.Save(); } private void Update() { if (Input.GetKeyDown((KeyCode)288) && currentProfileID != -1) { showUI = !showUI; if (showUI) { allowUpward = AllowUpwardAttack; allowLeft = AllowLeftAttack; allowRight = AllowRightAttack; itemCount = StartingItemCount.Value; resetPickups = false; seedInput = RandomSeed.Value.ToString(); } } if (Input.GetKeyDown((KeyCode)9) && !GetForceCompletionDisplay()) { ClearFsmCompletionVariables(); } if (_pendingTeleport) { _pendingTeleport = false; ((MonoBehaviour)this).StartCoroutine(DelayedTeleport(_pendingTeleportScene)); } } [IteratorStateMachine(typeof(<DelayedTeleport>d__193))] private IEnumerator DelayedTeleport(string sceneName) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <DelayedTeleport>d__193(0) { <>4__this = this, sceneName = sceneName }; } private void OnGUI() { //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: 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_0043: Expected O, but got Unknown //IL_004d: 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_040a: Unknown result type (might be due to invalid IL or missing references) //IL_040f: Unknown result type (might be due to invalid IL or missing references) //IL_041b: Unknown result type (might be due to invalid IL or missing references) //IL_0427: Unknown result type (might be due to invalid IL or missing references) //IL_0440: Expected O, but got Unknown //IL_043b: Unknown result type (might be due to invalid IL or missing references) //IL_0440: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015f: 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_016c: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Expected O, but got Unknown //IL_0315: Unknown result type (might be due to invalid IL or missing references) //IL_0329: Unknown result type (might be due to invalid IL or missing references) //IL_032e: Unknown result type (might be due to invalid IL or missing references) //IL_0335: Unknown result type (might be due to invalid IL or missing references) //IL_0348: 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_035d: Expected O, but got Unknown //IL_037c: 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_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0300: 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) if (_notificationMessage != null && Time.time <= _notificationEndTime) { if (_notificationStyle == null) { _notificationStyle = new GUIStyle(GUI.skin.box) { fontSize = 40, alignment = (TextAnchor)4 }; _notificationStyle.normal.textColor = Color.white; _notificationStyle.normal.background = MakeTexture(2, 2, new Color(0f, 0f, 0f, 0.7f)); } float num = 600f; float num2 = 120f; GUI.Box(new Rect(((float)Screen.width - num) / 2f, (float)(Screen.height / 2 - 100), num, num2), _notificationMessage, _notificationStyle); } else { _notificationMessage = null; } if (_isShowingPopup && !string.IsNullOrEmpty(_currentPopupText) && Time.time < _popupEndTime) { float num3 = Time.time - _popupStartTime; float num4 = 0f; num4 = ((num3 < 3f) ? (num3 / 3f) : ((!(num3 < 5f)) ? (1f - (num3 - 5f) / 3f) : 1f)); if (_popupTextStyle == null) { GUIStyle val = new GUIStyle(GUI.skin.label) { alignment = (TextAnchor)4, fontSize = 42, fontStyle = (FontStyle)1 }; val.normal.textColor = Color.white; _popupTextStyle = val; } float num5 = (float)Mathf.Min(Screen.width, Screen.height) * 0.3f * 0.75f; float num6 = ((float)Screen.width - num5) / 2f; float num7 = ((float)Screen.height - num5) / 2f - 30f; Color color = GUI.color; GUI.color = new Color(1f, 1f, 1f, num4); if ((Object)(object)_currentPopupSprite != (Object)null && (Object)(object)_currentPopupSprite.texture != (Object)null) { Rect textureRect = _currentPopupSprite.textureRect; Texture2D texture = _currentPopupSprite.texture; float num8 = ((Texture)texture).width; float num9 = ((Texture)texture).height; Rect val2 = default(Rect); ((Rect)(ref val2))..ctor(((Rect)(ref textureRect)).x / num8, ((Rect)(ref textureRect)).y / num9, ((Rect)(ref textureRect)).width / num8, ((Rect)(ref textureRect)).height / num9); if (((Object)_currentPopupSprite).name == "Wall_Jump_Prompt") { ((Rect)(ref val2)).y = ((Rect)(ref val2)).y + ((Rect)(ref val2)).height; ((Rect)(ref val2)).height = 0f - ((Rect)(ref val2)).height; } Rect val3 = default(Rect); if (((Object)_currentPopupSprite).name == "prompt_swiftstep" || ((Object)_currentPopupSprite).name == "prompt_hornet_silk_dash") { float num10 = num5 * 1.5f; float num11 = num6 - (num10 - num5) / 2f; ((Rect)(ref val3))..ctor(num11, num7, num10, num5); } else { ((Rect)(ref val3))..ctor(num6, num7, num5, num5); } GUI.DrawTextureWithTexCoords(val3, (Texture)(object)texture, val2); } else { Rect val4 = new Rect(num6, num7, num5, num5); GUIStyle val5 = new GUIStyle(GUI.skin.label) { alignment = (TextAnchor)4, fontSize = Mathf.RoundToInt(num5 * 0.5f) }; val5.normal.textColor = Color.white; GUI.Label(val4, "?", val5); } float num12 = num7 + num5 + 20f; GUI.Label(new Rect(0f, num12, (float)Screen.width, 80f), _currentPopupText, _popupTextStyle); GUI.color = color; } if (!showUI) { return; } if (((Rect)(ref _windowRect)).width == 0f || Mathf.Abs((float)Screen.height - _lastScreenHeight) > 1f) { float num13 = Screen.height; float num14 = 1080f; float num15 = 925f; float num16 = num13 / 8f; float num17 = num13 - num14 - num16; if (num17 < 0f) { num17 = 0f; } _windowRect = new Rect(20f, num17, num15, num14); _lastScreenHeight = num13; } _windowRect = GUILayout.Window(100, _windowRect, new WindowFunction(DrawUIWindow), Locale.Get("开局选项 & 场景随机"), Array.Empty<GUILayoutOption>()); } private void DrawUIWindow(int windowID) { //IL_007e: 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_0049: Unknown result type (might be due to invalid IL or missing references) if (PanelBackgroundEnabled.Value && (Object)(object)_backgroundSprite != (Object)null && (Object)(object)_backgroundSprite.texture != (Object)null) { GUI.DrawTexture(new Rect(0f, 0f, ((Rect)(ref _windowRect)).width, ((Rect)(ref _windowRect)).height), (Texture)(object)_backgroundSprite.texture, (ScaleMode)0); } else { GUI.DrawTexture(new Rect(0f, 0f, ((Rect)(ref _windowRect)).width, ((Rect)(ref _windowRect)).height), (Texture)(object)Texture2D.whiteTexture, (ScaleMode)0, true, 0f, new Color(0.15f, 0.15f, 0.15f, 0.85f), 0f, 0f); } GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(558f) }); PanelRenderer.DrawLeftPanel(this); GUILayout.EndVertical(); GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(270f) }); PanelRenderer.DrawScenePanel(this); GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUI.DragWindow(); } private void ApplySettings() { Log.LogInfo((object)"ApplySettings 开始执行"); StartingAbilityPickerAPI.SetAttackPermissions(allowUpward, allowLeft, allowRight); StartingAbilityPickerAPI.SetSkillRandomMode(skillMode); StartingAbilityPickerAPI.SetSkillCounts(skillTotal, skillV, skillH, skillS, skillA); StartingAbilityPickerAPI.SetStartingItemCount(itemCount); if (int.TryParse(seedInput, out var result)) { StartingAbilityPickerAPI.SetSeed(result); } StartingAbilityPickerAPI.SetResetSeedWorld(resetPickups); StartingAbilityPickerAPI.SetFullRandomMode(DirectionPatch.FullRandomMode); StartingAbilityPickerAPI.SetCrestCurseEnabled(crestCurseEnabled); StartingAbilityPickerAPI.SetForceCompletionDisplay(GetForceCompletionDisplay()); StartingAbilityPickerAPI.ApplyPending(); if (StartingAbilityPickerAPI.HasPendingChanges()) { _pendingSkillMode = skillMode; _pendingSkillTotal = skillTotal; _pendingSkillV = skillV; _pendingSkillH = skillH; _pendingSkillS = skillS; _pendingSkillA = skillA; _pendingItemCount = itemCount; if (resetPickups) { _pendingApply = true; Log.LogInfo((object)"重置种子世界,将在场景加载完成后给予技能和物品"); ResetSeedWorld(); } else { GivePendingSkillsAndItems(); RoomRandomMode.TryApply(); showUI = false; } } else if (resetPickups) { _pendingApply = true; Log.LogInfo((object)"重置种子世界,将在场景加载完成后给予技能和物品"); ResetSeedWorld(); } else { GivePendingSkillsAndItems(); RoomRandomMode.TryApply(); showUI = false; } Log.LogInfo((object)"ApplySettings 执行完成"); } private void ResetSeedWorld() { if (!int.TryParse(seedInput, out var result) || result == RandomSeed.Value) { result = new Random().Next(1, int.MaxValue); } seedInput = result.ToString(); RandomSeed.Value = result; ((BaseUnityPlugin)Instance).Config.Save(); TrySyncOtherMods(result); try { PlayerData instance = PlayerData.instance; if (instance == null) { return; } FieldInfo[] fields = typeof(PlayerData).GetFields(BindingFlags.Instance | BindingFlags.Public); int num = 0; FieldInfo[] array = fields; foreach (FieldInfo fieldInfo in array) { if (fieldInfo.Name.StartsWith("SkillTriggered_")) { fieldInfo.SetValue(instance, false); num++; } } Log.LogInfo((object)$"已重置 {num} 个技能触发器记录"); } catch (Exception arg) { Log.LogError((object)$"重置技能触发器失败: {arg}"); } } public static void ResetSeedWorldExternal(int newSeed) { seedInput = newSeed.ToString(); RandomSeed.Value = newSeed; ((BaseUnityPlugin)Instance).Config.Save(); Instance.TrySyncOtherMods(newSeed); try { PlayerData instance = PlayerData.instance; if (instance == null) { return; } FieldInfo[] fields = typeof(PlayerData).GetFields(BindingFlags.Instance | BindingFlags.Public); foreach (FieldInfo fieldInfo in fields) { if (fieldInfo.Name.StartsWith("SkillTriggered_")) { fieldInfo.SetValue(instance, false); } } } catch { } } private void TrySyncOtherMods(int newSeed) { try { Type type = Type.GetType("SilksongItemRandomizer.Plugin, SilksongItemRandomizer"); if (type != null) { PropertyInfo property = type.GetProperty("RandomSeed", BindingFlags.Static | BindingFlags.Public); if (property != null && property.GetValue(null) is ConfigEntry<int> val) { val.Value = newSeed; } type.GetMethod("ResetAllStaticData", BindingFlags.Static | BindingFlags.Public)?.Invoke(null, null); } } catch { } try { Type type2 = Type.GetType("SkillTriggerMod.Plugin, SkillTriggerMod"); if (type2 != null) { PropertyInfo property2 = type2.GetProperty("RandomSeed", BindingFlags.Static | BindingFlags.Public); if (property2 != null && property2.GetValue(null) is ConfigEntry<int> val2) { val2.Value = newSeed; } Type.GetType("SkillTriggerMod.SkillRandomizer, SkillTriggerMod")?.GetMethod("SetSeed", BindingFlags.Static | BindingFlags.Public)?.Invoke(null, new object[1] { newSeed }); type2.GetMethod("ResetAllRecords", BindingFlags.Static | BindingFlags.Public)?.Invoke(null, null); } string path = Path.Combine(Paths.ConfigPath, "SkillTriggerMod", "trigger_records.json"); string directoryName = Path.GetDirectoryName(path); if (!Directory.Exists(directoryName)) { Directory.CreateDirectory(directoryName); } File.WriteAllText(path, "[]"); } catch { } try { Type? type3 = Type.GetType("SilksongItemRandomizer.CrestRandomizer, SilksongItemRandomizer"); type3?.GetMethod("ResetMappings", BindingFlags.Static | BindingFlags.Public)?.Invoke(null, null); type3?.GetMethod("Initialize", BindingFlags.Static | BindingFlags.Public)?.Invoke(null, null); Type.GetType("SilksongItemRandomizer.CrestRandomizePatch, SilksongItemRandomizer")?.GetMethod("ResetProcessedIds", BindingFlags.Static | BindingFlags.Public)?.Invoke(null, null); Type.GetType("SilksongItemRandomizer.BenchRespawnPatch, SilksongItemRandomizer")?.GetMethod("ResetCooldown", BindingFlags.Static | BindingFlags.Public)?.Invoke