using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using P.E.A.K_MENU.Constants; using P.E.A.K_MENU.Features.BlowDart; using P.E.A.K_MENU.Features.Flight; using P.E.A.K_MENU.Features.ItemSpawn; using P.E.A.K_MENU.Features.Status; using P.E.A.K_MENU.Features.Teleport; using P.E.A.K_MENU.Input; using P.E.A.K_MENU.Patches; using P.E.A.K_MENU.UI; using P.E.A.K_MENU.UI.Pages; using Photon.Pun; using Photon.Realtime; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI; using Zorro.Core; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("ruangfafa.peakmenu")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("PEAK 游戏内实用菜单,包含物品生成、玩家传送、飞行、状态控制、特效吹箭、主题与可调整界面。本模组可能改变游戏玩法,作弊,请自行酌情使用以保护游戏体验!")] [assembly: AssemblyFileVersion("0.4.0.0")] [assembly: AssemblyInformationalVersion("0.4.0+545d91cd4ddde4bb63ed879e46067471fd597be4")] [assembly: AssemblyProduct("ruangfafa.peakmenu")] [assembly: AssemblyTitle("P.E.A.K_MENU")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/Ruangfafa/P.E.A.K_MENU")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.4.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace BepInEx { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] [Embedded] internal sealed class BepInAutoPluginAttribute : Attribute { public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace BepInEx.Preloader.Core.Patching { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] [Embedded] internal sealed class PatcherAutoPluginAttribute : Attribute { public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace Microsoft.CodeAnalysis { [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace P.E.A.K_MENU { internal static class ModUpdateSettings { private static ConfigFile? _config; private static ConfigEntry? _lastRunVersion; private static ConfigEntry? _lastAcknowledgedChangelogVersion; private static ConfigEntry? _lastAcknowledgedAnnouncementVersion; private static ConfigEntry? _lastHoverDownForceResetVersion; private static ConfigEntry? _showChangelogOnEveryLaunch; private static string _currentVersion = string.Empty; internal static string CurrentVersion => _currentVersion; internal static bool ShouldShowChangelog { get { if (!string.IsNullOrWhiteSpace(_currentVersion)) { ConfigEntry? showChangelogOnEveryLaunch = _showChangelogOnEveryLaunch; if (showChangelogOnEveryLaunch == null || !showChangelogOnEveryLaunch.Value) { return !string.Equals(_lastAcknowledgedChangelogVersion?.Value, _currentVersion, StringComparison.OrdinalIgnoreCase); } return true; } return false; } } internal static void Apply(ConfigFile config, string currentVersion) { _config = config; _lastRunVersion = config.Bind("Internal", "LastRunVersion", string.Empty, "上次成功应用版本更新默认设置时的 Mod 版本。"); _lastAcknowledgedChangelogVersion = config.Bind("Internal", "LastAcknowledgedChangelogVersion", string.Empty, "上次已确认关闭更新日志的 Mod 版本。"); _lastAcknowledgedAnnouncementVersion = config.Bind("Internal", "LastAcknowledgedAnnouncementVersion", string.Empty, "上次已确认关闭版本公告的 Mod 版本。"); _lastHoverDownForceResetVersion = config.Bind("Internal", "LastHoverDownForceResetVersion", string.Empty, "上次自动恢复浮空重力默认值时的 Mod 版本。"); _showChangelogOnEveryLaunch = config.Bind("Debug", "ShowChangelogOnEveryLaunch", false, "调试选项:开启后每次启动游戏都显示更新日志和当前版本公告。"); string text = (_currentVersion = currentVersion.Trim()); if (string.IsNullOrEmpty(text)) { Plugin.Log.LogWarning((object)"Could not resolve the current Mod version; update defaults were not applied."); return; } ResetHoverDownForceForVersion(config, text); if (!string.Equals(_lastRunVersion.Value, text, StringComparison.OrdinalIgnoreCase)) { if (!ItemSpawnConfiguration.IsInitialized) { Plugin.Log.LogWarning((object)"ItemSpawner configuration is unavailable; update defaults will be retried next launch."); return; } string text2 = (string.IsNullOrWhiteSpace(_lastRunVersion.Value) ? "" : _lastRunVersion.Value); MenuSettings.ResetWindowSize(); ItemSpawnConfiguration.ResetSpawnColumns(); _lastRunVersion.Value = text; config.Save(); Plugin.Log.LogInfo((object)("Mod version changed from " + text2 + " to " + text + "; window size and ItemSpawner columns were reset to defaults.")); } } internal static void AcknowledgeChangelog() { if (_lastAcknowledgedChangelogVersion != null && !string.IsNullOrWhiteSpace(_currentVersion)) { _lastAcknowledgedChangelogVersion.Value = _currentVersion; ConfigFile? config = _config; if (config != null) { config.Save(); } Plugin.Log.LogInfo((object)("Changelog acknowledged for version " + _currentVersion + ".")); } } private static void ResetHoverDownForceForVersion(ConfigFile config, string normalizedVersion) { if (_lastHoverDownForceResetVersion != null && !string.Equals(_lastHoverDownForceResetVersion.Value, normalizedVersion, StringComparison.OrdinalIgnoreCase)) { if (!FlightRuntime.IsInitialized) { Plugin.Log.LogWarning((object)"Flight configuration is unavailable; the hover calibration reset will be retried next launch."); return; } FlightRuntime.Service.ResetHoverDownForce(); _lastHoverDownForceResetVersion.Value = normalizedVersion; config.Save(); Plugin.Log.LogInfo((object)("Hover down force was reset to " + $"{255f:0.##} " + "for version " + normalizedVersion + ".")); } } internal static bool ShouldShowAnnouncement(string announcementVersion) { if (!string.IsNullOrWhiteSpace(announcementVersion) && string.Equals(announcementVersion, _currentVersion, StringComparison.OrdinalIgnoreCase)) { ConfigEntry? showChangelogOnEveryLaunch = _showChangelogOnEveryLaunch; if (showChangelogOnEveryLaunch == null || !showChangelogOnEveryLaunch.Value) { return !string.Equals(_lastAcknowledgedAnnouncementVersion?.Value, announcementVersion, StringComparison.OrdinalIgnoreCase); } return true; } return false; } internal static void AcknowledgeAnnouncement(string announcementVersion) { if (_lastAcknowledgedAnnouncementVersion != null && string.Equals(announcementVersion, _currentVersion, StringComparison.OrdinalIgnoreCase)) { _lastAcknowledgedAnnouncementVersion.Value = announcementVersion; ConfigFile? config = _config; if (config != null) { config.Save(); } Plugin.Log.LogInfo((object)("Announcement acknowledged for version " + announcementVersion + ".")); } } } [DefaultExecutionOrder(10000)] [BepInPlugin("ruangfafa.peakmenu", "P.E.A.K_MENU", "0.4.0")] public class Plugin : BaseUnityPlugin { private PeakMenuWindow _menuWindow; private MenuInputController _inputController; private FeatureShortcutController _featureShortcutController; private ChangelogOverlay _changelogOverlay; private AnnouncementOverlay _announcementOverlay; private Harmony _harmony; public const string Id = "ruangfafa.peakmenu"; internal static ManualLogSource Log { get; private set; } public static string Name => "P.E.A.K_MENU"; public static string Version => "0.4.0"; private void Awake() { //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; Log.LogInfo((object)"P.E.A.K_MENU Awake started."); MenuSettings.Initialize(((BaseUnityPlugin)this).Config); FeatureInputSettings.Initialize(((BaseUnityPlugin)this).Config); MenuIcons.Initialize(); InitializeFeature("ItemSpawn", delegate { ItemSpawnRuntime.Initialize(((BaseUnityPlugin)this).Config); }); InitializeFeature("Teleport", TeleportRuntime.Initialize); InitializeFeature("Status", StatusRuntime.Initialize); InitializeFeature("Flight", delegate { FlightRuntime.Initialize(((BaseUnityPlugin)this).Config); }); InitializeFeature("BlowDart", delegate { BlowDartRuntime.Initialize(((BaseUnityPlugin)this).Config); }); InitializeFeature("Update defaults", delegate { ModUpdateSettings.Apply(((BaseUnityPlugin)this).Config, ((BaseUnityPlugin)this).Info.Metadata.Version.ToString()); }); _menuWindow = new PeakMenuWindow(); _inputController = new MenuInputController(_menuWindow); _featureShortcutController = new FeatureShortcutController(); _changelogOverlay = new ChangelogOverlay(); _announcementOverlay = new AnnouncementOverlay(); _harmony = new Harmony("ruangfafa.peakmenu"); _harmony.PatchAll(); Log.LogInfo((object)("Plugin " + Name + " is loaded!")); } private void Update() { _changelogOverlay.Update(); _announcementOverlay.Update(!_changelogOverlay.IsVisible); if (!_changelogOverlay.IsVisible && !_announcementOverlay.IsVisible) { _inputController.Update(); _featureShortcutController.Update(); } _menuWindow.Update(); TeleportRuntime.Update(); StatusRuntime.Update(); FlightRuntime.Update(); BlowDartRuntime.Update(); } private void OnGUI() { _menuWindow.Draw(); _changelogOverlay.Draw(); _announcementOverlay.Draw(); } private void LateUpdate() { _menuWindow.LateUpdate(); _changelogOverlay.LateUpdate(); _announcementOverlay.LateUpdate(); } private void OnDisable() { _changelogOverlay?.HideWithoutAcknowledging(); _announcementOverlay?.HideWithoutAcknowledging(); MenuState.IsOpen = false; MenuState.IsRebinding = false; _menuWindow?.Close(); } private void OnDestroy() { MenuState.IsOpen = false; MenuState.IsRebinding = false; _menuWindow?.Dispose(); _changelogOverlay?.Dispose(); _announcementOverlay?.Dispose(); MenuIcons.Dispose(); FlightRuntime.Dispose(); BlowDartRuntime.Dispose(); ItemSpawnRuntime.Dispose(); TeleportRuntime.Dispose(); StatusRuntime.Dispose(); Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } private static void InitializeFeature(string name, Action initializer) { try { initializer(); Log.LogInfo((object)(name + " initialized.")); } catch (Exception arg) { Log.LogError((object)(name + " initialization failed: " + $"{arg}")); } } } } namespace P.E.A.K_MENU.UI { internal sealed class AnnouncementOverlay : IDisposable { private sealed class AnnouncementDefinition { internal string Version { get; } internal string Title { get; } internal float WaitSeconds { get; } internal IReadOnlyList BodyLines { get; } internal IReadOnlyList Actions { get; } internal AnnouncementDefinition(string version, string title, float waitSeconds, IReadOnlyList bodyLines, IReadOnlyList actions) { Version = version; Title = title; WaitSeconds = waitSeconds; BodyLines = bodyLines; Actions = actions; } } private sealed class AnnouncementAction { internal string Id { get; } internal string Label { get; } internal AnnouncementAction(string id, string label) { Id = id; Label = label; } } private const string AnnouncementResourceName = "P.E.A.K_MENU.ANNOUNCEMENTS.md"; private const float MaximumWidth = 700f; private const float MaximumHeight = 560f; private const float ScreenMargin = 32f; private readonly CursorController _cursorController = new CursorController(); private readonly AnnouncementDefinition? _announcement; private MenuStyles? _styles; private MenuTheme _loadedTheme; private GUIStyle? _headingStyle; private Vector2 _scrollPosition; private float _shownAt; private string _actionStatus = string.Empty; private bool _showAttempted; private bool _isVisible; private bool _disposed; internal bool IsVisible { get { if (_isVisible) { return !_disposed; } return false; } } private bool CanClose { get { if (_announcement != null) { return Time.realtimeSinceStartup - _shownAt >= _announcement.WaitSeconds; } return false; } } private int RemainingWaitSeconds { get { if (_announcement != null) { return Mathf.Max(0, Mathf.CeilToInt(_announcement.WaitSeconds - (Time.realtimeSinceStartup - _shownAt))); } return 0; } } private MenuStyles Styles { get { EnsureCurrentTheme(); return _styles; } } internal AnnouncementOverlay() { _loadedTheme = MenuSettings.Theme; _announcement = LoadCurrentAnnouncement(); } internal void Update(bool canShow) { if (!IsVisible) { if (canShow && !_showAttempted) { TryShow(); } } else if (CanClose && Input.GetKeyDown((KeyCode)27)) { CloseAndAcknowledge(); } } internal void LateUpdate() { if (IsVisible) { _cursorController.MaintainReleased(); } } internal void Draw() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0061: 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_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Expected O, but got Unknown //IL_010a: Unknown result type (might be due to invalid IL or missing references) if (IsVisible && _announcement != null) { EnsureCurrentTheme(); Color color = GUI.color; GUI.color = new Color(0f, 0f, 0f, 0.68f); GUI.DrawTexture(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), (Texture)(object)Texture2D.whiteTexture, (ScaleMode)0); GUI.color = color; float num = Mathf.Min(700f, Mathf.Max(320f, (float)Screen.width - 64f)); float num2 = Mathf.Min(560f, Mathf.Max(300f, (float)Screen.height - 64f)); num = Mathf.Min(num, (float)Screen.width); num2 = Mathf.Min(num2, (float)Screen.height); Rect val = default(Rect); ((Rect)(ref val))..ctor(((float)Screen.width - num) * 0.5f, ((float)Screen.height - num2) * 0.5f, num, num2); GUI.ModalWindow(938423, val, new WindowFunction(DrawWindowContents), GUIContent.none, Styles.Window); } } internal void HideWithoutAcknowledging() { Hide(acknowledge: false); } public void Dispose() { if (!_disposed) { Hide(acknowledge: false); _styles?.Dispose(); _styles = null; _disposed = true; } } private void TryShow() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) _showAttempted = true; if (!_disposed && _announcement != null && ModUpdateSettings.ShouldShowAnnouncement(_announcement.Version)) { _isVisible = true; _scrollPosition = Vector2.zero; _actionStatus = string.Empty; _shownAt = Time.realtimeSinceStartup; MenuState.IsOpen = true; _cursorController.Release(); Plugin.Log.LogInfo((object)("Showing announcement for version " + _announcement.Version + ".")); } } private void CloseAndAcknowledge() { Hide(acknowledge: true); } private void Hide(bool acknowledge) { if (_isVisible) { if (acknowledge && _announcement != null) { ModUpdateSettings.AcknowledgeAnnouncement(_announcement.Version); } _isVisible = false; MenuState.IsOpen = false; MenuState.IsRebinding = false; _cursorController.Restore(); } } private void DrawWindowContents(int windowId) { //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) if (_announcement == null) { return; } GUILayout.BeginHorizontal(Array.Empty()); GUILayout.FlexibleSpace(); GUILayout.Label("P.E.A.K MENU 公告", Styles.WindowTitleBold, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }); GUILayout.Space(14f); GUILayout.Label(" by Ruangfafa", Styles.WindowTitleNormal, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Space(14f); GUILayout.Label(_announcement.Title, _headingStyle, Array.Empty()); GUILayout.Space(10f); _scrollPosition = GUILayout.BeginScrollView(_scrollPosition, false, true, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true) }); DrawBody(_announcement.BodyLines); GUILayout.EndScrollView(); foreach (AnnouncementAction action in _announcement.Actions) { if (GUILayout.Button(action.Label, Styles.ActionButton, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(40f) })) { ExecuteAction(action.Id); } } if (!string.IsNullOrWhiteSpace(_actionStatus)) { GUILayout.Space(4f); GUILayout.Label(_actionStatus, Styles.MutedLabel, Array.Empty()); } GUILayout.Space(8f); GUILayout.BeginHorizontal(Array.Empty()); string text = (CanClose ? "按 Esc 也可以关闭" : $"请阅读公告,{RemainingWaitSeconds} 秒后可关闭"); GUILayout.Label(text, Styles.MutedLabel, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Height(40f), GUILayout.ExpandWidth(true) }); bool enabled = GUI.enabled; GUI.enabled = enabled && CanClose; string text2 = (CanClose ? "确认" : $"确认({RemainingWaitSeconds})"); if (GUILayout.Button(text2, Styles.ActionButton, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(150f), GUILayout.Height(40f) })) { CloseAndAcknowledge(); } GUI.enabled = enabled; GUILayout.EndHorizontal(); } private void ExecuteAction(string actionId) { if (actionId == "restore-item-spawner-defaults") { RestoreItemSpawnerDefaults(); return; } _actionStatus = "无法识别公告操作:" + actionId; Plugin.Log.LogWarning((object)("Unknown announcement action: " + actionId)); } private void RestoreItemSpawnerDefaults() { if (!ItemSpawnRuntime.IsInitialized) { _actionStatus = "物品生成器尚未初始化,暂时无法恢复默认列表。"; return; } ItemSpawnRuntime.Catalog.RefreshIfNeeded(); if (ItemSpawnRuntime.Catalog.AllItems.Count == 0) { _actionStatus = "游戏物品数据库尚未就绪,请进入游戏后再试。"; return; } ItemSpawnRuntime.Catalog.RestoreDefaults(); _actionStatus = "已恢复默认物品和默认排序。"; } private void DrawBody(IEnumerable lines) { foreach (string line in lines) { string text = line.TrimEnd(); if (string.IsNullOrWhiteSpace(text)) { GUILayout.Space(6f); continue; } string text2 = (text.StartsWith("- ", StringComparison.Ordinal) ? ("• " + text.Substring(2)) : text); GUILayout.Label(text2.Replace("`", string.Empty), Styles.Label, Array.Empty()); } } private void EnsureCurrentTheme() { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown MenuTheme theme = MenuSettings.Theme; if (_styles == null || _loadedTheme != theme) { _styles?.Dispose(); _loadedTheme = theme; _styles = new MenuStyles(theme); _headingStyle = new GUIStyle(_styles.Title) { fontSize = 21, alignment = (TextAnchor)3 }; } } private static AnnouncementDefinition? LoadCurrentAnnouncement() { try { Assembly assembly = typeof(AnnouncementOverlay).Assembly; using Stream stream = assembly.GetManifestResourceStream("P.E.A.K_MENU.ANNOUNCEMENTS.md"); if (stream == null) { throw new InvalidOperationException("Embedded resource 'P.E.A.K_MENU.ANNOUNCEMENTS.md' was not found."); } using StreamReader streamReader = new StreamReader(stream); string[] lines = streamReader.ReadToEnd().Replace("\r\n", "\n").Split('\n'); return ParseAnnouncements(lines).FirstOrDefault((AnnouncementDefinition announcement) => string.Equals(announcement.Version, ModUpdateSettings.CurrentVersion, StringComparison.OrdinalIgnoreCase)); } catch (Exception arg) { Plugin.Log.LogError((object)("Failed to load embedded announcements: " + $"{arg}")); return null; } } private static IReadOnlyList ParseAnnouncements(IReadOnlyList lines) { List list = new List(); int i = 0; while (i < lines.Count) { string text = lines[i].Trim(); if (!text.StartsWith("## ", StringComparison.Ordinal)) { i++; continue; } string text2 = text.Substring(3).Trim(); i++; string title = text2; float waitSeconds = 0f; List list2 = new List(); for (; i < lines.Count && !string.IsNullOrWhiteSpace(lines[i]); i++) { string text3 = lines[i].Trim(); if (text3.StartsWith("wait-seconds:", StringComparison.OrdinalIgnoreCase)) { string s = text3.Substring("wait-seconds:".Length).Trim(); if (float.TryParse(s, NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) { waitSeconds = Mathf.Max(0f, result); } } else if (text3.StartsWith("title:", StringComparison.OrdinalIgnoreCase)) { title = text3.Substring("title:".Length).Trim(); } else if (text3.StartsWith("action:", StringComparison.OrdinalIgnoreCase)) { string text4 = text3.Substring("action:".Length).Trim(); string[] array = text4.Split(new char[1] { '|' }, 2); if (array.Length == 2 && !string.IsNullOrWhiteSpace(array[0]) && !string.IsNullOrWhiteSpace(array[1])) { list2.Add(new AnnouncementAction(array[0].Trim(), array[1].Trim())); } } } if (i < lines.Count && string.IsNullOrWhiteSpace(lines[i])) { i++; } List list3 = new List(); for (; i < lines.Count && !lines[i].TrimStart().StartsWith("## ", StringComparison.Ordinal); i++) { list3.Add(lines[i]); } while (list3.Count > 0 && string.IsNullOrWhiteSpace(list3[list3.Count - 1])) { list3.RemoveAt(list3.Count - 1); } if (!string.IsNullOrWhiteSpace(text2)) { list.Add(new AnnouncementDefinition(text2, title, waitSeconds, list3, list2)); } } return list; } } internal sealed class ChangelogOverlay : IDisposable { private const string ChangelogResourceName = "P.E.A.K_MENU.CHANGELOG.md"; private const float MaximumWidth = 760f; private const float MaximumHeight = 720f; private const float ScreenMargin = 32f; private readonly CursorController _cursorController = new CursorController(); private readonly string[] _lines; private MenuStyles? _styles; private MenuTheme _loadedTheme; private GUIStyle? _versionHeadingStyle; private GUIStyle? _sectionHeadingStyle; private Vector2 _scrollPosition; private bool _isVisible; private bool _disposed; internal bool IsVisible { get { if (_isVisible) { return !_disposed; } return false; } } private MenuStyles Styles { get { EnsureCurrentTheme(); return _styles; } } internal ChangelogOverlay() { _loadedTheme = MenuSettings.Theme; _lines = LoadChangelogLines(); if (ModUpdateSettings.ShouldShowChangelog) { Show(); } } internal void Update() { if (IsVisible && Input.GetKeyDown((KeyCode)27)) { CloseAndAcknowledge(); } } internal void LateUpdate() { if (IsVisible) { _cursorController.MaintainReleased(); } } internal void Draw() { //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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: 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_0107: Expected O, but got Unknown //IL_0102: Unknown result type (might be due to invalid IL or missing references) if (IsVisible) { EnsureCurrentTheme(); Color color = GUI.color; GUI.color = new Color(0f, 0f, 0f, 0.68f); GUI.DrawTexture(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), (Texture)(object)Texture2D.whiteTexture, (ScaleMode)0); GUI.color = color; float num = Mathf.Min(760f, Mathf.Max(320f, (float)Screen.width - 64f)); float num2 = Mathf.Min(720f, Mathf.Max(300f, (float)Screen.height - 64f)); num = Mathf.Min(num, (float)Screen.width); num2 = Mathf.Min(num2, (float)Screen.height); Rect val = default(Rect); ((Rect)(ref val))..ctor(((float)Screen.width - num) * 0.5f, ((float)Screen.height - num2) * 0.5f, num, num2); GUI.ModalWindow(938422, val, new WindowFunction(DrawWindowContents), GUIContent.none, Styles.Window); } } internal void HideWithoutAcknowledging() { Hide(acknowledge: false); } public void Dispose() { if (!_disposed) { Hide(acknowledge: false); _styles?.Dispose(); _styles = null; _disposed = true; } } private void Show() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) if (!_disposed && !_isVisible) { _isVisible = true; _scrollPosition = Vector2.zero; MenuState.IsOpen = true; _cursorController.Release(); Plugin.Log.LogInfo((object)("Showing changelog for version " + ModUpdateSettings.CurrentVersion + ".")); } } private void CloseAndAcknowledge() { Hide(acknowledge: true); } private void Hide(bool acknowledge) { if (_isVisible) { if (acknowledge) { ModUpdateSettings.AcknowledgeChangelog(); } _isVisible = false; MenuState.IsOpen = false; MenuState.IsRebinding = false; _cursorController.Restore(); } } private void DrawWindowContents(int windowId) { //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) GUILayout.BeginHorizontal(Array.Empty()); GUILayout.FlexibleSpace(); GUILayout.Label("P.E.A.K MENU 更新日志", Styles.WindowTitleBold, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }); GUILayout.Space(14f); GUILayout.Label(" by Ruangfafa", Styles.WindowTitleNormal, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Space(4f); GUILayout.Label("当前版本:" + ModUpdateSettings.CurrentVersion, Styles.MutedLabel, Array.Empty()); GUILayout.Space(12f); _scrollPosition = GUILayout.BeginScrollView(_scrollPosition, false, true, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true) }); DrawMarkdownContents(); GUILayout.EndScrollView(); GUILayout.Space(12f); GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label("按 Esc 也可以关闭", Styles.MutedLabel, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Height(40f), GUILayout.ExpandWidth(true) }); if (GUILayout.Button("确认", Styles.ActionButton, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(150f), GUILayout.Height(40f) })) { CloseAndAcknowledge(); } GUILayout.EndHorizontal(); } private void DrawMarkdownContents() { string[] lines = _lines; foreach (string text in lines) { string text2 = text.TrimEnd(); if (string.IsNullOrWhiteSpace(text2)) { GUILayout.Space(6f); } else if (!text2.StartsWith("# ", StringComparison.Ordinal)) { if (text2.StartsWith("## ", StringComparison.Ordinal)) { GUILayout.Space(8f); GUILayout.Label(RemoveInlineMarkdown(text2.Substring(3)), _versionHeadingStyle, Array.Empty()); } else if (text2.StartsWith("### ", StringComparison.Ordinal)) { GUILayout.Space(4f); GUILayout.Label(RemoveInlineMarkdown(text2.Substring(4)), _sectionHeadingStyle, Array.Empty()); } else { string value = (text2.StartsWith("- ", StringComparison.Ordinal) ? ("• " + text2.Substring(2)) : text2); GUILayout.Label(RemoveInlineMarkdown(value), Styles.Label, Array.Empty()); } } } } private void EnsureCurrentTheme() { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown //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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown MenuTheme theme = MenuSettings.Theme; if (_styles == null || _loadedTheme != theme) { _styles?.Dispose(); _loadedTheme = theme; _styles = new MenuStyles(theme); _versionHeadingStyle = new GUIStyle(_styles.Title) { fontSize = 18, alignment = (TextAnchor)3 }; _sectionHeadingStyle = new GUIStyle(_styles.Label) { fontStyle = (FontStyle)1, fontSize = 15 }; } } private static string RemoveInlineMarkdown(string value) { return value.Replace("`", string.Empty); } private static string[] LoadChangelogLines() { try { Assembly assembly = typeof(ChangelogOverlay).Assembly; using Stream stream = assembly.GetManifestResourceStream("P.E.A.K_MENU.CHANGELOG.md"); if (stream == null) { throw new InvalidOperationException("Embedded resource 'P.E.A.K_MENU.CHANGELOG.md' was not found."); } using StreamReader streamReader = new StreamReader(stream); return streamReader.ReadToEnd().Replace("\r\n", "\n").Split('\n'); } catch (Exception arg) { Plugin.Log.LogError((object)("Failed to load embedded changelog: " + $"{arg}")); return new string[2] { "更新日志读取失败。", "请查看 Mod 包内的 CHANGELOG.md。" }; } } } internal sealed class CursorController { private bool _previousVisible; private CursorLockMode _previousLockMode; private bool _stateSaved; internal void Release() { //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) if (!_stateSaved) { _previousVisible = Cursor.visible; _previousLockMode = Cursor.lockState; _stateSaved = true; } MaintainReleased(); } internal void MaintainReleased() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) if ((int)Cursor.lockState != 0) { Cursor.lockState = (CursorLockMode)0; } if (!Cursor.visible) { Cursor.visible = true; } } internal void Restore() { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) if (_stateSaved) { if (Cursor.lockState != _previousLockMode) { Cursor.lockState = _previousLockMode; } if (Cursor.visible != _previousVisible) { Cursor.visible = _previousVisible; } _stateSaved = false; } } } internal interface IMenuPage { string Title { get; } void Draw(MenuStyles styles); } internal enum MenuCategory { ItemSpawner, Teleport, Flight, Status, BlowDart, Settings } internal static class MenuIcons { private static readonly Dictionary Icons = new Dictionary(); internal static Texture2D? Item => Get("item"); internal static Texture2D? Teleport => Get("teleport"); internal static Texture2D? Flight => Get("flight"); internal static Texture2D? Status => Get("status"); internal static Texture2D? BlowDart { get { if (!BlowDartRuntime.IsInitialized) { return null; } return BlowDartRuntime.Service.Icon; } } internal static void Initialize() { Dispose(); Assembly assembly = typeof(MenuIcons).Assembly; string[] manifestResourceNames = assembly.GetManifestResourceNames(); Plugin.Log.LogInfo((object)("Embedded resources: " + string.Join(", ", manifestResourceNames))); Load(assembly, "item", "item.png"); Load(assembly, "teleport", "teleport.png"); Load(assembly, "flight", "flight.png"); Load(assembly, "status", "status.png"); Plugin.Log.LogInfo((object)$"Loaded {Icons.Count} menu icons."); } internal static void Dispose() { foreach (Texture2D value in Icons.Values) { if (value != null) { Object.Destroy((Object)(object)value); } } Icons.Clear(); } private static Texture2D? Get(string key) { if (!Icons.TryGetValue(key, out Texture2D value)) { return null; } return value; } private static void Load(Assembly assembly, string key, string fileName) { //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Expected O, but got Unknown try { string text = assembly.GetManifestResourceNames().FirstOrDefault((string name) => name.EndsWith(fileName, StringComparison.OrdinalIgnoreCase)); if (text == null) { Plugin.Log.LogWarning((object)("Menu icon resource not found: " + fileName)); return; } using Stream stream = assembly.GetManifestResourceStream(text); if (stream == null) { Plugin.Log.LogWarning((object)("Unable to open menu icon: " + text)); return; } byte[] array; using (MemoryStream memoryStream = new MemoryStream()) { stream.CopyTo(memoryStream); array = memoryStream.ToArray(); } Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false) { name = "P.E.A.K_MENU_" + key + "_Icon", filterMode = (FilterMode)1, wrapMode = (TextureWrapMode)1, hideFlags = (HideFlags)61 }; if (!ImageConversion.LoadImage(val, array, false)) { Object.Destroy((Object)(object)val); Plugin.Log.LogWarning((object)("Failed to decode menu icon: " + text)); return; } Icons[key] = val; Plugin.Log.LogInfo((object)("Loaded menu icon '" + key + "': " + text + ", " + $"{((Texture)val).width}x{((Texture)val).height}.")); } catch (Exception arg) { Plugin.Log.LogError((object)("Failed to load menu icon " + $"'{fileName}': {arg}")); } } } internal static class MenuSettings { private static ConfigEntry? _toggleKey; private static ConfigEntry? _windowWidth; private static ConfigEntry? _windowHeight; private static ConfigEntry? _theme; internal static KeyCode ToggleKey => _toggleKey?.Value ?? ModConstants.DefaultToggleMenuKey; internal static float WindowWidth => Mathf.Max(_windowWidth?.Value ?? 850f, 520f); internal static float WindowHeight => Mathf.Max(_windowHeight?.Value ?? 850f, 360f); internal static MenuTheme Theme => _theme?.Value ?? MenuTheme.Iris; internal static void Initialize(ConfigFile config) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) _toggleKey = config.Bind("Menu", "ToggleKey", ModConstants.DefaultToggleMenuKey, "打开或关闭 P.E.A.K_MENU 的快捷键。"); _windowWidth = config.Bind("Menu", "WindowWidth", 850f, "菜单窗口宽度。"); _windowHeight = config.Bind("Menu", "WindowHeight", 850f, "菜单窗口高度。"); _theme = config.Bind("Appearance", "Theme", MenuTheme.Iris, "菜单主题颜色。"); ClampConfiguredSize(); } internal static void SetToggleKey(KeyCode keyCode) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) if (_toggleKey != null) { _toggleKey.Value = keyCode; Plugin.Log.LogInfo((object)$"Menu toggle key changed to: {keyCode}"); } } internal static void SetWindowSize(float width, float height) { float value = Mathf.Max(width, 520f); float value2 = Mathf.Max(height, 360f); if (_windowWidth != null) { _windowWidth.Value = value; } if (_windowHeight != null) { _windowHeight.Value = value2; } } internal static void SetTheme(MenuTheme theme) { if (_theme != null && _theme.Value != theme) { _theme.Value = theme; Plugin.Log.LogInfo((object)$"Menu theme changed to: {theme}"); } } internal static void ResetWindowSize() { SetWindowSize(850f, 850f); } internal static void ResetToggleKey() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) SetToggleKey(ModConstants.DefaultToggleMenuKey); } internal static void ResetTheme() { SetTheme(MenuTheme.Iris); } private static void ClampConfiguredSize() { SetWindowSize(WindowWidth, WindowHeight); } } internal static class MenuState { internal static bool IsOpen { get; set; } internal static bool IsRebinding { get; set; } } internal sealed class MenuStyles { private readonly struct ThemePalette { internal Color Window { get; init; } internal Color Sidebar { get; init; } internal Color Content { get; init; } internal Color Button { get; init; } internal Color ButtonHover { get; init; } internal Color ButtonActive { get; init; } internal Color Accent { get; init; } internal Color AccentHover { get; init; } internal Color ToggleOff { get; init; } internal Color ToggleHover { get; init; } internal Color Resize { get; init; } internal Color Separator { get; init; } internal static ThemePalette Create(MenuTheme theme) { return theme switch { MenuTheme.Ocean => CreateOcean(), MenuTheme.Emerald => CreateEmerald(), MenuTheme.Rose => CreateRose(), MenuTheme.Amber => CreateAmber(), _ => CreateIris(), }; } private static ThemePalette CreateIris() { //IL_0014: 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_0046: Unknown result type (might be due to invalid IL or missing references) return CreateBase(new Color(0.42f, 0.34f, 0.78f, 1f), new Color(0.52f, 0.43f, 0.92f, 1f), new Color(0.16f, 0.13f, 0.22f, 1f)); } private static ThemePalette CreateOcean() { //IL_0014: 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_0046: Unknown result type (might be due to invalid IL or missing references) return CreateBase(new Color(0.12f, 0.46f, 0.76f, 1f), new Color(0.18f, 0.58f, 0.92f, 1f), new Color(0.09f, 0.16f, 0.22f, 1f)); } private static ThemePalette CreateEmerald() { //IL_0014: 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_0046: Unknown result type (might be due to invalid IL or missing references) return CreateBase(new Color(0.1f, 0.52f, 0.38f, 1f), new Color(0.14f, 0.66f, 0.48f, 1f), new Color(0.08f, 0.18f, 0.15f, 1f)); } private static ThemePalette CreateRose() { //IL_0014: 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_0046: Unknown result type (might be due to invalid IL or missing references) return CreateBase(new Color(0.68f, 0.24f, 0.42f, 1f), new Color(0.82f, 0.31f, 0.51f, 1f), new Color(0.21f, 0.1f, 0.15f, 1f)); } private static ThemePalette CreateAmber() { //IL_0014: 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_0046: Unknown result type (might be due to invalid IL or missing references) return CreateBase(new Color(0.78f, 0.46f, 0.1f, 1f), new Color(0.94f, 0.59f, 0.14f, 1f), new Color(0.22f, 0.15f, 0.07f, 1f)); } private static ThemePalette CreateBase(Color accent, Color accentHover, Color tint) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_009f: 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_00ca: 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_00f5: 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) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0114: 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_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0166: 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_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017e: 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_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) return new ThemePalette { Window = Color.Lerp(new Color(0.07f, 0.08f, 0.1f, 0.98f), tint, 0.18f), Sidebar = Color.Lerp(new Color(0.045f, 0.05f, 0.065f, 1f), tint, 0.2f), Content = Color.Lerp(new Color(0.1f, 0.11f, 0.14f, 1f), tint, 0.14f), Button = Color.Lerp(new Color(0.12f, 0.13f, 0.16f, 1f), tint, 0.15f), ButtonHover = Color.Lerp(new Color(0.18f, 0.2f, 0.25f, 1f), accent, 0.16f), ButtonActive = Color.Lerp(new Color(0.22f, 0.24f, 0.3f, 1f), accent, 0.24f), Accent = accent, AccentHover = accentHover, ToggleOff = Color.Lerp(new Color(0.13f, 0.14f, 0.17f, 1f), tint, 0.15f), ToggleHover = Color.Lerp(new Color(0.19f, 0.21f, 0.26f, 1f), accent, 0.16f), Resize = new Color(accent.r, accent.g, accent.b, 0.2f), Separator = new Color(accent.r, accent.g, accent.b, 0.3f) }; } } private readonly Texture2D _windowBackground; private readonly Texture2D _sidebarBackground; private readonly Texture2D _contentBackground; private readonly Texture2D _buttonBackground; private readonly Texture2D _buttonHoverBackground; private readonly Texture2D _buttonActiveBackground; private readonly Texture2D _accentBackground; private readonly Texture2D _accentHoverBackground; private readonly Texture2D _toggleOffBackground; private readonly Texture2D _toggleHoverBackground; private readonly Texture2D _resizeBackground; private readonly Texture2D _resizeHoverBackground; internal GUIStyle Window { get; } internal GUIStyle Sidebar { get; } internal GUIStyle Content { get; } internal GUIStyle CategoryButton { get; } internal GUIStyle CategoryButtonSelected { get; } internal GUIStyle ActionButton { get; } internal GUIStyle Toggle { get; } internal GUIStyle ThemeButton { get; } internal GUIStyle ThemeButtonSelected { get; } internal GUIStyle Title { get; } internal GUIStyle SidebarTitle { get; } internal GUIStyle Label { get; } internal GUIStyle MutedLabel { get; } internal GUIStyle ResizeHandle { get; } internal GUIStyle WindowTitleBold { get; } internal GUIStyle WindowTitleNormal { get; } internal Texture2D SeparatorTexture { get; } internal Texture2D ManagementRowAlternateTexture { get; } internal Texture2D ManagementRowHoverTexture { get; } internal Texture2D ManagementDropIndicatorTexture { get; } internal MenuStyles(MenuTheme theme) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: 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) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_010b: 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_0124: Unknown result type (might be due to invalid IL or missing references) //IL_012e: 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) ThemePalette themePalette = ThemePalette.Create(theme); _windowBackground = CreateTexture(themePalette.Window); _sidebarBackground = CreateTexture(themePalette.Sidebar); _contentBackground = CreateTexture(themePalette.Content); _buttonBackground = CreateTexture(themePalette.Button); _buttonHoverBackground = CreateTexture(themePalette.ButtonHover); _buttonActiveBackground = CreateTexture(themePalette.ButtonActive); _accentBackground = CreateTexture(themePalette.Accent); _accentHoverBackground = CreateTexture(themePalette.AccentHover); _toggleOffBackground = CreateTexture(themePalette.ToggleOff); _toggleHoverBackground = CreateTexture(themePalette.ToggleHover); _resizeBackground = CreateTexture(themePalette.Resize); _resizeHoverBackground = CreateTexture(themePalette.AccentHover); SeparatorTexture = CreateTexture(themePalette.Separator); ManagementRowAlternateTexture = CreateTexture(Color.Lerp(themePalette.Content, themePalette.Button, 0.4f)); ManagementRowHoverTexture = CreateTexture(Color.Lerp(themePalette.Content, themePalette.ButtonHover, 0.55f)); ManagementDropIndicatorTexture = CreateTexture(themePalette.AccentHover); Window = CreateWindowStyle(); Sidebar = CreateSidebarStyle(); Content = CreateContentStyle(); CategoryButton = CreateCategoryButtonStyle(); CategoryButtonSelected = CreateSelectedCategoryButtonStyle(); ActionButton = CreateActionButtonStyle(); Toggle = CreateToggleStyle(); ThemeButton = CreateThemeButtonStyle(); ThemeButtonSelected = CreateSelectedThemeButtonStyle(); Title = CreateTitleStyle(); SidebarTitle = CreateSidebarTitleStyle(); Label = CreateLabelStyle(); MutedLabel = CreateMutedLabelStyle(); ResizeHandle = CreateResizeHandleStyle(); WindowTitleBold = CreateWindowTitleBoldStyle(); WindowTitleNormal = CreateWindowTitleNormalStyle(); } private GUIStyle CreateWindowStyle() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown //IL_005f: Expected O, but got Unknown //IL_0066: Unknown result type (might be due to invalid IL or missing references) GUIStyle val = new GUIStyle(GUI.skin.window) { fontSize = 14, alignment = (TextAnchor)1, border = new RectOffset(0, 0, 0, 0), padding = new RectOffset(12, 12, 30, 12), margin = new RectOffset(0, 0, 0, 0), overflow = new RectOffset(0, 0, 0, 0) }; ApplyBackgroundToAllStates(val, _windowBackground, Color.white); return val; } private GUIStyle CreateSidebarStyle() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown //IL_0050: Expected O, but got Unknown //IL_0057: Unknown result type (might be due to invalid IL or missing references) GUIStyle val = new GUIStyle(GUI.skin.box) { border = new RectOffset(0, 0, 0, 0), padding = new RectOffset(10, 10, 10, 10), margin = new RectOffset(0, 8, 0, 0), overflow = new RectOffset(0, 0, 0, 0) }; ApplyBackgroundToAllStates(val, _sidebarBackground, Color.white); return val; } private GUIStyle CreateContentStyle() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown //IL_0050: Expected O, but got Unknown //IL_0057: Unknown result type (might be due to invalid IL or missing references) GUIStyle val = new GUIStyle(GUI.skin.box) { border = new RectOffset(0, 0, 0, 0), padding = new RectOffset(16, 16, 14, 14), margin = new RectOffset(0, 0, 0, 0), overflow = new RectOffset(0, 0, 0, 0) }; ApplyBackgroundToAllStates(val, _contentBackground, Color.white); return val; } private GUIStyle CreateCategoryButtonStyle() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown //IL_005b: 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_006b: Expected O, but got Unknown //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: 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_011b: Unknown result type (might be due to invalid IL or missing references) GUIStyle val = new GUIStyle(GUI.skin.button) { alignment = (TextAnchor)3, imagePosition = (ImagePosition)3, padding = new RectOffset(44, 10, 5, 5), margin = new RectOffset(0, 0, 3, 3), border = new RectOffset(0, 0, 0, 0), overflow = new RectOffset(0, 0, 0, 0), fontSize = 14, fontStyle = (FontStyle)0 }; Color textColor = default(Color); ((Color)(ref textColor))..ctor(0.84f, 0.86f, 0.9f); SetState(val.normal, _buttonBackground, textColor); SetState(val.hover, _buttonHoverBackground, Color.white); SetState(val.active, _buttonActiveBackground, Color.white); SetState(val.focused, _buttonBackground, textColor); SetState(val.onNormal, _buttonBackground, textColor); SetState(val.onHover, _buttonHoverBackground, Color.white); SetState(val.onActive, _buttonActiveBackground, Color.white); SetState(val.onFocused, _buttonBackground, textColor); return val; } private GUIStyle CreateSelectedCategoryButtonStyle() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown //IL_001a: Unknown result type (might be due to invalid IL or missing references) GUIStyle val = new GUIStyle(CategoryButton) { fontStyle = (FontStyle)1 }; ApplyBackgroundToAllStates(val, _accentBackground, Color.white); return val; } private GUIStyle CreateActionButtonStyle() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //IL_0027: 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_0036: Expected O, but got Unknown //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: 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_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) GUIStyle val = new GUIStyle(GUI.skin.button) { alignment = (TextAnchor)4, padding = new RectOffset(14, 14, 8, 8), margin = new RectOffset(0, 0, 4, 4), border = new RectOffset(0, 0, 0, 0), overflow = new RectOffset(0, 0, 0, 0), fontSize = 14, fontStyle = (FontStyle)0 }; Color textColor = default(Color); ((Color)(ref textColor))..ctor(0.88f, 0.9f, 0.94f); SetState(val.normal, _buttonBackground, textColor); SetState(val.hover, _buttonHoverBackground, Color.white); SetState(val.active, _buttonActiveBackground, Color.white); SetState(val.focused, _buttonBackground, textColor); SetState(val.onNormal, _buttonBackground, textColor); SetState(val.onHover, _buttonHoverBackground, Color.white); SetState(val.onActive, _buttonActiveBackground, Color.white); SetState(val.onFocused, _buttonBackground, textColor); return val; } private GUIStyle CreateToggleStyle() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //IL_0027: 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_0036: Expected O, but got Unknown //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: 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_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) GUIStyle val = new GUIStyle(GUI.skin.toggle) { alignment = (TextAnchor)3, padding = new RectOffset(40, 12, 8, 8), margin = new RectOffset(0, 0, 4, 4), border = new RectOffset(0, 0, 0, 0), overflow = new RectOffset(0, 0, 0, 0), fontSize = 14 }; Color textColor = default(Color); ((Color)(ref textColor))..ctor(0.86f, 0.88f, 0.92f); SetState(val.normal, _toggleOffBackground, textColor); SetState(val.hover, _toggleHoverBackground, Color.white); SetState(val.active, _toggleHoverBackground, Color.white); SetState(val.focused, _toggleOffBackground, textColor); SetState(val.onNormal, _accentBackground, Color.white); SetState(val.onHover, _accentHoverBackground, Color.white); SetState(val.onActive, _accentHoverBackground, Color.white); SetState(val.onFocused, _accentBackground, Color.white); return val; } private GUIStyle CreateThemeButtonStyle() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown return new GUIStyle(ActionButton) { alignment = (TextAnchor)4, fontSize = 13 }; } private GUIStyle CreateSelectedThemeButtonStyle() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown //IL_001a: Unknown result type (might be due to invalid IL or missing references) GUIStyle val = new GUIStyle(ThemeButton) { fontStyle = (FontStyle)1 }; ApplyBackgroundToAllStates(val, _accentBackground, Color.white); return val; } private static GUIStyle CreateTitleStyle() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0025: 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_0034: Expected O, but got Unknown //IL_0035: Expected O, but got Unknown //IL_003c: Unknown result type (might be due to invalid IL or missing references) GUIStyle val = new GUIStyle(GUI.skin.label) { fontSize = 20, fontStyle = (FontStyle)1, alignment = (TextAnchor)3, margin = new RectOffset(0, 0, 0, 8) }; ClearAllStateBackgrounds(val); ApplyTextColorToAllStates(val, Color.white); return val; } private static GUIStyle CreateSidebarTitleStyle() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0025: 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_0034: Expected O, but got Unknown //IL_0035: Expected O, but got Unknown //IL_004b: Unknown result type (might be due to invalid IL or missing references) GUIStyle val = new GUIStyle(GUI.skin.label) { fontSize = 15, fontStyle = (FontStyle)1, alignment = (TextAnchor)3, margin = new RectOffset(4, 0, 0, 6) }; ClearAllStateBackgrounds(val); ApplyTextColorToAllStates(val, new Color(0.78f, 0.81f, 0.87f)); return val; } private static GUIStyle CreateLabelStyle() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_003c: Unknown result type (might be due to invalid IL or missing references) GUIStyle val = new GUIStyle(GUI.skin.label) { fontSize = 14, wordWrap = true, alignment = (TextAnchor)3 }; ClearAllStateBackgrounds(val); ApplyTextColorToAllStates(val, new Color(0.86f, 0.88f, 0.92f)); return val; } private static GUIStyle CreateMutedLabelStyle() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_003c: Unknown result type (might be due to invalid IL or missing references) GUIStyle val = new GUIStyle(GUI.skin.label) { fontSize = 13, wordWrap = true, alignment = (TextAnchor)3 }; ClearAllStateBackgrounds(val); ApplyTextColorToAllStates(val, new Color(0.58f, 0.61f, 0.68f)); return val; } private GUIStyle CreateResizeHandleStyle() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0025: 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_0034: Expected O, but got Unknown //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Expected O, but got Unknown //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown //IL_0062: Expected O, but got Unknown //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) GUIStyle val = new GUIStyle(GUI.skin.box) { alignment = (TextAnchor)4, fontSize = 18, fontStyle = (FontStyle)1, border = new RectOffset(0, 0, 0, 0), padding = new RectOffset(0, 0, 0, 0), margin = new RectOffset(0, 0, 0, 0), overflow = new RectOffset(0, 0, 0, 0) }; Color textColor = default(Color); ((Color)(ref textColor))..ctor(0.75f, 0.78f, 0.84f); SetState(val.normal, _resizeBackground, textColor); SetState(val.hover, _resizeHoverBackground, Color.white); SetState(val.active, _resizeHoverBackground, Color.white); SetState(val.focused, _resizeBackground, textColor); SetState(val.onNormal, _resizeBackground, textColor); SetState(val.onHover, _resizeHoverBackground, Color.white); SetState(val.onActive, _resizeHoverBackground, Color.white); SetState(val.onFocused, _resizeBackground, textColor); return val; } private static GUIStyle CreateWindowTitleBoldStyle() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Expected O, but got Unknown //IL_006a: 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_0079: Expected O, but got Unknown //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Expected O, but got Unknown //IL_0089: Expected O, but got Unknown //IL_0090: Unknown result type (might be due to invalid IL or missing references) GUIStyle val = new GUIStyle(GUI.skin.label) { fontSize = 14, fontStyle = (FontStyle)1, alignment = (TextAnchor)3, wordWrap = false, clipping = (TextClipping)1, stretchWidth = false, stretchHeight = false, fixedHeight = 20f, padding = new RectOffset(0, 0, 0, 0), margin = new RectOffset(0, 0, 0, 0), border = new RectOffset(0, 0, 0, 0), overflow = new RectOffset(0, 0, 0, 0) }; ClearAllStateBackgrounds(val); ApplyTextColorToAllStates(val, Color.white); return val; } private static GUIStyle CreateWindowTitleNormalStyle() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Expected O, but got Unknown //IL_006a: 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_0079: Expected O, but got Unknown //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Expected O, but got Unknown //IL_0089: Expected O, but got Unknown //IL_009f: Unknown result type (might be due to invalid IL or missing references) GUIStyle val = new GUIStyle(GUI.skin.label) { fontSize = 13, fontStyle = (FontStyle)0, alignment = (TextAnchor)3, wordWrap = false, clipping = (TextClipping)1, stretchWidth = false, stretchHeight = false, fixedHeight = 20f, padding = new RectOffset(0, 0, 0, 0), margin = new RectOffset(0, 0, 0, 0), border = new RectOffset(0, 0, 0, 0), overflow = new RectOffset(0, 0, 0, 0) }; ClearAllStateBackgrounds(val); ApplyTextColorToAllStates(val, new Color(0.72f, 0.74f, 0.8f)); return val; } internal void Dispose() { DestroyTexture(_windowBackground); DestroyTexture(_sidebarBackground); DestroyTexture(_contentBackground); DestroyTexture(_buttonBackground); DestroyTexture(_buttonHoverBackground); DestroyTexture(_buttonActiveBackground); DestroyTexture(_accentBackground); DestroyTexture(_accentHoverBackground); DestroyTexture(_toggleOffBackground); DestroyTexture(_toggleHoverBackground); DestroyTexture(_resizeBackground); DestroyTexture(_resizeHoverBackground); DestroyTexture(SeparatorTexture); DestroyTexture(ManagementRowAlternateTexture); DestroyTexture(ManagementRowHoverTexture); DestroyTexture(ManagementDropIndicatorTexture); } private static void ApplyBackgroundToAllStates(GUIStyle style, Texture2D background, Color textColor) { //IL_0007: 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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0055: 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) SetState(style.normal, background, textColor); SetState(style.hover, background, textColor); SetState(style.active, background, textColor); SetState(style.focused, background, textColor); SetState(style.onNormal, background, textColor); SetState(style.onHover, background, textColor); SetState(style.onActive, background, textColor); SetState(style.onFocused, background, textColor); } private static void ApplyTextColorToAllStates(GUIStyle style, Color textColor) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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) style.normal.textColor = textColor; style.hover.textColor = textColor; style.active.textColor = textColor; style.focused.textColor = textColor; style.onNormal.textColor = textColor; style.onHover.textColor = textColor; style.onActive.textColor = textColor; style.onFocused.textColor = textColor; } private static void ClearAllStateBackgrounds(GUIStyle style) { style.normal.background = null; style.hover.background = null; style.active.background = null; style.focused.background = null; style.onNormal.background = null; style.onHover.background = null; style.onActive.background = null; style.onFocused.background = null; } private static void SetState(GUIStyleState state, Texture2D background, Color textColor) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) state.background = background; state.textColor = textColor; } private static Texture2D CreateTexture(Color color) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Expected O, but got Unknown //IL_002e: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(1, 1, (TextureFormat)4, false); ((Object)val).name = "P.E.A.K_MENU Style Texture"; ((Object)val).hideFlags = (HideFlags)61; ((Texture)val).wrapMode = (TextureWrapMode)1; ((Texture)val).filterMode = (FilterMode)0; val.SetPixel(0, 0, color); val.Apply(false, false); return val; } private static void DestroyTexture(Texture2D texture) { if ((Object)(object)texture != (Object)null) { Object.Destroy((Object)(object)texture); } } } internal enum MenuTheme { Iris, Ocean, Emerald, Rose, Amber } internal sealed class PeakMenuWindow { private const float TitleBarHeight = 38f; private const float ResizeHandleMargin = 4f; private const float CategoryIconSize = 24f; private const float CategoryIconLeftPadding = 10f; private readonly CursorController _cursorController = new CursorController(); private readonly Dictionary _pages; private MenuStyles? _styles; private MenuTheme _loadedTheme; private bool _isOpen; private bool _positionInitialized; private bool _closeAfterMouseRelease; private bool _disposed; private bool _isDragging; private bool _isResizing; private Vector2 _dragStartMouse; private Vector2 _dragStartPosition; private Vector2 _resizeStartMouse; private Vector2 _resizeStartSize; private Rect _windowRect; private MenuCategory _selectedCategory; internal bool IsOpen => _isOpen; private MenuStyles Styles { get { EnsureCurrentTheme(); return _styles; } } internal PeakMenuWindow() { _loadedTheme = MenuSettings.Theme; _pages = new Dictionary { { MenuCategory.ItemSpawner, new ItemSpawnerPage() }, { MenuCategory.Teleport, new TeleportPage() }, { MenuCategory.Flight, new FlightPage() }, { MenuCategory.Status, new StatusPage() }, { MenuCategory.BlowDart, new BlowDartPage() }, { MenuCategory.Settings, new SettingsPage() } }; } internal void Toggle() { if (_isOpen) { Close(); } else { Open(); } } internal void Open() { if (!_disposed && !_isOpen) { _isOpen = true; _closeAfterMouseRelease = false; _isDragging = false; _isResizing = false; MenuState.IsOpen = true; _cursorController.Release(); ApplyConfiguredWindowSize(); EnsureCurrentTheme(); Plugin.Log.LogInfo((object)"P.E.A.K_MENU opened."); } } internal void Close() { if (_isOpen || _closeAfterMouseRelease) { FinishClose(); } } internal void Update() { if (_closeAfterMouseRelease && !Input.GetMouseButton(0) && !Input.GetMouseButton(1) && !Input.GetMouseButton(2)) { FinishClose(); } else if (_isOpen) { RecoverLostPointerRelease(); } } internal void LateUpdate() { if (!_disposed && (_isOpen || _closeAfterMouseRelease)) { _cursorController.MaintainReleased(); } } internal void Draw() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) if (_disposed || !_isOpen) { return; } InitializePosition(); EnsureCurrentTheme(); try { HandleWindowPointerInput(); _windowRect = GUI.Window(938421, _windowRect, new WindowFunction(DrawWindowContents), "", Styles.Window); ClampToScreen(); HandleClickOutside(); } catch (Exception arg) { Plugin.Log.LogError((object)("Failed to draw P.E.A.K_MENU: " + $"{arg}")); Close(); } } internal void Dispose() { if (!_disposed) { Close(); _styles?.Dispose(); _styles = null; _disposed = true; } } private void EnsureCurrentTheme() { MenuTheme theme = MenuSettings.Theme; if (_styles == null || _loadedTheme != theme) { _styles?.Dispose(); _loadedTheme = theme; _styles = new MenuStyles(theme); Plugin.Log.LogInfo((object)$"Applied menu theme: {theme}"); } } private void BeginCloseAfterMouseRelease() { if (_isOpen && !_isDragging && !_isResizing) { _closeAfterMouseRelease = true; MenuState.IsOpen = true; _cursorController.MaintainReleased(); } } private void FinishClose() { _isOpen = false; _closeAfterMouseRelease = false; _isDragging = false; _isResizing = false; MenuState.IsOpen = false; MenuState.IsRebinding = false; _cursorController.Restore(); Plugin.Log.LogInfo((object)"P.E.A.K_MENU closed."); } private void DrawWindowContents(int windowId) { DrawCustomTitleBar(); GUILayout.Space(20f); try { GUILayout.BeginHorizontal(Array.Empty()); DrawSidebar(); DrawCurrentPage(); GUILayout.EndHorizontal(); } catch (Exception ex) { Plugin.Log.LogError((object)$"Failed to draw menu contents: {ex}"); try { GUILayout.EndHorizontal(); } catch { } DrawPageError(ex); } DrawResizeHandle(); } private void DrawCustomTitleBar() { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0073: 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_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) Rect val = default(Rect); ((Rect)(ref val))..ctor(12f, 0f, Mathf.Max(0f, ((Rect)(ref _windowRect)).width - 24f), 38f); GUIContent val2 = new GUIContent("P.E.A.K MENU"); GUIContent val3 = new GUIContent(" by Ruangfafa"); Vector2 val4 = Styles.WindowTitleBold.CalcSize(val2); Vector2 val5 = Styles.WindowTitleNormal.CalcSize(val3); float num = 14f; float num2 = val4.x + num + val5.x; float num3 = Mathf.Max(0f, ((Rect)(ref val)).x + (((Rect)(ref val)).width - num2) * 0.5f); float num4 = ((Rect)(ref val)).y + (((Rect)(ref val)).height - val4.y) * 0.5f; float num5 = ((Rect)(ref val)).y + (((Rect)(ref val)).height - val5.y) * 0.5f; GUI.Label(new Rect(num3, num4, val4.x + 2f, val4.y), val2, Styles.WindowTitleBold); GUI.Label(new Rect(num3 + val4.x + num, num5, val5.x + 2f, val5.y), val3, Styles.WindowTitleNormal); } private void DrawSidebar() { GUILayout.BeginVertical(Styles.Sidebar, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(150f), GUILayout.ExpandHeight(true) }); GUILayout.Label("分类", Styles.SidebarTitle, Array.Empty()); GUILayout.Space(6f); DrawCategoryButton(MenuCategory.ItemSpawner, "物品生成"); DrawCategoryButton(MenuCategory.Teleport, "传送"); DrawCategoryButton(MenuCategory.Flight, "飞行"); DrawCategoryButton(MenuCategory.Status, "状态"); DrawCategoryButton(MenuCategory.BlowDart, "吹箭"); GUILayout.FlexibleSpace(); DrawCategoryButton(MenuCategory.Settings, "设置"); GUILayout.EndVertical(); } private void DrawCategoryButton(MenuCategory category, string label) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) bool flag = _selectedCategory == category; GUIStyle val = (flag ? Styles.CategoryButtonSelected : Styles.CategoryButton); Texture2D categoryIcon = GetCategoryIcon(category); Rect rect = GUILayoutUtility.GetRect(GUIContent.none, val, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Height(42f), GUILayout.ExpandWidth(true) }); bool flag2 = GUI.Button(rect, label, val); if (categoryIcon != null) { float num = ((Rect)(ref rect)).y + (((Rect)(ref rect)).height - 24f) * 0.5f; Rect val2 = default(Rect); ((Rect)(ref val2))..ctor(((Rect)(ref rect)).x + 10f, num, 24f, 24f); GUI.DrawTexture(val2, (Texture)(object)categoryIcon, (ScaleMode)2, true); } if (!flag2 || (flag && category != MenuCategory.Teleport)) { return; } if (category == MenuCategory.Teleport && !TeleportRuntime.IsInitialized) { Plugin.Log.LogWarning((object)"TeleportRuntime is not initialized."); return; } if (category == MenuCategory.Teleport) { TeleportRuntime.Service.RefreshPlayers(); } _selectedCategory = category; Plugin.Log.LogInfo((object)$"Selected menu category: {category}"); } private static Texture2D? GetCategoryIcon(MenuCategory category) { return (Texture2D?)(category switch { MenuCategory.ItemSpawner => MenuIcons.Item, MenuCategory.Teleport => MenuIcons.Teleport, MenuCategory.Flight => MenuIcons.Flight, MenuCategory.Status => MenuIcons.Status, MenuCategory.BlowDart => MenuIcons.BlowDart, _ => null, }); } private void DrawCurrentPage() { GUILayout.BeginVertical(Styles.Content, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true) }); if (!_pages.TryGetValue(_selectedCategory, out IMenuPage value)) { GUILayout.Label("页面不存在。", Styles.Label, Array.Empty()); GUILayout.EndVertical(); return; } GUILayout.Label(value.Title, Styles.Title, Array.Empty()); DrawSeparator(); GUILayout.Space(12f); value.Draw(Styles); GUILayout.EndVertical(); } private void DrawSeparator() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) Rect rect = GUILayoutUtility.GetRect(1f, 1f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); GUI.DrawTexture(rect, (Texture)(object)Styles.SeparatorTexture, (ScaleMode)0); } private void DrawResizeHandle() { //IL_0035: Unknown result type (might be due to invalid IL or missing references) float num = 24f; Rect val = default(Rect); ((Rect)(ref val))..ctor(((Rect)(ref _windowRect)).width - num - 4f, ((Rect)(ref _windowRect)).height - num - 4f, num, num); GUI.Box(val, "◢", Styles.ResizeHandle); } private void HandleWindowPointerInput() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected I4, but got Unknown //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0043: 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) Event current = Event.current; if (current != null) { Vector2 mousePosition = current.mousePosition; Rect titleBarScreenRect = GetTitleBarScreenRect(); Rect resizeHandleScreenRect = GetResizeHandleScreenRect(); EventType type = current.type; switch ((int)type) { case 0: HandlePointerDown(current, mousePosition, titleBarScreenRect, resizeHandleScreenRect); break; case 3: HandlePointerDrag(current, mousePosition); break; case 1: HandlePointerUp(current); break; case 2: break; } } } private void HandlePointerDown(Event currentEvent, Vector2 mousePosition, Rect titleBarRect, Rect resizeHandleRect) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0086: 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) if (currentEvent.button == 0) { if (((Rect)(ref resizeHandleRect)).Contains(mousePosition)) { _isResizing = true; _isDragging = false; _resizeStartMouse = mousePosition; _resizeStartSize = new Vector2(((Rect)(ref _windowRect)).width, ((Rect)(ref _windowRect)).height); currentEvent.Use(); } else if (((Rect)(ref titleBarRect)).Contains(mousePosition)) { _isDragging = true; _isResizing = false; _dragStartMouse = mousePosition; _dragStartPosition = new Vector2(((Rect)(ref _windowRect)).x, ((Rect)(ref _windowRect)).y); currentEvent.Use(); } } } private void HandlePointerDrag(Event currentEvent, Vector2 mousePosition) { //IL_0012: 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) if (currentEvent.button == 0) { if (_isResizing) { ResizeWindow(mousePosition); currentEvent.Use(); } else if (_isDragging) { MoveWindow(mousePosition); currentEvent.Use(); } } } private void HandlePointerUp(Event currentEvent) { if (currentEvent.button == 0) { if (_isResizing) { _isResizing = false; SaveCurrentWindowSize(); currentEvent.Use(); } else if (_isDragging) { _isDragging = false; currentEvent.Use(); } } } private void MoveWindow(Vector2 mousePosition) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) Vector2 val = mousePosition - _dragStartMouse; float num = _dragStartPosition.x + val.x; float num2 = _dragStartPosition.y + val.y; ((Rect)(ref _windowRect)).x = Mathf.Clamp(num, 0f, Mathf.Max(0f, (float)Screen.width - ((Rect)(ref _windowRect)).width)); ((Rect)(ref _windowRect)).y = Mathf.Clamp(num2, 0f, Mathf.Max(0f, (float)Screen.height - ((Rect)(ref _windowRect)).height)); } private void ResizeWindow(Vector2 mousePosition) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: 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_0081: Unknown result type (might be due to invalid IL or missing references) Vector2 val = mousePosition - _resizeStartMouse; float num = (float)Screen.width - ((Rect)(ref _windowRect)).x; float num2 = (float)Screen.height - ((Rect)(ref _windowRect)).y; float num3 = Mathf.Min(520f, num); float num4 = Mathf.Min(360f, num2); ((Rect)(ref _windowRect)).width = Mathf.Clamp(_resizeStartSize.x + val.x, num3, num); ((Rect)(ref _windowRect)).height = Mathf.Clamp(_resizeStartSize.y + val.y, num4, num2); } private Rect GetTitleBarScreenRect() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) return new Rect(((Rect)(ref _windowRect)).x, ((Rect)(ref _windowRect)).y, ((Rect)(ref _windowRect)).width, 38f); } private Rect GetResizeHandleScreenRect() { //IL_0046: Unknown result type (might be due to invalid IL or missing references) float num = 24f; return new Rect(((Rect)(ref _windowRect)).x + ((Rect)(ref _windowRect)).width - num - 4f, ((Rect)(ref _windowRect)).y + ((Rect)(ref _windowRect)).height - num - 4f, num, num); } private void RecoverLostPointerRelease() { if ((_isDragging || _isResizing) && !Input.GetMouseButton(0)) { if (_isResizing) { SaveCurrentWindowSize(); } _isDragging = false; _isResizing = false; } } private void SaveCurrentWindowSize() { MenuSettings.SetWindowSize(((Rect)(ref _windowRect)).width, ((Rect)(ref _windowRect)).height); Plugin.Log.LogInfo((object)("Menu resized to " + $"{((Rect)(ref _windowRect)).width:0} x " + $"{((Rect)(ref _windowRect)).height:0}.")); } private void InitializePosition() { //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) if (!_positionInitialized) { float num = Mathf.Clamp(MenuSettings.WindowWidth, Mathf.Min(520f, (float)Screen.width), (float)Screen.width); float num2 = Mathf.Clamp(MenuSettings.WindowHeight, Mathf.Min(360f, (float)Screen.height), (float)Screen.height); float num3 = (float)Screen.width - num - 20f; float num4 = 80f; _windowRect = new Rect(Mathf.Max(0f, num3), Mathf.Max(0f, num4), num, num2); _positionInitialized = true; } } private void ApplyConfiguredWindowSize() { if (_positionInitialized) { float num = (float)Screen.width - ((Rect)(ref _windowRect)).x; float num2 = (float)Screen.height - ((Rect)(ref _windowRect)).y; float num3 = Mathf.Min(520f, num); float num4 = Mathf.Min(360f, num2); ((Rect)(ref _windowRect)).width = Mathf.Clamp(MenuSettings.WindowWidth, num3, num); ((Rect)(ref _windowRect)).height = Mathf.Clamp(MenuSettings.WindowHeight, num4, num2); ClampToScreen(); } } private void ClampToScreen() { float num = Screen.width; float num2 = Screen.height; float num3 = Mathf.Min(520f, num); float num4 = Mathf.Min(360f, num2); ((Rect)(ref _windowRect)).width = Mathf.Clamp(((Rect)(ref _windowRect)).width, num3, num); ((Rect)(ref _windowRect)).height = Mathf.Clamp(((Rect)(ref _windowRect)).height, num4, num2); ((Rect)(ref _windowRect)).x = Mathf.Clamp(((Rect)(ref _windowRect)).x, 0f, Mathf.Max(0f, (float)Screen.width - ((Rect)(ref _windowRect)).width)); ((Rect)(ref _windowRect)).y = Mathf.Clamp(((Rect)(ref _windowRect)).y, 0f, Mathf.Max(0f, (float)Screen.height - ((Rect)(ref _windowRect)).height)); } private void HandleClickOutside() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) if (!_isDragging && !_isResizing && !_closeAfterMouseRelease) { Event current = Event.current; if (current != null && (int)current.type == 0 && current.button == 0 && !((Rect)(ref _windowRect)).Contains(current.mousePosition)) { BeginCloseAfterMouseRelease(); current.Use(); } } } private void DrawPageError(Exception exception) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) Rect val = default(Rect); ((Rect)(ref val))..ctor(20f, 50f, Mathf.Max(100f, ((Rect)(ref _windowRect)).width - 40f), Mathf.Max(100f, ((Rect)(ref _windowRect)).height - 38f - 32f)); GUI.Label(val, "菜单页面绘制失败。\n\n" + exception.GetType().Name + "\n" + exception.Message + "\n\n请查看 BepInEx/LogOutput.log。", Styles.Label); } } internal sealed class ShortcutRebindControl { private FeatureShortcutAction? _waitingForAction; internal void DrawButtons(FeatureShortcutAction action, MenuStyles styles) { FeatureInputBinding binding = FeatureInputSettings.GetBinding(action); string text = ((_waitingForAction == action) ? "请按按键或滚轮..." : (binding.DisplayName + "(点击修改)")); if (GUILayout.Button(text, styles.ActionButton, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(180f), GUILayout.Height(38f) })) { _waitingForAction = action; MenuState.IsRebinding = true; } if (GUILayout.Button("恢复默认", styles.ActionButton, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(82f), GUILayout.Height(38f) })) { Cancel(); FeatureInputSettings.ResetBinding(action); } } internal void CaptureEvent() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Invalid comparison between Unknown and I4 //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Invalid comparison between Unknown and I4 FeatureShortcutAction? waitingForAction = _waitingForAction; if (!waitingForAction.HasValue) { return; } Event current = Event.current; if (current != null) { FeatureInputBinding binding; if ((int)current.type == 4 && (int)current.keyCode == 27) { Cancel(); current.Use(); } else if (FeatureInputBinding.TryCapture(current, out binding)) { FeatureInputSettings.SetBinding(_waitingForAction.Value, binding); Cancel(); current.Use(); } } } private void Cancel() { _waitingForAction = null; MenuState.IsRebinding = false; } } } namespace P.E.A.K_MENU.UI.Pages { internal sealed class BlowDartPage : IMenuPage { private bool _effectDropdownOpen; private bool _inputsInitialized; private string _amountInput = "20"; private string _durationInput = "5"; public string Title => "吹箭"; public void Draw(MenuStyles styles) { if (!BlowDartRuntime.IsInitialized) { GUILayout.Label("吹箭功能尚未初始化。", styles.MutedLabel, Array.Empty()); return; } BlowDartService service = BlowDartRuntime.Service; EnsureInputsInitialized(service); GUILayout.Label("设置只影响你自己发射的吹箭;未安装 Mod 的玩家仍可正常受击。", styles.MutedLabel, Array.Empty()); GUILayout.Space(6f); GUILayout.Label("其他玩家发射的吹箭保持游戏原有效果。", styles.MutedLabel, Array.Empty()); GUILayout.Label("选择“无效果(原版)”时,你发射的吹箭同样使用原版效果。", styles.MutedLabel, Array.Empty()); GUILayout.Space(12f); if (GUILayout.Button("获取吹箭", styles.ActionButton, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(40f) })) { service.GiveBlowDart(); } GUILayout.Space(14f); GUILayout.Label("吹箭效果", styles.Label, Array.Empty()); GUILayout.Space(4f); if (GUILayout.Button(BlowDartService.GetDisplayName(service.EffectType) + (_effectDropdownOpen ? " ▴" : " ▾"), styles.ActionButton, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(38f) })) { _effectDropdownOpen = !_effectDropdownOpen; } if (_effectDropdownOpen) { foreach (BlowDartEffectType value in Enum.GetValues(typeof(BlowDartEffectType))) { GUIStyle val = ((value == service.EffectType) ? styles.ThemeButtonSelected : styles.ThemeButton); if (GUILayout.Button(BlowDartService.GetDisplayName(value), val, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(32f) })) { service.SetEffectType(value); _effectDropdownOpen = false; } } } if (BlowDartService.UsesAmount(service.EffectType)) { DrawAmountInput(service, styles); } else if (service.EffectType == BlowDartEffectType.Whirlwind) { DrawDurationInput(service, styles); } GUILayout.Space(14f); GUILayout.Label(service.LastStatus, service.LastSucceeded ? styles.Label : styles.MutedLabel, Array.Empty()); } private void DrawAmountInput(BlowDartService service, MenuStyles styles) { GUILayout.Space(14f); GUILayout.Label("赋予值(1–200)", styles.Label, Array.Empty()); string text = GUILayout.TextField(_amountInput, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Height(36f), GUILayout.ExpandWidth(true) }); if (text != _amountInput) { _amountInput = text; ProcessAmountInput(service); } GUILayout.Label($"当前:{service.AmountPercent}%(底层 " + $"{(float)service.AmountPercent / 100f:0.##})", styles.MutedLabel, Array.Empty()); } private void DrawDurationInput(BlowDartService service, MenuStyles styles) { GUILayout.Space(14f); GUILayout.Label("持续时间(秒)", styles.Label, Array.Empty()); string text = GUILayout.TextField(_durationInput, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Height(36f), GUILayout.ExpandWidth(true) }); if (text != _durationInput) { _durationInput = text; ProcessDurationInput(service); } GUILayout.Label($"当前:{service.DurationSeconds:0.##} 秒", styles.MutedLabel, Array.Empty()); } private void EnsureInputsInitialized(BlowDartService service) { if (!_inputsInitialized) { _amountInput = service.AmountPercent.ToString(CultureInfo.InvariantCulture); _durationInput = service.DurationSeconds.ToString("0.##", CultureInfo.InvariantCulture); _inputsInitialized = true; } } private void ProcessAmountInput(BlowDartService service) { if (int.TryParse(_amountInput, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result)) { service.SetAmountPercent(result); } } private void ProcessDurationInput(BlowDartService service) { if (float.TryParse(_durationInput, NumberStyles.Float, CultureInfo.InvariantCulture, out var result) || float.TryParse(_durationInput, NumberStyles.Float, CultureInfo.CurrentCulture, out result)) { service.SetDurationSeconds(result); } } } internal sealed class FlightPage : IMenuPage { private static readonly float[] GravityCalibrationSteps = new float[6] { -9f, -3f, -1f, 1f, 3f, 9f }; private bool _showGravityCalibration; private readonly ShortcutRebindControl _shortcutRebind = new ShortcutRebindControl(); public string Title => "飞行"; public void Draw(MenuStyles styles) { if (!FlightRuntime.IsInitialized) { GUILayout.Label("飞行功能尚未初始化。", styles.MutedLabel, Array.Empty()); return; } FlightService service = FlightRuntime.Service; GUILayout.Label("飞行总开关仅启用快捷键;进入实际飞行后才会开启无敌与防击退。", styles.MutedLabel, Array.Empty()); GUILayout.Space(6f); GUILayout.Label("退出实际飞行时会恢复此前的无敌与防击退状态。", styles.MutedLabel, Array.Empty()); GUILayout.Space(12f); GUILayout.BeginHorizontal(Array.Empty()); bool flag = GUILayout.Toggle(service.Enabled, "启用飞行总开关", styles.Toggle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Height(40f), GUILayout.ExpandWidth(true) }); _shortcutRebind.DrawButtons(FeatureShortcutAction.ToggleFlightSystem, styles); GUILayout.EndHorizontal(); if (flag != service.Enabled) { service.SetEnabled(flag); } GUI.enabled = service.Enabled; GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Space(24f); bool flag2 = GUILayout.Toggle(FeatureInputSettings.DoubleTapFlightEnabled, "允许双击空格进入或退出实际飞行", styles.Toggle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Height(36f), GUILayout.ExpandWidth(true) }); GUILayout.EndHorizontal(); if (flag2 != FeatureInputSettings.DoubleTapFlightEnabled) { FeatureInputSettings.DoubleTapFlightEnabled = flag2; } GUI.enabled = true; GUILayout.Space(12f); GUILayout.Label("WASD 移动方式", styles.Label, Array.Empty()); GUILayout.Space(4f); GUILayout.BeginHorizontal(Array.Empty()); if (GUILayout.Button("随视角飞行", service.HorizontalWasdMovement ? styles.ThemeButton : styles.ThemeButtonSelected, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Height(36f), GUILayout.ExpandWidth(true) })) { service.SetHorizontalWasdMovement(horizontal: false); } if (GUILayout.Button("水平平移", service.HorizontalWasdMovement ? styles.ThemeButtonSelected : styles.ThemeButton, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Height(36f), GUILayout.ExpandWidth(true) })) { service.SetHorizontalWasdMovement(horizontal: true); } GUILayout.EndHorizontal(); GUILayout.Label(service.HorizontalWasdMovement ? "WASD 只改变水平位置,高度由空格和 Ctrl 控制。" : "W/S 跟随视角俯仰,A/D 保持水平移动。", styles.MutedLabel, Array.Empty()); GUILayout.Space(12f); GUILayout.Label("飞行速度", styles.Label, Array.Empty()); GUILayout.Space(4f); GUILayout.Label($"当前速度:{service.FlightSpeed:0.##}", styles.MutedLabel, Array.Empty()); GUILayout.Label("调整范围为 16–255;实际飞行时,每次提高或降低 16 点。", styles.MutedLabel, Array.Empty()); GUILayout.Space(6f); DrawSpeedShortcutRow(service, styles, increase: true); DrawSpeedShortcutRow(service, styles, increase: false); GUILayout.Space(12f); DrawGravityCalibration(service, styles); GUILayout.Space(12f); GUILayout.Label("实际飞行状态", styles.Label, Array.Empty()); GUILayout.Space(4f); GUILayout.Label(ResolveFlightStatus(service), service.ActivelyFlying ? styles.Label : styles.MutedLabel, Array.Empty()); GUILayout.BeginHorizontal(Array.Empty()); GUI.enabled = service.Enabled; if (GUILayout.Button(service.ActivelyFlying ? "退出实际飞行" : "进入实际飞行", styles.ActionButton, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Height(38f), GUILayout.ExpandWidth(true) })) { service.ToggleActiveFlight(); } GUI.enabled = true; _shortcutRebind.DrawButtons(FeatureShortcutAction.ToggleActiveFlight, styles); GUILayout.EndHorizontal(); GUILayout.Space(12f); GUILayout.Label("操作:WASD 按所选方式移动,空格上升,Ctrl 下降,Shift 加速。", styles.MutedLabel, Array.Empty()); GUILayout.Label("启用子项后,双击空格可进入或退出实际飞行;进入时速度重置为 16。", styles.MutedLabel, Array.Empty()); GUILayout.Label("退出实际飞行后:保留正常重力,并限制 2 秒最大下落速度。", styles.MutedLabel, Array.Empty()); GUILayout.Space(8f); GUILayout.Label(service.LastStatus, service.LastSucceeded ? styles.Label : styles.MutedLabel, Array.Empty()); _shortcutRebind.CaptureEvent(); } private void DrawSpeedShortcutRow(FlightService service, MenuStyles styles, bool increase) { GUILayout.BeginHorizontal(Array.Empty()); GUI.enabled = service.Enabled && service.ActivelyFlying; if (GUILayout.Button(increase ? "提高飞行速度" : "降低飞行速度", styles.ActionButton, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Height(38f), GUILayout.ExpandWidth(true) })) { service.AdjustFlightSpeed(increase ? 1f : (-1f)); } GUI.enabled = true; _shortcutRebind.DrawButtons(increase ? FeatureShortcutAction.IncreaseFlightSpeed : FeatureShortcutAction.DecreaseFlightSpeed, styles); GUILayout.EndHorizontal(); } private void DrawGravityCalibration(FlightService service, MenuStyles styles) { if (GUILayout.Button(_showGravityCalibration ? "高级校准 ▾" : "高级校准 ▸", styles.ActionButton, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(32f) })) { _showGravityCalibration = !_showGravityCalibration; } if (!_showGravityCalibration) { return; } GUILayout.Space(6f); GUILayout.Label($"浮空重力校准:{service.HoverDownForce:0.##}", styles.Label, Array.Empty()); GUILayout.Label("增加 = 加强向下补偿;角色仍在缓慢上浮时使用。", styles.MutedLabel, Array.Empty()); GUILayout.Label("减少 = 减弱向下补偿;角色正在缓慢下沉时使用。", styles.MutedLabel, Array.Empty()); GUILayout.Label("仅可在实际飞行状态下校准;可按不同步长快速微调。", styles.MutedLabel, Array.Empty()); GUILayout.Space(6f); GUILayout.BeginHorizontal(Array.Empty()); GUI.enabled = service.Enabled && service.ActivelyFlying; float[] gravityCalibrationSteps = GravityCalibrationSteps; foreach (float num in gravityCalibrationSteps) { string text = ((num > 0f) ? $"+{num:0}" : $"{num:0}"); if (GUILayout.Button(text, styles.ActionButton, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Height(34f), GUILayout.ExpandWidth(true) })) { service.AdjustHoverDownForce(num); } } GUI.enabled = true; GUILayout.EndHorizontal(); if (GUILayout.Button($"恢复默认({255f:0.##})", styles.ActionButton, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(34f) })) { service.ResetHoverDownForce(); } } private static string ResolveFlightStatus(FlightService service) { if (!service.Enabled) { return "飞行总开关未开启"; } if (service.ActivelyFlying) { return "正在飞行"; } return "正常状态 / 等待双击空格"; } } internal sealed class ItemSpawnerPage : IMenuPage { private const float ItemRowHeight = 56f; private const float IconSize = 40f; private const float SpawnColumnSpacing = 6f; private const float ManagementHeaderHeight = 22f; private const float ManagementSearchHeight = 32f; private const float ManagementSectionSpacing = 10f; private const float ManagementContentSpacing = 4f; private const float ManagementSearchSpacing = 6f; private const float ManagedItemRowHeight = 34f; private const float AddItemRowHeight = 42f; private const float ManagementScrollbarWidth = 20f; private const float ManagementDragHandleWidth = 38f; private const float ManagementAutoScrollEdge = 28f; private const float ManagementAutoScrollSpeed = 260f; private Vector2 _spawnScroll; private Vector2 _manageScroll; private Vector2 _addItemsScroll; private string _managementStatus = string.Empty; private bool _managementOpen; private string _searchText = string.Empty; private ItemSpawnEntry? _draggedItem; private bool _draggedFromVisible; private int _dragControlId; private Vector2 _dragMouseScreen; private Rect _visibleListScreenRect; private float _visibleListContentHeight; private int _visibleItemCount; private readonly ShortcutRebindControl _shortcutRebind = new ShortcutRebindControl(); public string Title { get { if (!_managementOpen) { return "物品生成"; } return "物品管理"; } } public void Draw(MenuStyles styles) { try { if (!ItemSpawnRuntime.IsInitialized) { GUILayout.Label("ItemSpawn 尚未初始化。", styles.MutedLabel, Array.Empty()); GUILayout.Space(8f); GUILayout.Label("请确认当前 Profile 已部署最新 DLL,并检查 LogOutput.log 中的初始化错误。", styles.MutedLabel, Array.Empty()); return; } ItemSpawnRuntime.Catalog.RefreshIfNeeded(); if (_managementOpen) { DrawManagement(styles); return; } DrawSpawnList(styles); } catch (Exception ex) { Plugin.Log.LogError((object)$"Failed to draw ItemSpawnerPage: {ex}"); GUILayout.Label("物品页面加载失败。", styles.Label, Array.Empty()); GUILayout.Space(8f); GUILayout.Label(ex.GetType().Name + "\n" + ex.Message, styles.MutedLabel, Array.Empty()); } _shortcutRebind.CaptureEvent(); } private void DrawSpawnList(MenuStyles styles) { //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_017b: 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_019f: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) GUILayout.Label("点击物品后,将通过 PEAK 原生网络流程生成并交给本地玩家。", styles.MutedLabel, Array.Empty()); GUILayout.Space(8f); GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label("生成上一个物品", styles.Label, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Height(38f), GUILayout.ExpandWidth(true) }); _shortcutRebind.DrawButtons(FeatureShortcutAction.SpawnLastItem, styles); GUILayout.EndHorizontal(); GUILayout.Space(8f); GUILayout.BeginHorizontal(Array.Empty()); GUILayout.FlexibleSpace(); GUILayout.Label("左键增加,右键减少", styles.MutedLabel, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Height(32f), GUILayout.ExpandWidth(false) }); GUILayout.Space(8f); int spawnColumns = ItemSpawnConfiguration.SpawnColumns; Rect rect = GUILayoutUtility.GetRect(64f, 32f, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(64f), GUILayout.Height(32f) }); Event current = Event.current; if ((int)current.type == 0 && ((Rect)(ref rect)).Contains(current.mousePosition) && (current.button == 0 || current.button == 1)) { int spawnColumns2 = ((current.button == 0) ? (spawnColumns % 9 + 1) : ((spawnColumns + 7) % 9 + 1)); ItemSpawnConfiguration.SetSpawnColumns(spawnColumns2); current.Use(); } GUI.Button(rect, $"{spawnColumns}列", styles.ActionButton); GUILayout.EndHorizontal(); GUILayout.Space(6f); IReadOnlyList visibleItems = ItemSpawnRuntime.Catalog.GetVisibleItems(); _spawnScroll = GUILayout.BeginScrollView(_spawnScroll, false, true, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true) }); if (visibleItems.Count == 0) { GUILayout.Label("物品数据库尚未准备好。请进入关卡后重新打开菜单。", styles.MutedLabel, Array.Empty()); } else { DrawSpawnGrid(visibleItems, styles); } GUILayout.EndScrollView(); GUILayout.Space(6f); GUILayout.Label(ItemSpawnRuntime.Spawner.LastStatus, ItemSpawnRuntime.Spawner.LastSucceeded ? styles.Label : styles.MutedLabel, Array.Empty()); GUILayout.Space(4f); if (GUILayout.Button("物品管理", styles.ActionButton, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(38f) })) { _managementOpen = true; _searchText = string.Empty; _managementStatus = string.Empty; _manageScroll = Vector2.zero; _addItemsScroll = Vector2.zero; } } private static void DrawSpawnGrid(IReadOnlyList entries, MenuStyles styles) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) int spawnColumns = ItemSpawnConfiguration.SpawnColumns; Rect row = default(Rect); for (int i = 0; i < entries.Count; i += spawnColumns) { Rect rect = GUILayoutUtility.GetRect(1f, 56f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); float num = Mathf.Max(1f, (((Rect)(ref rect)).width - 6f * (float)(spawnColumns - 1)) / (float)spawnColumns); for (int j = 0; j < spawnColumns; j++) { int num2 = i + j; if (num2 >= entries.Count) { break; } ((Rect)(ref row))..ctor(((Rect)(ref rect)).x + (float)j * (num + 6f), ((Rect)(ref rect)).y, num, ((Rect)(ref rect)).height); DrawSpawnButton(row, entries[num2], styles); } } } private static void DrawSpawnButton(Rect row, ItemSpawnEntry entry, MenuStyles styles) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) if (GUI.Button(row, GUIContent.none, styles.ActionButton)) { ItemSpawnRuntime.Spawner.Spawn(entry); } Rect iconRect = default(Rect); ((Rect)(ref iconRect))..ctor(((Rect)(ref row)).x + 8f, ((Rect)(ref row)).y + (((Rect)(ref row)).height - 40f) * 0.5f, 40f, 40f); DrawItemIcon(entry, iconRect, styles); Rect val = default(Rect); ((Rect)(ref val))..ctor(((Rect)(ref iconRect)).xMax + 10f, ((Rect)(ref row)).y, Mathf.Max(0f, ((Rect)(ref row)).width - 40f - 30f), ((Rect)(ref row)).height); GUI.Label(val, entry.DisplayName, styles.Label); } private static void DrawItemIcon(ItemSpawnEntry entry, Rect iconRect, MenuStyles styles) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (entry.Icon == null) { GUI.Label(iconRect, "□", styles.Label); return; } Rect val = CalculateSpriteUv(entry.Icon); GUI.DrawTextureWithTexCoords(iconRect, (Texture)(object)entry.Icon.texture, val, true); } private void DrawManagement(MenuStyles styles) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) GUILayout.Label("拖动三横杠可调整顺序,或将下方物品拖到已显示列表。", styles.MutedLabel, Array.Empty()); GUILayout.Space(8f); Rect rect = GUILayoutUtility.GetRect(0f, float.MaxValue, 0f, float.MaxValue, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true) }); DrawManagementLists(rect, styles); GUILayout.Space(6f); if (!string.IsNullOrWhiteSpace(_managementStatus)) { GUILayout.Label(_managementStatus, styles.MutedLabel, Array.Empty()); GUILayout.Space(4f); } if (GUILayout.Button("重新扫描游戏物品", styles.ActionButton, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(36f) })) { ItemSpawnRuntime.Catalog.ForceRefresh(); _manageScroll = Vector2.zero; _addItemsScroll = Vector2.zero; _managementStatus = "已重新扫描游戏物品。"; } if (GUILayout.Button("恢复默认物品和排序", styles.ActionButton, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(36f) })) { ItemSpawnRuntime.Catalog.RestoreDefaults(); _manageScroll = Vector2.zero; _addItemsScroll = Vector2.zero; _managementStatus = "已恢复默认物品和默认排序。"; } if (GUILayout.Button("返回物品列表", styles.ActionButton, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(38f) })) { _managementOpen = false; _searchText = string.Empty; _managementStatus = string.Empty; _manageScroll = Vector2.zero; _addItemsScroll = Vector2.zero; CancelManagementDrag(); } } private void DrawManagementLists(Rect area, MenuStyles styles) { //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0114: 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) float num = 100f; float num2 = Mathf.Max(1f, (((Rect)(ref area)).height - num) * 0.5f); Rect val = default(Rect); ((Rect)(ref val))..ctor(((Rect)(ref area)).x, ((Rect)(ref area)).y, ((Rect)(ref area)).width, 22f); Rect val2 = default(Rect); ((Rect)(ref val2))..ctor(((Rect)(ref area)).x, ((Rect)(ref val)).yMax + 4f, ((Rect)(ref area)).width, num2); Rect val3 = default(Rect); ((Rect)(ref val3))..ctor(((Rect)(ref area)).x, ((Rect)(ref val2)).yMax + 10f, ((Rect)(ref area)).width, 22f); Rect val4 = default(Rect); ((Rect)(ref val4))..ctor(((Rect)(ref area)).x, ((Rect)(ref val3)).yMax + 4f, ((Rect)(ref area)).width, 32f); Rect area2 = default(Rect); ((Rect)(ref area2))..ctor(((Rect)(ref area)).x, ((Rect)(ref val4)).yMax + 6f, ((Rect)(ref area)).width, num2); GUI.Label(val, "已显示物品", styles.Label); DrawVisibleItemsList(val2, styles); GUI.Label(val3, "添加物品", styles.Label); _searchText = GUI.TextField(val4, _searchText); DrawAddItemsList(area2, styles); DrawManagementDropIndicator(val2, styles); } private void DrawVisibleItemsList(Rect area, MenuStyles styles) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) ItemSpawnEntry[] array = ItemSpawnRuntime.Catalog.GetVisibleItems().ToArray(); float num = Mathf.Max(1f, ((Rect)(ref area)).width - 20f); float num2 = Mathf.Max(((Rect)(ref area)).height, (float)array.Length * 34f); _visibleListScreenRect = ConvertToScreenRect(area); _visibleListContentHeight = num2; _visibleItemCount = array.Length; UpdateManagementAutoScroll(((Rect)(ref area)).height); _manageScroll = GUI.BeginScrollView(area, _manageScroll, new Rect(0f, 0f, num, num2), false, true); if (array.Length == 0) { GUI.Label(new Rect(0f, 0f, num, 34f), "当前没有显示任何物品。", styles.MutedLabel); } else { for (int i = 0; i < array.Length; i++) { DrawManagedItemRow(new Rect(0f, (float)i * 34f, num, 34f), array[i], i, styles); } } GUI.EndScrollView(); } private void DrawAddItemsList(Rect area, MenuStyles styles) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) ItemSpawnEntry[] searchResults = GetSearchResults(); float num = Mathf.Max(1f, ((Rect)(ref area)).width - 20f); float num2 = Mathf.Max(((Rect)(ref area)).height, (searchResults.Length != 0) ? ((float)searchResults.Length * 42f) : 42f); _addItemsScroll = GUI.BeginScrollView(area, _addItemsScroll, new Rect(0f, 0f, num, num2), false, true); if (searchResults.Length == 0) { string value = _searchText.Trim(); GUI.Label(new Rect(0f, 0f, num, 42f), string.IsNullOrWhiteSpace(value) ? "所有已发现物品都已添加,或当前没有可添加物品。" : "没有找到匹配的物品。", styles.MutedLabel); } else { for (int i = 0; i < searchResults.Length; i++) { DrawAddItemRow(new Rect(0f, (float)i * 42f, num, 42f), searchResults[i], i, styles); } } GUI.EndScrollView(); } private void DrawManagedItemRow(Rect row, ItemSpawnEntry entry, int rowIndex, MenuStyles styles) { //IL_0000: 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_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) DrawManagementRowBackground(row, rowIndex, styles); Rect iconRect = default(Rect); ((Rect)(ref iconRect))..ctor(((Rect)(ref row)).x + 2f, ((Rect)(ref row)).y + 4f, 26f, 26f); DrawItemIcon(entry, iconRect, styles); Rect val = default(Rect); ((Rect)(ref val))..ctor(((Rect)(ref row)).xMax - 58f, ((Rect)(ref row)).y, 58f, 34f); Rect handleRect = default(Rect); ((Rect)(ref handleRect))..ctor(((Rect)(ref val)).x - 38f, ((Rect)(ref row)).y, 38f, 34f); GUI.Label(new Rect(((Rect)(ref row)).x + 30f, ((Rect)(ref row)).y, Mathf.Max(0f, ((Rect)(ref handleRect)).x - ((Rect)(ref row)).x - 34f), 34f), entry.DisplayName, styles.Label); DrawManagementDragHandle(handleRect, entry, fromVisible: true, styles); if (GUI.Button(val, "删除", styles.ActionButton)) { ItemSpawnRuntime.Catalog.Remove(entry.PrefabName); } } private ItemSpawnEntry[] GetSearchResults() { string query = _searchText.Trim(); IEnumerable source = from entry in ItemSpawnRuntime.Catalog.AllItems where !ItemSpawnRuntime.Catalog.ContainsVisible(entry.PrefabName) where MatchesSearch(entry, query) select entry; return source.ToArray(); } private void DrawAddItemRow(Rect row, ItemSpawnEntry entry, int rowIndex, MenuStyles styles) { //IL_0000: 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_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) DrawManagementRowBackground(row, rowIndex, styles); Rect iconRect = default(Rect); ((Rect)(ref iconRect))..ctor(((Rect)(ref row)).x + 2f, ((Rect)(ref row)).y + 7f, 28f, 28f); DrawItemIcon(entry, iconRect, styles); Rect val = default(Rect); ((Rect)(ref val))..ctor(((Rect)(ref row)).xMax - 64f, ((Rect)(ref row)).y + 4f, 64f, 34f); Rect handleRect = default(Rect); ((Rect)(ref handleRect))..ctor(((Rect)(ref val)).x - 38f, ((Rect)(ref row)).y + 4f, 38f, 34f); GUI.Label(new Rect(((Rect)(ref row)).x + 38f, ((Rect)(ref row)).y, Mathf.Max(0f, ((Rect)(ref handleRect)).x - ((Rect)(ref row)).x - 44f), 42f), entry.DisplayName, styles.Label); DrawManagementDragHandle(handleRect, entry, fromVisible: false, styles); if (GUI.Button(val, "添加", styles.ActionButton)) { ItemSpawnRuntime.Catalog.Add(entry.PrefabName); _managementStatus = "已添加:" + entry.DisplayName; _manageScroll = new Vector2(0f, float.MaxValue); } } private void DrawManagementDragHandle(Rect handleRect, ItemSpawnEntry entry, bool fromVisible, MenuStyles styles) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected I4, but got Unknown //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: 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_00b5: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0114: 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) int controlID = GUIUtility.GetControlID((FocusType)2, handleRect); Event current = Event.current; if (_dragControlId == controlID && _draggedItem != null) { _dragMouseScreen = GUIUtility.GUIToScreenPoint(current.mousePosition); } EventType typeForControl = current.GetTypeForControl(controlID); switch ((int)typeForControl) { case 0: if (current.button == 0 && ((Rect)(ref handleRect)).Contains(current.mousePosition)) { _draggedItem = entry; _draggedFromVisible = fromVisible; _dragControlId = controlID; _dragMouseScreen = GUIUtility.GUIToScreenPoint(current.mousePosition); GUIUtility.hotControl = controlID; current.Use(); } break; case 3: if (GUIUtility.hotControl == controlID) { _dragMouseScreen = GUIUtility.GUIToScreenPoint(current.mousePosition); current.Use(); } break; case 1: if (GUIUtility.hotControl == controlID) { _dragMouseScreen = GUIUtility.GUIToScreenPoint(current.mousePosition); CompleteManagementDrag(); current.Use(); } break; } GUI.Box(handleRect, GUIContent.none, styles.ActionButton); float num = ((Rect)(ref handleRect)).center.x - 7f; for (int i = -1; i <= 1; i++) { GUI.DrawTexture(new Rect(num, ((Rect)(ref handleRect)).center.y + (float)i * 5f - 1f, 14f, 2f), (Texture)(object)styles.ManagementDropIndicatorTexture, (ScaleMode)0); } } private void CompleteManagementDrag() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) ItemSpawnEntry draggedItem = _draggedItem; bool draggedFromVisible = _draggedFromVisible; if (draggedItem != null && ((Rect)(ref _visibleListScreenRect)).Contains(_dragMouseScreen)) { int managementDropIndex = GetManagementDropIndex(); if (ItemSpawnRuntime.Catalog.PlaceAt(draggedItem.PrefabName, managementDropIndex)) { _managementStatus = (draggedFromVisible ? ("已调整:" + draggedItem.DisplayName) : ("已添加:" + draggedItem.DisplayName)); } } CancelManagementDrag(); } private void CancelManagementDrag() { if (GUIUtility.hotControl == _dragControlId) { GUIUtility.hotControl = 0; } _draggedItem = null; _draggedFromVisible = false; _dragControlId = 0; } private void UpdateManagementAutoScroll(float viewportHeight) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) if (_draggedItem != null && ((Rect)(ref _visibleListScreenRect)).Contains(_dragMouseScreen)) { float num = _dragMouseScreen.y - ((Rect)(ref _visibleListScreenRect)).yMin; float num2 = ((Rect)(ref _visibleListScreenRect)).yMax - _dragMouseScreen.y; float num3 = ((num < 28f) ? (-1f) : ((num2 < 28f) ? 1f : 0f)); if (num3 != 0f) { float num4 = Mathf.Max(0f, _visibleListContentHeight - viewportHeight); _manageScroll.y = Mathf.Clamp(_manageScroll.y + num3 * 260f * Time.unscaledDeltaTime, 0f, num4); } } } private void DrawManagementDropIndicator(Rect visibleListRect, MenuStyles styles) { //IL_000f: 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) if (_draggedItem != null && ((Rect)(ref _visibleListScreenRect)).Contains(_dragMouseScreen)) { int managementDropIndex = GetManagementDropIndex(); float num = ((Rect)(ref visibleListRect)).y + (float)managementDropIndex * 34f - _manageScroll.y; num = Mathf.Clamp(num, ((Rect)(ref visibleListRect)).y + 1.5f, ((Rect)(ref visibleListRect)).yMax - 1.5f); GUI.DrawTexture(new Rect(((Rect)(ref visibleListRect)).x, num - 1.5f, Mathf.Max(1f, ((Rect)(ref visibleListRect)).width - 20f), 3f), (Texture)(object)styles.ManagementDropIndicatorTexture, (ScaleMode)0); } } private int GetManagementDropIndex() { float num = _dragMouseScreen.y - ((Rect)(ref _visibleListScreenRect)).yMin + _manageScroll.y; return Mathf.Clamp(Mathf.RoundToInt(num / 34f), 0, _visibleItemCount); } private static Rect ConvertToScreenRect(Rect rect) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) Vector2 val = GUIUtility.GUIToScreenPoint(((Rect)(ref rect)).position); return new Rect(val, ((Rect)(ref rect)).size); } private static void DrawManagementRowBackground(Rect row, int rowIndex, MenuStyles styles) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) Texture2D val = (((Rect)(ref row)).Contains(Event.current.mousePosition) ? styles.ManagementRowHoverTexture : ((rowIndex % 2 == 1) ? styles.ManagementRowAlternateTexture : null)); if (val != null) { GUI.DrawTexture(row, (Texture)(object)val, (ScaleMode)0); } } private static bool MatchesSearch(ItemSpawnEntry entry, string query) { if (string.IsNullOrWhiteSpace(query)) { return true; } if (!entry.DisplayName.Contains(query, StringComparison.OrdinalIgnoreCase)) { return entry.PrefabName.Contains(query, StringComparison.OrdinalIgnoreCase); } return true; } private static Rect CalculateSpriteUv(Sprite sprite) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) Texture2D texture = sprite.texture; Rect textureRect = sprite.textureRect; return new Rect(((Rect)(ref textureRect)).x / (float)((Texture)texture).width, ((Rect)(ref textureRect)).y / (float)((Texture)texture).height, ((Rect)(ref textureRect)).width / (float)((Texture)texture).width, ((Rect)(ref textureRect)).height / (float)((Texture)texture).height); } } internal sealed class SettingsPage : IMenuPage { private bool _waitingForKey; public string Title => "设置"; public void Draw(MenuStyles styles) { GUILayout.Label("菜单外观、尺寸与快捷键设置。", styles.MutedLabel, Array.Empty()); GUILayout.Space(14f); DrawThemeSection(styles); GUILayout.Space(18f); DrawShortcutSection(styles); GUILayout.Space(18f); DrawWindowSizeSection(styles); } private static void DrawThemeSection(MenuStyles styles) { GUILayout.Label("主题色", styles.Label, Array.Empty()); GUILayout.Space(6f); GUILayout.Label("当前主题:" + GetThemeDisplayName(MenuSettings.Theme), styles.MutedLabel, Array.Empty()); GUILayout.Space(8f); GUILayout.BeginHorizontal(Array.Empty()); DrawThemeButton(styles, MenuTheme.Iris, "鸢尾花"); DrawThemeButton(styles, MenuTheme.Ocean, "海洋"); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty()); DrawThemeButton(styles, MenuTheme.Emerald, "翡翠"); DrawThemeButton(styles, MenuTheme.Rose, "玫瑰"); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty()); DrawThemeButton(styles, MenuTheme.Amber, "琥珀"); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Space(6f); if (GUILayout.Button("恢复默认主题(鸢尾花)", styles.ActionButton, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(36f) })) { MenuSettings.ResetTheme(); } } private static void DrawThemeButton(MenuStyles styles, MenuTheme theme, string label) { GUIStyle val = ((MenuSettings.Theme == theme) ? styles.ThemeButtonSelected : styles.ThemeButton); if (GUILayout.Button(label, val, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Height(38f), GUILayout.ExpandWidth(true) })) { MenuSettings.SetTheme(theme); } } private void DrawShortcutSection(MenuStyles styles) { //IL_002c: 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) GUILayout.Label("菜单快捷键", styles.Label, Array.Empty()); GUILayout.Space(6f); string text = (_waitingForKey ? "请按下新的快捷键..." : $"当前快捷键:{MenuSettings.ToggleKey}"); if (GUILayout.Button(text, styles.ActionButton, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(40f) })) { BeginRebind(); } if (_waitingForKey) { GUILayout.Label("按下任意按键完成绑定,按 Esc 取消。", styles.MutedLabel, Array.Empty()); CaptureKeyEvent(); } if (GUILayout.Button($"恢复默认快捷键({ModConstants.DefaultToggleMenuKey})", styles.ActionButton, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(36f) })) { CancelRebind(); MenuSettings.ResetToggleKey(); } } private static void DrawWindowSizeSection(MenuStyles styles) { GUILayout.Label("窗口尺寸", styles.Label, Array.Empty()); GUILayout.Space(6f); GUILayout.Label($"当前大小:{MenuSettings.WindowWidth:0} × " + $"{MenuSettings.WindowHeight:0}", styles.MutedLabel, Array.Empty()); GUILayout.Label("拖动窗口右下角的小三角可以调整大小。", styles.MutedLabel, Array.Empty()); GUILayout.Space(6f); if (GUILayout.Button("恢复默认窗口大小", styles.ActionButton, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(36f) })) { MenuSettings.ResetWindowSize(); } } private void BeginRebind() { _waitingForKey = true; MenuState.IsRebinding = true; Plugin.Log.LogInfo((object)"Waiting for a new menu shortcut key."); } private void CancelRebind() { _waitingForKey = false; MenuState.IsRebinding = false; } private void CaptureKeyEvent() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 //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_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Invalid comparison between Unknown and I4 //IL_0030: Unknown result type (might be due to invalid IL or missing references) Event current = Event.current; if (current == null || (int)current.type != 4) { return; } KeyCode keyCode = current.keyCode; if ((int)keyCode != 0) { if ((int)keyCode == 27) { CancelRebind(); current.Use(); } else { MenuSettings.SetToggleKey(keyCode); CancelRebind(); current.Use(); } } } private static string GetThemeDisplayName(MenuTheme theme) { return theme switch { MenuTheme.Iris => "鸢尾花", MenuTheme.Ocean => "海洋", MenuTheme.Emerald => "翡翠", MenuTheme.Rose => "玫瑰", MenuTheme.Amber => "琥珀", _ => "鸢尾花", }; } } internal sealed class StatusPage : IMenuPage { private Vector2 _pageScroll; private string _weightInput = "0"; private readonly ShortcutRebindControl _shortcutRebind = new ShortcutRebindControl(); public string Title => "状态"; public void Draw(MenuStyles styles) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) if (!StatusRuntime.IsInitialized) { GUILayout.Label("状态功能尚未初始化。", styles.MutedLabel, Array.Empty()); return; } StatusService service = StatusRuntime.Service; _pageScroll = GUILayout.BeginScrollView(_pageScroll, false, true, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true) }); DrawInvincibility(service, styles); GUILayout.Space(14f); DrawInfiniteStamina(service, styles); GUILayout.Space(14f); DrawRevive(service, styles); GUILayout.Space(14f); DrawWeight(service, styles); GUILayout.Space(16f); GUILayout.Label(service.LastStatus, service.LastSucceeded ? styles.Label : styles.MutedLabel, Array.Empty()); GUILayout.EndScrollView(); _shortcutRebind.CaptureEvent(); } private void DrawInvincibility(StatusService service, MenuStyles styles) { GUILayout.Label("角色保护", styles.Label, Array.Empty()); GUILayout.Space(4f); GUILayout.BeginHorizontal(Array.Empty()); GUI.enabled = !service.FlightProtectionLock; bool flag = GUILayout.Toggle(service.Invincible, "启用无敌", styles.Toggle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Height(40f), GUILayout.ExpandWidth(true) }); GUI.enabled = true; _shortcutRebind.DrawButtons(FeatureShortcutAction.ToggleInvincibility, styles); GUILayout.EndHorizontal(); if (!service.FlightProtectionLock && flag != service.Invincible) { service.SetInvincible(flag); } GUILayout.BeginHorizontal(Array.Empty()); GUI.enabled = service.Invincible && !service.FlightProtectionLock; bool flag2 = GUILayout.Toggle(service.AntiKnockback, "阻止击退、摔倒与外力", styles.Toggle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Height(40f), GUILayout.ExpandWidth(true) }); GUI.enabled = true; _shortcutRebind.DrawButtons(FeatureShortcutAction.ToggleAntiKnockback, styles); GUILayout.EndHorizontal(); if (!service.FlightProtectionLock && flag2 != service.AntiKnockback) { service.SetAntiKnockback(flag2); } if (service.FlightProtectionLock) { GUILayout.Label("实际飞行期间,角色保护状态由飞行功能管理。", styles.MutedLabel, Array.Empty()); } else { GUILayout.Label("防击退需要先开启无敌。", styles.MutedLabel, Array.Empty()); } } private void DrawInfiniteStamina(StatusService service, MenuStyles styles) { GUILayout.Label("体力", styles.Label, Array.Empty()); GUILayout.Space(4f); GUILayout.BeginHorizontal(Array.Empty()); bool flag = GUILayout.Toggle(service.InfiniteStamina, "无限体力", styles.Toggle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Height(40f), GUILayout.ExpandWidth(true) }); _shortcutRebind.DrawButtons(FeatureShortcutAction.ToggleInfiniteStamina, styles); GUILayout.EndHorizontal(); if (flag != service.InfiniteStamina) { service.SetInfiniteStamina(flag); } } private void DrawRevive(StatusService service, MenuStyles styles) { GUILayout.Label("死亡恢复", styles.Label, Array.Empty()); GUILayout.Space(4f); GUILayout.BeginHorizontal(Array.Empty()); if (GUILayout.Button("复活自己", styles.ActionButton, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Height(42f), GUILayout.ExpandWidth(true) })) { service.ReviveSelf(); } _shortcutRebind.DrawButtons(FeatureShortcutAction.ReviveSelf, styles); GUILayout.EndHorizontal(); GUILayout.Space(4f); GUILayout.Label("仅在本地角色已经死亡后生效,复活位置优先使用幽灵当前位置。", styles.MutedLabel, Array.Empty()); } private void DrawWeight(StatusService service, MenuStyles styles) { GUILayout.Label("负重重量", styles.Label, Array.Empty()); GUILayout.Space(4f); GUILayout.BeginHorizontal(Array.Empty()); bool flag = GUILayout.Toggle(service.WeightOverrideEnabled, "启用负重覆盖", styles.Toggle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Height(38f), GUILayout.ExpandWidth(true) }); _shortcutRebind.DrawButtons(FeatureShortcutAction.ToggleWeightOverride, styles); GUILayout.EndHorizontal(); if (flag != service.WeightOverrideEnabled) { service.SetWeightOverride(flag); } GUILayout.Space(4f); GUI.enabled = service.WeightOverrideEnabled; GUILayout.BeginHorizontal(Array.Empty()); _weightInput = GUILayout.TextField(_weightInput, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Height(36f), GUILayout.ExpandWidth(true) }); if (GUILayout.Button("确定", styles.ActionButton, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(76f), GUILayout.Height(36f) })) { ApplyWeight(service); } GUILayout.EndHorizontal(); GUI.enabled = true; GUILayout.Label("输入 0 可实现无负重。", styles.MutedLabel, Array.Empty()); } private void ApplyWeight(StatusService service) { if (!float.TryParse(_weightInput, NumberStyles.Float, CultureInfo.InvariantCulture, out var result) && !float.TryParse(_weightInput, NumberStyles.Float, CultureInfo.CurrentCulture, out result)) { service.SetInputError("负重格式无效。"); return; } service.SetWeight(result); _weightInput = result.ToString("0.###", CultureInfo.InvariantCulture); } } internal sealed class TeleportPage : IMenuPage { private const float PlayerRowHeight = 46f; private const float ActionButtonWidth = 58f; private Vector2 _playerScroll; public string Title => "传送"; public void Draw(MenuStyles styles) { //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) if (!TeleportRuntime.IsInitialized) { GUILayout.Label("传送功能尚未初始化。", styles.MutedLabel, Array.Empty()); return; } TeleportService service = TeleportRuntime.Service; if (!service.HasOtherPlayers) { GUILayout.Label("当前没有其他玩家。", styles.MutedLabel, Array.Empty()); GUILayout.Space(8f); GUILayout.Label("请等待其他玩家加入,页面会自动刷新。", styles.MutedLabel, Array.Empty()); GUILayout.Space(10f); if (GUILayout.Button("重新扫描房间玩家", styles.ActionButton, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(38f) })) { service.RefreshPlayers(); _playerScroll = Vector2.zero; } return; } GUILayout.Label("点击“去”传送到对方,点击“来”将对方传送到自己附近。", styles.MutedLabel, Array.Empty()); GUILayout.Space(10f); DrawPlayerList(service, styles); GUILayout.Space(8f); GUILayout.Label(service.LastStatus, service.LastSucceeded ? styles.Label : styles.MutedLabel, Array.Empty()); GUILayout.Space(6f); if (GUILayout.Button("刷新房间玩家", styles.ActionButton, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(38f) })) { service.RefreshPlayers(); _playerScroll = Vector2.zero; } } private void DrawPlayerList(TeleportService service, MenuStyles styles) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) IReadOnlyList players = service.Players; _playerScroll = GUILayout.BeginScrollView(_playerScroll, false, true, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true) }); TeleportPlayerEntry[] array = new TeleportPlayerEntry[players.Count]; for (int i = 0; i < players.Count; i++) { array[i] = players[i]; } TeleportPlayerEntry[] array2 = array; foreach (TeleportPlayerEntry player in array2) { DrawPlayerRow(player, service, styles); } GUILayout.EndScrollView(); } private static void DrawPlayerRow(TeleportPlayerEntry player, TeleportService service, MenuStyles styles) { GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(46f) }); GUILayout.Label(player.DisplayName, styles.Label, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.ExpandWidth(true), GUILayout.Height(46f) }); if (GUILayout.Button("去", styles.ActionButton, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(58f), GUILayout.Height(36f) })) { service.TeleportLocalTo(player); } if (GUILayout.Button("来", styles.ActionButton, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(58f), GUILayout.Height(36f) })) { service.BringPlayerToLocal(player); } GUILayout.EndHorizontal(); } } } namespace P.E.A.K_MENU.Patches { [HarmonyPatch] internal static class BlowDartPatch { private static MethodBase TargetMethod() { return AccessTools.Method(typeof(Action_RaycastDart), "DartImpact", new Type[3] { typeof(Character), typeof(Vector3), typeof(Vector3) }, (Type[])null); } [HarmonyPrefix] private static bool Prefix(Action_RaycastDart __instance, Character hitCharacter, Vector3 origin, Vector3 endpoint) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) if (!BlowDartRuntime.IsInitialized || hitCharacter == null) { return true; } if (BlowDartRuntime.Service.EffectType == BlowDartEffectType.None) { return true; } return !BlowDartRuntime.Service.TryHandleHit(__instance, hitCharacter, origin, endpoint); } } [HarmonyPatch] internal static class CharacterInputPatch { private static MethodInfo? _resetInputMethod; private static IEnumerable TargetMethods() { Type characterInputType = AccessTools.TypeByName("CharacterInput"); if ((object)characterInputType == null) { Plugin.Log.LogError((object)"CharacterInput type was not found. Game input blocking will not work."); yield break; } _resetInputMethod = AccessTools.Method(characterInputType, "ResetInput", (Type[])null, (Type[])null); MethodInfo methodInfo = AccessTools.Method(characterInputType, "Sample", (Type[])null, (Type[])null); if ((object)methodInfo != null) { Plugin.Log.LogInfo((object)"Patching CharacterInput.Sample."); yield return methodInfo; } else { Plugin.Log.LogWarning((object)"CharacterInput.Sample was not found."); } MethodInfo methodInfo2 = AccessTools.Method(characterInputType, "SampleAlways", (Type[])null, (Type[])null); if ((object)methodInfo2 != null) { Plugin.Log.LogInfo((object)"Patching CharacterInput.SampleAlways."); yield return methodInfo2; } else { Plugin.Log.LogWarning((object)"CharacterInput.SampleAlways was not found."); } } private static bool Prefix(object __instance) { if (!MenuState.IsOpen) { return true; } ClearCachedInput(__instance); return false; } private static void ClearCachedInput(object instance) { if ((object)_resetInputMethod == null) { return; } try { _resetInputMethod.Invoke(instance, null); } catch (Exception arg) { Plugin.Log.LogError((object)$"Failed to reset CharacterInput: {arg}"); } } } [HarmonyPatch] internal static class StatusProtectionPatch { internal static bool InvincibleEnabled { get; set; } internal static bool AntiKnockbackEnabled { get; set; } = true; internal static bool WeightOverrideEnabled { get; set; } internal static float WeightOverrideValue { get; set; } private static IEnumerable TargetMethods() { string[] array = new string[10] { "DieInstantly", "RPCA_Die", "Fall", "RPCA_Fall", "RPCA_FallWithScreenShake", "AddForce", "AddForceAtPosition", "RPCA_AddForceAtPosition", "AddForceToBodyPart", "RPCA_AddForceToBodyPart" }; MethodInfo[] characterMethods = AccessTools.GetDeclaredMethods(typeof(Character)).ToArray(); string[] array2 = array; foreach (string methodName in array2) { MethodInfo[] array3 = characterMethods.Where((MethodInfo method) => method.Name.Equals(methodName, StringComparison.Ordinal)).ToArray(); MethodInfo[] array4 = array3; foreach (MethodInfo methodInfo in array4) { Plugin.Log.LogInfo((object)("Status protection patch target: Character." + methodInfo.Name + "(" + string.Join(", ", from parameter in methodInfo.GetParameters() select parameter.ParameterType.Name) + ")")); yield return methodInfo; } } } private static bool Prefix(object __instance, MethodBase __originalMethod) { if (!InvincibleEnabled) { return true; } Character val = (Character)((__instance is Character) ? __instance : null); if (val == null || !val.IsLocal) { return true; } string name = __originalMethod.Name; if (name == "DieInstantly" || name == "RPCA_Die") { Plugin.Log.LogInfo((object)("Blocked local death: " + name)); return false; } if (!AntiKnockbackEnabled) { return true; } if (name == "Fall" || name == "RPCA_Fall" || name == "RPCA_FallWithScreenShake") { Plugin.Log.LogInfo((object)("Blocked local fall: " + name)); return false; } switch (name) { default: if (!(name == "RPCA_AddForceToBodyPart")) { return true; } break; case "AddForce": case "AddForceAtPosition": case "RPCA_AddForceAtPosition": case "AddForceToBodyPart": break; } if (IsCharacterClimbing(val)) { return true; } Plugin.Log.LogInfo((object)("Blocked local force: " + name)); return false; } private static bool IsCharacterClimbing(Character character) { if (character == null) { return false; } string[] array = new string[6] { "isClimbing", "IsClimbing", "climbing", "Climbing", "isClimb", "IsClimb" }; Type type = ((object)character).GetType(); string[] array2 = array; bool flag = default(bool); bool flag2 = default(bool); foreach (string text in array2) { PropertyInfo propertyInfo = AccessTools.Property(type, text); if ((object)propertyInfo != null && propertyInfo.PropertyType == typeof(bool)) { try { object value = propertyInfo.GetValue(character); int num; if (value is bool) { flag = (bool)value; num = 1; } else { num = 0; } if (((uint)num & (flag ? 1u : 0u)) != 0) { return true; } } catch { } } FieldInfo fieldInfo = AccessTools.Field(type, text); if ((object)fieldInfo == null || !(fieldInfo.FieldType == typeof(bool))) { continue; } try { object value2 = fieldInfo.GetValue(character); int num2; if (value2 is bool) { flag2 = (bool)value2; num2 = 1; } else { num2 = 0; } if (((uint)num2 & (flag2 ? 1u : 0u)) != 0) { return true; } } catch { } } object data = character.data; if (data == null) { return false; } Type type2 = data.GetType(); string[] array3 = array; bool flag3 = default(bool); bool flag4 = default(bool); foreach (string text2 in array3) { PropertyInfo propertyInfo2 = AccessTools.Property(type2, text2); if ((object)propertyInfo2 != null && propertyInfo2.PropertyType == typeof(bool)) { try { object value3 = propertyInfo2.GetValue(data); int num3; if (value3 is bool) { flag3 = (bool)value3; num3 = 1; } else { num3 = 0; } if (((uint)num3 & (flag3 ? 1u : 0u)) != 0) { return true; } } catch { } } FieldInfo fieldInfo2 = AccessTools.Field(type2, text2); if ((object)fieldInfo2 == null || !(fieldInfo2.FieldType == typeof(bool))) { continue; } try { object value4 = fieldInfo2.GetValue(data); int num4; if (value4 is bool) { flag4 = (bool)value4; num4 = 1; } else { num4 = 0; } if (((uint)num4 & (flag4 ? 1u : 0u)) != 0) { return true; } } catch { } } return false; } } [HarmonyPatch(typeof(CharacterAfflictions), "UpdateWeight")] internal static class WeightOverridePatch { private static void Postfix(CharacterAfflictions __instance) { if (!StatusProtectionPatch.WeightOverrideEnabled) { return; } Character localCharacter = Character.localCharacter; if (localCharacter != null) { CharacterAfflictions val = ((Component)localCharacter).GetComponent() ?? ((Component)localCharacter).GetComponentInChildren(true); if (val != null && __instance == val) { __instance.SetStatus((STATUSTYPE)7, StatusProtectionPatch.WeightOverrideValue, true); } } } } } namespace P.E.A.K_MENU.Input { internal readonly struct FeatureInputBinding { internal const string NoneValue = "None"; internal const string MouseWheelUpValue = "MouseWheelUp"; internal const string MouseWheelDownValue = "MouseWheelDown"; private readonly string _value; internal string Value => _value ?? "None"; internal string DisplayName => Value switch { "None" => "未指定", "MouseWheelUp" => "滚轮向上", "MouseWheelDown" => "滚轮向下", _ => Value, }; internal FeatureInputBinding(string? value) { _value = Normalize(value); } internal bool IsPressed() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) if (Value == "MouseWheelUp") { return Input.mouseScrollDelta.y > 0f; } if (Value == "MouseWheelDown") { return Input.mouseScrollDelta.y < 0f; } if (Enum.TryParse(Value, ignoreCase: true, out KeyCode result) && (int)result != 0) { return Input.GetKeyDown(result); } return false; } internal static bool TryCapture(Event currentEvent, out FeatureInputBinding binding) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Invalid comparison between Unknown and I4 //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_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) if ((int)currentEvent.type == 6) { binding = new FeatureInputBinding((currentEvent.delta.y < 0f) ? "MouseWheelUp" : "MouseWheelDown"); return true; } if ((int)currentEvent.type == 4 && (int)currentEvent.keyCode != 0) { binding = new FeatureInputBinding(((object)currentEvent.keyCode/*cast due to .constrained prefix*/).ToString()); return true; } binding = default(FeatureInputBinding); return false; } private unsafe static string Normalize(string? value) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrWhiteSpace(value)) { return "None"; } string text = value.Trim(); if (text.Equals("MouseWheelUp", StringComparison.OrdinalIgnoreCase)) { return "MouseWheelUp"; } if (text.Equals("MouseWheelDown", StringComparison.OrdinalIgnoreCase)) { return "MouseWheelDown"; } if (Enum.TryParse(text, ignoreCase: true, out KeyCode result) && (int)result != 0) { return ((object)(*(KeyCode*)(&result))/*cast due to .constrained prefix*/).ToString(); } return "None"; } } internal static class FeatureInputSettings { private static readonly Dictionary> Bindings = new Dictionary>(); private static ConfigEntry? _doubleTapFlightEnabled; internal static bool DoubleTapFlightEnabled { get { return _doubleTapFlightEnabled?.Value ?? true; } set { if (_doubleTapFlightEnabled != null) { _doubleTapFlightEnabled.Value = value; } } } internal static void Initialize(ConfigFile config) { Bindings.Clear(); _doubleTapFlightEnabled = config.Bind("Flight.Input", "DoubleTapSpaceEnabled", true, "是否允许双击空格进入或退出实际飞行。"); Bind(config, FeatureShortcutAction.ToggleFlightSystem, "ToggleFlightSystem", "None"); Bind(config, FeatureShortcutAction.ToggleActiveFlight, "ToggleActiveFlight", "None"); Bind(config, FeatureShortcutAction.IncreaseFlightSpeed, "IncreaseFlightSpeed", "MouseWheelUp"); Bind(config, FeatureShortcutAction.DecreaseFlightSpeed, "DecreaseFlightSpeed", "MouseWheelDown"); Bind(config, FeatureShortcutAction.ToggleInvincibility, "ToggleInvincibility", "None"); Bind(config, FeatureShortcutAction.ToggleAntiKnockback, "ToggleAntiKnockback", "None"); Bind(config, FeatureShortcutAction.ToggleInfiniteStamina, "ToggleInfiniteStamina", "None"); Bind(config, FeatureShortcutAction.ReviveSelf, "ReviveSelf", "None"); Bind(config, FeatureShortcutAction.ToggleWeightOverride, "ToggleWeightOverride", "None"); Bind(config, FeatureShortcutAction.SpawnLastItem, "SpawnLastItem", "None"); } internal static FeatureInputBinding GetBinding(FeatureShortcutAction action) { if (!Bindings.TryGetValue(action, out ConfigEntry value)) { return new FeatureInputBinding(GetDefaultValue(action)); } return new FeatureInputBinding(value.Value); } internal static void SetBinding(FeatureShortcutAction action, FeatureInputBinding binding) { if (Bindings.TryGetValue(action, out ConfigEntry value)) { value.Value = binding.Value; } } internal static void ResetBinding(FeatureShortcutAction action) { SetBinding(action, new FeatureInputBinding(GetDefaultValue(action))); } internal static bool IsPressed(FeatureShortcutAction action) { return GetBinding(action).IsPressed(); } private static void Bind(ConfigFile config, FeatureShortcutAction action, string key, string defaultValue) { Bindings[action] = config.Bind("FeatureShortcuts", key, defaultValue, "功能快捷键。可填写 Unity KeyCode、MouseWheelUp、MouseWheelDown 或 None。"); } private static string GetDefaultValue(FeatureShortcutAction action) { return action switch { FeatureShortcutAction.IncreaseFlightSpeed => "MouseWheelUp", FeatureShortcutAction.DecreaseFlightSpeed => "MouseWheelDown", _ => "None", }; } } internal enum FeatureShortcutAction { ToggleFlightSystem, ToggleActiveFlight, IncreaseFlightSpeed, DecreaseFlightSpeed, ToggleInvincibility, ToggleAntiKnockback, ToggleInfiniteStamina, ReviveSelf, ToggleWeightOverride, SpawnLastItem } internal sealed class FeatureShortcutController { internal void Update() { if (!MenuState.IsOpen && !MenuState.IsRebinding) { UpdateFlightShortcuts(); UpdateStatusShortcuts(); UpdateItemSpawnShortcuts(); } } private static void UpdateFlightShortcuts() { if (FlightRuntime.IsInitialized) { FlightService service = FlightRuntime.Service; if (FeatureInputSettings.IsPressed(FeatureShortcutAction.ToggleFlightSystem)) { service.SetEnabled(!service.Enabled); } if (FeatureInputSettings.IsPressed(FeatureShortcutAction.ToggleActiveFlight)) { service.ToggleActiveFlight(); } if (FeatureInputSettings.IsPressed(FeatureShortcutAction.IncreaseFlightSpeed)) { service.AdjustFlightSpeed(1f); } if (FeatureInputSettings.IsPressed(FeatureShortcutAction.DecreaseFlightSpeed)) { service.AdjustFlightSpeed(-1f); } } } private static void UpdateStatusShortcuts() { if (StatusRuntime.IsInitialized) { StatusService service = StatusRuntime.Service; if (FeatureInputSettings.IsPressed(FeatureShortcutAction.ToggleInvincibility) && !service.FlightProtectionLock) { service.SetInvincible(!service.Invincible); } if (FeatureInputSettings.IsPressed(FeatureShortcutAction.ToggleAntiKnockback) && service.Invincible && !service.FlightProtectionLock) { service.SetAntiKnockback(!service.AntiKnockback); } if (FeatureInputSettings.IsPressed(FeatureShortcutAction.ToggleInfiniteStamina)) { service.SetInfiniteStamina(!service.InfiniteStamina); } if (FeatureInputSettings.IsPressed(FeatureShortcutAction.ReviveSelf)) { service.ReviveSelf(); } if (FeatureInputSettings.IsPressed(FeatureShortcutAction.ToggleWeightOverride)) { service.SetWeightOverride(!service.WeightOverrideEnabled); } } } private static void UpdateItemSpawnShortcuts() { if (ItemSpawnRuntime.IsInitialized && FeatureInputSettings.IsPressed(FeatureShortcutAction.SpawnLastItem)) { ItemSpawnRuntime.Spawner.SpawnLast(); } } } internal sealed class MenuInputController { private readonly PeakMenuWindow _menuWindow; internal MenuInputController(PeakMenuWindow menuWindow) { _menuWindow = menuWindow; } internal void Update() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) if (MenuState.IsRebinding) { return; } if (_menuWindow.IsOpen) { if (ShouldCloseMenu()) { _menuWindow.Close(); } } else if (Input.GetKeyDown(MenuSettings.ToggleKey)) { _menuWindow.Open(); } } private static bool ShouldCloseMenu() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) if (!Input.GetKeyDown(MenuSettings.ToggleKey) && !Input.GetKeyDown((KeyCode)27) && !Input.GetKeyDown((KeyCode)9) && !Input.GetKeyDown((KeyCode)119) && !Input.GetKeyDown((KeyCode)97) && !Input.GetKeyDown((KeyCode)115) && !Input.GetKeyDown((KeyCode)100) && !Input.GetKeyDown((KeyCode)304) && !Input.GetKeyDown((KeyCode)303)) { return Input.GetKeyDown((KeyCode)32); } return true; } } } namespace P.E.A.K_MENU.Features.Teleport { internal sealed class TeleportPlayerEntry { internal Character Character { get; } internal int ActorNumber { get; } internal int ViewId { get; } internal string DisplayName { get; } internal bool IsValid { get { if ((Object)(object)Character != (Object)null && (Object)(object)((Component)Character).gameObject != (Object)null) { return ((Component)Character).gameObject.activeInHierarchy; } return false; } } internal TeleportPlayerEntry(Character character, int actorNumber, int viewId, string displayName) { Character = character; ActorNumber = actorNumber; ViewId = viewId; DisplayName = displayName; } public override string ToString() { return DisplayName + " " + $"({ActorNumber}, {ViewId})"; } } internal static class TeleportRuntime { private static TeleportService? _service; internal static bool IsInitialized => _service != null; internal static TeleportService Service { get { if (_service == null) { throw new InvalidOperationException("TeleportRuntime 尚未初始化。"); } return _service; } } internal static void Initialize() { if (_service == null) { _service = new TeleportService(); Plugin.Log.LogInfo((object)"Teleport runtime initialized."); } } internal static void Update() { _service?.Update(); } internal static void Dispose() { _service?.Clear(); _service = null; Plugin.Log.LogInfo((object)"Teleport runtime disposed."); } } internal sealed class TeleportService { private const float AutomaticRefreshInterval = 1f; private const float HorizontalArrivalOffset = 1.1f; private const float VerticalArrivalOffset = 0.15f; private readonly List _players = new List(); private float _nextRefreshTime; internal IReadOnlyList Players => _players; internal bool HasOtherPlayers => _players.Count > 0; internal string LastStatus { get; private set; } = "正在扫描房间玩家……"; internal bool LastSucceeded { get; private set; } internal void Update() { if (!(Time.unscaledTime < _nextRefreshTime)) { RefreshPlayers(); _nextRefreshTime = Time.unscaledTime + 1f; } } internal bool RefreshPlayers() { _nextRefreshTime = Time.unscaledTime + 1f; Character[] array = Resources.FindObjectsOfTypeAll(); Character val = ResolveCurrentLocalCharacter(array); List list = new List(); Character[] array2 = array; foreach (Character val2 in array2) { if (!IsUsablePlayerCharacter(val2) || IsLocalCharacter(val2, val)) { continue; } PhotonView photonView = ((MonoBehaviourPun)val2).photonView; if (photonView != null) { int actorNumber = ResolveActorNumber(photonView, val2); if (!list.Any((TeleportPlayerEntry player) => player.ActorNumber == actorNumber)) { string displayName = ResolveDisplayName(photonView, val2, actorNumber); list.Add(new TeleportPlayerEntry(val2, actorNumber, photonView.ViewID, displayName)); } } } list.Sort((TeleportPlayerEntry left, TeleportPlayerEntry right) => string.Compare(left.DisplayName, right.DisplayName, StringComparison.OrdinalIgnoreCase)); _players.Clear(); _players.AddRange(list); if (val == null) { LastSucceeded = false; LastStatus = "尚未找到本地玩家,请先进入关卡。"; return false; } if (_players.Count == 0) { LastSucceeded = false; LastStatus = "当前没有自己以外的玩家。"; return false; } LastSucceeded = true; LastStatus = $"已扫描到 {_players.Count} 名其他玩家。"; return true; } internal void TeleportLocalTo(TeleportPlayerEntry selectedTarget) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) LastSucceeded = false; Character val = ResolveCurrentLocalCharacter(); TeleportPlayerEntry freshTarget; if (val == null) { LastStatus = "未找到本地玩家,请先进入关卡。"; } else if (TryResolveFreshTarget(selectedTarget, out freshTarget)) { TeleportPlayerEntry teleportPlayerEntry = freshTarget; Vector3 val2 = ResolveCharacterWorldPosition(teleportPlayerEntry.Character); Vector3 val3 = CalculateArrivalPosition(teleportPlayerEntry.Character, val); Plugin.Log.LogInfo((object)("TeleportLocalTo target root=" + $"{((Component)teleportPlayerEntry.Character).transform.position}, " + $"body={val2}, " + $"destination={val3}.")); if (!TryWarpCharacter(val, val3, out string error)) { LastStatus = "传送失败:" + error; return; } LastSucceeded = true; LastStatus = "已传送到 " + teleportPlayerEntry.DisplayName + " 附近。"; Plugin.Log.LogInfo((object)("Teleported local player to " + teleportPlayerEntry.DisplayName + " " + $"({teleportPlayerEntry.ActorNumber}).")); } } internal void BringPlayerToLocal(TeleportPlayerEntry selectedTarget) { //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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) LastSucceeded = false; Character val = ResolveCurrentLocalCharacter(); TeleportPlayerEntry freshTarget; if (val == null) { LastStatus = "未找到本地玩家,请先进入关卡。"; } else if (TryResolveFreshTarget(selectedTarget, out freshTarget)) { Vector3 val2 = ResolveCharacterWorldPosition(val); TeleportPlayerEntry teleportPlayerEntry = freshTarget; Vector3 val3 = CalculateArrivalPosition(val, teleportPlayerEntry.Character); Plugin.Log.LogInfo((object)("BringPlayerToLocal local root=" + $"{((Component)val).transform.position}, " + $"body={val2}, " + $"destination={val3}.")); if (!TryWarpCharacter(teleportPlayerEntry.Character, val3, out string error)) { LastStatus = "传送失败:" + error; return; } LastSucceeded = true; LastStatus = "已将 " + teleportPlayerEntry.DisplayName + " 传送到你附近。"; Plugin.Log.LogInfo((object)("Brought player " + teleportPlayerEntry.DisplayName + " " + $"({teleportPlayerEntry.ActorNumber}) " + "to the local player.")); } } internal void Clear() { _players.Clear(); _nextRefreshTime = 0f; LastSucceeded = false; LastStatus = "正在扫描房间玩家……"; } private bool TryResolveFreshTarget(TeleportPlayerEntry selectedTarget, out TeleportPlayerEntry? freshTarget) { freshTarget = null; if (selectedTarget == null) { LastSucceeded = false; LastStatus = "目标玩家无效。"; return false; } int actorNumber = selectedTarget.ActorNumber; int viewId = selectedTarget.ViewId; if (!RefreshPlayers()) { LastSucceeded = false; LastStatus = "房间中已没有其他玩家。"; return false; } freshTarget = _players.FirstOrDefault((TeleportPlayerEntry player) => player.ViewId == viewId) ?? _players.FirstOrDefault((TeleportPlayerEntry player) => player.ActorNumber == actorNumber); if (freshTarget == null) { LastSucceeded = false; LastStatus = "目标玩家已经离开房间。"; return false; } if (!freshTarget.IsValid) { LastSucceeded = false; LastStatus = "目标玩家角色已经失效。"; RefreshPlayers(); freshTarget = null; return false; } if (!IsUsablePlayerCharacter(freshTarget.Character)) { LastSucceeded = false; LastStatus = "目标不是当前登记的玩家角色。"; freshTarget = null; return false; } if (IsLocalCharacter(freshTarget.Character, ResolveCurrentLocalCharacter())) { LastSucceeded = false; LastStatus = "不能选择本地玩家自己。"; freshTarget = null; return false; } if (((MonoBehaviourPun)freshTarget.Character).photonView == null) { LastSucceeded = false; LastStatus = "目标玩家没有可用的 PhotonView。"; freshTarget = null; return false; } return true; } private static bool TryWarpCharacter(Character character, Vector3 destination, out string error) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) error = string.Empty; if (character == null) { error = "角色对象为空。"; return false; } PhotonView photonView = ((MonoBehaviourPun)character).photonView; if (photonView == null) { error = "角色 PhotonView 不存在。"; return false; } try { photonView.RPC("WarpPlayerRPC", (RpcTarget)0, new object[2] { destination, false }); return true; } catch (Exception ex) { error = ex.Message; Plugin.Log.LogError((object)("WarpPlayerRPC failed for '" + ((Object)character).name + "': " + $"{ex}")); return false; } } private static Vector3 CalculateArrivalPosition(Character anchor, Character movingCharacter) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ResolveCharacterWorldPosition(anchor); Vector3 val2 = ResolveCharacterSideDirection(anchor); int num = ResolveActorNumber(((MonoBehaviourPun)movingCharacter).photonView, movingCharacter); float num2 = ((num % 2 == 0) ? 1f : (-1f)); return val + val2 * 1.1f * num2 + Vector3.up * 0.15f; } private static Vector3 ResolveCharacterWorldPosition(Character character) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) Rigidbody[] componentsInChildren = ((Component)character).GetComponentsInChildren(true); if (componentsInChildren.Length == 0) { return ((Component)character).transform.position; } string[] array = new string[6] { "hip", "hips", "pelvis", "torso", "chest", "body" }; string[] array2 = array; foreach (string value in array2) { Rigidbody[] array3 = componentsInChildren; foreach (Rigidbody val in array3) { if (IsUsableBodyRigidbody(val)) { string text = ((Object)val).name ?? string.Empty; if (text.Contains(value, StringComparison.OrdinalIgnoreCase)) { return val.worldCenterOfMass; } } } } Vector3 val2 = Vector3.zero; int num = 0; Rigidbody[] array4 = componentsInChildren; foreach (Rigidbody val3 in array4) { if (IsUsableBodyRigidbody(val3)) { val2 += val3.worldCenterOfMass; num++; } } if (num > 0) { return val2 / (float)num; } return ((Component)character).transform.position; } private static bool IsUsableBodyRigidbody(Rigidbody? rigidbody) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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_003a: 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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) if (rigidbody == null) { return false; } GameObject gameObject = ((Component)rigidbody).gameObject; if (gameObject == null || !gameObject.activeInHierarchy) { return false; } Vector3 worldCenterOfMass = rigidbody.worldCenterOfMass; if (!float.IsNaN(worldCenterOfMass.x) && !float.IsNaN(worldCenterOfMass.y) && !float.IsNaN(worldCenterOfMass.z) && !float.IsInfinity(worldCenterOfMass.x) && !float.IsInfinity(worldCenterOfMass.y)) { return !float.IsInfinity(worldCenterOfMass.z); } return false; } private static Vector3 ResolveCharacterSideDirection(Character character) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: 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_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) Vector3 right = ((Component)character).transform.right; Rigidbody[] componentsInChildren = ((Component)character).GetComponentsInChildren(true); Rigidbody[] array = componentsInChildren; foreach (Rigidbody val in array) { if (IsUsableBodyRigidbody(val)) { string text = ((Object)val).name ?? string.Empty; if (text.Contains("hip", StringComparison.OrdinalIgnoreCase) || text.Contains("pelvis", StringComparison.OrdinalIgnoreCase) || text.Contains("torso", StringComparison.OrdinalIgnoreCase) || text.Contains("chest", StringComparison.OrdinalIgnoreCase)) { right = ((Component)val).transform.right; break; } } } right.y = 0f; if (((Vector3)(ref right)).sqrMagnitude < 0.001f) { return Vector3.right; } return ((Vector3)(ref right)).normalized; } private static bool IsUsableCharacter(Character? character) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) if (character == null) { return false; } GameObject gameObject = ((Component)character).gameObject; if (gameObject != null) { Scene scene = gameObject.scene; if (((Scene)(ref scene)).IsValid()) { if (!gameObject.activeInHierarchy) { return false; } return ((MonoBehaviourPun)character).photonView != null; } } return false; } private static bool IsUsablePlayerCharacter(Character? character) { if (IsUsableCharacter(character) && character.IsPlayerControlled) { return character.IsRegisteredToPlayer; } return false; } private static Character? ResolveCurrentLocalCharacter(Character[]? discoveredCharacters = null) { Character[] source = discoveredCharacters ?? Resources.FindObjectsOfTypeAll(); Character val = ((IEnumerable)source).FirstOrDefault((Func)((Character character) => IsUsablePlayerCharacter(character) && IsLocalCharacter(character, null))); if (val != null) { return val; } Character localCharacter = Character.localCharacter; if (!IsUsablePlayerCharacter(localCharacter)) { return null; } return localCharacter; } private static bool IsLocalCharacter(Character? character, Character? knownLocalCharacter) { if (character == null) { return false; } if (knownLocalCharacter != null && character == knownLocalCharacter) { return true; } if (character.IsLocal) { return true; } PhotonView photonView = ((MonoBehaviourPun)character).photonView; if (photonView == null) { return false; } if (photonView.IsMine) { return true; } Player localPlayer = PhotonNetwork.LocalPlayer; int num = ((localPlayer != null) ? localPlayer.ActorNumber : 0); if (num != 0 && photonView.Owner != null) { return photonView.Owner.ActorNumber == num; } return false; } private static int ResolveActorNumber(PhotonView? photonView, Character character) { if (((photonView != null) ? photonView.Owner : null) != null) { return photonView.Owner.ActorNumber; } if (photonView != null && photonView.ViewID != 0) { return photonView.ViewID; } return ((Object)character).GetInstanceID(); } private static string ResolveDisplayName(PhotonView photonView, Character character, int actorNumber) { Player owner = photonView.Owner; string text = ((owner != null) ? owner.NickName : null); if (!string.IsNullOrWhiteSpace(text)) { return text; } if (!string.IsNullOrWhiteSpace(((Object)character).name)) { return ((Object)character).name; } return $"玩家 {actorNumber}"; } } } namespace P.E.A.K_MENU.Features.Status { internal sealed class StatusEffectDefinition { internal string Id { get; } internal string DisplayName { get; } internal string Description { get; } internal StatusEffectKind Kind { get; } internal StatusValueMode ValueMode { get; } internal bool ShowAmount { get; } internal bool ShowDuration { get; } internal STATUSTYPE? StatusType { get; } internal float DefaultAmount { get; } internal float DefaultDuration { get; } internal StatusEffectDefinition(string id, string displayName, string description, StatusEffectKind kind, StatusValueMode valueMode, bool showAmount, bool showDuration, STATUSTYPE? statusType = null, float defaultAmount = 0.1f, float defaultDuration = 3f) { Id = id; DisplayName = displayName; Description = description; Kind = kind; ValueMode = valueMode; ShowAmount = showAmount; ShowDuration = showDuration; StatusType = statusType; DefaultAmount = defaultAmount; DefaultDuration = defaultDuration; } } internal enum StatusEffectKind { GameStatus } internal enum StatusValueMode { AmountOnly, NativeDecay, TimedConstant, TimedDecay } internal enum StatusApplyMode { Add, Subtract, Set, Clear } internal static class StatusRuntime { private static StatusService? _service; internal static bool IsInitialized => _service != null; internal static StatusService Service { get { if (_service == null) { throw new InvalidOperationException("StatusRuntime 尚未初始化。"); } return _service; } } internal static void Initialize() { if (_service == null) { _service = new StatusService(); Plugin.Log.LogInfo((object)"Status runtime initialized."); } } internal static void Update() { _service?.Update(); } internal static void Dispose() { _service?.Dispose(); _service = null; Plugin.Log.LogInfo((object)"Status runtime disposed."); } } internal sealed class StatusService : IDisposable { private sealed class ActiveTimedStatus { internal STATUSTYPE StatusType { get; } internal StatusValueMode ValueMode { get; } internal float StartAmount { get; } internal float StartTime { get; } internal float EndTime { get; } internal ActiveTimedStatus(STATUSTYPE statusType, StatusValueMode valueMode, float startAmount, float startTime, float endTime) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) StatusType = statusType; ValueMode = valueMode; StartAmount = startAmount; StartTime = startTime; EndTime = endTime; } } private const float MaintenanceInterval = 0.05f; private static readonly PropertyInfo? InfiniteStaminaProperty = typeof(Character).GetProperty("infiniteStam", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); private static readonly FieldInfo? InfiniteStaminaField = typeof(Character).GetField("infiniteStam", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); private static readonly PropertyInfo? StatusesLockedProperty = typeof(Character).GetProperty("statusesLocked", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); private static readonly FieldInfo? StatusesLockedField = typeof(Character).GetField("statusesLocked", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); private static readonly MethodInfo? GetStatusMethod = FindGetStatusMethod(); private readonly Dictionary _timedStatuses = new Dictionary(); private readonly List _specialEffects = new List(); private float _nextMaintenanceTime; private bool _invincible; private bool _antiKnockback = true; private bool _infiniteStamina; private bool _flightProtectionLock; private bool _weightOverrideEnabled; private float _customWeight; private Character? _lastCharacter; internal bool Invincible => _invincible; internal bool AntiKnockback => _antiKnockback; internal bool InfiniteStamina => _infiniteStamina; internal bool FlightProtectionLock => _flightProtectionLock; internal bool WeightOverrideEnabled => _weightOverrideEnabled; internal float CustomWeight => _customWeight; internal IReadOnlyList SpecialEffects => _specialEffects; internal string LastStatus { get; private set; } = "等待操作。"; internal bool LastSucceeded { get; private set; } internal StatusService() { BuildStatusEffectList(); LogRuntimeMembers(); } internal void Update() { if (Time.unscaledTime < _nextMaintenanceTime) { return; } _nextMaintenanceTime = Time.unscaledTime + 0.05f; Character localCharacter = Character.localCharacter; if (localCharacter == null) { _lastCharacter = null; return; } if (_lastCharacter != localCharacter) { _lastCharacter = localCharacter; ApplyPersistentSettings(localCharacter); } if (_infiniteStamina) { SetCharacterBoolean(localCharacter, InfiniteStaminaProperty, InfiniteStaminaField, value: true); } if (_invincible) { MaintainInvincibility(localCharacter); } MaintainTimedStatuses(localCharacter); if (_weightOverrideEnabled) { ApplyWeight(localCharacter, _customWeight); } } internal void SetInvincible(bool enabled, bool force = false) { if (_flightProtectionLock && !force && !enabled) { LastSucceeded = false; LastStatus = "实际飞行期间,无敌已被锁定。"; return; } _invincible = enabled; StatusProtectionPatch.InvincibleEnabled = enabled; Character localCharacter = Character.localCharacter; if (!enabled) { if (localCharacter != null) { SetCharacterBoolean(localCharacter, StatusesLockedProperty, StatusesLockedField, value: false); } LastSucceeded = true; LastStatus = "无敌已关闭。"; return; } if (localCharacter == null) { Fail("未找到本地玩家,请先进入关卡。"); return; } bool flag = SetCharacterBoolean(localCharacter, StatusesLockedProperty, StatusesLockedField, value: true); ClearNegativeEffectsInternal(localCharacter, preserveWeight: true, preserveTimedStatuses: true, showResult: false); LastSucceeded = true; if (_antiKnockback) { LastStatus = (flag ? "无敌已开启:锁定状态,并阻止死亡、击退与摔倒。" : "无敌已开启:阻止死亡、击退与摔倒。"); } else { LastStatus = (flag ? "无敌已开启:锁定状态并阻止死亡。" : "无敌已开启:阻止死亡。"); } } internal void SetAntiKnockback(bool enabled, bool force = false) { if (_flightProtectionLock && !force && !enabled) { LastSucceeded = false; LastStatus = "实际飞行期间,防击退已被锁定。"; return; } _antiKnockback = enabled; StatusProtectionPatch.AntiKnockbackEnabled = enabled; LastSucceeded = true; LastStatus = (enabled ? "附加保护已开启:阻止击退、摔倒与外力。" : "附加保护已关闭:恢复原版击退与摔倒。"); } internal void SetFlightProtectionLock(bool locked) { _flightProtectionLock = locked; if (locked) { LastSucceeded = true; LastStatus = "实际飞行已锁定无敌与防击退。"; } else { LastSucceeded = true; LastStatus = "飞行保护锁定已解除。"; } } internal void SetInfiniteStamina(bool enabled) { _infiniteStamina = enabled; Character localCharacter = Character.localCharacter; if (localCharacter == null) { Fail("未找到本地玩家,请先进入关卡。"); return; } bool flag = (LastSucceeded = SetCharacterBoolean(localCharacter, InfiniteStaminaProperty, InfiniteStaminaField, enabled)); LastStatus = ((!flag) ? "没有找到 infiniteStam 成员。" : (enabled ? "无限体力已开启。" : "无限体力已关闭。")); Plugin.Log.LogInfo((object)($"SetInfiniteStamina({enabled}): " + $"changed={flag}.")); } internal void ClearNegativeEffects() { Character localCharacter = Character.localCharacter; if (localCharacter == null) { Fail("未找到本地玩家,请先进入关卡。"); } else { ClearNegativeEffectsInternal(localCharacter, preserveWeight: true, preserveTimedStatuses: false, showResult: true); } } internal void ReviveSelf() { //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_0099: 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_008f: 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_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) Character localCharacter = Character.localCharacter; if (localCharacter == null || !localCharacter.IsLocal) { Fail("未找到本地玩家,请先进入关卡。"); return; } PhotonView photonView = ((MonoBehaviourPun)localCharacter).photonView; if (photonView == null) { Fail("本地角色 PhotonView 不存在,无法复活。"); return; } bool dead; try { dead = localCharacter.data.dead; } catch (Exception ex) { Fail("无法读取角色死亡状态:" + ex.Message); return; } if (!dead) { LastSucceeded = false; LastStatus = "当前角色没有死亡,不需要复活。"; return; } try { Vector3 val; if (localCharacter.Ghost != null) { val = ((Component)localCharacter.Ghost).transform.position; } else { val = localCharacter.Head; if (!IsFiniteVector(val)) { val = ((Component)localCharacter).transform.position; } } val += Vector3.up * 4f; if (!IsFiniteVector(val)) { Fail("计算出的复活位置无效。"); return; } photonView.RPC("RPCA_ReviveAtPosition", (RpcTarget)0, new object[3] { val, false, -1 }); LastSucceeded = true; LastStatus = "已执行复活自己的请求。"; Plugin.Log.LogInfo((object)("Self revive requested at " + $"{val} with current " + "three-argument RPC signature.")); } catch (Exception ex2) { Fail("复活失败:" + ex2.GetBaseException().Message); Plugin.Log.LogError((object)$"Self revive failed: {ex2}"); } } internal void SetWeightOverride(bool enabled) { _weightOverrideEnabled = enabled; StatusProtectionPatch.WeightOverrideEnabled = enabled; if (!enabled) { LastSucceeded = true; LastStatus = "负重覆盖已关闭,游戏将恢复计算真实负重。"; return; } Character localCharacter = Character.localCharacter; if (localCharacter == null) { Fail("未找到本地玩家,请先进入关卡。"); return; } bool flag = (LastSucceeded = ApplyWeight(localCharacter, _customWeight)); LastStatus = (flag ? $"负重覆盖已开启:{_customWeight:0.##}。" : "没有找到 CharacterAfflictions。"); } internal void SetWeight(float weight) { if (!IsFiniteNumber(weight)) { Fail("负重数值无效。"); return; } weight = Mathf.Clamp(weight, 0f, 1000f); _customWeight = weight; _weightOverrideEnabled = true; StatusProtectionPatch.WeightOverrideEnabled = true; StatusProtectionPatch.WeightOverrideValue = weight; Character localCharacter = Character.localCharacter; if (localCharacter == null) { Fail("未找到本地玩家,请先进入关卡。"); return; } bool flag = (LastSucceeded = ApplyWeight(localCharacter, weight)); LastStatus = (flag ? $"负重已覆盖为 {weight:0.##}。" : "没有找到 CharacterAfflictions。"); } internal void ApplySpecialEffect(StatusEffectDefinition effect, float amount, float duration, StatusApplyMode applyMode) { if (effect == null) { Fail("特殊效果为空。"); return; } Character localCharacter = Character.localCharacter; if (localCharacter == null) { Fail("未找到本地玩家,请先进入关卡。"); return; } if (effect.ShowAmount && !IsFiniteNumber(amount)) { Fail("持有量数值无效。"); return; } if (effect.ShowDuration && (!IsFiniteNumber(duration) || duration <= 0f)) { Fail("持续时间必须大于 0 秒。"); return; } amount = Mathf.Clamp(amount, -10000f, 10000f); duration = Mathf.Clamp(duration, 0.1f, 36000f); if (!(LastSucceeded = effect.Kind == StatusEffectKind.GameStatus && ApplyGameStatus(localCharacter, effect, amount, duration, applyMode))) { LastStatus = "无法施加“" + effect.DisplayName + "”。"; return; } LastStatus = BuildAppliedStatusMessage(effect, amount, duration, applyMode); Plugin.Log.LogInfo((object)("ApplySpecialEffect: id=" + effect.Id + ", " + $"amount={amount}, " + $"duration={duration}, " + $"mode={applyMode}, " + $"valueMode={effect.ValueMode}.")); } internal bool TryReadStatus(StatusEffectDefinition effect, out float value) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) value = 0f; if (!effect.StatusType.HasValue) { return false; } Character localCharacter = Character.localCharacter; if (localCharacter == null) { return false; } CharacterAfflictions val = FindAfflictions(localCharacter); if (val == null) { return false; } return TryGetStatusValue(val, effect.StatusType.Value, out value); } internal void SetInputError(string message) { Fail(message); } public void Dispose() { Character localCharacter = Character.localCharacter; if (localCharacter != null) { SetCharacterBoolean(localCharacter, InfiniteStaminaProperty, InfiniteStaminaField, value: false); SetCharacterBoolean(localCharacter, StatusesLockedProperty, StatusesLockedField, value: false); ClearTimedStatuses(localCharacter); } _invincible = false; _antiKnockback = true; _infiniteStamina = false; _flightProtectionLock = false; _weightOverrideEnabled = false; _customWeight = 0f; StatusProtectionPatch.InvincibleEnabled = false; StatusProtectionPatch.AntiKnockbackEnabled = true; StatusProtectionPatch.WeightOverrideEnabled = false; StatusProtectionPatch.WeightOverrideValue = 0f; _timedStatuses.Clear(); _lastCharacter = null; } private void ApplyPersistentSettings(Character character) { SetCharacterBoolean(character, InfiniteStaminaProperty, InfiniteStaminaField, _infiniteStamina); SetCharacterBoolean(character, StatusesLockedProperty, StatusesLockedField, _invincible); if (_weightOverrideEnabled) { ApplyWeight(character, _customWeight); } } private void MaintainInvincibility(Character character) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0087: 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) SetCharacterBoolean(character, StatusesLockedProperty, StatusesLockedField, value: true); CharacterAfflictions val = FindAfflictions(character); if (val == null) { return; } foreach (STATUSTYPE value in Enum.GetValues(typeof(STATUSTYPE))) { string text = ((object)value/*cast due to .constrained prefix*/).ToString().ToLowerInvariant(); if ((text.Contains("injury") || text.Contains("poison") || text.Contains("curse")) && !_timedStatuses.ContainsKey(value)) { TrySetStatusValue(val, value, 0f); } } } private void ClearNegativeEffectsInternal(Character character, bool preserveWeight, bool preserveTimedStatuses, bool showResult) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) CharacterAfflictions val = FindAfflictions(character); if (val == null) { if (showResult) { Fail("没有找到 CharacterAfflictions。"); } return; } int num = 0; foreach (STATUSTYPE value in Enum.GetValues(typeof(STATUSTYPE))) { string text = ((object)value/*cast due to .constrained prefix*/).ToString(); if ((!preserveWeight || !text.Equals("Weight", StringComparison.OrdinalIgnoreCase)) && (!preserveTimedStatuses || !_timedStatuses.ContainsKey(value)) && TrySetStatusValue(val, value, 0f)) { num++; } } if (!preserveTimedStatuses) { _timedStatuses.Clear(); } if (showResult) { LastSucceeded = num > 0; LastStatus = ((num > 0) ? $"已清除 {num} 项角色状态。" : "没有清除任何状态。"); } } private bool ApplyWeight(Character character, float weight) { CharacterAfflictions val = FindAfflictions(character); if (val == null) { return false; } bool flag = TrySetStatusValue(val, (STATUSTYPE)7, weight); if (flag) { StatusProtectionPatch.WeightOverrideValue = weight; } return flag; } private bool ApplyGameStatus(Character character, StatusEffectDefinition effect, float inputAmount, float duration, StatusApplyMode applyMode) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) if (!effect.StatusType.HasValue) { return false; } CharacterAfflictions val = FindAfflictions(character); if (val == null) { return false; } STATUSTYPE value = effect.StatusType.Value; float value2 = 0f; TryGetStatusValue(val, value, out value2); float num = CalculateFinalAmount(value2, inputAmount, applyMode); num = Mathf.Clamp(num, 0f, 10000f); switch (effect.ValueMode) { case StatusValueMode.AmountOnly: case StatusValueMode.NativeDecay: _timedStatuses.Remove(value); return TrySetStatusValue(val, value, num); case StatusValueMode.TimedConstant: case StatusValueMode.TimedDecay: if (!TrySetStatusValue(val, value, num)) { return false; } if (num <= 0f || applyMode == StatusApplyMode.Clear) { _timedStatuses.Remove(value); return true; } _timedStatuses[value] = new ActiveTimedStatus(value, effect.ValueMode, num, Time.unscaledTime, Time.unscaledTime + duration); return true; default: return false; } } private void MaintainTimedStatuses(Character character) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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_00b8: Unknown result type (might be due to invalid IL or missing references) if (_timedStatuses.Count == 0) { return; } CharacterAfflictions val = FindAfflictions(character); if (val == null) { return; } float unscaledTime = Time.unscaledTime; STATUSTYPE[] array = _timedStatuses.Keys.ToArray(); STATUSTYPE[] array2 = array; foreach (STATUSTYPE val2 in array2) { ActiveTimedStatus activeTimedStatus = _timedStatuses[val2]; if (unscaledTime >= activeTimedStatus.EndTime) { TrySetStatusValue(val, val2, 0f); _timedStatuses.Remove(val2); continue; } float value; if (activeTimedStatus.ValueMode == StatusValueMode.TimedDecay) { float num = Mathf.InverseLerp(activeTimedStatus.StartTime, activeTimedStatus.EndTime, unscaledTime); value = Mathf.Lerp(activeTimedStatus.StartAmount, 0f, num); } else { value = activeTimedStatus.StartAmount; } TrySetStatusValue(val, val2, value); } } private void ClearTimedStatuses(Character character) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) CharacterAfflictions val = FindAfflictions(character); if (val != null) { foreach (STATUSTYPE key in _timedStatuses.Keys) { TrySetStatusValue(val, key, 0f); } } _timedStatuses.Clear(); } private void BuildStatusEffectList() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) _specialEffects.Clear(); foreach (STATUSTYPE value in Enum.GetValues(typeof(STATUSTYPE))) { string text = ((object)value/*cast due to .constrained prefix*/).ToString(); if (!text.Equals("Weight", StringComparison.OrdinalIgnoreCase) && !(NormalizeName(text) == "injury")) { StatusValueMode statusValueMode = ResolveStatusValueMode(text); bool showDuration = statusValueMode == StatusValueMode.TimedConstant || statusValueMode == StatusValueMode.TimedDecay; float defaultAmount = ResolveDefaultAmount(); _specialEffects.Add(new StatusEffectDefinition("status_" + text, TranslateStatusName(text), BuildStatusDescription(text, statusValueMode), StatusEffectKind.GameStatus, statusValueMode, showAmount: true, showDuration, (STATUSTYPE?)value, defaultAmount, 3f)); } } Plugin.Log.LogInfo((object)($"Loaded {_specialEffects.Count} " + "status effect definitions.")); } private static StatusValueMode ResolveStatusValueMode(string runtimeName) { string text = NormalizeName(runtimeName); if (text.Contains("poison")) { return StatusValueMode.NativeDecay; } if (text.Contains("web") || text.Contains("blind") || text.Contains("snowblind") || text.Contains("lowgravity") || text.Contains("numb") || text.Contains("sleep") || text.Contains("stun")) { return StatusValueMode.TimedConstant; } return StatusValueMode.AmountOnly; } private static float ResolveDefaultAmount() { return 0.1f; } private static string BuildStatusDescription(string runtimeName, StatusValueMode valueMode) { return "游戏状态:" + runtimeName + "。" + valueMode switch { StatusValueMode.AmountOnly => "只修改持有量,不使用菜单计时。", StatusValueMode.NativeDecay => "设置一次持有量,之后由游戏原生逻辑自然减少。", StatusValueMode.TimedConstant => "在指定秒数内保持该持有量,到期归零。", StatusValueMode.TimedDecay => "在指定秒数内逐渐衰减到零。", _ => string.Empty, }; } private static string TranslateStatusName(string runtimeName) { return NormalizeName(runtimeName) switch { "poison" => "中毒", "cold" => "寒冷", "hot" => "炎热", "heat" => "炎热", "hunger" => "饥饿", "curse" => "诅咒", "drowsy" => "困倦", "sleep" => "睡眠", "web" => "蜘蛛网", "webbed" => "蜘蛛网", "webs" => "蜘蛛网", "blind" => "失明", "snowblind" => "雪盲", "numb" => "麻木", "lowgravity" => "低重力", "zombiebite" => "僵尸咬伤", "thorn" => "刺", "thorns" => "刺", "thron" => "刺", "throns" => "刺", "spore" => "孢子", "spores" => "孢子", "crab" => "奇异", "crabs" => "奇异", "stamina" => "体力", _ => runtimeName, }; } private static string NormalizeName(string value) { return value.Replace("_", string.Empty).Replace("-", string.Empty).Replace(" ", string.Empty) .ToLowerInvariant(); } private static float CalculateFinalAmount(float currentAmount, float inputAmount, StatusApplyMode mode) { return mode switch { StatusApplyMode.Add => currentAmount + Mathf.Abs(inputAmount), StatusApplyMode.Subtract => currentAmount - Mathf.Abs(inputAmount), StatusApplyMode.Set => inputAmount, StatusApplyMode.Clear => 0f, _ => inputAmount, }; } private static string BuildAppliedStatusMessage(StatusEffectDefinition effect, float amount, float duration, StatusApplyMode mode) { string text = mode switch { StatusApplyMode.Add => "增加", StatusApplyMode.Subtract => "减少", StatusApplyMode.Set => "设为", StatusApplyMode.Clear => "清零", _ => "修改", }; if (effect.ShowDuration) { return "已将“" + effect.DisplayName + "”" + text + " " + $"{amount:0.##},持续 " + $"{duration:0.##} 秒。"; } return "已将“" + effect.DisplayName + "”" + text + " " + $"{amount:0.##}。"; } private static CharacterAfflictions? FindAfflictions(Character character) { CharacterAfflictions component = ((Component)character).GetComponent(); if (component != null) { return component; } return ((Component)character).GetComponentInChildren(true); } private static bool TrySetStatusValue(CharacterAfflictions afflictions, STATUSTYPE type, float value) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) try { afflictions.SetStatus(type, value, true); return true; } catch (Exception ex) { Plugin.Log.LogWarning((object)($"SetStatus({type}, {value}) failed: " + ex.Message)); return false; } } private static bool TryGetStatusValue(CharacterAfflictions afflictions, STATUSTYPE type, out float value) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) value = 0f; if ((object)GetStatusMethod != null) { try { object raw = GetStatusMethod.Invoke(afflictions, new object[1] { type }); if (TryConvertFloat(raw, out value)) { return true; } } catch { } } return TryReadStatusFromMembers(afflictions, type, out value); } private static MethodInfo? FindGetStatusMethod() { Type typeFromHandle = typeof(CharacterAfflictions); return typeFromHandle.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).FirstOrDefault(delegate(MethodInfo method) { if (!method.Name.Equals("GetStatus", StringComparison.OrdinalIgnoreCase)) { return false; } ParameterInfo[] parameters = method.GetParameters(); if (parameters.Length != 1 || parameters[0].ParameterType != typeof(STATUSTYPE)) { return false; } return method.ReturnType == typeof(float) || method.ReturnType == typeof(double) || method.ReturnType == typeof(int); }); } private static bool TryReadStatusFromMembers(CharacterAfflictions afflictions, STATUSTYPE type, out float value) { //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) value = 0f; Type type2 = ((object)afflictions).GetType(); IEnumerable enumerable = type2.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).Cast().Concat(type2.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)); foreach (MemberInfo item in enumerable) { object obj2; try { MemberInfo memberInfo = item; object obj = ((memberInfo is FieldInfo fieldInfo) ? fieldInfo.GetValue(afflictions) : ((!(memberInfo is PropertyInfo { CanRead: not false } propertyInfo)) ? null : propertyInfo.GetValue(afflictions))); obj2 = obj; } catch { continue; } if (obj2 != null) { if (TryReadDictionaryValue(obj2, type, out value)) { return true; } if (TryReadIndexedValue(obj2, Convert.ToInt32(type), out value)) { return true; } } } return false; } private static bool TryReadDictionaryValue(object container, STATUSTYPE type, out float value) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) value = 0f; if (!(container is IDictionary dictionary)) { return false; } try { if (!dictionary.Contains(type)) { return false; } object raw = dictionary[type]; return TryConvertFloat(raw, out value); } catch { return false; } } private static bool TryReadIndexedValue(object container, int index, out float value) { value = 0f; if (index < 0) { return false; } try { if (container is Array array) { if (index >= array.Length) { return false; } return TryConvertFloat(array.GetValue(index), out value); } if (container is IList list) { if (index >= list.Count) { return false; } return TryConvertFloat(list[index], out value); } } catch { return false; } return false; } private static bool SetCharacterBoolean(Character character, PropertyInfo? property, FieldInfo? field, bool value) { try { if ((object)property != null && property.CanWrite) { property.SetValue(character, value); return true; } if ((object)field != null) { field.SetValue(character, value); return true; } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Failed to set Character boolean: " + ex.Message)); } return false; } private static bool TryConvertFloat(object? raw, out float value) { try { if (raw == null) { value = 0f; return false; } value = Convert.ToSingle(raw, CultureInfo.InvariantCulture); return true; } catch { value = 0f; return false; } } private static bool IsFiniteNumber(float value) { if (!float.IsNaN(value)) { return !float.IsInfinity(value); } return false; } private static bool IsFiniteVector(Vector3 value) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) if (!float.IsNaN(value.x) && !float.IsNaN(value.y) && !float.IsNaN(value.z) && !float.IsInfinity(value.x) && !float.IsInfinity(value.y)) { return !float.IsInfinity(value.z); } return false; } private static void LogRuntimeMembers() { Plugin.Log.LogInfo((object)("Status runtime members: infiniteStamProperty=" + $"{(object)InfiniteStaminaProperty != null}, " + "infiniteStamField=" + $"{(object)InfiniteStaminaField != null}, " + "statusesLockedProperty=" + $"{(object)StatusesLockedProperty != null}, " + "statusesLockedField=" + $"{(object)StatusesLockedField != null}, " + "GetStatus=" + $"{(object)GetStatusMethod != null}.")); Plugin.Log.LogInfo((object)("CharacterAfflictions.STATUSTYPE: " + string.Join(", ", Enum.GetNames(typeof(STATUSTYPE))))); } private void Fail(string message) { LastSucceeded = false; LastStatus = message; } } } namespace P.E.A.K_MENU.Features.ItemSpawn { internal sealed class ItemCatalogService : IDisposable { private readonly ItemIconResolver _iconResolver = new ItemIconResolver(); private readonly List _allItems = new List(); private readonly List _visibleNames = new List(); private int _loadedDatabaseId; internal IReadOnlyList AllItems => _allItems; internal void RefreshIfNeeded(bool force = false) { ItemDatabase instance = SingletonAsset.Instance; if (instance != null && ((DatabaseAsset)(object)instance).Objects != null) { int instanceID = ((Object)instance).GetInstanceID(); if (force || _loadedDatabaseId != instanceID || _allItems.Count <= 0) { LoadDatabase(instance, instanceID); } } } internal void ForceRefresh() { RefreshIfNeeded(force: true); } internal IReadOnlyList GetVisibleItems() { RefreshIfNeeded(); List list = new List(); foreach (string visibleName in _visibleNames) { ItemSpawnEntry itemSpawnEntry = FindByPrefabName(visibleName); if (itemSpawnEntry != null) { list.Add(itemSpawnEntry); } } return list; } internal bool ContainsVisible(string prefabName) { return _visibleNames.Contains(prefabName, StringComparer.OrdinalIgnoreCase); } internal void Add(string prefabName) { if (!ContainsVisible(prefabName)) { ItemSpawnEntry itemSpawnEntry = FindByPrefabName(prefabName); if (itemSpawnEntry != null) { _visibleNames.Add(itemSpawnEntry.PrefabName); Save(); Plugin.Log.LogInfo((object)("Added item to ItemSpawn list: " + itemSpawnEntry.PrefabName)); } } } internal bool PlaceAt(string prefabName, int insertionIndex) { ItemSpawnEntry itemSpawnEntry = FindByPrefabName(prefabName); if (itemSpawnEntry == null) { return false; } int num = _visibleNames.FindIndex((string name) => string.Equals(name, prefabName, StringComparison.OrdinalIgnoreCase)); int num2 = Math.Max(0, Math.Min(_visibleNames.Count, insertionIndex)); if (num >= 0) { if (num < num2) { num2--; } if (num == num2) { return false; } _visibleNames.RemoveAt(num); } num2 = Math.Min(num2, _visibleNames.Count); _visibleNames.Insert(num2, itemSpawnEntry.PrefabName); Save(); Plugin.Log.LogInfo((object)("Placed item in ItemSpawn list: " + $"{itemSpawnEntry.PrefabName} at {num2}")); return true; } internal void Remove(string prefabName) { int num = _visibleNames.RemoveAll((string name) => string.Equals(name, prefabName, StringComparison.OrdinalIgnoreCase)); if (num > 0) { Save(); Plugin.Log.LogInfo((object)("Removed item from ItemSpawn list: " + prefabName)); } } internal void Move(string prefabName, int direction) { int num = _visibleNames.FindIndex((string name) => string.Equals(name, prefabName, StringComparison.OrdinalIgnoreCase)); if (num >= 0) { int num2 = num + direction; if (num2 >= 0 && num2 < _visibleNames.Count) { string value = _visibleNames[num]; _visibleNames[num] = _visibleNames[num2]; _visibleNames[num2] = value; Save(); } } } internal void RestoreDefaults() { _visibleNames.Clear(); string[] preferredPrefabNames = ItemSpawnDefaults.PreferredPrefabNames; foreach (string preferred in preferredPrefabNames) { ItemSpawnEntry itemSpawnEntry = FindByPrefabName(preferred); ItemSpawnEntry itemSpawnEntry2 = itemSpawnEntry ?? _allItems.FirstOrDefault((ItemSpawnEntry entry) => entry.PrefabName.Contains(preferred, StringComparison.OrdinalIgnoreCase) || entry.DisplayName.Contains(preferred, StringComparison.OrdinalIgnoreCase)); if (itemSpawnEntry2 != null && !ContainsVisible(itemSpawnEntry2.PrefabName)) { _visibleNames.Add(itemSpawnEntry2.PrefabName); } } if (_visibleNames.Count == 0) { IEnumerable collection = from entry in _allItems.Take(12) select entry.PrefabName; _visibleNames.AddRange(collection); } Save(); Plugin.Log.LogInfo((object)("Restored default ItemSpawn list: " + $"{_visibleNames.Count} items.")); } public void Dispose() { _iconResolver.Dispose(); _allItems.Clear(); _visibleNames.Clear(); _loadedDatabaseId = 0; } private void LoadDatabase(ItemDatabase database, int databaseId) { _allItems.Clear(); foreach (Item @object in ((DatabaseAsset)(object)database).Objects) { if (@object != null && !string.IsNullOrWhiteSpace(((Object)@object).name)) { string displayName = ResolveDisplayName(@object); Sprite icon = _iconResolver.Resolve(@object); ItemSpawnEntry entry = new ItemSpawnEntry(@object, displayName, icon); if (!_allItems.Any((ItemSpawnEntry existing) => string.Equals(existing.PrefabName, entry.PrefabName, StringComparison.OrdinalIgnoreCase))) { _allItems.Add(entry); } } } _allItems.Sort((ItemSpawnEntry left, ItemSpawnEntry right) => string.Compare(left.DisplayName, right.DisplayName, StringComparison.OrdinalIgnoreCase)); _loadedDatabaseId = databaseId; LoadConfiguredOrder(); Plugin.Log.LogInfo((object)("Item catalog loaded: " + $"{_allItems.Count} items.")); } private void LoadConfiguredOrder() { _visibleNames.Clear(); IReadOnlyList readOnlyList = ItemSpawnConfiguration.LoadVisibleItemNames(); foreach (string item in readOnlyList) { if (FindByPrefabName(item) != null && !ContainsVisible(item)) { _visibleNames.Add(item); } } if (_visibleNames.Count == 0) { RestoreDefaults(); } } private ItemSpawnEntry? FindByPrefabName(string prefabName) { return _allItems.FirstOrDefault((ItemSpawnEntry entry) => string.Equals(entry.PrefabName, prefabName, StringComparison.OrdinalIgnoreCase)); } private void Save() { ItemSpawnConfiguration.SaveVisibleItemNames(_visibleNames); } private static string ResolveDisplayName(Item item) { return ((Object)item).name ?? "Unknown Item"; } } internal sealed class ItemIconResolver : IDisposable { private readonly Dictionary _cache = new Dictionary(StringComparer.OrdinalIgnoreCase); private readonly List _generatedSprites = new List(); internal Sprite? Resolve(Item item) { string text = ((Object)item).name ?? string.Empty; if (_cache.TryGetValue(text, out Sprite value)) { return value; } Sprite val = null; try { ItemUIData uIData = item.UIData; val = CreateSprite(uIData.icon); if (val == null && uIData.hasAltIcon) { val = CreateSprite(uIData.altIcon); } if (val == null) { Image componentInChildren = ((Component)item).GetComponentInChildren(true); val = ((componentInChildren != null) ? componentInChildren.sprite : null); } if (val == null) { SpriteRenderer componentInChildren2 = ((Component)item).GetComponentInChildren(true); val = ((componentInChildren2 != null) ? componentInChildren2.sprite : null); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Failed to resolve icon for '" + text + "': " + ex.Message)); } _cache[text] = val; return val; } public void Dispose() { foreach (Sprite generatedSprite in _generatedSprites) { if ((Object)(object)generatedSprite != (Object)null) { Object.Destroy((Object)(object)generatedSprite); } } _generatedSprites.Clear(); _cache.Clear(); } private Sprite? CreateSprite(Texture2D? texture) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) if (texture == null || ((Texture)texture).width <= 0 || ((Texture)texture).height <= 0) { return null; } Sprite val = Sprite.Create(texture, new Rect(0f, 0f, (float)((Texture)texture).width, (float)((Texture)texture).height), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0); ((Object)val).name = ((Object)texture).name + "_P.E.A.K_MENU_Icon"; _generatedSprites.Add(val); return val; } } internal static class ItemSpawnConfiguration { internal const int DefaultSpawnColumns = 4; private static ConfigEntry? _visibleItems; private static ConfigEntry? _spawnColumns; internal static bool IsInitialized => _spawnColumns != null; internal static int SpawnColumns => Math.Max(1, Math.Min(9, _spawnColumns?.Value ?? 4)); internal static void Initialize(ConfigFile config) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown _visibleItems = config.Bind("ItemSpawn", "VisibleItems", string.Empty, "物品生成页面显示的物品 prefab 名称。多个名称使用 | 分隔,保存顺序即菜单显示顺序。留空时使用默认物品和默认排序。"); _spawnColumns = config.Bind("ItemSpawn", "SpawnColumns", 4, new ConfigDescription("物品生成主列表的显示列数。", (AcceptableValueBase)(object)new AcceptableValueRange(1, 9), Array.Empty())); } internal static void SetSpawnColumns(int columns) { if (_spawnColumns != null) { _spawnColumns.Value = Math.Max(1, Math.Min(9, columns)); } } internal static void ResetSpawnColumns() { SetSpawnColumns(4); } internal static IReadOnlyList LoadVisibleItemNames() { string text = _visibleItems?.Value ?? string.Empty; if (string.IsNullOrWhiteSpace(text)) { return Array.Empty(); } return (from value in text.Split(new char[1] { '|' }, StringSplitOptions.RemoveEmptyEntries) select value.Trim() into value where !string.IsNullOrWhiteSpace(value) select value).Distinct(StringComparer.OrdinalIgnoreCase).ToArray(); } internal static void SaveVisibleItemNames(IEnumerable names) { if (_visibleItems != null) { string value = string.Join("|", names.Where((string name) => !string.IsNullOrWhiteSpace(name)).Distinct(StringComparer.OrdinalIgnoreCase)); _visibleItems.Value = value; } } internal static void Clear() { if (_visibleItems != null) { _visibleItems.Value = string.Empty; } } } internal static class ItemSpawnDefaults { internal static readonly string[] PreferredPrefabNames = new string[127] { "ScoutEffigy", "Backpack", "BookOfBones", "Airplane Food", "HealingPuffShroom", "Bandages", "FirstAidKit", "Cure-All", "Antidote", "RescueHook", "RescueHook_Infinite", "ChainShooter", "RopeSpool", "Anti-Rope Spool", "RopeShooter", "RopeShooterAnti", "HealingDart Variant", "PortableStovetopItem", "ClimbingSpike", "MagicBean", "ShelfShroom", "CloudFungus", "BounceShroom", "WarpFungus", "Bugle", "Bugle_Magic", "Bugle_Scoutmaster Variant", "AncientIdol", "Torch", "Candle", "Lantern", "Lantern_Faerie", "Amulet_SuperJump", "Amulet_Healing", "Amulet_InfiniteStamina", "Amulet_Clone", "Cursed Skull", "RitualDagger", "Flag_Plantable_Checkpoint", "Flare", "Balloon", "BalloonBunch", "Marshmallow", "Glizzy", "Granola Bar", "Sports Drink", "Energy Drink", "Lollipop", "FortifiedMilk", "Item_Honeycomb", "Beehive", "PandorasBox", "MedicinalRoot", "Mandrake", "Prickleberry_Red", "Prickleberry_Gold", "Winterberry Orange", "Winterberry Yellow", "Pepper Berry", "Napberry", "Shroomberry_Red", "Shroomberry_Purple", "Shroomberry_Yellow", "Shroomberry_Blue", "Shroomberry_Green", "Snowball", "Heat Pack", "AloeVera", "Sunscreen", "Parasol", "CactusBall", "Dynamite", "Scorpion", "EarlyWorm", "Frog", "FrogLegs", "ScoutCannonItem", "Rocketpack", "AntiZooka", "Jetpack", "Glider", "ScoutsHonor", "TrailMix", "ScoutCookies", "ScoutCookies_Vanilla", "Item_Coconut_half", "Item_Coconut", "Apple Berry Red", "Apple Berry Yellow", "Apple Berry Green", "Berrynana Yellow", "Berrynana Brown", "Berrynana Blue", "Berrynana Pink", "Berrynana Peel Yellow", "Berrynana Peel Brown Variant", "Berrynana Peel Blue Variant", "Berrynana Peel Pink Variant", "Kingberry Green", "Kingberry Yellow", "Kingberry Purple", "Bugfix", "Mushroom Chubby", "Mushroom Cluster", "Mushroom Cluster Poison", "Mushroom Glow", "Mushroom Lace", "Mushroom Lace Poison", "Mushroom Normie", "Mushroom Normie Poison", "Clusterberry Black", "Clusterberry Red", "Clusterberry Yellow", "NestEgg", "NestEgg_Raven", "Egg", "EggRaven", "EggTurkey", "Shell Big", "Pirate Compass", "Parachute", "BingBong", "Frisbee", "Compass", "Binoculars", "Fannypack", "Passport" }; internal const int FallbackItemCount = 12; } internal sealed class ItemSpawnEntry { internal Item Prefab { get; } internal string PrefabName { get; } internal string DisplayName { get; } internal Sprite? Icon { get; } internal ItemSpawnEntry(Item prefab, string displayName, Sprite? icon) { Prefab = prefab; PrefabName = ((Object)prefab).name ?? string.Empty; DisplayName = (string.IsNullOrWhiteSpace(displayName) ? PrefabName : displayName); Icon = icon; } public override string ToString() { return DisplayName + " (" + PrefabName + ")"; } } internal static class ItemSpawnRuntime { private static ItemCatalogService? _catalog; private static ItemSpawnService? _spawner; private static bool _initialized; internal static bool IsInitialized { get { if (_initialized && _catalog != null) { return _spawner != null; } return false; } } internal static ItemCatalogService Catalog { get { if (_catalog == null) { throw new InvalidOperationException("ItemSpawn Catalog 尚未初始化。"); } return _catalog; } } internal static ItemSpawnService Spawner { get { if (_spawner == null) { throw new InvalidOperationException("ItemSpawn Spawner 尚未初始化。"); } return _spawner; } } internal static void Initialize(ConfigFile config) { if (IsInitialized) { Plugin.Log.LogInfo((object)"ItemSpawn runtime is already initialized."); return; } Plugin.Log.LogInfo((object)"Initializing ItemSpawn runtime..."); ItemSpawnConfiguration.Initialize(config); _catalog = new ItemCatalogService(); _spawner = new ItemSpawnService(); _initialized = true; Plugin.Log.LogInfo((object)"ItemSpawn runtime initialized successfully."); } internal static void Dispose() { if (_initialized || _catalog != null || _spawner != null) { _catalog?.Dispose(); _catalog = null; _spawner = null; _initialized = false; Plugin.Log.LogInfo((object)"ItemSpawn runtime disposed."); } } } internal sealed class ItemSpawnService { private ItemSpawnEntry? _lastSpawnedItem; internal string LastStatus { get; private set; } = "选择物品以生成。"; internal bool LastSucceeded { get; private set; } internal void Spawn(ItemSpawnEntry entry) { LastSucceeded = false; if (entry.Prefab == null) { LastStatus = "物品预制体无效。"; return; } Character localCharacter = Character.localCharacter; if (localCharacter == null) { LastStatus = "未找到本地玩家,请先进入关卡。"; return; } if (GameUtils.instance == null) { LastStatus = "GameUtils 尚未初始化,请稍后再试。"; return; } try { GameUtils.instance.InstantiateAndGrab(entry.Prefab, localCharacter, 0); LastSucceeded = true; _lastSpawnedItem = entry; LastStatus = "已生成:" + entry.DisplayName; Plugin.Log.LogInfo((object)("Spawned item '" + entry.PrefabName + "' through InstantiateAndGrab.")); } catch (Exception ex) { LastSucceeded = false; LastStatus = "生成失败:" + ex.Message; Plugin.Log.LogError((object)("Failed to spawn '" + entry.PrefabName + "': " + $"{ex}")); } } internal void SpawnLast() { if (_lastSpawnedItem == null) { LastSucceeded = false; LastStatus = "尚未生成过物品。"; } else { Spawn(_lastSpawnedItem); } } internal void ClearStatus() { LastSucceeded = false; LastStatus = "选择物品以生成。"; } } } namespace P.E.A.K_MENU.Features.Flight { internal sealed class FlightController : MonoBehaviour { private const float FlightForceMultiplier = 50f; private const float SprintForceMultiplier = 4f; private const float MaximumForce = 110000f; private Character? _character; private CharacterMovement? _characterMovement; private void Awake() { _character = ((Component)this).GetComponent(); _characterMovement = ((Component)this).GetComponent(); if (_character == null) { Plugin.Log.LogWarning((object)"FlightController could not find Character component."); ((Behaviour)this).enabled = false; } else { Plugin.Log.LogInfo((object)("FlightController initialized on " + ((Object)_character).name + ".")); } } private void Update() { Character character = _character; if (character != null && character.IsLocal && FlightRuntime.Service.ActivelyFlying) { if (MenuState.IsOpen) { ApplyHoverCompensation(character); } else { ApplyFlight(character); } } } private void ApplyFlight(Character character) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0025: 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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008a: 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_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) float flightSpeed = FlightRuntime.Service.FlightSpeed; float hoverDownForce = FlightRuntime.Service.HoverDownForce; float num = flightSpeed * 50f; Vector3 val = Vector3.zero; Vector3 val2 = ResolveLookDirection(character); Vector3 val3 = (FlightRuntime.Service.HorizontalWasdMovement ? ResolveHorizontalForwardDirection(character, val2) : val2); if (Input.GetKey((KeyCode)119)) { val += val3 * num; } if (Input.GetKey((KeyCode)115)) { val -= val3 * num; } Vector3 val4 = ResolveRightDirection(character, val2); if (Input.GetKey((KeyCode)100)) { val += val4 * num; } if (Input.GetKey((KeyCode)97)) { val -= val4 * num; } if (Input.GetKey((KeyCode)32)) { val += Vector3.up * num; } else if (Input.GetKey((KeyCode)306) || Input.GetKey((KeyCode)305)) { val += Vector3.down * num; } if (Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303)) { val *= 4f; RestoreSprintStamina(character); } TryMaintainGroundedState(character); val = ClampForce(val); if (IsFiniteVector(val)) { ApplyMassWeightedForceToRagdoll(character, val); ApplyForceToRagdoll(character, Vector3.down * hoverDownForce); } } private static void ApplyHoverCompensation(Character character) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) TryMaintainGroundedState(character); Vector3 force = Vector3.down * FlightRuntime.Service.HoverDownForce; ApplyForceToRagdoll(character, force); } private static void ApplyForceToRagdoll(Character character, Vector3 force) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) if (!IsFiniteVector(force)) { return; } try { if (character.refs == null || character.refs.ragdoll == null || character.refs.ragdoll.partList == null) { return; } foreach (Bodypart part in character.refs.ragdoll.partList) { if (part != null) { part.AddForce(force, (ForceMode)0); } } } catch (Exception ex) { Plugin.Log.LogDebug((object)("Failed to apply flight force: " + ex.GetBaseException().Message)); } } private static void ApplyMassWeightedForceToRagdoll(Character character, Vector3 force) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) if (!IsFiniteVector(force) || ((Vector3)(ref force)).sqrMagnitude < 0.001f) { return; } try { if (character.refs == null || character.refs.ragdoll == null || character.refs.ragdoll.partList == null) { return; } int num = 0; float num2 = 0f; foreach (Bodypart part in character.refs.ragdoll.partList) { Rigidbody val = ResolveRigidbody(part); if (IsUsableRigidbody(val)) { num++; num2 += val.mass; } } if (num == 0 || num2 <= 0f || float.IsNaN(num2) || float.IsInfinity(num2)) { ApplyForceToRagdoll(character, force); return; } float num3 = (float)num / num2; foreach (Bodypart part2 in character.refs.ragdoll.partList) { Rigidbody val2 = ResolveRigidbody(part2); if (IsUsableRigidbody(val2)) { part2.AddForce(force * val2.mass * num3, (ForceMode)0); } } } catch (Exception ex) { Plugin.Log.LogDebug((object)("Failed to apply mass-weighted flight force: " + ex.GetBaseException().Message)); } } private static Vector3 ResolveLookDirection(Character character) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) Vector3 val = character.data.lookDirection; if (!IsFiniteVector(val) || ((Vector3)(ref val)).sqrMagnitude < 0.001f) { val = ((Component)character).transform.forward; } if (!IsFiniteVector(val) || ((Vector3)(ref val)).sqrMagnitude < 0.001f) { val = Vector3.forward; } ((Vector3)(ref val)).Normalize(); return val; } private static Vector3 ResolveRightDirection(Character character, Vector3 lookDirection) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000e: 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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) Vector3 val = lookDirection; val.y = 0f; if (!IsFiniteVector(val) || ((Vector3)(ref val)).sqrMagnitude < 0.001f) { val = ((Component)character).transform.forward; val.y = 0f; } if (!IsFiniteVector(val) || ((Vector3)(ref val)).sqrMagnitude < 0.001f) { val = Vector3.forward; } ((Vector3)(ref val)).Normalize(); Vector3 val2 = Vector3.Cross(Vector3.up, val); if (!IsFiniteVector(val2) || ((Vector3)(ref val2)).sqrMagnitude < 0.001f) { val2 = ((Component)character).transform.right; val2.y = 0f; } if (!IsFiniteVector(val2) || ((Vector3)(ref val2)).sqrMagnitude < 0.001f) { val2 = Vector3.right; } ((Vector3)(ref val2)).Normalize(); return val2; } private static Vector3 ResolveHorizontalForwardDirection(Character character, Vector3 lookDirection) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000e: 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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) Vector3 val = lookDirection; val.y = 0f; if (!IsFiniteVector(val) || ((Vector3)(ref val)).sqrMagnitude < 0.001f) { val = ((Component)character).transform.forward; val.y = 0f; } if (!IsFiniteVector(val) || ((Vector3)(ref val)).sqrMagnitude < 0.001f) { val = Vector3.forward; } ((Vector3)(ref val)).Normalize(); return val; } private void RestoreSprintStamina(Character character) { CharacterMovement characterMovement = _characterMovement; if (characterMovement == null) { return; } try { character.AddStamina(characterMovement.sprintStaminaUsage * Time.deltaTime); } catch (Exception ex) { Plugin.Log.LogDebug((object)("Failed to restore flight sprint stamina: " + ex.Message)); } } private static void TryMaintainGroundedState(Character character) { try { character.data.isGrounded = true; } catch (Exception ex) { Plugin.Log.LogDebug((object)("Failed to maintain flight grounded state: " + ex.Message)); } } private static Vector3 ClampForce(Vector3 force) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) force.x = Mathf.Clamp(force.x, -110000f, 110000f); force.y = Mathf.Clamp(force.y, -110000f, 110000f); force.z = Mathf.Clamp(force.z, -110000f, 110000f); return force; } private static Rigidbody? ResolveRigidbody(Bodypart? part) { if (part != null) { return ((Component)part).GetComponent(); } return null; } private static bool IsUsableRigidbody(Rigidbody? rigidbody) { if (rigidbody != null && ((Component)rigidbody).gameObject != null && ((Component)rigidbody).gameObject.activeInHierarchy && rigidbody.mass > 0f && !float.IsNaN(rigidbody.mass)) { return !float.IsInfinity(rigidbody.mass); } return false; } private static bool IsFiniteVector(Vector3 value) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) if (!float.IsNaN(value.x) && !float.IsNaN(value.y) && !float.IsNaN(value.z) && !float.IsInfinity(value.x) && !float.IsInfinity(value.y)) { return !float.IsInfinity(value.z); } return false; } } internal static class FlightRuntime { private static FlightService? _service; internal static bool IsInitialized => _service != null; internal static FlightService Service { get { if (_service == null) { throw new InvalidOperationException("FlightRuntime 尚未初始化。"); } return _service; } } internal static void Initialize(ConfigFile config) { if (_service == null) { _service = new FlightService(config); Plugin.Log.LogInfo((object)"Flight runtime initialized."); } } internal static void Update() { _service?.Update(); } internal static void Dispose() { _service?.Dispose(); _service = null; Plugin.Log.LogInfo((object)"Flight runtime disposed."); } } internal sealed class FlightService : IDisposable { private const float DefaultFlightSpeed = 16f; private const float MinimumFlightSpeed = 16f; private const float MaximumFlightSpeed = 255f; internal const float DefaultHoverDownForce = 255f; private const float MinimumHoverDownForce = 0f; private const float MaximumHoverDownForce = 500f; private const float DoubleTapInterval = 0.3f; private const float ScrollSpeedStep = 16f; private const float SlowFallDuration = 2f; private const float MaximumSlowFallSpeed = -6f; private bool _enabled; private bool _activelyFlying; private readonly ConfigEntry _hoverDownForce; private readonly ConfigEntry _horizontalWasdMovement; private float _flightSpeed = 16f; private float _lastSpacePressTime = -100f; private Character? _activeCharacter; private bool _savedInvincible; private bool _savedAntiKnockback; private bool _hasSavedStatusState; private float _slowFallUntil; private bool _slowFallWasApplied; private readonly Dictionary _slowFallGravityStates = new Dictionary(); internal bool Enabled => _enabled; internal bool ActivelyFlying => _activelyFlying; internal float FlightSpeed => _flightSpeed; internal float HoverDownForce => Mathf.Clamp(_hoverDownForce.Value, 0f, 500f); internal bool HorizontalWasdMovement => _horizontalWasdMovement.Value; internal string LastStatus { get; private set; } = "飞行功能尚未开启。"; internal bool LastSucceeded { get; private set; } internal FlightService(ConfigFile config) { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Expected O, but got Unknown _hoverDownForce = config.Bind("Flight", "HoverDownForce", 255f, new ConfigDescription("实际飞行浮空时的向下重力补偿力。增加可抑制自动上浮,减少可缓解自动下沉。", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 500f), Array.Empty())); _horizontalWasdMovement = config.Bind("Flight", "HorizontalWasdMovement", false, "WASD 是否仅进行水平平移。关闭时 W/S 会跟随视角俯仰。"); } internal void Update() { MaintainSlowFall(); if (!_enabled) { return; } if (_activelyFlying) { MaintainStatusProtection(); } Character localCharacter = Character.localCharacter; if (localCharacter == null) { _activeCharacter = null; LastSucceeded = false; LastStatus = "未找到本地玩家,请先进入关卡。"; return; } if (_activeCharacter != localCharacter) { _activeCharacter = localCharacter; EnsureFlightController(localCharacter); Plugin.Log.LogInfo((object)("Flight character changed: " + ((Object)localCharacter).name + ".")); } if (!MenuState.IsOpen && FeatureInputSettings.DoubleTapFlightEnabled) { DetectDoubleSpace(); } } internal void SetEnabled(bool enabled) { if (_enabled != enabled) { if (enabled) { EnableFlightSystem(); } else { DisableFlightSystem(restoreStatusState: true); } } } internal void AdjustFlightSpeed(float direction) { if (_enabled && _activelyFlying && !Mathf.Approximately(direction, 0f)) { float flightSpeed = _flightSpeed; _flightSpeed = Mathf.Clamp(_flightSpeed + Mathf.Sign(direction) * 16f, 16f, 255f); if (!Mathf.Approximately(flightSpeed, _flightSpeed)) { LastSucceeded = true; LastStatus = ((direction > 0f) ? $"提高飞行速度:{_flightSpeed:0.##}。" : $"降低飞行速度:{_flightSpeed:0.##}。"); } } } internal void AdjustHoverDownForce(float direction) { if (_enabled && _activelyFlying && !Mathf.Approximately(direction, 0f)) { _hoverDownForce.Value = Mathf.Clamp(HoverDownForce + direction, 0f, 500f); LastSucceeded = true; LastStatus = "浮空重力校准已调整为 " + $"{HoverDownForce:0.##}。"; } } internal void SetHorizontalWasdMovement(bool horizontal) { if (_horizontalWasdMovement.Value != horizontal) { _horizontalWasdMovement.Value = horizontal; LastSucceeded = true; LastStatus = (horizontal ? "WASD 已切换为水平平移。" : "WASD 已切换为随视角飞行。"); } } internal void ResetHoverDownForce() { _hoverDownForce.Value = 255f; LastSucceeded = true; LastStatus = "浮空重力校准已恢复默认值 " + $"{255f:0.##}。"; } internal void ToggleActiveFlight() { if (!_enabled) { LastSucceeded = false; LastStatus = "请先开启飞行总开关。"; } else { SetActiveFlight(!_activelyFlying); } } public void Dispose() { DisableFlightSystem(restoreStatusState: true); ClearSlowFallImmediately(); _activeCharacter = null; } private void EnableFlightSystem() { if (!StatusRuntime.IsInitialized) { LastSucceeded = false; LastStatus = "状态功能尚未初始化,无法开启飞行保护。"; return; } Character localCharacter = Character.localCharacter; if (localCharacter == null || !localCharacter.IsLocal) { LastSucceeded = false; LastStatus = "未找到本地玩家,请先进入关卡。"; return; } EnsureFlightController(localCharacter); _enabled = true; _activelyFlying = false; _activeCharacter = localCharacter; _lastSpacePressTime = -100f; LastSucceeded = true; LastStatus = "飞行总开关已开启。双击空格开始飞行。"; Plugin.Log.LogInfo((object)"Flight system enabled in standby mode."); } private void DisableFlightSystem(bool restoreStatusState) { Character localCharacter = Character.localCharacter; bool activelyFlying = _activelyFlying; _activelyFlying = false; _enabled = false; _activeCharacter = null; _lastSpacePressTime = -100f; if (activelyFlying && localCharacter != null && localCharacter.IsLocal) { RefreshSlowFall(localCharacter); } if (restoreStatusState) { RestoreStatusProtection(); } else if (StatusRuntime.IsInitialized) { StatusRuntime.Service.SetFlightProtectionLock(locked: false); } _hasSavedStatusState = false; LastSucceeded = true; LastStatus = (activelyFlying ? "飞行已关闭,已恢复此前状态,并获得 2 秒缓降保护。" : "飞行总开关已关闭。"); Plugin.Log.LogInfo((object)"Physical flight system disabled."); } private void SetActiveFlight(bool active) { if (!_enabled || _activelyFlying == active) { return; } Character localCharacter = Character.localCharacter; if (active) { if (localCharacter == null || !localCharacter.IsLocal) { LastSucceeded = false; LastStatus = "未找到本地玩家,无法进入飞行状态。"; } else if (BeginStatusProtection()) { ClearSlowFallImmediately(); _activeCharacter = localCharacter; EnsureFlightController(localCharacter); _activelyFlying = true; TryResetFalling(localCharacter); LastSucceeded = true; LastStatus = "已进入物理飞行状态。"; Plugin.Log.LogInfo((object)"Physical flight enabled."); } } else { _activelyFlying = false; RestoreStatusProtection(); if (localCharacter != null && localCharacter.IsLocal) { RefreshSlowFall(localCharacter); } LastSucceeded = true; LastStatus = "已退出飞行:获得 2 秒缓降保护。"; Plugin.Log.LogInfo((object)"Physical flight disabled."); } } private bool BeginStatusProtection() { if (!StatusRuntime.IsInitialized) { LastSucceeded = false; LastStatus = "状态功能尚未初始化,无法进入飞行状态。"; return false; } StatusService service = StatusRuntime.Service; _savedInvincible = service.Invincible; _savedAntiKnockback = service.AntiKnockback; _hasSavedStatusState = true; service.SetFlightProtectionLock(locked: true); service.SetInvincible(enabled: true, force: true); service.SetAntiKnockback(enabled: true, force: true); return true; } private void RestoreStatusProtection() { if (_hasSavedStatusState) { if (StatusRuntime.IsInitialized) { StatusService service = StatusRuntime.Service; service.SetFlightProtectionLock(locked: false); service.SetInvincible(_savedInvincible, force: true); service.SetAntiKnockback(_savedAntiKnockback, force: true); } _hasSavedStatusState = false; } } private static void EnsureFlightController(Character character) { FlightController component = ((Component)character).GetComponent(); if (component == null) { ((Component)character).gameObject.AddComponent(); Plugin.Log.LogInfo((object)("FlightController added to " + ((Object)character).name + " by FlightService.")); } } private void DetectDoubleSpace() { if (!Input.GetKeyDown((KeyCode)32)) { return; } float unscaledTime = Time.unscaledTime; float num = unscaledTime - _lastSpacePressTime; if (num <= 0.3f) { _lastSpacePressTime = -100f; if (!_activelyFlying) { _flightSpeed = 16f; } ToggleActiveFlight(); } else { _lastSpacePressTime = unscaledTime; } } private void RefreshSlowFall(Character character) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) RestoreSlowFallGravityStates(); float unscaledTime = Time.unscaledTime; _slowFallUntil = unscaledTime + 2f; Rigidbody[] componentsInChildren = ((Component)character).GetComponentsInChildren(true); Rigidbody[] array = componentsInChildren; foreach (Rigidbody val in array) { if (IsUsableRigidbody(val)) { _slowFallGravityStates[val] = val.useGravity; Vector3 linearVelocity = val.linearVelocity; if (linearVelocity.y < -6f) { linearVelocity.y = -6f; val.linearVelocity = linearVelocity; } } } _slowFallWasApplied = _slowFallGravityStates.Count > 0; if (!_slowFallWasApplied) { _slowFallUntil = 0f; } else { Plugin.Log.LogInfo((object)("Flight exit protection applied: " + $"{2f:0.##} seconds " + "slow fall.")); } } private void MaintainSlowFall() { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) if (!_slowFallWasApplied) { return; } float unscaledTime = Time.unscaledTime; if (unscaledTime >= _slowFallUntil) { ClearSlowFallImmediately(); return; } KeyValuePair[] array = _slowFallGravityStates.ToArray(); for (int i = 0; i < array.Length; i++) { KeyValuePair keyValuePair = array[i]; Rigidbody key = keyValuePair.Key; if (!IsUsableRigidbody(key)) { _slowFallGravityStates.Remove(key); continue; } key.useGravity = keyValuePair.Value; Vector3 linearVelocity = key.linearVelocity; if (linearVelocity.y < -6f) { linearVelocity.y = -6f; key.linearVelocity = linearVelocity; } } if (_slowFallGravityStates.Count <= 0) { _slowFallUntil = 0f; _slowFallWasApplied = false; } } private void ClearSlowFallImmediately() { RestoreSlowFallGravityStates(); _slowFallUntil = 0f; _slowFallWasApplied = false; } private void RestoreSlowFallGravityStates() { KeyValuePair[] array = _slowFallGravityStates.ToArray(); for (int i = 0; i < array.Length; i++) { KeyValuePair keyValuePair = array[i]; Rigidbody key = keyValuePair.Key; if (key != null) { try { key.useGravity = keyValuePair.Value; } catch (Exception ex) { Plugin.Log.LogDebug((object)("Failed to restore slow-fall gravity: " + ex.Message)); } } } _slowFallGravityStates.Clear(); } private static bool IsUsableRigidbody(Rigidbody? rigidbody) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) if (rigidbody == null) { return false; } GameObject gameObject = ((Component)rigidbody).gameObject; if (gameObject != null) { Scene scene = gameObject.scene; if (((Scene)(ref scene)).IsValid()) { return gameObject.activeInHierarchy; } } return false; } private static void TryResetFalling(Character character) { try { character.RPCA_UnFall(); } catch (Exception ex) { Plugin.Log.LogDebug((object)("RPCA_UnFall failed while starting flight: " + ex.Message)); } } private void MaintainStatusProtection() { if (StatusRuntime.IsInitialized) { StatusService service = StatusRuntime.Service; if (!service.FlightProtectionLock) { service.SetFlightProtectionLock(locked: true); } if (!service.Invincible) { service.SetInvincible(enabled: true, force: true); } if (!service.AntiKnockback) { service.SetAntiKnockback(enabled: true, force: true); } } } } [HarmonyPatch(typeof(Character), "Awake")] internal static class FlightCharacterPatch { [HarmonyPostfix] private static void Postfix(Character __instance) { if (__instance != null && __instance.IsLocal) { FlightController component = ((Component)__instance).GetComponent(); if (component == null) { ((Component)__instance).gameObject.AddComponent(); Plugin.Log.LogInfo((object)("FlightController added to " + ((Object)__instance).name + ".")); } } } } } namespace P.E.A.K_MENU.Features.BlowDart { internal enum BlowDartEffectType { None, Injury, Hunger, Poison, Cold, Hot, Drowsy, Curse, Spores, Petrify, Whirlwind } internal static class BlowDartRuntime { private static BlowDartService? _service; internal static bool IsInitialized => _service != null; internal static BlowDartService Service => _service ?? throw new InvalidOperationException("BlowDartRuntime 尚未初始化。"); internal static void Initialize(ConfigFile config) { if (_service == null) { _service = new BlowDartService(config); Plugin.Log.LogInfo((object)"Blow dart runtime initialized."); } } internal static void Update() { _service?.Update(); } internal static void Dispose() { _service?.Dispose(); _service = null; } } internal sealed class BlowDartService : IDisposable { private const int MinimumAmountPercent = 1; private const int MaximumAmountPercent = 200; private const float MinimumDuration = 0.1f; private const float MaximumDuration = 600f; private readonly ConfigEntry _effectType; private readonly ConfigEntry _amountPercent; private readonly ConfigEntry _durationSeconds; private readonly Dictionary _whirlwindStopTimes = new Dictionary(); private Item? _blowDartItem; private Texture2D? _blowDartIcon; internal BlowDartEffectType EffectType => _effectType.Value; internal int AmountPercent => Mathf.Clamp(_amountPercent.Value, 1, 200); internal float DurationSeconds => Mathf.Clamp(_durationSeconds.Value, 0.1f, 600f); internal Texture2D? Icon { get { ResolveBlowDartItem(); return _blowDartIcon; } } internal string LastStatus { get; private set; } = "请选择吹箭效果。"; internal bool LastSucceeded { get; private set; } internal BlowDartService(ConfigFile config) { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Expected O, but got Unknown //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Expected O, but got Unknown _effectType = config.Bind("BlowDart", "Effect", BlowDartEffectType.None, "本地玩家发射吹箭时赋予目标的效果。"); _amountPercent = config.Bind("BlowDart", "AmountPercent", 20, new ConfigDescription("数值状态的百分制增量;100 对应底层 1。", (AcceptableValueBase)(object)new AcceptableValueRange(1, 200), Array.Empty())); _durationSeconds = config.Bind("BlowDart", "DurationSeconds", 5f, new ConfigDescription("小旋风效果持续秒数。", (AcceptableValueBase)(object)new AcceptableValueRange(0.1f, 600f), Array.Empty())); } internal void SetEffectType(BlowDartEffectType effectType) { _effectType.Value = effectType; LastSucceeded = true; LastStatus = "吹箭效果已设为:" + GetDisplayName(effectType) + "。"; } internal void SetAmountPercent(int amountPercent) { _amountPercent.Value = Mathf.Clamp(amountPercent, 1, 200); LastSucceeded = true; LastStatus = "吹箭赋予值已设为 " + $"{AmountPercent}%。"; } internal void SetDurationSeconds(float durationSeconds) { if (!float.IsNaN(durationSeconds) && !float.IsInfinity(durationSeconds)) { _durationSeconds.Value = Mathf.Clamp(durationSeconds, 0.1f, 600f); LastSucceeded = true; LastStatus = "小旋风时间已设为 " + $"{DurationSeconds:0.##} 秒。"; } } internal bool TryHandleHit(Action_RaycastDart action, Character target, Vector3 origin, Vector3 endpoint) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) if (action == null || target == null) { return false; } try { SendVisualOnlyImpact(action, origin, endpoint); if (EffectType == BlowDartEffectType.Whirlwind) { ApplyWhirlwind(target); return true; } if (!TryResolveStatusType(EffectType, out var statusType)) { return false; } ApplyStatus(target, statusType, (float)AmountPercent / 100f); LastSucceeded = true; LastStatus = "已向 " + target.characterName + " 赋予" + GetDisplayName(EffectType) + " " + $"{AmountPercent}%。"; return true; } catch (Exception ex) { LastSucceeded = false; LastStatus = "吹箭效果应用失败:" + ex.GetBaseException().Message; Plugin.Log.LogError((object)$"Blow dart effect failed: {ex}"); return false; } } internal void GiveBlowDart() { Character localCharacter = Character.localCharacter; Item val = ResolveBlowDartItem(); if (localCharacter == null || !localCharacter.IsLocal) { Fail("未找到本地玩家,请先进入关卡。"); return; } if (val == null) { Fail("没有在游戏物品数据库中找到吹箭。"); return; } if (GameUtils.instance == null) { Fail("GameUtils 尚未初始化,无法生成吹箭。"); return; } try { GameUtils.instance.InstantiateAndGrab(val, localCharacter, 0); LastSucceeded = true; LastStatus = "已获取吹箭。"; } catch (Exception ex) { Fail("获取吹箭失败:" + ex.GetBaseException().Message); } } internal void Update() { if (_whirlwindStopTimes.Count == 0) { return; } float unscaledTime = Time.unscaledTime; List list = new List(); foreach (KeyValuePair whirlwindStopTime in _whirlwindStopTimes) { if (!(unscaledTime < whirlwindStopTime.Value)) { SendWhirlwindStop(whirlwindStopTime.Key); list.Add(whirlwindStopTime.Key); } } foreach (int item in list) { _whirlwindStopTimes.Remove(item); } } public void Dispose() { foreach (int item in new List(_whirlwindStopTimes.Keys)) { SendWhirlwindStop(item); } _whirlwindStopTimes.Clear(); _blowDartItem = null; _blowDartIcon = null; } internal static bool UsesAmount(BlowDartEffectType effectType) { if (effectType != BlowDartEffectType.None) { return effectType != BlowDartEffectType.Whirlwind; } return false; } internal static string GetDisplayName(BlowDartEffectType effectType) { return effectType switch { BlowDartEffectType.None => "无效果(原版)", BlowDartEffectType.Injury => "受伤", BlowDartEffectType.Hunger => "饥饿", BlowDartEffectType.Poison => "中毒", BlowDartEffectType.Cold => "寒冷", BlowDartEffectType.Hot => "炎热", BlowDartEffectType.Drowsy => "困倦", BlowDartEffectType.Curse => "诅咒", BlowDartEffectType.Spores => "孢子", BlowDartEffectType.Petrify => "石化", BlowDartEffectType.Whirlwind => "小旋风", _ => effectType.ToString(), }; } private static void SendVisualOnlyImpact(Action_RaycastDart action, Vector3 origin, Vector3 endpoint) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) PhotonView componentInParent = ((Component)action).GetComponentInParent(); if (componentInParent == null) { throw new InvalidOperationException("吹箭 PhotonView 不可用。"); } componentInParent.RPC("RPC_DartImpact", (RpcTarget)0, new object[3] { -1, origin, endpoint }); } private static void ApplyStatus(Character target, STATUSTYPE statusType, float amount) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) PhotonView photonView = ((MonoBehaviourPun)target).photonView; if (PhotonNetwork.IsMasterClient) { float[] array = new float[CharacterAfflictions.NumStatusTypes]; array[statusType] = amount; photonView.RPC("RPC_ApplyStatusesFromFloatArray", (RpcTarget)0, new object[1] { array }); return; } Rigidbody bodypartRig = target.GetBodypartRig((BodypartType)0); Vector3 val = ((bodypartRig == null) ? target.Center : ((Component)bodypartRig).transform.position); photonView.RPC("RPCA_Stick", (RpcTarget)0, new object[5] { (object)(BodypartType)0, val, val, statusType, amount }); photonView.RPC("RPCA_ClearJoint", (RpcTarget)0, new object[1] { (object)(BodypartType)0 }); } private void ApplyWhirlwind(Character target) { int viewID = ((MonoBehaviourPun)target).photonView.ViewID; ((MonoBehaviourPun)target).photonView.RPC("StartWhirlwindRPC", (RpcTarget)0, Array.Empty()); _whirlwindStopTimes[viewID] = Time.unscaledTime + DurationSeconds; LastSucceeded = true; LastStatus = "已向 " + target.characterName + " 赋予小旋风 " + $"{DurationSeconds:0.##} 秒。"; } private static void SendWhirlwindStop(int viewId) { try { PhotonView val = PhotonView.Find(viewId); if (val != null) { val.RPC("StopWhirlwindRPC", (RpcTarget)0, Array.Empty()); } } catch (Exception ex) { Plugin.Log.LogDebug((object)("Failed to stop blow dart whirlwind: " + ex.Message)); } } private Item? ResolveBlowDartItem() { if (_blowDartItem != null) { return _blowDartItem; } if (!ItemSpawnRuntime.IsInitialized) { return null; } ItemSpawnRuntime.Catalog.RefreshIfNeeded(); foreach (ItemSpawnEntry allItem in ItemSpawnRuntime.Catalog.AllItems) { Item prefab = allItem.Prefab; if (((Component)prefab).GetComponentInChildren(true) != null) { _blowDartItem = prefab; Sprite? icon = allItem.Icon; _blowDartIcon = ((icon != null) ? icon.texture : null); Plugin.Log.LogInfo((object)("Resolved blow dart item: " + ((Object)prefab).name + ".")); return prefab; } } return null; } private static bool TryResolveStatusType(BlowDartEffectType effectType, out STATUSTYPE statusType) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected I4, but got Unknown //IL_0055: Unknown result type (might be due to invalid IL or missing references) statusType = (STATUSTYPE)(int)(effectType switch { BlowDartEffectType.Injury => 0, BlowDartEffectType.Hunger => 1, BlowDartEffectType.Poison => 3, BlowDartEffectType.Cold => 2, BlowDartEffectType.Hot => 8, BlowDartEffectType.Drowsy => 6, BlowDartEffectType.Curse => 5, BlowDartEffectType.Spores => 10, BlowDartEffectType.Petrify => 13, _ => 0, }); return UsesAmount(effectType); } private void Fail(string message) { LastSucceeded = false; LastStatus = message; Plugin.Log.LogWarning((object)message); } } } namespace P.E.A.K_MENU.Constants { internal static class ModConstants { internal const int WindowId = 938421; internal const int ChangelogWindowId = 938422; internal const int AnnouncementWindowId = 938423; internal const float DefaultWindowWidth = 850f; internal const float DefaultWindowHeight = 850f; internal const float MinimumWindowWidth = 520f; internal const float MinimumWindowHeight = 360f; internal const float WindowMargin = 20f; internal const float WindowTop = 80f; internal const float SidebarWidth = 150f; internal const float CategoryButtonHeight = 42f; internal const float ResizeHandleSize = 24f; internal const string WindowTitle = ""; internal const string MainWindowTitle = "P.E.A.K MENU"; internal const string WindowAuthorText = " by Ruangfafa"; internal static readonly KeyCode DefaultToggleMenuKey = (KeyCode)287; } } namespace System.Diagnostics.CodeAnalysis { [AttributeUsage(AttributeTargets.Parameter, Inherited = false)] [ExcludeFromCodeCoverage] internal sealed class ConstantExpectedAttribute : Attribute { public object? Min { get; set; } public object? Max { get; set; } } [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, Inherited = false)] [ExcludeFromCodeCoverage] internal sealed class ExperimentalAttribute : Attribute { public string DiagnosticId { get; } public string? UrlFormat { get; set; } public ExperimentalAttribute(string diagnosticId) { DiagnosticId = diagnosticId; } } [AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)] [ExcludeFromCodeCoverage] internal sealed class MemberNotNullAttribute : Attribute { public string[] Members { get; } public MemberNotNullAttribute(string member) { Members = new string[1] { member }; } public MemberNotNullAttribute(params string[] members) { Members = members; } } [AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)] [ExcludeFromCodeCoverage] internal sealed class MemberNotNullWhenAttribute : Attribute { public bool ReturnValue { get; } public string[] Members { get; } public MemberNotNullWhenAttribute(bool returnValue, string member) { ReturnValue = returnValue; Members = new string[1] { member }; } public MemberNotNullWhenAttribute(bool returnValue, params string[] members) { ReturnValue = returnValue; Members = members; } } [AttributeUsage(AttributeTargets.Constructor, AllowMultiple = false, Inherited = false)] [ExcludeFromCodeCoverage] internal sealed class SetsRequiredMembersAttribute : Attribute { } [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)] [ExcludeFromCodeCoverage] internal sealed class StringSyntaxAttribute : Attribute { public const string CompositeFormat = "CompositeFormat"; public const string DateOnlyFormat = "DateOnlyFormat"; public const string DateTimeFormat = "DateTimeFormat"; public const string EnumFormat = "EnumFormat"; public const string GuidFormat = "GuidFormat"; public const string Json = "Json"; public const string NumericFormat = "NumericFormat"; public const string Regex = "Regex"; public const string TimeOnlyFormat = "TimeOnlyFormat"; public const string TimeSpanFormat = "TimeSpanFormat"; public const string Uri = "Uri"; public const string Xml = "Xml"; public string Syntax { get; } public object?[] Arguments { get; } public StringSyntaxAttribute(string syntax) { Syntax = syntax; Arguments = new object[0]; } public StringSyntaxAttribute(string syntax, params object?[] arguments) { Syntax = syntax; Arguments = arguments; } } [AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)] [ExcludeFromCodeCoverage] internal sealed class UnscopedRefAttribute : Attribute { } } namespace System.Runtime.Versioning { [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, Inherited = false)] [ExcludeFromCodeCoverage] internal sealed class RequiresPreviewFeaturesAttribute : Attribute { public string? Message { get; } public string? Url { get; set; } public RequiresPreviewFeaturesAttribute() { } public RequiresPreviewFeaturesAttribute(string? message) { Message = message; } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } [AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)] [ExcludeFromCodeCoverage] internal sealed class CallerArgumentExpressionAttribute : Attribute { public string ParameterName { get; } public CallerArgumentExpressionAttribute(string parameterName) { ParameterName = parameterName; } } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface, Inherited = false)] [ExcludeFromCodeCoverage] internal sealed class CollectionBuilderAttribute : Attribute { public Type BuilderType { get; } public string MethodName { get; } public CollectionBuilderAttribute(Type builderType, string methodName) { BuilderType = builderType; MethodName = methodName; } } [AttributeUsage(AttributeTargets.All, AllowMultiple = true, Inherited = false)] [ExcludeFromCodeCoverage] internal sealed class CompilerFeatureRequiredAttribute : Attribute { public const string RefStructs = "RefStructs"; public const string RequiredMembers = "RequiredMembers"; public string FeatureName { get; } public bool IsOptional { get; set; } public CompilerFeatureRequiredAttribute(string featureName) { FeatureName = featureName; } } [AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)] [ExcludeFromCodeCoverage] internal sealed class InterpolatedStringHandlerArgumentAttribute : Attribute { public string[] Arguments { get; } public InterpolatedStringHandlerArgumentAttribute(string argument) { Arguments = new string[1] { argument }; } public InterpolatedStringHandlerArgumentAttribute(params string[] arguments) { Arguments = arguments; } } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = false, Inherited = false)] [ExcludeFromCodeCoverage] internal sealed class InterpolatedStringHandlerAttribute : Attribute { } [EditorBrowsable(EditorBrowsableState.Never)] [ExcludeFromCodeCoverage] internal static class IsExternalInit { } [AttributeUsage(AttributeTargets.Method, Inherited = false)] [ExcludeFromCodeCoverage] internal sealed class ModuleInitializerAttribute : Attribute { } [AttributeUsage(AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property, AllowMultiple = false, Inherited = false)] [ExcludeFromCodeCoverage] internal sealed class OverloadResolutionPriorityAttribute : Attribute { public int Priority { get; } public OverloadResolutionPriorityAttribute(int priority) { Priority = priority; } } [AttributeUsage(AttributeTargets.Parameter, Inherited = true, AllowMultiple = false)] [ExcludeFromCodeCoverage] internal sealed class ParamCollectionAttribute : Attribute { } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false, Inherited = false)] [ExcludeFromCodeCoverage] internal sealed class RequiredMemberAttribute : Attribute { } [AttributeUsage(AttributeTargets.Parameter, Inherited = false)] [EditorBrowsable(EditorBrowsableState.Never)] [ExcludeFromCodeCoverage] internal sealed class RequiresLocationAttribute : Attribute { } [AttributeUsage(AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Event | AttributeTargets.Interface, Inherited = false)] [ExcludeFromCodeCoverage] internal sealed class SkipLocalsInitAttribute : Attribute { } }