using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using PEAKLib.Core; using PEAKLib.Items.UnityEditor; using Photon.Pun; using UnityEngine; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("NanJu.LevelMOD")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("0.1.0.0")] [assembly: AssemblyInformationalVersion("0.1.0")] [assembly: AssemblyProduct("MyStaff")] [assembly: AssemblyTitle("NanJu.LevelMOD")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.1.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace MyStaff { public class AreaTitleDisplay : MonoBehaviour { public static HashSet allAreas = new HashSet(); private HashSet notifiedPlayers = new HashSet(); private void OnEnable() { allAreas.Add(this); } private void OnDisable() { allAreas.Remove(this); } private void Awake() { if ((Object)(object)((Component)this).GetComponent() == (Object)null) { BoxCollider val = ((Component)this).gameObject.AddComponent(); ((Collider)val).isTrigger = true; } else { ((Component)this).GetComponent().isTrigger = true; } } private void OnTriggerEnter(Collider other) { Character val = ((Component)other).GetComponent(); if ((Object)(object)val == (Object)null) { val = ((Component)other).GetComponentInParent(); } if ((Object)(object)val != (Object)null && val.refs.view.IsMine && !notifiedPlayers.Contains(val)) { notifiedPlayers.Add(val); DisplayAreaTitle(); } } private void DisplayAreaTitle() { string text = ((Object)((Component)this).gameObject).name; if (text.StartsWith("文字_")) { text = text.Substring(3); } else if (text.StartsWith("死亡文字_")) { text = text.Substring(5); } if ((Object)(object)GUIManager.instance != (Object)null) { GUIManager.instance.SetHeroTitle(text, (AudioClip)null); } } public static void ScanAndAttachToPrefab(GameObject prefab) { if ((Object)(object)prefab == (Object)null) { return; } Transform[] componentsInChildren = prefab.GetComponentsInChildren(true); foreach (Transform val in componentsInChildren) { GameObject gameObject = ((Component)val).gameObject; if (((Object)gameObject).name.StartsWith("文字_") || ((Object)gameObject).name.StartsWith("死亡文字_")) { EnsureSetup(gameObject); } } } public static void ScanAndAttachToScene() { GameObject[] array = Object.FindObjectsByType((FindObjectsSortMode)0); foreach (GameObject val in array) { if (((Object)val).name.StartsWith("文字_") || ((Object)val).name.StartsWith("死亡文字_")) { EnsureSetup(val); } } } public static void ForceScan() { GameObject[] array = Resources.FindObjectsOfTypeAll(); for (int i = 0; i < array.Length; i++) { Object val = (Object)(object)array[i]; GameObject val2 = (GameObject)(object)((val is GameObject) ? val : null); if ((Object)(object)val2 != (Object)null && (((Object)val2).name.StartsWith("文字_") || ((Object)val2).name.StartsWith("死亡文字_"))) { EnsureSetup(val2); } } } private static void EnsureSetup(GameObject obj) { if ((Object)(object)obj.GetComponent() == (Object)null) { ((Collider)obj.AddComponent()).isTrigger = true; } else { obj.GetComponent().isTrigger = true; } if ((Object)(object)obj.GetComponent() == (Object)null) { obj.AddComponent(); } } } public class DeathPoint : MonoBehaviour { private void OnTriggerEnter(Collider other) { Character val = ((Component)other).GetComponent(); if ((Object)(object)val == (Object)null) { val = ((Component)other).GetComponentInParent(); } if ((Object)(object)val != (Object)null && val.refs.view.IsMine) { if (val.data.dead) { Plugin.SendLog("⚠ 玩家已死亡,跳过死亡区域: " + ((Object)((Component)this).gameObject).name); return; } Plugin.SendLog("✓ 玩家进入死亡区域,触发死亡: " + ((Object)((Component)this).gameObject).name); ((MonoBehaviour)val).Invoke("DieInstantly", 0.02f); } } } [HarmonyPatch] public class DeathRevivePatch { [CompilerGenerated] private sealed class d__2 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; private Vector3 5__1; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__2(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007e: 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_00ab: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; _isReviving = true; <>2__current = (object)new WaitForSeconds(1f); <>1__state = 1; return true; case 1: <>1__state = -1; if ((Object)(object)Character.localCharacter != (Object)null && Character.localCharacter.data.dead) { 5__1 = SaveManager.Instance.GetRevivePosition(); if (5__1 != Vector3.zero) { ((MonoBehaviourPun)Character.localCharacter).photonView.RPC("RPCA_ReviveAtPosition", (RpcTarget)0, new object[3] { 5__1, false, -1 }); } else { ((MonoBehaviourPun)Character.localCharacter).photonView.RPC("RPCA_Revive", (RpcTarget)0, new object[1] { false }); } } _isReviving = false; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private static bool _isReviving; [HarmonyPostfix] [HarmonyPatch(typeof(Character), "RPCA_Die")] public static void RPCA_DiePostfix(Character __instance, Vector3 itemSpawnPoint) { if (__instance.refs.view.IsMine && !_isReviving) { GameStatsManager.Instance?.AddDeath(); ((MonoBehaviour)__instance).StartCoroutine(ReviveCoroutine()); } } [IteratorStateMachine(typeof(d__2))] private static IEnumerator ReviveCoroutine() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__2(0); } [HarmonyPrefix] [HarmonyPatch(typeof(Character), "RPCA_Revive")] public static bool RPCA_RevivePrefix(ref bool applyStatus) { applyStatus = false; return true; } [HarmonyPrefix] [HarmonyPatch(typeof(Character), "RPCA_ReviveAtPosition")] public static bool RPCA_ReviveAtPositionPrefix(ref bool applyStatus) { applyStatus = false; return true; } [HarmonyPrefix] [HarmonyPatch(typeof(Character), "ApplyPostReviveStatus")] public static bool ApplyPostReviveStatusPrefix() { return false; } } public class EndArea : MonoBehaviour { private bool triggered = false; private void Awake() { if ((Object)(object)((Component)this).GetComponent() == (Object)null) { BoxCollider val = ((Component)this).gameObject.AddComponent(); ((Collider)val).isTrigger = true; } else { ((Component)this).GetComponent().isTrigger = true; } } private void OnTriggerEnter(Collider other) { Character val = ((Component)other).GetComponent(); if ((Object)(object)val == (Object)null) { val = ((Component)other).GetComponentInParent(); } if ((Object)(object)val != (Object)null && val.refs.view.IsMine && !triggered) { triggered = true; ShowEndMessage(); } } private void ShowEndMessage() { string text = ((Object)((Component)this).gameObject).name; if (text.StartsWith("终点区域_")) { text = text.Substring(5); } string text2 = GameStatsManager.Instance?.deathCount.ToString() ?? "0"; string text3 = GameStatsManager.Instance?.GetFormattedTime() ?? "00:00:00"; string text4 = text + "\n通关时间: " + text3 + "\n死亡次数: " + text2; if ((Object)(object)GUIManager.instance != (Object)null) { GUIManager.instance.SetHeroTitle(text4, (AudioClip)null); } } public static void ScanAndAttach(GameObject prefab = null) { Object[] componentsInChildren; Object[] array; if ((Object)(object)prefab != (Object)null) { componentsInChildren = (Object[])(object)prefab.GetComponentsInChildren(true); array = componentsInChildren; Transform[] array2 = (Transform[])(object)array; foreach (Transform val in array2) { GameObject gameObject = ((Component)val).gameObject; if (((Object)gameObject).name.StartsWith("终点区域_") && (Object)(object)gameObject.GetComponent() == (Object)null) { gameObject.AddComponent(); } } return; } componentsInChildren = (Object[])(object)Object.FindObjectsByType((FindObjectsSortMode)0); array = componentsInChildren; GameObject[] array3 = (GameObject[])(object)array; foreach (GameObject val2 in array3) { if (((Object)val2).name.StartsWith("终点区域_") && (Object)(object)val2.GetComponent() == (Object)null) { val2.AddComponent(); } } } } public class EndGameZone : MonoBehaviour { public static bool playerHasEnteredZone; private void Awake() { Collider component = ((Component)this).GetComponent(); if ((Object)(object)component == (Object)null) { BoxCollider val = ((Component)this).gameObject.AddComponent(); ((Collider)val).isTrigger = true; } else { component.isTrigger = true; } MovePeakToZone(); } private void MovePeakToZone() { //IL_0030: 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) GameObject val = GameObject.Find("Peak"); if ((Object)(object)val != (Object)null) { val.transform.SetParent(((Component)this).transform); val.transform.localPosition = Vector3.zero; val.transform.localRotation = Quaternion.identity; Debug.Log((object)("[EndGameZone] 已将 Peak 对象移动到 " + ((Object)((Component)this).gameObject).name + " 子级")); } else { Debug.Log((object)"[EndGameZone] 找不到 Peak 对象"); } } private void OnTriggerEnter(Collider other) { Character val = ((Component)other).GetComponent(); if ((Object)(object)val == (Object)null) { val = ((Component)other).GetComponentInParent(); } if ((Object)(object)val != (Object)null && val.refs.view.IsMine) { playerHasEnteredZone = true; GameEndPatch.forceAllowEndGame = true; Debug.Log((object)("[EndGameZone] 玩家进入离开游戏区域,已解锁结束功能: " + val.characterName)); } } private void OnTriggerExit(Collider other) { Character val = ((Component)other).GetComponent(); if ((Object)(object)val == (Object)null) { val = ((Component)other).GetComponentInParent(); } if ((Object)(object)val != (Object)null && val.refs.view.IsMine) { playerHasEnteredZone = false; GameEndPatch.forceAllowEndGame = false; Debug.Log((object)("[EndGameZone] 玩家离开离开游戏区域,已锁定结束功能: " + val.characterName)); } } public static void ScanAndAttach(GameObject prefab = null) { Object[] componentsInChildren; Object[] array; if ((Object)(object)prefab != (Object)null) { componentsInChildren = (Object[])(object)prefab.GetComponentsInChildren(true); array = componentsInChildren; Transform[] array2 = (Transform[])(object)array; foreach (Transform val in array2) { GameObject gameObject = ((Component)val).gameObject; if (((Object)gameObject).name == "离开游戏" && (Object)(object)gameObject.GetComponent() == (Object)null) { gameObject.AddComponent(); } } return; } componentsInChildren = (Object[])(object)Object.FindObjectsByType((FindObjectsSortMode)0); array = componentsInChildren; GameObject[] array3 = (GameObject[])(object)array; foreach (GameObject val2 in array3) { if (((Object)val2).name == "离开游戏" && (Object)(object)val2.GetComponent() == (Object)null) { val2.AddComponent(); } } } } [HarmonyPatch] public class FlarePatch { private static bool hasTriggeredEndGame; [HarmonyPostfix] [HarmonyPatch(typeof(Flare), "Update")] public static void UpdatePostfix(Flare __instance) { if (!hasTriggeredEndGame && EndGameZone.playerHasEnteredZone && !((Object)(object)__instance == (Object)null) && !((Object)(object)((ItemComponent)__instance).item == (Object)null)) { BoolItemData data = ((ItemComponent)__instance).GetData((DataEntryKey)3); if (data != null && data.Value && (Object)(object)((ItemComponent)__instance).item.holderCharacter != (Object)null) { Debug.Log((object)"[FlarePatch] 触发游戏通关"); hasTriggeredEndGame = true; EndGameZone.playerHasEnteredZone = false; EndGame(); } } } private static void EndGame() { if ((Object)(object)Character.localCharacter == (Object)null) { Debug.LogError((object)"[FlarePatch] Character.localCharacter 为 null"); return; } GameEndPatch.forceAllowEndGame = true; MethodInfo method = ((object)Character.localCharacter).GetType().GetMethod("RPCEndGame", BindingFlags.Instance | BindingFlags.NonPublic); if (method != null) { method.Invoke(Character.localCharacter, null); Debug.Log((object)"[FlarePatch] 成功调用 RPCEndGame"); } else { Debug.LogError((object)"[FlarePatch] 找不到 RPCEndGame 方法"); } } } [HarmonyPatch] public class GameEndPatch { public static bool forceAllowEndGame; [HarmonyPrefix] [HarmonyPatch(typeof(Character), "CheckEndGame")] public static bool CheckEndGamePrefix() { if (forceAllowEndGame) { return true; } return false; } } public class GameStatsManager : MonoBehaviour { public int deathCount = 0; public float startTime = 0f; public bool gameStarted = false; public static GameStatsManager Instance { get; private set; } private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); StartTimer(); } else { Object.Destroy((Object)(object)((Component)this).gameObject); } } public void StartTimer() { if (!gameStarted) { gameStarted = true; startTime = Time.time; } } public void AddDeath() { deathCount++; ShowDeathMilestone(); } private void ShowDeathMilestone() { foreach (AreaTitleDisplay allArea in AreaTitleDisplay.allAreas) { string name = ((Object)((Component)allArea).gameObject).name; if (!name.StartsWith("死亡文字_")) { continue; } string text = name.Substring(5); int num = text.IndexOf('_'); if (num <= 0) { continue; } string s = text.Substring(0, num); if (int.TryParse(s, out var result) && deathCount == result) { string text2 = text.Substring(num + 1); if ((Object)(object)GUIManager.instance != (Object)null) { GUIManager.instance.SetHeroTitle(text2, (AudioClip)null); } break; } } } public string GetFormattedTime() { if (!gameStarted) { return "00:00:00"; } float num = Time.time - startTime; TimeSpan timeSpan = TimeSpan.FromSeconds(num); return $"{timeSpan.Hours:D2}:{timeSpan.Minutes:D2}:{timeSpan.Seconds:D2}"; } public void Reset() { deathCount = 0; startTime = Time.time; gameStarted = true; } } [HarmonyPatch(typeof(GUIManager))] public class HeroTitlePositionPatch { [HarmonyPrefix] [HarmonyPatch("SetHeroTitle")] public static void SetHeroTitlePrefix(GUIManager __instance) { //IL_0038: 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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance.heroObject != (Object)null) { RectTransform component = __instance.heroObject.GetComponent(); if ((Object)(object)component != (Object)null) { component.anchorMin = new Vector2(0.5f, 1f); component.anchorMax = new Vector2(0.5f, 1f); component.pivot = new Vector2(0.5f, 1f); component.anchoredPosition = new Vector2(0f, -80f); ((Transform)component).localScale = new Vector3(0.8f, 0.8f, 1f); } } if ((Object)(object)__instance.heroBG != (Object)null) { ((Component)__instance.heroBG).gameObject.SetActive(false); } } } [HarmonyPatch] public class NoFallDamagePatch { [HarmonyPrefix] [HarmonyPatch(typeof(CharacterMovement), "CheckFallDamage")] public static bool CheckFallDamagePrefix() { return false; } } [HarmonyPatch] public class NoHungerPatch { [HarmonyPrefix] [HarmonyPatch(typeof(CharacterAfflictions), "AddStatus")] public static bool AddStatusPrefix(STATUSTYPE statusType) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 if ((int)statusType == 1) { return false; } return true; } } public class ParasolSpawner : MonoBehaviour { [Header("设置")] public GameObject parasolPrefab; public float detectionRadius = 3f; private bool isPlayerNearby = false; private string parasolPrefabName = "Parasol"; private void Awake() { SphereCollider val = ((Component)this).gameObject.GetComponent(); if ((Object)(object)val == (Object)null) { val = ((Component)this).gameObject.AddComponent(); } ((Collider)val).isTrigger = true; val.radius = detectionRadius; if ((Object)(object)parasolPrefab != (Object)null) { parasolPrefabName = ((Object)parasolPrefab).name; } Plugin.SendLog("✓ 伞生成器 " + ((Object)((Component)this).gameObject).name + " 已初始化,预制件名称: " + parasolPrefabName); } private void OnTriggerEnter(Collider other) { Character val = ((Component)other).GetComponent(); if ((Object)(object)val == (Object)null) { val = ((Component)other).GetComponentInParent(); } if ((Object)(object)val != (Object)null && val.refs.view.IsMine) { isPlayerNearby = true; Plugin.SendLog("✓ 玩家靠近了 " + ((Object)((Component)this).gameObject).name + ",按E键生成伞"); } } private void OnTriggerExit(Collider other) { Character val = ((Component)other).GetComponent(); if ((Object)(object)val == (Object)null) { val = ((Component)other).GetComponentInParent(); } if ((Object)(object)val != (Object)null && val.refs.view.IsMine) { isPlayerNearby = false; } } private void Update() { if (isPlayerNearby && (Object)(object)Character.localCharacter != (Object)null && Character.localCharacter.refs.view.IsMine && Input.GetKeyDown((KeyCode)101)) { Plugin.SendLog("✓ 玩家按了E键,检查是否需要生成伞"); TryGiveParasol(); } } private void TryGiveParasol() { if (HasParasolInHand()) { Plugin.SendLog("⚠ 玩家手上已经有伞了,不需要生成"); } else { SpawnParasol(); } } private bool HasParasolInHand() { if ((Object)(object)Character.localCharacter == (Object)null || (Object)(object)Character.localCharacter.data == (Object)null) { return false; } Item currentItem = Character.localCharacter.data.currentItem; if ((Object)(object)currentItem != (Object)null) { string itemName = currentItem.GetItemName((ItemInstanceData)null); if (itemName.ToLower().Contains("parasol") || itemName.ToLower().Contains("伞")) { Plugin.SendLog("✓ 发现玩家手上有伞: " + itemName); return true; } } return false; } private void SpawnParasol() { //IL_000b: 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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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_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_00f4: 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_0055: 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) //IL_0071: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((Component)Character.localCharacter).transform.position + ((Component)Character.localCharacter).transform.forward * 0.5f + Vector3.up * 0.5f; try { GameObject val2 = PhotonNetwork.InstantiateItemRoom(parasolPrefabName, val, ((Component)Character.localCharacter).transform.rotation); if ((Object)(object)val2 != (Object)null) { Plugin.SendLog($"✓ 成功在玩家面前生成伞,位置: {val}"); Item component = val2.GetComponent(); if ((Object)(object)component != (Object)null) { Plugin.SendLog("✓ 尝试让玩家捡起伞"); component.RequestPickup(Character.localCharacter.refs.view); } } else { Plugin.SendLog("⚠ PhotonNetwork.InstantiateItemRoom 返回 null,尝试备用方法"); SpawnFallback(val); } } catch (Exception ex) { Plugin.SendLog("⚠ 使用官方方法失败: " + ex.Message + ",尝试备用方法"); SpawnFallback(val); } } private void SpawnFallback(Vector3 spawnPosition) { //IL_0018: 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_0054: 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_00b3: Unknown result type (might be due to invalid IL or missing references) GameObject val = GetParasolPrefab(); if ((Object)(object)val != (Object)null) { GameObject val2 = Object.Instantiate(val, spawnPosition, ((Component)Character.localCharacter).transform.rotation); Rigidbody component = val2.GetComponent(); if ((Object)(object)component != (Object)null) { component.isKinematic = false; component.useGravity = true; component.linearVelocity = Vector3.zero; component.angularVelocity = Vector3.zero; } val2.SetActive(true); Item component2 = val2.GetComponent(); if ((Object)(object)component2 != (Object)null) { Plugin.SendLog("✓ 备用方法成功,尝试让玩家捡起伞"); component2.RequestPickup(Character.localCharacter.refs.view); } Plugin.SendLog($"✓ 备用方法成功在玩家面前生成伞,位置: {spawnPosition}"); } else { Plugin.SendLog("⚠ 未找到Parasol预制件!"); } } private GameObject GetParasolPrefab() { if ((Object)(object)parasolPrefab != (Object)null) { return parasolPrefab; } Item val = default(Item); if (ItemDatabase.TryGetItem("Parasol", ref val) && (Object)(object)val != (Object)null) { Plugin.SendLog("✓ 从ItemDatabase找到Parasol"); return ((Component)val).gameObject; } Object[] array = (Object[])(object)Resources.FindObjectsOfTypeAll(); Object[] array2 = array; Object[] array3 = array2; foreach (Object val2 in array3) { GameObject val3 = (GameObject)(object)((val2 is GameObject) ? val2 : null); if ((Object)(object)val3 != (Object)null && (((Object)val3).name == "Parasol" || ((Object)val3).name == "parasol")) { Plugin.SendLog("✓ 找到Parasol游戏对象: " + ((Object)val3).name); return val3; } } return null; } } [BepInPlugin("NANJU.QWQ.dev", "NANAJU", "0.1.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string modGUID = "NANJU.QWQ.dev"; public const string modName = "NANAJU"; public const string modVersion = "0.1.0"; private readonly Harmony _harmony = new Harmony("NANJU.QWQ.dev"); internal static ManualLogSource mls = Logger.CreateLogSource("NANJU.QWQ.dev"); private GameObject shrinePrefab; private readonly Vector3 shrinePosition = new Vector3(-2.04801f, 0.9f, -360.3f); private readonly Vector3 shrineRotation = new Vector3(-89.98f, 0f, 0f); private bool spawnedShrine = false; private void Awake() { CreateGameStatsManager(); PatchAllStuff(); BundleLoader.LoadBundleWithName((BaseUnityPlugin)(object)this, "jitai.peak", (Action)delegate(PeakBundle peakBundle) { UnityItemContent val = peakBundle.LoadAsset("jitai"); if ((Object)(object)val == (Object)null) { val = peakBundle.LoadAsset("其他"); } if ((Object)(object)val == (Object)null) { peakBundle.Mod.RegisterContent(); } else { shrinePrefab = val.ItemPrefab; if ((Object)(object)shrinePrefab == (Object)null) { peakBundle.Mod.RegisterContent(); } else { Renderer[] componentsInChildren = shrinePrefab.GetComponentsInChildren(); if (componentsInChildren.Length != 0) { Shader val2 = Shader.Find("W/Character"); if ((Object)(object)val2 != (Object)null) { Renderer[] array = componentsInChildren; foreach (Renderer val3 in array) { val3.material.shader = val2; } } } if ((Object)(object)shrinePrefab.GetComponentInChildren() == (Object)null) { ((Collider)shrinePrefab.AddComponent()).isTrigger = true; } AttachScriptsToPrefabChildren(shrinePrefab); AreaTitleDisplay.ScanAndAttachToPrefab(shrinePrefab); EndArea.ScanAndAttach(shrinePrefab); peakBundle.Mod.RegisterContent(); } } }); } private void CreateGameStatsManager() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown GameObject val = new GameObject("GameStatsManager"); val.AddComponent(); Object.DontDestroyOnLoad((Object)(object)val); } private void Start() { SceneManager.sceneLoaded += OnSceneLoaded; SceneManager.sceneUnloaded += OnSceneUnloaded; } private void OnDestroy() { SceneManager.sceneLoaded -= OnSceneLoaded; SceneManager.sceneUnloaded -= OnSceneUnloaded; } private void OnSceneUnloaded(Scene scene) { Match match = new Regex("^Level_(\\d+)$").Match(((Scene)(ref scene)).name); if (match.Success) { spawnedShrine = false; Debug.Log((object)"[Plugin] 离开 Level 场景,重置 spawnedShrine 和 FlarePatch"); } } private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) ((MonoBehaviour)this).Invoke("AutoAttachScripts", 0.5f); Match match = new Regex("^Level_(\\d+)$").Match(((Scene)(ref scene)).name); if ((int)mode != 0 || !match.Success || !int.TryParse(match.Groups[1].Value, out var _)) { return; } if (!spawnedShrine && (Object)(object)shrinePrefab != (Object)null) { GameObject val = Object.Instantiate(shrinePrefab); val.transform.position = shrinePosition; val.transform.eulerAngles = shrineRotation; ((Object)val).name = "CustomShrine"; Rigidbody val2 = val.GetComponent(); if ((Object)(object)val2 == (Object)null) { val2 = val.AddComponent(); } val2.isKinematic = true; Rigidbody[] componentsInChildren = val.GetComponentsInChildren(); foreach (Rigidbody val3 in componentsInChildren) { if ((Object)(object)((Component)val3).transform != (Object)(object)val.transform) { val3.linearVelocity = Vector3.zero; val3.angularVelocity = Vector3.zero; } } spawnedShrine = true; HideSceneObjects(); } else if (spawnedShrine) { HideSceneObjects(); } } private void HideSceneObjects() { string[] array = new string[6] { "Biome_1", "Biome_2", "Biome_3", "Biome_4", "Global", "EdgeWalls" }; string[] array2 = array; foreach (string text in array2) { GameObject val = GameObject.Find(text); if ((Object)(object)val != (Object)null) { val.SetActive(false); } } GameObject val2 = GameObject.Find("FogSphereSystem"); if ((Object)(object)val2 != (Object)null) { Object.Destroy((Object)(object)val2); } } private void AttachScriptsToPrefabChildren(GameObject prefab) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) Transform[] componentsInChildren = prefab.GetComponentsInChildren(true); foreach (Transform val in componentsInChildren) { GameObject gameObject = ((Component)val).gameObject; if (((Object)gameObject).name.Contains("初始保存点")) { SaveManager.Instance.SetInitialSavePoint(gameObject.transform.position); } else if (((Object)gameObject).name.Contains("保存点") && (Object)(object)gameObject.GetComponent() == (Object)null) { gameObject.AddComponent(); EnsureCollider(gameObject); } else if (((Object)gameObject).name.Contains("死亡点") && (Object)(object)gameObject.GetComponent() == (Object)null) { gameObject.AddComponent(); EnsureCollider(gameObject); } else if (((Object)gameObject).name.Contains("伞") && (Object)(object)gameObject.GetComponent() == (Object)null) { gameObject.AddComponent(); } } EndGameZone.ScanAndAttach(prefab); } private void AutoAttachScripts() { //IL_0039: Unknown result type (might be due to invalid IL or missing references) GameObject[] array = Object.FindObjectsByType((FindObjectsSortMode)0); GameObject[] array2 = array; foreach (GameObject val in array2) { if (((Object)val).name.Contains("初始保存点")) { SaveManager.Instance.SetInitialSavePoint(val.transform.position); } else if (((Object)val).name.Contains("保存点") && (Object)(object)val.GetComponent() == (Object)null) { val.AddComponent(); EnsureCollider(val); } else if (((Object)val).name.Contains("死亡点") && (Object)(object)val.GetComponent() == (Object)null) { val.AddComponent(); EnsureCollider(val); } else if (((Object)val).name.Contains("伞") && (Object)(object)val.GetComponent() == (Object)null) { val.AddComponent(); } } ((MonoBehaviour)this).Invoke("FindInitialSavePointLater", 2f); AreaTitleDisplay.ScanAndAttachToScene(); EndArea.ScanAndAttach(); EndGameZone.ScanAndAttach(); ((MonoBehaviour)this).Invoke("ForceScanAreaTitles", 1f); } private void EnsureCollider(GameObject obj) { Collider component = obj.GetComponent(); if ((Object)(object)component == (Object)null) { ((Collider)obj.AddComponent()).isTrigger = true; } else { component.isTrigger = true; } } private void FindInitialSavePointLater() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) GameObject[] array = Object.FindObjectsByType((FindObjectsSortMode)0); foreach (GameObject val in array) { if (((Object)val).name.Contains("初始保存点")) { SaveManager.Instance.SetInitialSavePoint(val.transform.position); break; } } } private void ForceScanAreaTitles() { AreaTitleDisplay.ForceScan(); } public static void SendLog(string msg) { } public void PatchAllStuff() { _harmony.PatchAll(Assembly.GetExecutingAssembly()); } } public class SaveManager : MonoBehaviour { private static SaveManager _instance; private Vector3 _lastSavePoint = Vector3.zero; private Vector3 _initialSavePoint = Vector3.zero; public static SaveManager Instance { get { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown if ((Object)(object)_instance == (Object)null) { GameObject val = new GameObject("SaveManager"); _instance = val.AddComponent(); Object.DontDestroyOnLoad((Object)(object)val); Plugin.SendLog("✓ SaveManager 实例创建"); } return _instance; } } private void Awake() { if ((Object)(object)_instance == (Object)null) { _instance = this; Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); Plugin.SendLog("✓ SaveManager Awake, 设置为 DontDestroyOnLoad"); } else if ((Object)(object)_instance != (Object)(object)this) { Object.Destroy((Object)(object)((Component)this).gameObject); } } public void SetLastSavePoint(Vector3 position) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: 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) _lastSavePoint = position; Plugin.SendLog($"✓ 保存点已更新: {position}"); } public void SetInitialSavePoint(Vector3 position) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: 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) _initialSavePoint = position; Plugin.SendLog($"✓ 初始保存点已设置: {position}"); } public Vector3 GetLastSavePoint() { //IL_0007: 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_0022: 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) Plugin.SendLog($"获取保存点位置: {_lastSavePoint}"); return _lastSavePoint; } public Vector3 GetInitialSavePoint() { //IL_0007: 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_0022: 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) Plugin.SendLog($"获取初始保存点位置: {_initialSavePoint}"); return _initialSavePoint; } public Vector3 GetRevivePosition() { //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_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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0063: 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_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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_007c: 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) //IL_0087: 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) if (_lastSavePoint != Vector3.zero) { Plugin.SendLog("使用最后保存点复活"); return _lastSavePoint; } if (_initialSavePoint != Vector3.zero) { Plugin.SendLog("使用初始保存点复活"); return _initialSavePoint; } Plugin.SendLog("⚠ 没有保存点,先尝试找初始保存点"); Vector3 val = FindInitialSavePointInScene(); if (val != Vector3.zero) { _initialSavePoint = val; Plugin.SendLog($"✓ 实时查找到初始保存点: {val}"); return val; } Plugin.SendLog("⚠ 没有找到初始保存点,尝试找普通保存点"); return FindSavePointInScene(); } public Vector3 FindSavePointInScene() { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: 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_0057: 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_007f: Unknown result type (might be due to invalid IL or missing references) GameObject[] array = Object.FindObjectsByType((FindObjectsSortMode)0); GameObject[] array2 = array; foreach (GameObject val in array2) { if (((Object)val).name.Contains("保存点")) { Plugin.SendLog($"✓ 在场景中找到保存点: {((Object)val).name}, 位置: {val.transform.position}"); return val.transform.position; } } Plugin.SendLog("⚠ 场景中未找到保存点"); return Vector3.zero; } public Vector3 FindInitialSavePointInScene() { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: 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_0057: 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_007f: Unknown result type (might be due to invalid IL or missing references) GameObject[] array = Object.FindObjectsByType((FindObjectsSortMode)0); GameObject[] array2 = array; foreach (GameObject val in array2) { if (((Object)val).name.Contains("初始保存点")) { Plugin.SendLog($"✓ 在场景中找到初始保存点: {((Object)val).name}, 位置: {val.transform.position}"); return val.transform.position; } } Plugin.SendLog("⚠ 场景中未找到初始保存点"); return Vector3.zero; } public bool HasSavePoint() { //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) bool flag = _lastSavePoint != Vector3.zero; Plugin.SendLog($"检查是否有保存点: {flag}"); return flag; } public bool HasInitialSavePoint() { //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) bool flag = _initialSavePoint != Vector3.zero; Plugin.SendLog($"检查是否有初始保存点: {flag}"); return flag; } } public class SavePoint : MonoBehaviour { private bool hasSaved = false; private void OnTriggerEnter(Collider other) { //IL_0055: 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_0060: Unknown result type (might be due to invalid IL or missing references) Character val = ((Component)other).GetComponent(); if ((Object)(object)val == (Object)null) { val = ((Component)other).GetComponentInParent(); } if ((Object)(object)val != (Object)null && val.refs.view.IsMine && !hasSaved) { hasSaved = true; Vector3 position = ((Component)this).transform.position; SaveManager.Instance.SetLastSavePoint(position); GameStatsManager.Instance?.StartTimer(); if ((Object)(object)GUIManager.instance != (Object)null) { GUIManager.instance.SetHeroTitle(val.characterName + " 已保存", (AudioClip)null); } } } } public static class MyPluginInfo { public const string PLUGIN_GUID = "NanJu.LevelMOD"; public const string PLUGIN_NAME = "MyStaff"; public const string PLUGIN_VERSION = "0.1.0"; } }