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 _externalTranslations; private static string _languageFolderPath; private static bool _isLoaded; private static readonly Dictionary FallbackEnglish = new Dictionary { { "开局选项 & 场景随机", "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 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 dictionary = new Dictionary(); foreach (string item in list) { try { Dictionary dictionary2 = JsonConvert.DeserializeObject>(File.ReadAllText(item)); if (dictionary2 == null) { continue; } foreach (KeyValuePair 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()); 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()); 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()); 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 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)?.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()); 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()); 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()); 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()); 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()); 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()); 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()); 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()); 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 d__184 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public Plugin <>4__this; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public 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 d__193 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public Plugin <>4__this; public string sceneName; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public 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 d__176 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; private string 5__2; private string[] 5__3; private WWW 5__4; private int 5__5; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public 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; } 5__2 = null; 5__3 = null; 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; 5__2 = Path.Combine(Paths.PluginPath, "elesanren-Hard_Item_Randomizer", "nandu"); string text = Path.Combine(5__2, "4.png"); if (File.Exists(text)) { 5__4 = new WWW("file://" + text); <>1__state = -3; <>2__current = 5__4; <>1__state = 1; return true; } goto IL_0124; } case 1: <>1__state = -3; if (string.IsNullOrEmpty(5__4.error) && (Object)(object)5__4.texture != (Object)null) { _backgroundSprite = Sprite.Create(5__4.texture, new Rect(0f, 0f, (float)((Texture)5__4.texture).width, (float)((Texture)5__4.texture).height), new Vector2(0.5f, 0.5f)); } <>m__Finally1(); 5__4 = null; goto IL_0124; case 2: { <>1__state = -4; if (string.IsNullOrEmpty(5__4.error) && (Object)(object)5__4.texture != (Object)null) { Sprite val = Sprite.Create(5__4.texture, new Rect(0f, 0f, (float)((Texture)5__4.texture).width, (float)((Texture)5__4.texture).height), new Vector2(0.5f, 0.5f)); switch (5__5) { case 0: _beginnerIcon = val; break; case 1: _focusedIcon = val; break; case 2: _overflowIcon = val; break; } } <>m__Finally2(); 5__4 = null; goto IL_0278; } IL_0278: 5__5++; goto IL_028a; IL_0124: 5__3 = new string[3] { "1.png", "2.png", "3.png" }; 5__5 = 0; goto IL_028a; IL_028a: if (5__5 < 3) { string text2 = Path.Combine(5__2, 5__3[5__5]); if (File.Exists(text2)) { 5__4 = new WWW("file://" + text2); <>1__state = -4; <>2__current = 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 (5__4 != null) { ((IDisposable)5__4).Dispose(); } } private void <>m__Finally2() { <>1__state = -1; if (5__4 != null) { ((IDisposable)5__4).Dispose(); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__169 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public 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 d__189 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public Plugin <>4__this; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public 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 _abilityConfig = new Dictionary(); 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 chosenProfileSet = new HashSet(); 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 CfgAllowDashLeft; public static ConfigEntry CfgAllowDashRight; public static ConfigEntry CfgAllowHarpoonLeft; public static ConfigEntry CfgAllowHarpoonRight; public static ConfigEntry CfgAllowFloatLeft; public static ConfigEntry CfgAllowFloatRight; public static ConfigEntry CfgAllowWallJumpLeft; public static ConfigEntry CfgAllowWallJumpRight; public static ConfigEntry CfgAllowHeal; private static readonly string CompletionConfigPath = Path.Combine(Paths.ConfigPath, "StartingAbilityPicker", "completion_per_profile.json"); private static Dictionary _profileCompletionDisplay = new Dictionary(); 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 UseNativeSkillGiving { get; private set; } public static ConfigEntry ChosenProfiles { get; private set; } public static ConfigEntry StartingSkillCount { get; private set; } public static ConfigEntry StartingItemCount { get; private set; } public static ConfigEntry RandomSeed { get; private set; } public static ConfigEntry CfgCrestCurseEnabled { get; private set; } public static ConfigEntry EnemyRandoAdjustEnabled { get; private set; } public static ConfigEntry PanelBackgroundEnabled { get; private set; } public static ConfigEntry CfgDirectionEnabled { get; private set; } public static ConfigEntry 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(d__169))] private IEnumerator ProcessPopupQueue() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new 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("General", "ChosenProfiles", "", "已选择过开局选项的存档ID列表"); StartingSkillCount = ((BaseUnityPlugin)this).Config.Bind("General", "StartingSkillCount", 0, "开局随机技能数量 (0-5)"); StartingItemCount = ((BaseUnityPlugin)this).Config.Bind("General", "StartingItemCount", 0, "开局随机物品数量 (0-5)"); RandomSeed = ((BaseUnityPlugin)this).Config.Bind("General", "RandomSeed", 0, "随机种子 (0 表示随机)"); CfgCrestCurseEnabled = ((BaseUnityPlugin)this).Config.Bind("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("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("UI", "PanelBackgroundEnabled", true, "显示开局选项面板背景图片"); UseNativeSkillGiving = ((BaseUnityPlugin)this).Config.Bind("General", "UseNativeSkillGiving", true, "技能给予使用原生物品获得动画"); SkillRandomizer.UseNativeItemGiving = UseNativeSkillGiving.Value; CfgDirectionEnabled = ((BaseUnityPlugin)this).Config.Bind("Direction", "Enabled", true, "启用方向分裂系统"); DirectionEnabled = CfgDirectionEnabled.Value; CfgAllowDashLeft = ((BaseUnityPlugin)this).Config.Bind("Direction", "DashLeft", false, "允许向左冲刺"); CfgAllowDashRight = ((BaseUnityPlugin)this).Config.Bind("Direction", "DashRight", false, "允许向右冲刺"); CfgAllowHarpoonLeft = ((BaseUnityPlugin)this).Config.Bind("Direction", "HarpoonLeft", false, "允许向左飞针"); CfgAllowHarpoonRight = ((BaseUnityPlugin)this).Config.Bind("Direction", "HarpoonRight", false, "允许向右飞针"); CfgAllowFloatLeft = ((BaseUnityPlugin)this).Config.Bind("Direction", "FloatLeft", false, "允许向左漂浮"); CfgAllowFloatRight = ((BaseUnityPlugin)this).Config.Bind("Direction", "FloatRight", false, "允许向右漂浮"); CfgAllowWallJumpLeft = ((BaseUnityPlugin)this).Config.Bind("Direction", "WallJumpLeft", false, "允许向左壁跳"); CfgAllowWallJumpRight = ((BaseUnityPlugin)this).Config.Bind("Direction", "WallJumpRight", false, "允许向右壁跳"); CfgAllowHeal = ((BaseUnityPlugin)this).Config.Bind("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("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(d__176))] private IEnumerator LoadAllImages() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__176(0); } private void LoadAbilityConfig() { try { if (File.Exists(AbilityConfigPath)) { _abilityConfig = JsonConvert.DeserializeObject>(File.ReadAllText(AbilityConfigPath)) ?? new Dictionary(); } 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(d__184))] private IEnumerator DelayedGiveAfterSceneLoad() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new 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(d__189))] private IEnumerator ShowUIAuto() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new 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(d__193))] private IEnumerator DelayedTeleport(string sceneName) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new 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()); } 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()); 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 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 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(null, null); } catch { } } public int GetCurrentSeed() { if (_sceneLoaderType == null) { return 0; } try { FieldInfo field = _sceneLoaderType.GetField("CurrentSeed", BindingFlags.Static | BindingFlags.Public); if (field != null) { return (int)field.GetValue(null); } } catch (Exception ex) { Log.LogWarning((object)("获取当前种子失败: " + ex.Message)); } return 0; } public string GetCurrentSceneName() { if (_sceneLoader == null) { return ""; } try { return (string)_currentSceneNameField?.GetValue(_sceneLoader); } catch { return ""; } } public bool GetSceneRandomEnabled() { if (_sceneLoaderType == null) { return false; } try { FieldInfo field = _sceneLoaderType.GetField("EnableRandomization", BindingFlags.Static | BindingFlags.Public); if (field != null) { return (bool)field.GetValue(null); } } catch { } return false; } public void SetSceneRandomEnabled(bool enabled) { if (_sceneLoaderType == null) { return; } try { _sceneLoaderType.GetField("EnableRandomization", BindingFlags.Static | BindingFlags.Public)?.SetValue(null, enabled); if (_sceneLoader != null) { FieldInfo field = _sceneLoaderType.GetField("cfgEnableRandomization", BindingFlags.Instance | BindingFlags.NonPublic); if (field != null) { object value = field.GetValue(_sceneLoader); value?.GetType().GetProperty("Value")?.SetValue(value, enabled, null); } } } catch { } } public bool GetShowSceneLabel() { if (_cfgShowSceneLabelProp != null && _sceneLoader != null) { try { return (bool)_cfgShowSceneLabelProp.GetValue(_sceneLoader); } catch { } } return true; } public void SetShowSceneLabel(bool value, bool isSeed = false) { try { if (!isSeed) { if (_cfgShowSceneLabelProp != null && _sceneLoader != null) { _cfgShowSceneLabelProp.SetValue(_sceneLoader, value, null); } } else if (_seedManager != null) { object obj = _seedManager.GetType().GetField("cfgShowSeedOnScreen", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(_seedManager); obj?.GetType().GetProperty("Value")?.SetValue(obj, value, null); } } catch { } } public bool GetShowSeedLabel() { try { if (_seedManager != null) { object obj = _seedManager.GetType().GetField("cfgShowSeedOnScreen", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(_seedManager); return (bool)(obj?.GetType().GetProperty("Value")?.GetValue(obj) ?? ((object)true)); } } catch { } return true; } private void LoadCompletionConfig() { try { if (File.Exists(CompletionConfigPath)) { _profileCompletionDisplay = JsonConvert.DeserializeObject>(File.ReadAllText(CompletionConfigPath)) ?? new Dictionary(); } else { _profileCompletionDisplay.Clear(); } } catch (Exception arg) { Log.LogWarning((object)$"加载完成度配置失败: {arg}"); } } private void SaveCompletionConfig() { try { string directoryName = Path.GetDirectoryName(CompletionConfigPath); if (!Directory.Exists(directoryName)) { Directory.CreateDirectory(directoryName); } File.WriteAllText(CompletionConfigPath, JsonConvert.SerializeObject((object)_profileCompletionDisplay, (Formatting)1)); } catch (Exception arg) { Log.LogWarning((object)$"保存完成度配置失败: {arg}"); } } public bool GetForceCompletionDisplay() { int num = currentProfileID; if (num == -1) { return true; } if (_profileCompletionDisplay.TryGetValue(num, out var value)) { return value; } return true; } private void RefreshCompletionUI(bool forceShow = false) { if (!GetForceCompletionDisplay() && !forceShow) { ClearFsmCompletionVariables(); return; } PlayerData instance = PlayerData.instance; if (instance == null) { return; } string value = Mathf.RoundToInt(instance.completionPercentage) + "%"; string[] array = new string[4] { "Inv", "Tools", "Journal", "Quests" }; for (int i = 0; i < array.Length; i++) { GameObject val = GameObject.Find(array[i]); if ((Object)(object)val == (Object)null) { continue; } PlayMakerFSM component = val.GetComponent(); if (!((Object)(object)component == (Object)null)) { FsmString val2 = component.FsmVariables.FindFsmString("Completion Percentage Str"); if (val2 != null) { val2.Value = value; } } } } private void ClearFsmCompletionVariables() { try { string[] array = new string[4] { "Inv", "Tools", "Journal", "Quests" }; for (int i = 0; i < array.Length; i++) { GameObject val = GameObject.Find(array[i]); if ((Object)(object)val == (Object)null) { continue; } PlayMakerFSM component = val.GetComponent(); if ((Object)(object)component == (Object)null) { continue; } FsmString[] stringVariables = component.FsmVariables.StringVariables; foreach (FsmString val2 in stringVariables) { if (((NamedVariable)val2).Name.IndexOf("Completion", StringComparison.OrdinalIgnoreCase) >= 0) { val2.Value = ""; } } } } catch (Exception arg) { Log.LogWarning((object)$"清空完成度变量失败: {arg}"); } } public bool GetItemRandomEnabled() { 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; } public void ApplyStartingSettings() { GivePendingSkillsAndItems(); } public void SetItemRandomEnabled(bool value) { try { (Type.GetType("SilksongItemRandomizer.Plugin, SilksongItemRandomizer")?.GetProperty("PublicItemRandomEnabled", BindingFlags.Static | BindingFlags.Public))?.SetValue(null, value); } catch { } } public void SetEnemyRandoAdjustEnabled(bool value) { EnemyRandoAdjustEnabled.Value = value; 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, value); } } } catch (Exception arg) { Log.LogError((object)$"设置怪物调整开关失败: {arg}"); } } public void SetPanelBackgroundEnabled(bool value) { PanelBackgroundEnabled.Value = value; } } [HarmonyPatch(typeof(SaveStats), "GetCompletionPercentage")] public static class SaveStats_GetCompletionPercentage_Patch { [HarmonyPostfix] private static void Postfix(ref string __result) { if ((Object)(object)Plugin.Instance != (Object)null && !Plugin.Instance.GetForceCompletionDisplay()) { __result = ""; } } } [HarmonyPatch(typeof(SaveStats), "get_UnlockedCompletionRate")] public static class SaveStats_UnlockedCompletionRate_Patch { [HarmonyPostfix] private static void Postfix(ref bool __result) { if ((Object)(object)Plugin.Instance != (Object)null && !Plugin.Instance.GetForceCompletionDisplay()) { __result = false; } } } [HarmonyPatch(typeof(PlayerData), "CountGameCompletion")] public static class PlayerData_CountGameCompletion_Patch { [HarmonyPrefix] private static bool Prefix() { if ((Object)(object)Plugin.Instance != (Object)null) { return Plugin.Instance.GetForceCompletionDisplay(); } return true; } } [HarmonyPatch(typeof(ConvertFloatToString), "OnEnter")] public static class ConvertFloatToString_Patch { private static void Postfix(ConvertFloatToString __instance) { if ((Object)(object)Plugin.Instance != (Object)null && !Plugin.Instance.GetForceCompletionDisplay() && __instance.stringVariable != null && ((NamedVariable)__instance.stringVariable).Name == "Completion Percentage Str") { __instance.stringVariable.Value = ""; } } } [HarmonyPatch(typeof(BuildString), "OnEnter")] public static class BuildString_Patch { private static void Postfix(BuildString __instance) { if ((Object)(object)Plugin.Instance != (Object)null && !Plugin.Instance.GetForceCompletionDisplay() && __instance.storeResult != null && ((NamedVariable)__instance.storeResult).Name == "Completion Percentage Str") { __instance.storeResult.Value = ""; } } } [HarmonyPatch] public static class DirectionPatch { private static readonly FieldInfo InputHandlerField; private static readonly FieldInfo InputActionsField; private static readonly FieldInfo UpField; private static readonly FieldInfo DownField; private static readonly PropertyInfo IsPressedProp; private static readonly FieldInfo FacingRightField; private static readonly FieldInfo CStateField; private static readonly FieldInfo OnGroundField; private static readonly FieldInfo AllowAttackCancellingDownspikeRecoveryField; private static FieldInfo _inputHandlerField; private static FieldInfo _inputActionsField; private static FieldInfo _moveVectorField; private static PropertyInfo _moveVectorProperty; private static bool _fullRandomMode; public static bool FullRandomMode { get { return _fullRandomMode; } set { if (_fullRandomMode != value) { _fullRandomMode = value; ApplyFullRandomMode(value); if (Plugin.CfgFullRandomMode != null) { Plugin.CfgFullRandomMode.Value = value; ((BaseUnityPlugin)Plugin.Instance).Config.Save(); } } } } static DirectionPatch() { if (Plugin.CfgFullRandomMode != null) { _fullRandomMode = Plugin.CfgFullRandomMode.Value; } else { _fullRandomMode = false; } Type typeFromHandle = typeof(HeroController); InputHandlerField = typeFromHandle.GetField("inputHandler", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); FacingRightField = typeFromHandle.GetField("facingRight", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); CStateField = typeFromHandle.GetField("cState", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); AllowAttackCancellingDownspikeRecoveryField = typeFromHandle.GetField("allowAttackCancellingDownspikeRecovery", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (InputHandlerField != null) { InputActionsField = InputHandlerField.FieldType.GetField("inputActions", BindingFlags.Instance | BindingFlags.Public); if (InputActionsField != null) { Type fieldType = InputActionsField.FieldType; UpField = fieldType.GetField("Up"); DownField = fieldType.GetField("Down"); if (UpField != null) { IsPressedProp = UpField.FieldType.GetProperty("IsPressed"); } } } if (CStateField != null) { OnGroundField = CStateField.FieldType.GetField("onGround", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } _inputHandlerField = typeFromHandle.GetField("inputHandler", BindingFlags.Instance | BindingFlags.NonPublic); if (!(_inputHandlerField != null)) { return; } _inputActionsField = _inputHandlerField.FieldType.GetField("inputActions", BindingFlags.Instance | BindingFlags.Public); if (_inputActionsField != null) { _moveVectorField = _inputActionsField.FieldType.GetField("MoveVector", BindingFlags.Instance | BindingFlags.Public); if (_moveVectorField != null) { _moveVectorProperty = _moveVectorField.FieldType.GetProperty("Vector", BindingFlags.Instance | BindingFlags.Public); } } } public static void SetAllowAttackDirection(bool allowUp, bool allowLeft, bool allowRight) { Plugin.AllowUpwardAttack = allowUp; Plugin.AllowLeftAttack = allowLeft; Plugin.AllowRightAttack = allowRight; Plugin.SaveAttackDirections(); Plugin.allowUpward = allowUp; Plugin.allowLeft = allowLeft; Plugin.allowRight = allowRight; } public static void SetAllowDashDirection(bool allowLeft, bool allowRight) { Plugin.AllowDashLeft = allowLeft; Plugin.AllowDashRight = allowRight; Plugin.CfgAllowDashLeft.Value = allowLeft; Plugin.CfgAllowDashRight.Value = allowRight; ((BaseUnityPlugin)Plugin.Instance).Config.Save(); } public static void SetAllowHarpoonDirection(bool allowLeft, bool allowRight) { Plugin.AllowHarpoonLeft = allowLeft; Plugin.AllowHarpoonRight = allowRight; Plugin.CfgAllowHarpoonLeft.Value = allowLeft; Plugin.CfgAllowHarpoonRight.Value = allowRight; ((BaseUnityPlugin)Plugin.Instance).Config.Save(); } public static void SetAllowFloatDirection(bool allowLeft, bool allowRight) { Plugin.AllowFloatLeft = allowLeft; Plugin.AllowFloatRight = allowRight; Plugin.CfgAllowFloatLeft.Value = allowLeft; Plugin.CfgAllowFloatRight.Value = allowRight; ((BaseUnityPlugin)Plugin.Instance).Config.Save(); } public static void SetAllowWallJumpDirection(bool allowLeft, bool allowRight) { Plugin.AllowWallJumpLeft = allowLeft; Plugin.AllowWallJumpRight = allowRight; Plugin.CfgAllowWallJumpLeft.Value = allowLeft; Plugin.CfgAllowWallJumpRight.Value = allowRight; ((BaseUnityPlugin)Plugin.Instance).Config.Save(); } public static void SetAllowHeal(bool allow) { Plugin.AllowHeal = allow; Plugin.CfgAllowHeal.Value = allow; ((BaseUnityPlugin)Plugin.Instance).Config.Save(); } private static void ApplyFullRandomMode(bool enabled) { if (enabled) { SetAllowAttackDirection(allowUp: false, allowLeft: false, allowRight: false); SetAllowDashDirection(allowLeft: false, allowRight: false); SetAllowHarpoonDirection(allowLeft: false, allowRight: false); SetAllowFloatDirection(allowLeft: false, allowRight: false); SetAllowWallJumpDirection(allowLeft: false, allowRight: false); SetAllowHeal(allow: false); } else { SetAllowAttackDirection(allowUp: true, allowLeft: true, allowRight: true); SetAllowDashDirection(allowLeft: true, allowRight: true); SetAllowHarpoonDirection(allowLeft: true, allowRight: true); SetAllowFloatDirection(allowLeft: true, allowRight: true); SetAllowWallJumpDirection(allowLeft: true, allowRight: true); SetAllowHeal(allow: true); } Plugin.Log.LogInfo((object)("全随机模式 " + (enabled ? "开启" : "关闭") + ",方向限制已" + (enabled ? "全部禁用(仅下劈)" : "全部允许"))); ItemRandomizer.RefreshPool(); } private static float GetMoveInput() { //IL_0070: Unknown result type (might be due to invalid IL or missing references) try { object obj = _inputHandlerField?.GetValue(HeroController.instance); if (obj == null) { return 0f; } object obj2 = _inputActionsField?.GetValue(obj); if (obj2 == null) { return 0f; } object obj3 = _moveVectorField?.GetValue(obj2); if (obj3 == null) { return 0f; } return ((Vector2)(_moveVectorProperty?.GetValue(obj3))).x; } catch { return 0f; } } [HarmonyPatch(typeof(HeroController), "DoAttack")] [HarmonyPrefix] private static bool Prefix_DoAttack(HeroController __instance, ref bool __runOriginal) { //IL_00c9: Unknown result type (might be due to invalid IL or missing references) try { if (!__runOriginal) { return false; } object obj = InputHandlerField?.GetValue(__instance); if (obj == null) { return true; } object obj2 = InputActionsField?.GetValue(obj); if (obj2 == null) { return true; } object obj3 = UpField?.GetValue(obj2); object obj4 = DownField?.GetValue(obj2); bool num = obj3 != null && IsPressedProp != null && (bool)IsPressedProp.GetValue(obj3); bool flag = obj4 != null && IsPressedProp != null && (bool)IsPressedProp.GetValue(obj4); bool flag2 = ((FacingRightField != null) ? ((bool)FacingRightField.GetValue(__instance)) : (((Component)__instance).transform.localScale.x > 0f)); bool flag3 = true; object obj5 = CStateField?.GetValue(__instance); if (obj5 != null && OnGroundField != null) { flag3 = (bool)OnGroundField.GetValue(obj5); } bool flag4 = AllowAttackCancellingDownspikeRecoveryField != null && (bool)AllowAttackCancellingDownspikeRecoveryField.GetValue(__instance); bool allowUpwardAttack = Plugin.AllowUpwardAttack; bool allowLeftAttack = Plugin.AllowLeftAttack; bool allowRightAttack = Plugin.AllowRightAttack; if (!(num ? allowUpwardAttack : ((flag && (flag4 || !flag3)) || (flag2 ? allowRightAttack : allowLeftAttack)))) { __runOriginal = false; return false; } } catch (Exception arg) { Plugin.Log.LogError((object)$"DirectionPatch.DoAttack 出错: {arg}"); } return true; } [HarmonyPatch(typeof(HeroController), "HeroDash")] [HarmonyPrefix] private static bool Prefix_HeroDash(HeroController __instance, ref bool __runOriginal) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.DirectionEnabled) { return true; } if (!(((FacingRightField != null) ? ((bool)FacingRightField.GetValue(__instance)) : (((Component)__instance).transform.localScale.x > 0f)) ? Plugin.AllowDashRight : Plugin.AllowDashLeft)) { __runOriginal = false; return false; } return true; } [HarmonyPatch(typeof(HeroController), "CanHarpoonDash")] [HarmonyPostfix] private static void Postfix_CanHarpoonDash(HeroController __instance, ref bool __result) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) if (__result && Plugin.DirectionEnabled && !(((FacingRightField != null) ? ((bool)FacingRightField.GetValue(__instance)) : (((Component)__instance).transform.localScale.x > 0f)) ? Plugin.AllowHarpoonRight : Plugin.AllowHarpoonLeft)) { __result = false; } } [HarmonyPatch(typeof(HeroController), "StartFloat")] [HarmonyPrefix] private static bool Prefix_StartFloat(HeroController __instance) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.DirectionEnabled) { return true; } float moveInput = GetMoveInput(); if (Mathf.Abs(moveInput) > 0.1f) { if (!(FacingRightField != null)) { _ = ((Component)__instance).transform.localScale; } else { _ = (bool)FacingRightField.GetValue(__instance); } if ((!(moveInput > 0f) || !Plugin.AllowFloatRight) && (!(moveInput < 0f) || !Plugin.AllowFloatLeft)) { return false; } } return true; } [HarmonyPatch(typeof(HeroController), "DoWallJump")] [HarmonyPrefix] private static bool Prefix_DoWallJump(HeroController __instance) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.DirectionEnabled) { return true; } if (!(((FacingRightField != null) ? ((bool)FacingRightField.GetValue(__instance)) : (((Component)__instance).transform.localScale.x > 0f)) ? Plugin.AllowWallJumpRight : Plugin.AllowWallJumpLeft)) { return false; } return true; } [HarmonyPatch(typeof(HeroController), "CanBind")] [HarmonyPostfix] private static void Postfix_CanBind(ref bool __result) { if (__result && Plugin.DirectionEnabled && !Plugin.AllowHeal) { __result = false; } } } public static class RoomRandomMode { private static bool _isPending; public static bool IsPending => _isPending; public static void ResetPending() { _isPending = false; } public static void Toggle() { _isPending = !_isPending; } public static void TryApply() { if (!_isPending) { return; } PlayerData instance = PlayerData.instance; if (instance == null) { Plugin.Log.LogError((object)"RoomRandomMode: PlayerData 不可用"); _isPending = false; return; } try { bool @bool = instance.GetBool("hasDash"); bool bool2 = instance.GetBool("hasSuperJump"); int @int = instance.GetInt("silkRegenMax"); if (@bool && bool2 && @int >= 1) { Plugin.Log.LogInfo((object)"RoomRandomMode: 能力已存在,跳过"); _isPending = false; return; } if (!@bool) { instance.SetBool("hasDash", true); } if (!bool2) { instance.SetBool("hasSuperJump", true); } if (@int < 1) { instance.SetInt("silkRegenMax", 1); } Plugin.Log.LogInfo((object)"RoomRandomMode: 已给予疾风步(hasDash)、超级跳(hasSuperJump)、丝之心(silkRegenMax=1)"); } catch (Exception arg) { Plugin.Log.LogError((object)$"RoomRandomMode 出错: {arg}"); } finally { _isPending = false; } } } public static class SkillRandomizer { [CompilerGenerated] private sealed class d__40 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public Action onComplete; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__40(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { if (<>1__state != 0) { return false; } <>1__state = -1; GetRng(); try { PlayerData instance = PlayerData.instance; if (instance == null) { return false; } List list = new List(); foreach (string allField in AllFields) { switch (allField) { case "hasNeedolinMemoryPowerup": if (!instance.hasNeedolinMemoryPowerup) { list.Add(allField); } continue; case "hasFastTravelTeleport": if (!instance.UnlockedFastTravelTeleport) { list.Add(allField); } continue; case "HasSeenEvaHeal": if (!instance.HasBoundCrestUpgrader) { list.Add(allField); } continue; } 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) { return false; } GiveSkill(list[_rng.Next(list.Count)]); } finally { onComplete?.Invoke(); } 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 d__42 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public List categoryFields; public Action onComplete; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__42(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { if (<>1__state != 0) { return false; } <>1__state = -1; GetRng(); try { PlayerData instance = PlayerData.instance; if (instance == null) { return false; } List list = new List(); foreach (string categoryField in categoryFields) { switch (categoryField) { case "hasNeedolinMemoryPowerup": if (!instance.hasNeedolinMemoryPowerup) { list.Add(categoryField); } continue; case "hasFastTravelTeleport": if (!instance.UnlockedFastTravelTeleport) { list.Add(categoryField); } continue; case "HasSeenEvaHeal": if (!instance.HasBoundCrestUpgrader) { list.Add(categoryField); } continue; } FieldInfo field = typeof(PlayerData).GetField(categoryField, BindingFlags.Instance | BindingFlags.Public); if (field != null && field.FieldType == typeof(bool) && !(bool)field.GetValue(instance)) { list.Add(categoryField); } } if (list.Count == 0) { return false; } GiveSkill(list[_rng.Next(list.Count)]); } finally { onComplete?.Invoke(); } 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 d__38 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public bool finished; private float 5__2; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public 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; 5__2 = 15f; break; case 1: <>1__state = -1; 5__2 -= Time.deltaTime; break; } if (!finished && 5__2 > 0f) { <>2__current = null; <>1__state = 1; return 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 readonly Dictionary SkillChineseNames = new Dictionary { { "hasNeedleThrow", "丝之矛" }, { "hasThreadSphere", "灵丝风暴" }, { "hasHarpoonDash", "飞针" }, { "hasSilkCharge", "丝刃标" }, { "hasSilkBomb", "符文之怒" }, { "hasSilkBossNeedle", "苍白之爪" }, { "hasNeedolin", "丝忆弦针" }, { "hasDash", "疾风步" }, { "hasBrolly", "流浪者披风" }, { "hasDoubleJump", "雪绒披风" }, { "hasChargeSlash", "蓄力斩" }, { "hasSuperJump", "灵丝升腾" }, { "hasWalljump", "蛛攀术" }, { "HasSeenEvaHeal", "风铃摇" }, { "hasParry", "格挡" }, { "hasNeedolinMemoryPowerup", "深邃挽歌" }, { "hasFastTravelTeleport", "幻兽歌" } }; private static readonly Dictionary BestPickNames = new Dictionary { { "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" }, { "HasSeenEvaHeal", "EvaHeal_Prompt" }, { "hasParry", "Cross Stitch" }, { "hasNeedolinMemoryPowerup", "Needolin_Prompt" }, { "hasFastTravelTeleport", "FastTravel_Prompt" } }; private static readonly Dictionary FallbackKeywords = new Dictionary { { "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" } }, { "HasSeenEvaHeal", new string[5] { "EvaHeal", "Eva", "Heal", "Windchime", "风铃" } }, { "hasParry", new string[4] { "Cross Stitch", "Parry", "Block", "格挡" } }, { "hasNeedolinMemoryPowerup", new string[4] { "Needolin", "Memory", "Powerup", "挽歌" } }, { "hasFastTravelTeleport", new string[5] { "FastTravel", "Teleport", "Fast", "Travel", "传送" } } }; public static readonly List VerticalSkills = new List { "hasSuperJump", "hasDoubleJump", "hasWalljump", "hasBrolly", "hasHarpoonDash" }; public static readonly List HorizontalSkills = new List { "hasDash", "hasBrolly", "hasHarpoonDash", "hasSilkCharge" }; public static readonly List SpecialSkills = new List { "hasNeedolin", "hasChargeSlash", "hasBrolly", "hasHarpoonDash", "HasSeenEvaHeal", "hasNeedolinMemoryPowerup", "hasFastTravelTeleport" }; public static readonly List AttackSkills = new List { "hasSilkBomb", "hasSilkBossNeedle", "hasThreadSphere", "hasSilkSpear", "hasSilkCharge", "hasParry", "hasNeedleThrow" }; private static readonly List AllFields = SkillChineseNames.Keys.ToList(); private static Random _rng; private static Dictionary _icons = new Dictionary(); private static Sprite _fallback; private static bool _cacheBuilt; private static readonly Dictionary SkillToItemMap = new Dictionary { { "hasNeedleThrow", "Silk Spear" }, { "hasThreadSphere", "Thread Sphere" }, { "hasHarpoonDash", "Harpoon Dash" }, { "hasSilkCharge", "Silk Charge" }, { "hasSilkBomb", "Silk Bomb" }, { "hasSilkBossNeedle", "Silk Boss Needle" }, { "hasNeedolin", "Needolin" }, { "hasDash", "Swift Step" }, { "hasBrolly", "Drifter's Cloak" }, { "hasDoubleJump", "Faydown Cloak" }, { "hasChargeSlash", "Charge Slash" }, { "hasSuperJump", "Silk Soar" }, { "hasWalljump", "Cling Grip" }, { "hasParry", "Cross Stitch" } }; private static SkillGetMsg _cachedSkillMsgPrefab; private static PowerUpGetMsg _cachedPowerUpMsgPrefab; private static readonly string SKILL_MSG_BUNDLE_NAME = "c3ef29e95eda5580682bb076589a723c.bundle"; private static readonly string SKILL_MSG_ASSET_PATH = "Assets/Prefabs/UI/Hornet UI/Silk_Skill_Get_Prompt.prefab"; private static AssetBundle _cachedBundle; private static bool _bundleLoadAttempted = false; private static bool _popupErrorLogged = false; private static bool _itemDescriptionErrorLogged = false; public static bool UseNativeItemGiving { get; set; } = true; public static void SetSeed(int seed) { _rng = ((seed == 0) ? new Random() : new Random(seed)); _cacheBuilt = false; } private static Random GetRng() { return _rng ?? (_rng = new Random()); } private static void BuildIconCache() { if (_cacheBuilt) { return; } _cacheBuilt = true; _icons.Clear(); SavedItem[] array = null; Sprite[] array2 = null; try { array = Resources.FindObjectsOfTypeAll(); array2 = Resources.FindObjectsOfTypeAll(); } catch (Exception ex) { Plugin.Log.LogWarning((object)("构建图标缓存时资源获取失败: " + ex.Message)); return; } foreach (string allField in AllFields) { bool flag = false; if (BestPickNames.TryGetValue(allField, out var bestName)) { SavedItem val = ((IEnumerable)array).FirstOrDefault((Func)((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)array2).FirstOrDefault((Func)((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)array).FirstOrDefault((Func)((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)array2).FirstOrDefault((Func)((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 && !_popupErrorLogged) { Plugin.Log.LogWarning((object)("✗ " + allField + " 未找到图标")); _popupErrorLogged = true; } } if (!((Object)(object)_fallback == (Object)null)) { return; } SavedItem val5 = ((IEnumerable)array).FirstOrDefault((Func)((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)array2).FirstOrDefault((Func)((Sprite s) => Object.op_Implicit((Object)(object)s) && ((Object)s).name.Contains("Rosary"))); } } public static Sprite GetIcon(string field) { BuildIconCache(); if (!_icons.TryGetValue(field, out var value)) { return _fallback; } return value; } public static string GetDisplayName(string skillField) { if (SkillChineseNames.TryGetValue(skillField, out var value)) { return Locale.Get(value); } return skillField; } public static PowerUps? GetPowerUpEnum(string skillField) { return skillField switch { "hasDash" => (PowerUps)0, "hasWalljump" => (PowerUps)1, "hasHarpoonDash" => (PowerUps)2, "hasNeedolin" => (PowerUps)3, "hasSuperJump" => (PowerUps)4, "HasSeenEvaHeal" => (PowerUps)5, _ => null, }; } public static bool TryGetSkillFieldFromItem(SavedItem item, out string skillField) { skillField = null; if ((Object)(object)item == (Object)null) { return false; } string name = ((Object)item).name; foreach (KeyValuePair item2 in SkillToItemMap) { if (string.Equals(item2.Value, name, StringComparison.OrdinalIgnoreCase)) { skillField = item2.Key; return true; } } return false; } private static PowerUpGetMsg GetPowerUpMsgPrefab() { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_cachedPowerUpMsgPrefab != (Object)null) { return _cachedPowerUpMsgPrefab; } try { PowerUpGetMsg[] array = Resources.FindObjectsOfTypeAll(); PowerUpGetMsg[] array2 = array; foreach (PowerUpGetMsg val in array2) { if ((Object)(object)val != (Object)null && (Object)(object)((Component)val).gameObject != (Object)null) { Scene scene = ((Component)val).gameObject.scene; if (((Scene)(ref scene)).name == null) { _cachedPowerUpMsgPrefab = val; return _cachedPowerUpMsgPrefab; } } } array2 = array; foreach (PowerUpGetMsg val2 in array2) { if ((Object)(object)val2 != (Object)null && (Object)(object)((Component)val2).gameObject != (Object)null) { _cachedPowerUpMsgPrefab = val2; return _cachedPowerUpMsgPrefab; } } } catch (Exception ex) { if (!_popupErrorLogged) { Plugin.Log.LogWarning((object)("PowerUpGetMsg 预制体加载失败: " + ex.Message)); } } return null; } private static SkillGetMsg GetSkillMsgPrefab() { //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_cachedSkillMsgPrefab != (Object)null) { return _cachedSkillMsgPrefab; } if (!_bundleLoadAttempted) { _bundleLoadAttempted = true; try { AssetBundle val = null; foreach (AssetBundle allLoadedAssetBundle in AssetBundle.GetAllLoadedAssetBundles()) { if ((Object)(object)allLoadedAssetBundle != (Object)null && ((Object)allLoadedAssetBundle).name == SKILL_MSG_BUNDLE_NAME) { val = allLoadedAssetBundle; break; } } if ((Object)(object)val == (Object)null) { string text = Path.Combine(Application.streamingAssetsPath, "aa", "StandaloneWindows64", SKILL_MSG_BUNDLE_NAME); if (File.Exists(text)) { val = AssetBundle.LoadFromFile(text); if ((Object)(object)val != (Object)null) { _cachedBundle = val; } } } if ((Object)(object)val != (Object)null) { GameObject val2 = val.LoadAsset(SKILL_MSG_ASSET_PATH); if ((Object)(object)val2 != (Object)null) { _cachedSkillMsgPrefab = val2.GetComponent(); if ((Object)(object)_cachedSkillMsgPrefab != (Object)null) { return _cachedSkillMsgPrefab; } } } } catch (Exception ex) { if (!_popupErrorLogged) { Plugin.Log.LogWarning((object)("SkillGetMsg 预制体加载失败: " + ex.Message)); } } } try { SkillGetMsg[] array = Resources.FindObjectsOfTypeAll(); foreach (SkillGetMsg val3 in array) { Scene scene = ((Component)val3).gameObject.scene; if (((Scene)(ref scene)).name == null && ((Object)val3).name.Contains("SkillGetMsg")) { _cachedSkillMsgPrefab = val3; return _cachedSkillMsgPrefab; } } } catch { } return null; } private static ToolItemSkill GetSafeToolItemSkill(string skillField, string displayName, Sprite icon) { //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0176: 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_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) SavedItem val = null; if (SkillToItemMap.TryGetValue(skillField, out var itemName)) { try { val = ((IEnumerable)Resources.FindObjectsOfTypeAll()).FirstOrDefault((Func)((SavedItem i) => string.Equals(((Object)i).name, itemName, StringComparison.OrdinalIgnoreCase))); ToolItemSkill val2 = (ToolItemSkill)(object)((val is ToolItemSkill) ? val : null); if (val2 != null && (Object)(object)val2 != (Object)null && (Object)(object)val2.PromptSprite != (Object)null) { return val2; } } catch { } } try { ToolItemSkill val3 = ScriptableObject.CreateInstance(); if ((Object)(object)val3 == (Object)null) { return null; } FieldInfo[] fields = typeof(ToolItemSkill).GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (FieldInfo fieldInfo in fields) { if (fieldInfo.FieldType == typeof(Sprite) && fieldInfo.GetValue(val3) == null) { fieldInfo.SetValue(val3, icon ?? _fallback); } else if (fieldInfo.FieldType == typeof(LocalisedString) && fieldInfo.GetValue(val3) == null) { LocalisedString val4 = default(LocalisedString); FieldInfo field = typeof(LocalisedString).GetField("m_Fallback", BindingFlags.Instance | BindingFlags.NonPublic); if (field != null) { field.SetValue(val4, displayName); } FieldInfo field2 = typeof(LocalisedString).GetField("m_Key", BindingFlags.Instance | BindingFlags.NonPublic); if (field2 != null) { field2.SetValue(val4, "SKILL_" + skillField); } fieldInfo.SetValue(val3, val4); } } if ((Object)(object)val != (Object)null) { string itemDescription = GetItemDescription(val); if (!string.IsNullOrEmpty(itemDescription)) { FieldInfo field3 = typeof(ToolItemSkill).GetField("promptDescription", BindingFlags.Instance | BindingFlags.NonPublic); if (field3 != null) { LocalisedString val5 = default(LocalisedString); FieldInfo field4 = typeof(LocalisedString).GetField("m_Fallback", BindingFlags.Instance | BindingFlags.NonPublic); if (field4 != null) { field4.SetValue(val5, itemDescription); } FieldInfo field5 = typeof(LocalisedString).GetField("m_Key", BindingFlags.Instance | BindingFlags.NonPublic); if (field5 != null) { field5.SetValue(val5, "DESC_" + skillField); } field3.SetValue(val3, val5); } } } ((ToolItem)val3).name = "Temp_" + displayName; return val3; } catch (Exception arg) { if (!_popupErrorLogged) { Plugin.Log.LogError((object)$"创建临时 ToolItemSkill 失败: {arg}"); } return null; } } private static string GetItemDescription(SavedItem item) { //IL_0083: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)item == (Object)null) { return ""; } try { CollectableItem val = (CollectableItem)(object)((item is CollectableItem) ? item : null); if (val != null) { return val.GetDescription((ReadSource)3); } CollectableRelic val2 = (CollectableRelic)(object)((item is CollectableRelic) ? item : null); if (val2 != null) { PropertyInfo property = typeof(CollectableRelic).GetProperty("Description", BindingFlags.Instance | BindingFlags.Public); if (property != null) { return property.GetValue(val2)?.ToString() ?? ""; } } ToolItem val3 = (ToolItem)(object)((item is ToolItem) ? item : null); if (val3 != null) { return LocalisedString.op_Implicit(val3.Description); } MethodInfo method = ((object)item).GetType().GetMethod("GetDescription", BindingFlags.Instance | BindingFlags.Public); if (method != null && method.DeclaringType != typeof(SavedItem)) { return (string)method.Invoke(item, new object[1] { 3 }); } } catch (Exception ex) { if (!_itemDescriptionErrorLogged) { Plugin.Log.LogWarning((object)("获取物品描述失败: " + ((Object)item).name + ", " + ex.Message)); _itemDescriptionErrorLogged = true; } } return ""; } 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_0171: 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) //IL_0140: 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)Resources.FindObjectsOfTypeAll()).FirstOrDefault((Func)((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(); for (int i = 0; i < val.Slots.Length; i++) { saveData.Slots.Add(new SlotData { IsUnlocked = !val.Slots[i].IsLocked }); } val.SaveData = saveData; } for (int j = 0; j < saveData.Slots.Count && j < val.Slots.Length; 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; val.SaveData = saveData; Plugin.Log.LogInfo((object)$"[SkillRandomizer] 已为纹章 {crestId} 解锁一个法术槽(索引 {j})"); break; } } } catch (Exception ex) { Plugin.Log.LogWarning((object)("[SkillRandomizer] 解锁法术槽失败: " + ex.Message)); } } private static void ShowGenericNativePopup(string skillField, string displayName, Sprite icon) { ToolItemSkill safeToolItemSkill = GetSafeToolItemSkill(skillField, displayName, icon); if ((Object)(object)safeToolItemSkill != (Object)null) { SkillGetMsg skillMsgPrefab = GetSkillMsgPrefab(); if ((Object)(object)skillMsgPrefab != (Object)null) { bool finished = false; SkillGetMsg.Spawn(skillMsgPrefab, safeToolItemSkill, (Action)delegate { finished = true; }); ((MonoBehaviour)Plugin.Instance).StartCoroutine(WaitForPopupEnd(finished)); return; } } Plugin.ShowSkillPopup(icon, displayName); } [IteratorStateMachine(typeof(d__38))] private static IEnumerator WaitForPopupEnd(bool finished) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__38(0) { finished = finished }; } public static void GiveSkill(string skillField) { //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) PlayerData instance = PlayerData.instance; if (instance == null) { return; } switch (skillField) { case "hasNeedolinMemoryPowerup": if (!instance.hasNeedolinMemoryPowerup) { instance.hasNeedolinMemoryPowerup = true; ShowGenericNativePopup(skillField, GetDisplayName(skillField), GetIcon(skillField)); } return; case "hasFastTravelTeleport": if (!instance.UnlockedFastTravelTeleport) { instance.UnlockedFastTravelTeleport = true; ShowGenericNativePopup(skillField, GetDisplayName(skillField), GetIcon(skillField)); } return; case "HasSeenEvaHeal": { if (instance.HasBoundCrestUpgrader) { return; } instance.HasBoundCrestUpgrader = true; instance.HasSeenEvaHeal = true; PowerUps val = (PowerUps)5; PowerUpGetMsg powerUpMsgPrefab = GetPowerUpMsgPrefab(); if ((Object)(object)powerUpMsgPrefab != (Object)null) { bool finished3 = false; PowerUpGetMsg.Spawn(powerUpMsgPrefab, val, (Action)delegate { finished3 = true; }); ((MonoBehaviour)Plugin.Instance).StartCoroutine(WaitForPopupEnd(finished3)); } else { Plugin.ShowSkillPopup(GetIcon(skillField), GetDisplayName(skillField)); } return; } } FieldInfo field = typeof(PlayerData).GetField(skillField, BindingFlags.Instance | BindingFlags.Public); if (field == null || field.FieldType != typeof(bool)) { Plugin.Log.LogWarning((object)("GiveSkill: 未找到字段 " + skillField + " 或类型不匹配")); return; } if ((bool)field.GetValue(instance)) { return; } EnsureSpellSlotsUnlocked(); PowerUps? powerUpEnum = GetPowerUpEnum(skillField); if (powerUpEnum.HasValue) { PowerUpGetMsg powerUpMsgPrefab2 = GetPowerUpMsgPrefab(); if ((Object)(object)powerUpMsgPrefab2 != (Object)null) { field.SetValue(instance, true); bool finished = false; PowerUpGetMsg.Spawn(powerUpMsgPrefab2, powerUpEnum.Value, (Action)delegate { finished = true; }); ((MonoBehaviour)Plugin.Instance).StartCoroutine(WaitForPopupEnd(finished)); return; } } string displayName = GetDisplayName(skillField); Sprite icon = GetIcon(skillField); ToolItemSkill safeToolItemSkill = GetSafeToolItemSkill(skillField, displayName, icon); if ((Object)(object)safeToolItemSkill != (Object)null) { field.SetValue(instance, true); SkillGetMsg skillMsgPrefab = GetSkillMsgPrefab(); if ((Object)(object)skillMsgPrefab != (Object)null) { bool finished2 = false; SkillGetMsg.Spawn(skillMsgPrefab, safeToolItemSkill, (Action)delegate { finished2 = true; }); ((MonoBehaviour)Plugin.Instance).StartCoroutine(WaitForPopupEnd(finished2)); return; } } field.SetValue(instance, true); Plugin.ShowSkillPopup(icon, displayName); } [IteratorStateMachine(typeof(d__40))] public static IEnumerator GiveRandomSkillCoroutine(Action onComplete = null) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__40(0) { onComplete = onComplete }; } public static void GiveRandomSkill() { ((MonoBehaviour)Plugin.Instance).StartCoroutine(GiveRandomSkillCoroutine()); } [IteratorStateMachine(typeof(d__42))] public static IEnumerator GiveRandomSkillFromCategoryCoroutine(List categoryFields, Action onComplete = null) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__42(0) { categoryFields = categoryFields, onComplete = onComplete }; } public static void GiveRandomSkillFromCategory(List categoryFields) { ((MonoBehaviour)Plugin.Instance).StartCoroutine(GiveRandomSkillFromCategoryCoroutine(categoryFields)); } public static void GiveWallJump() { GiveSkill("hasWalljump"); } public static void GiveHarpoonDash() { GiveSkill("hasHarpoonDash"); } } public static class ItemRandomizer { private static List _allItems; private static readonly Random _rng = new Random(); public static SavedItem GetRandomItem() { if (_allItems == null) { _allItems = (from item in Resources.FindObjectsOfTypeAll() where item is CollectableItem || item is ToolBase select item).ToList(); } if (_allItems.Count != 0) { return _allItems[_rng.Next(_allItems.Count)]; } return null; } } public class DirectionPermissions { public bool DashLeft; public bool DashRight; public bool HarpoonLeft; public bool HarpoonRight; public bool FloatLeft; public bool FloatRight; public bool WallJumpLeft; public bool WallJumpRight; public bool AllowHeal = true; } public class StartingSettings { public bool AllowUpward; public bool AllowLeft; public bool AllowRight; public bool UseTypeMode; public int SkillTotal; public int SkillVertical; public int SkillHorizontal; public int SkillSpecial; public int SkillAttack; public int StartingItemCount; public int Seed; public bool ResetSeedWorld; public bool FullRandomMode; public bool CrestCurseEnabled; public bool ForceCompletionDisplay = true; public DirectionPermissions MovementPermissions; } public class StartingAbilityPickerConfig { public int Seed; public bool FullRandomMode; public DirectionPermissions MovementPermissions; public bool CrestCurseEnabled; public bool ForceCompletionDisplay = true; public bool UseNativeSkillGiving = true; public bool PanelBackgroundEnabled = true; public int DefaultStartingItemCount; public int DefaultSkillTotal; public int DefaultSkillV; public int DefaultSkillH; public int DefaultSkillS; public int DefaultSkillA; public bool DefaultSkillTypeMode; public bool DefaultResetPickups; public (bool up, bool left, bool right) DefaultAttackPermissions = (false, false, false); public bool DisableBuiltinShortcut; } public static class StartingAbilityPickerAPI { private static bool _initialized = false; private static StartingAbilityPickerConfig _config; private static DirectionPermissions _currentMovement = new DirectionPermissions(); private static bool _fullRandomMode = false; private static bool _crestCurseEnabled = false; private static bool _forceCompletionDisplay = true; private static bool _useTypeMode = false; private static int _skillTotal = 0; private static int _skillV = 0; private static int _skillH = 0; private static int _skillS = 0; private static int _skillA = 0; private static int _itemCount = 0; private static int _seed = 0; private static bool _resetSeedWorld = false; private static bool _allowUpward = false; private static bool _allowLeft = false; private static bool _allowRight = false; private static bool _pendingChanges = false; private static bool _applied = false; private static bool _isGameReady = false; public static void Initialize(StartingAbilityPickerConfig config) { if (!_initialized) { _config = config ?? new StartingAbilityPickerConfig(); _fullRandomMode = _config.FullRandomMode; _crestCurseEnabled = _config.CrestCurseEnabled; _forceCompletionDisplay = _config.ForceCompletionDisplay; _useTypeMode = _config.DefaultSkillTypeMode; _skillTotal = _config.DefaultSkillTotal; _skillV = _config.DefaultSkillV; _skillH = _config.DefaultSkillH; _skillS = _config.DefaultSkillS; _skillA = _config.DefaultSkillA; _itemCount = _config.DefaultStartingItemCount; _seed = _config.Seed; _resetSeedWorld = _config.DefaultResetPickups; (_allowUpward, _allowLeft, _allowRight) = _config.DefaultAttackPermissions; if (_config.MovementPermissions != null) { _currentMovement.DashLeft = _config.MovementPermissions.DashLeft; _currentMovement.DashRight = _config.MovementPermissions.DashRight; _currentMovement.HarpoonLeft = _config.MovementPermissions.HarpoonLeft; _currentMovement.HarpoonRight = _config.MovementPermissions.HarpoonRight; _currentMovement.FloatLeft = _config.MovementPermissions.FloatLeft; _currentMovement.FloatRight = _config.MovementPermissions.FloatRight; _currentMovement.WallJumpLeft = _config.MovementPermissions.WallJumpLeft; _currentMovement.WallJumpRight = _config.MovementPermissions.WallJumpRight; _currentMovement.AllowHeal = _config.MovementPermissions.AllowHeal; } SyncToPlugin(); Plugin.SaveDirectionSettings(); Plugin.SaveAttackDirections(); _initialized = true; _pendingChanges = true; } } private static void SyncToPlugin() { Plugin.SetFullRandomMode(_fullRandomMode); Plugin.SetCrestCurseEnabled(_crestCurseEnabled); Plugin.Instance?.SetForceCompletionDisplay(_forceCompletionDisplay); SkillRandomizer.UseNativeItemGiving = _config?.UseNativeSkillGiving ?? true; if (_config != null) { Plugin.PanelBackgroundEnabled.Value = _config.PanelBackgroundEnabled; } Plugin.skillMode = _useTypeMode; Plugin.skillTotal = _skillTotal; Plugin.skillV = _skillV; Plugin.skillH = _skillH; Plugin.skillS = _skillS; Plugin.skillA = _skillA; Plugin.itemCount = _itemCount; Plugin.seedInput = _seed.ToString(); Plugin.resetPickups = _resetSeedWorld; Plugin.allowUpward = _allowUpward; Plugin.allowLeft = _allowLeft; Plugin.allowRight = _allowRight; Plugin.AllowDashLeft = _currentMovement.DashLeft; Plugin.AllowDashRight = _currentMovement.DashRight; Plugin.AllowHarpoonLeft = _currentMovement.HarpoonLeft; Plugin.AllowHarpoonRight = _currentMovement.HarpoonRight; Plugin.AllowFloatLeft = _currentMovement.FloatLeft; Plugin.AllowFloatRight = _currentMovement.FloatRight; Plugin.AllowWallJumpLeft = _currentMovement.WallJumpLeft; Plugin.AllowWallJumpRight = _currentMovement.WallJumpRight; Plugin.AllowHeal = _currentMovement.AllowHeal; Plugin.AllowUpwardAttack = _allowUpward; Plugin.AllowLeftAttack = _allowLeft; Plugin.AllowRightAttack = _allowRight; } public static void MarkGameReady() { _isGameReady = true; if (_pendingChanges) { ApplyPending(); } } public static void ApplyPending() { if (_pendingChanges) { DirectionPatch.FullRandomMode = _fullRandomMode; DirectionPatch.SetAllowAttackDirection(_allowUpward, _allowLeft, _allowRight); if (_currentMovement != null) { DirectionPatch.SetAllowDashDirection(_currentMovement.DashLeft, _currentMovement.DashRight); DirectionPatch.SetAllowHarpoonDirection(_currentMovement.HarpoonLeft, _currentMovement.HarpoonRight); DirectionPatch.SetAllowFloatDirection(_currentMovement.FloatLeft, _currentMovement.FloatRight); DirectionPatch.SetAllowWallJumpDirection(_currentMovement.WallJumpLeft, _currentMovement.WallJumpRight); DirectionPatch.SetAllowHeal(_currentMovement.AllowHeal); } Plugin.SetCrestCurseEnabled(_crestCurseEnabled); Plugin.Instance?.SetForceCompletionDisplay(_forceCompletionDisplay); PlayerData instance = PlayerData.instance; if (instance != null) { instance.SetBool("SkillRandomMode", _useTypeMode); instance.SetInt("SkillTotalCount", _skillTotal); instance.SetInt("SkillVerticalCount", _skillV); instance.SetInt("SkillHorizontalCount", _skillH); instance.SetInt("SkillSpecialCount", _skillS); instance.SetInt("SkillAttackCount", _skillA); } if (_resetSeedWorld) { Plugin.ResetSeedWorldExternal(_seed); } _pendingChanges = false; _applied = true; } } public static void SetFullRandomMode(bool enabled) { _fullRandomMode = enabled; Plugin.SetFullRandomMode(enabled); _pendingChanges = true; ApplyPending(); } public static bool GetFullRandomMode() { return _fullRandomMode; } public static void SetCrestCurseEnabled(bool enabled) { _crestCurseEnabled = enabled; Plugin.SetCrestCurseEnabled(enabled); _pendingChanges = true; ApplyPending(); } public static bool GetCrestCurseEnabled() { return _crestCurseEnabled; } public static void SetForceCompletionDisplay(bool enabled) { _forceCompletionDisplay = enabled; Plugin.Instance?.SetForceCompletionDisplay(enabled); _pendingChanges = true; ApplyPending(); } public static bool GetForceCompletionDisplay() { return _forceCompletionDisplay; } public static void SetAttackPermissions(bool up, bool left, bool right) { _allowUpward = up; _allowLeft = left; _allowRight = right; Plugin.allowUpward = up; Plugin.allowLeft = left; Plugin.allowRight = right; Plugin.AllowUpwardAttack = up; Plugin.AllowLeftAttack = left; Plugin.AllowRightAttack = right; _pendingChanges = true; ApplyPending(); } public static (bool up, bool left, bool right) GetAttackPermissions() { return (_allowUpward, _allowLeft, _allowRight); } public static void SetMovementPermissions(DirectionPermissions perms) { if (perms != null) { _currentMovement.DashLeft = perms.DashLeft; _currentMovement.DashRight = perms.DashRight; _currentMovement.HarpoonLeft = perms.HarpoonLeft; _currentMovement.HarpoonRight = perms.HarpoonRight; _currentMovement.FloatLeft = perms.FloatLeft; _currentMovement.FloatRight = perms.FloatRight; _currentMovement.WallJumpLeft = perms.WallJumpLeft; _currentMovement.WallJumpRight = perms.WallJumpRight; _currentMovement.AllowHeal = perms.AllowHeal; Plugin.AllowDashLeft = perms.DashLeft; Plugin.AllowDashRight = perms.DashRight; Plugin.AllowHarpoonLeft = perms.HarpoonLeft; Plugin.AllowHarpoonRight = perms.HarpoonRight; Plugin.AllowFloatLeft = perms.FloatLeft; Plugin.AllowFloatRight = perms.FloatRight; Plugin.AllowWallJumpLeft = perms.WallJumpLeft; Plugin.AllowWallJumpRight = perms.WallJumpRight; Plugin.AllowHeal = perms.AllowHeal; _pendingChanges = true; ApplyPending(); } } public static DirectionPermissions GetMovementPermissions() { return _currentMovement; } public static void SetSkillRandomMode(bool useTypeMode) { _useTypeMode = useTypeMode; Plugin.skillMode = useTypeMode; _pendingChanges = true; ApplyPending(); } public static bool GetSkillRandomMode() { return _useTypeMode; } public static void SetSkillCounts(int total, int v, int h, int s, int a) { _skillTotal = total; _skillV = v; _skillH = h; _skillS = s; _skillA = a; Plugin.skillTotal = total; Plugin.skillV = v; Plugin.skillH = h; Plugin.skillS = s; Plugin.skillA = a; _pendingChanges = true; ApplyPending(); } public static (int total, int v, int h, int s, int a) GetSkillCounts() { return (_skillTotal, _skillV, _skillH, _skillS, _skillA); } public static void SetStartingItemCount(int count) { _itemCount = count; Plugin.itemCount = count; _pendingChanges = true; ApplyPending(); } public static int GetStartingItemCount() { return _itemCount; } public static void SetSeed(int seed) { _seed = seed; Plugin.seedInput = seed.ToString(); Plugin.RandomSeed.Value = seed; _pendingChanges = true; ApplyPending(); } public static int GetSeed() { return _seed; } public static void SetResetSeedWorld(bool reset) { _resetSeedWorld = reset; Plugin.resetPickups = reset; _pendingChanges = true; ApplyPending(); } public static bool GetResetSeedWorld() { return _resetSeedWorld; } public static bool HasPendingChanges() { return _pendingChanges; } public static void ApplySettingsNow(StartingSettings settings) { if (settings != null) { _allowUpward = settings.AllowUpward; _allowLeft = settings.AllowLeft; _allowRight = settings.AllowRight; _useTypeMode = settings.UseTypeMode; _skillTotal = settings.SkillTotal; _skillV = settings.SkillVertical; _skillH = settings.SkillHorizontal; _skillS = settings.SkillSpecial; _skillA = settings.SkillAttack; _itemCount = settings.StartingItemCount; _seed = settings.Seed; _resetSeedWorld = settings.ResetSeedWorld; _fullRandomMode = settings.FullRandomMode; _crestCurseEnabled = settings.CrestCurseEnabled; _forceCompletionDisplay = settings.ForceCompletionDisplay; if (settings.MovementPermissions != null) { _currentMovement = settings.MovementPermissions; } SyncToPlugin(); ApplyPending(); if ((Object)(object)Plugin.Instance != (Object)null) { Plugin.Instance.ApplyStartingSettings(); } } } public static void RefreshUI() { SyncToPlugin(); } public static void SetItemRandomEnabled(bool enabled) { SilksongItemRandomizerAPI.SetEnabled(enabled); } public static void SetSceneRandomEnabled(bool enabled) { HKSilksong_RandomizerAPI.SetEnabled(enabled); } public static void SetTrapRandomEnabled(bool enabled) { SilksongItemRandomizerAPI.SetTrapEnabled(enabled); } public static void SetEnemyRandomEnabled(bool enabled) { (Type.GetType("SilksongItemRandomizer.EnemyRandoAdjuster, SilksongItemRandomizer")?.GetProperty("Enabled", BindingFlags.Static | BindingFlags.Public))?.SetValue(null, enabled); } public static void GiveSkill(string skillField) { SkillRandomizer.GiveSkill(skillField); } public static void GiveRandomSkill() { SkillRandomizer.GiveRandomSkill(); } public static void GiveRandomSkillFromCategory(string[] categoryFields) { SkillRandomizer.GiveRandomSkillFromCategory(new List(categoryFields)); } public static int GetCurrentRoomSeed() { try { return HKSilksong_RandomizerAPI.GetCurrentRoomSeed(); } catch { return 0; } } public static string GetCurrentRoomScene() { try { return HKSilksong_RandomizerAPI.GetCurrentSceneName(); } catch { return ""; } } public static void SetRoomRandomizationEnabled(bool enabled) { try { HKSilksong_RandomizerAPI.SetEnabled(enabled); } catch { } } public static bool IsRoomRandomizationEnabled() { try { return HKSilksong_RandomizerAPI.IsSceneRandomEnabled(); } catch { return false; } } public static void TeleportToRoom(string sceneName, string entryGate = null) { try { HKSilksong_RandomizerAPI.TeleportToScene(sceneName, entryGate); } catch { } } public static string GetDisplayName(string skillField) { try { return SkillRandomizer.GetDisplayName(skillField); } catch { return skillField; } } public static Sprite GetIcon(string skillField) { try { return SkillRandomizer.GetIcon(skillField); } catch { return null; } } public static void ShowSettingsUI(bool show) { Plugin.Instance.ShowUI = show; } public static bool IsSettingsUIVisible() { return Plugin.Instance.ShowUI; } } }