using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using Microsoft.CodeAnalysis; using Photon.Pun; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("DestinyWind")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("一键复活自己的 PEAK 模组。死亡/幽灵状态下按快捷键弹出复活菜单,选择队友即可复活并传送到其身边。")] [assembly: AssemblyFileVersion("1.9.0.0")] [assembly: AssemblyInformationalVersion("1.9.0")] [assembly: AssemblyProduct("SelfResurrection")] [assembly: AssemblyTitle("DestinyWind.SelfResurrection")] [assembly: AssemblyVersion("1.9.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } 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 SelfResurrection { [BepInPlugin("destinywind.peak.selfresurrection", "Self Resurrection", "1.9.0")] [BepInProcess("PEAK.exe")] public class Plugin : BaseUnityPlugin { public const string PluginGuid = "destinywind.peak.selfresurrection"; public const string PluginName = "Self Resurrection"; public const string PluginVersion = "1.9.0"; internal static ManualLogSource Log = null; private ConfigEntry _menuKey; private ConfigEntry _teleportOffsetUp; private ConfigEntry _cooldown; private float _lastRevive = -999f; private bool _menuVisible; private Vector2 _scroll; private List _allies = new List(); private static readonly KeyCode[] _selectKeys; private string _hint = ""; private float _hintExpire = -1f; private bool _hintErr; private void Awake() { //IL_009a: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; _menuKey = ((BaseUnityPlugin)this).Config.Bind("按键", "MenuKey", (KeyCode)278, "打开复活菜单的按键,可改为任意 KeyCode(如 F1/F5/T/Keypad7/Mouse3 等)。仅死亡/幽灵状态下生效。"); _teleportOffsetUp = ((BaseUnityPlugin)this).Config.Bind("防弹飞", "TeleportOffsetUp", 2f, "传送到队友上方的偏移(米)"); _cooldown = ((BaseUnityPlugin)this).Config.Bind("行为", "Cooldown", 1.5f, "复活冷却秒数"); ((BaseUnityPlugin)this).Config.Save(); Log.LogInfo((object)string.Format("Self Resurrection v{0} 已加载,菜单键: {1}", "1.9.0", _menuKey.Value)); } private void Update() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) try { if (Input.GetKeyDown(_menuKey.Value)) { if (_menuVisible) { _menuVisible = false; } else { TryOpenMenu(); } } else { if (!_menuVisible) { return; } if (Input.GetKeyDown((KeyCode)27)) { _menuVisible = false; return; } for (int i = 0; i < _selectKeys.Length; i++) { if (!Input.GetKeyDown(_selectKeys[i])) { continue; } if (i < _allies.Count) { Character val = _allies[i]; if ((Object)(object)val != (Object)null && (Object)(object)val.data != (Object)null && !val.data.dead) { ReviveTo(val); break; } RebuildAllies(); Hint("该队友已失效,列表已刷新"); } break; } float num = 0f; if (Input.GetKeyDown((KeyCode)273)) { num = -40f; } else if (Input.GetKeyDown((KeyCode)274)) { num = 40f; } else if (Input.GetKeyDown((KeyCode)280)) { num = -200f; } else if (Input.GetKeyDown((KeyCode)281)) { num = 200f; } else if (Input.GetKeyDown((KeyCode)278)) { _scroll.y = 0f; } else if (Input.GetKeyDown((KeyCode)279)) { _scroll.y = 99999f; } if (num != 0f) { _scroll.y = Mathf.Max(0f, _scroll.y + num); } } } catch (Exception ex) { Log.LogError((object)("Update 异常: " + ex)); } } private void TryOpenMenu() { //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) Character localCharacter = Character.localCharacter; if ((Object)(object)localCharacter == (Object)null || (Object)(object)localCharacter.data == (Object)null) { Hint("本地角色尚未加载"); return; } if (!localCharacter.data.dead) { Hint("只有死亡/幽灵状态下才能复活"); return; } RebuildAllies(); if (_allies.Count == 0) { Hint("没有可用队友"); return; } _menuVisible = true; _scroll = Vector2.zero; Log.LogInfo((object)$"复活菜单已打开,可选队友 {_allies.Count} 个"); } private void RebuildAllies() { //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: 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_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) _allies.Clear(); try { Character localCharacter = Character.localCharacter; if ((Object)(object)localCharacter == (Object)null) { return; } int num = -1; try { PhotonView photonView = ((MonoBehaviourPun)localCharacter).photonView; if ((Object)(object)photonView != (Object)null && photonView.Owner != null) { num = photonView.Owner.ActorNumber; } } catch { } Dictionary dictionary = new Dictionary(); foreach (Character allCharacter in Character.AllCharacters) { if ((Object)(object)allCharacter == (Object)null || (Object)(object)allCharacter.data == (Object)null || (Object)(object)allCharacter == (Object)(object)localCharacter || allCharacter.data.dead) { continue; } try { if (allCharacter.IsGhost) { continue; } } catch { } bool flag = false; try { flag = ((Component)allCharacter).gameObject.activeInHierarchy; } catch { } int num2 = -1; try { PhotonView photonView2 = ((MonoBehaviourPun)allCharacter).photonView; if ((Object)(object)photonView2 != (Object)null && photonView2.Owner != null) { num2 = photonView2.Owner.ActorNumber; } } catch { } if (num2 == num) { continue; } float num3; try { Vector3 center = allCharacter.Center; if (float.IsNaN(center.y) || float.IsInfinity(center.y) || center.y < -50f || center.y > 1000f) { Log.LogWarning((object)$"跳过位置异常的队友实例 {allCharacter.characterName}: {center}"); continue; } num3 = Vector3.Distance(localCharacter.Center, center); } catch { continue; } if (num2 >= 0) { if (!dictionary.TryGetValue(num2, out var value)) { dictionary[num2] = (allCharacter, flag, num3); } else if ((flag && !value.Item2) || ((flag == value.Item2 && num3 < value.Item3) ? true : false)) { dictionary[num2] = (allCharacter, flag, num3); } } else { _allies.Add(allCharacter); } } foreach (KeyValuePair item in dictionary) { _allies.Add(item.Value.Item1); } } catch (Exception ex) { Log.LogWarning((object)("重建队友列表失败: " + ex.Message)); } } private void ReviveTo(Character ally) { //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: Unknown result type (might be due to invalid IL or missing references) //IL_02ba: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_0310: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: 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_0177: 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_0142: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) if (Time.time - _lastRevive < _cooldown.Value) { Hint($"冷却中,还需 {_cooldown.Value - (Time.time - _lastRevive):F1}s"); return; } Character localCharacter = Character.localCharacter; if ((Object)(object)localCharacter == (Object)null || (Object)(object)localCharacter.data == (Object)null) { Hint("本地角色不可用"); return; } if ((Object)(object)ally == (Object)null || (Object)(object)ally.data == (Object)null || ally.data.dead) { Hint("该队友已死亡"); RebuildAllies(); return; } try { if (ally.IsGhost) { Hint("该队友已是幽灵"); RebuildAllies(); return; } } catch { } try { if (!((Component)ally).gameObject.activeInHierarchy) { Hint("该队友实例已失效,请重新选择"); RebuildAllies(); return; } } catch { Hint("该队友实例异常"); RebuildAllies(); return; } Vector3 center; try { center = ally.Center; } catch { Hint("无法获取队友位置"); RebuildAllies(); return; } if (float.IsNaN(center.y) || float.IsInfinity(center.y) || center.y < -50f || center.y > 1000f) { Hint("队友位置异常,请重新选择"); Log.LogWarning((object)$"队友 {ally.characterName} 位置异常: {center},拒绝传送"); RebuildAllies(); return; } try { Log.LogInfo((object)$"复活前状态: dead={localCharacter.data.dead}, fullyPassedOut={localCharacter.data.fullyPassedOut}"); Character.Revive(); bool flag = !localCharacter.data.dead && !localCharacter.data.fullyPassedOut; Log.LogInfo((object)$"已调用 Character.Revive(),复活后状态: dead={localCharacter.data.dead}, fullyPassedOut={localCharacter.data.fullyPassedOut}, 本地复活成功={flag}"); if (!flag) { Hint("本地复活未生效,请重试"); Log.LogWarning((object)"Character.Revive() 调用后本地状态仍为死亡,可能 RPC 未同步执行"); } PhotonView photonView = ((MonoBehaviourPun)localCharacter).photonView; if ((Object)(object)photonView != (Object)null) { Vector3 val; try { val = ally.Center; } catch { val = center; } if (float.IsNaN(val.y) || float.IsInfinity(val.y) || val.y < -50f || val.y > 1000f) { Log.LogWarning((object)$"队友最新位置异常 {val},回退到验证过的位置 {center}"); val = center; } Vector3 val2 = val + Vector3.up * _teleportOffsetUp.Value; photonView.RPC("WarpPlayerRPC", (RpcTarget)0, new object[2] { val2, true }); Log.LogInfo((object)$"已发送 WarpPlayerRPC 传送至 {ally.characterName} 身边, pos={val2}"); } else { Log.LogWarning((object)"无法获取 PhotonView,传送失败(复活已执行)"); } _lastRevive = Time.time; _menuVisible = false; Hint("已复活并传送到 [" + ally.characterName + "] 身边"); Log.LogInfo((object)("复活并传送到 " + ally.characterName + " 身边完成")); } catch (Exception ex) { Hint("复活失败:" + ex.Message); Log.LogError((object)("Revive 异常: " + ex)); } } private void OnGUI() { try { if (_menuVisible) { DrawMenu(); } if (_hintExpire >= Time.time) { DrawHint(); } } catch (Exception ex) { Log.LogError((object)("OnGUI 异常: " + ex)); } } private void DrawMenu() { //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_00cb: 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_00e1: 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_027a: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0281: 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_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_029d: 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_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) Character localCharacter = Character.localCharacter; if ((Object)(object)localCharacter == (Object)null || (Object)(object)localCharacter.data == (Object)null || !localCharacter.data.dead) { _menuVisible = false; return; } Vector3 val = Vector3.zero; bool flag = false; try { val = localCharacter.Center; if (!float.IsNaN(val.y) && !float.IsInfinity(val.y) && val.y > -50f && val.y < 1000f) { flag = true; } } catch { } float num = 380f; float num2 = 380f; Rect val2 = default(Rect); ((Rect)(ref val2))..ctor(((float)Screen.width - num) / 2f, ((float)Screen.height - num2) / 2f, num, num2); Color color = GUI.color; GUI.color = new Color(0f, 0f, 0f, 0.88f); GUI.DrawTexture(val2, (Texture)(object)Texture2D.whiteTexture); GUI.color = color; GUILayout.BeginArea(val2); try { GUILayout.Label("选择复活目标队友", Style(18), Array.Empty()); GUILayout.Label("昏迷的队友也可作为目标,显示高度便于判断安全", Style(12), Array.Empty()); GUILayout.Space(4f); if (_allies.Count == 0) { GUILayout.Label("没有可用队友", Style(14), Array.Empty()); } else { _scroll = GUILayout.BeginScrollView(_scroll, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(240f) }); Character[] array = _allies.ToArray(); for (int i = 0; i < array.Length; i++) { Character val3 = array[i]; if ((Object)(object)val3 == (Object)null || (Object)(object)val3.data == (Object)null || val3.data.dead) { continue; } try { if (!((Component)val3).gameObject.activeInHierarchy) { continue; } } catch { continue; } try { if (val3.IsGhost) { continue; } } catch { } string text = ((i < _selectKeys.Length) ? ((object)Unsafe.As(ref _selectKeys[i])/*cast due to .constrained prefix*/).ToString().Replace("Alpha", "") : "-"); string text2 = val3.characterName ?? "(未知)"; string text3 = ""; try { if (val3.data.fullyPassedOut) { text3 = " [昏迷]"; } else if (val3.data.passedOut) { text3 = " [半昏迷]"; } } catch { } string text4 = ""; try { Vector3 center = val3.Center; if (!float.IsNaN(center.y) && center.y > -50f && center.y < 1000f) { text4 += $" H:{center.y:F0}m"; if (flag) { float num3 = Vector3.Distance(val, center); text4 += $" 距离:{num3:F0}m"; } } } catch { } string text5 = "[" + text + "] " + text2 + text3 + text4; if (GUILayout.Button(text5, Style(14), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(32f) })) { ReviveTo(val3); } GUILayout.Space(2f); } GUILayout.EndScrollView(); } GUILayout.Space(4f); GUILayout.Label("选择:点击列表项 或 按数字/字母键 [1-9 Q-P]", Style(10), Array.Empty()); GUILayout.Label("翻页:↑↓ 逐行 / PageUp Down 大幅 / 鼠标滚轮", Style(10), Array.Empty()); GUILayout.Label("H=高度 距离=直线距离 关闭:ESC 或再次按菜单键", Style(10), Array.Empty()); GUILayout.Space(2f); if (GUILayout.Button("关闭 (ESC)", Style(12), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(26f) })) { _menuVisible = false; } } finally { GUILayout.EndArea(); } } private void DrawHint() { //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_001f: Expected O, but got Unknown //IL_004c: 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_0051: 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_0058: 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_009b: 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_00c6: 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) GUIStyle val = new GUIStyle(GUI.skin.label) { fontSize = 32, fontStyle = (FontStyle)1 }; Color color = (_hintErr ? new Color(1f, 0.5f, 0.5f) : new Color(0.6f, 1f, 0.6f)); Color color2 = GUI.color; GUI.color = Color.black; GUI.Label(new Rect(22f, 22f, 1200f, 60f), _hint, val); GUI.Label(new Rect(18f, 18f, 1200f, 60f), _hint, val); GUI.color = color; GUI.Label(new Rect(20f, 20f, 1200f, 60f), _hint, val); GUI.color = color2; } private static GUIStyle Style(int size) { //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_002a: 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_0045: Expected O, but got Unknown GUIStyle val = new GUIStyle(GUI.skin.label) { fontSize = size, fontStyle = (FontStyle)1, richText = true }; val.normal.textColor = Color.white; val.hover.textColor = Color.yellow; return val; } private void Hint(string text) { _hint = text; _hintExpire = Time.time + 3f; _hintErr = text.Contains("失败") || text.Contains("不可用") || text.Contains("冷却") || text.Contains("只有") || text.Contains("没有") || text.Contains("尚未"); } static Plugin() { KeyCode[] array = new KeyCode[19]; RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); _selectKeys = (KeyCode[])(object)array; } } }