From 445ff4ae6238596a3b742883d68a5dbd4d093e52 Mon Sep 17 00:00:00 2001 From: HungDK <> Date: Tue, 24 Mar 2026 17:14:45 +0700 Subject: [PATCH] Fix dead and revive error before enter world --- .../Scripts/UI/Popup/PopupManager.cs | 30 +++++++++++++++++-- Assets/Scripts/CECHostPlayer.Combat.cs | 5 +--- Assets/Scripts/CECHostPlayer.World.cs | 4 +-- Assets/Scripts/CECHostPlayer.cs | 4 ++- 4 files changed, 34 insertions(+), 9 deletions(-) diff --git a/Assets/PerfectWorld/Scripts/UI/Popup/PopupManager.cs b/Assets/PerfectWorld/Scripts/UI/Popup/PopupManager.cs index 50ec155b01..5d8ab010a7 100644 --- a/Assets/PerfectWorld/Scripts/UI/Popup/PopupManager.cs +++ b/Assets/PerfectWorld/Scripts/UI/Popup/PopupManager.cs @@ -6,6 +6,7 @@ namespace BrewMonster public class PopupManager : MonoBehaviour { public static PopupManager Instance { get; private set; } + private static bool s_shouldShowRevivePopup; [SerializeField] private GameObject ReviveOptionPopup; @@ -14,6 +15,7 @@ namespace BrewMonster if (Instance == null) { Instance = this; + ApplyRevivePopupState(); } else { @@ -31,11 +33,35 @@ namespace BrewMonster public void OnPlayerDied() { - ReviveOptionPopup.SetActive(true); + s_shouldShowRevivePopup = true; + ApplyRevivePopupState(); } public void OnPlayerRevived() { - ReviveOptionPopup.SetActive(false); + s_shouldShowRevivePopup = false; + ApplyRevivePopupState(); + } + + private void ApplyRevivePopupState() + { + if (ReviveOptionPopup == null) + { + return; + } + + ReviveOptionPopup.SetActive(s_shouldShowRevivePopup); + } + + public static void NotifyPlayerDied() + { + s_shouldShowRevivePopup = true; + Instance?.ApplyRevivePopupState(); + } + + public static void NotifyPlayerRevived() + { + s_shouldShowRevivePopup = false; + Instance?.ApplyRevivePopupState(); } } diff --git a/Assets/Scripts/CECHostPlayer.Combat.cs b/Assets/Scripts/CECHostPlayer.Combat.cs index 2dda8e9018..c0f6a630c2 100644 --- a/Assets/Scripts/CECHostPlayer.Combat.cs +++ b/Assets/Scripts/CECHostPlayer.Combat.cs @@ -876,10 +876,7 @@ namespace BrewMonster EventBus.PublishChannel(GetCharacterID(), new ClearComActFlagAllRankNodesEvent(true)); PlayAction((int)PLAYER_ACTION_TYPE.ACT_GROUNDDIE); - if (PopupManager.Instance != null) - { - PopupManager.Instance.OnPlayerDied(); - } + PopupManager.NotifyPlayerDied(); } private bool NormalAttackObject(int idTarget, bool bForceAttack, bool bMoreClose = false) diff --git a/Assets/Scripts/CECHostPlayer.World.cs b/Assets/Scripts/CECHostPlayer.World.cs index c81bc56248..3f02371a88 100644 --- a/Assets/Scripts/CECHostPlayer.World.cs +++ b/Assets/Scripts/CECHostPlayer.World.cs @@ -1,4 +1,4 @@ -using BrewMonster.Network; +using BrewMonster.Network; using BrewMonster.Scripts; using CSNetwork; using CSNetwork.GPDataType; @@ -35,7 +35,7 @@ namespace BrewMonster } public void OnMsgHstGoto(in ECMSG Msg) { - PopupManager.Instance.OnPlayerRevived(); + PopupManager.NotifyPlayerRevived(); // p1 is a byte[] buffer; parse into cmd_notify_hostpos then set position // p1 是一个 byte[] 缓冲区;解析为 cmd_notify_hostpos 然后设置位置 byte[] buf = (byte[])Msg.dwParam1; diff --git a/Assets/Scripts/CECHostPlayer.cs b/Assets/Scripts/CECHostPlayer.cs index 3b3a67d0a4..7f2aeea186 100644 --- a/Assets/Scripts/CECHostPlayer.cs +++ b/Assets/Scripts/CECHostPlayer.cs @@ -1454,9 +1454,11 @@ namespace BrewMonster //m_pWorkMan.StartWork_p0(pWork); EventBus.PublishChannel(GetCharacterID(), new ClearComActFlagAllRankNodesEvent(true)); PlayAction((int)PLAYER_ACTION_TYPE.ACT_GROUNDDIE); + PopupManager.NotifyPlayerDied(); } else { + PopupManager.NotifyPlayerRevived(); UnityGameSession.c2s_CmdGetAllData(true, true, false); UnityGameSession.c2s_CmdSendEnterPKPrecinct(); UnityGameSession.RequesrQueryPlayerCash(); @@ -2632,7 +2634,7 @@ namespace BrewMonster { /* CECGameUIMan pGameUI = g_pGame.GetGameRun().GetUIManager().GetInGameUIMan(); pGameUI.PopupReviveDialog(true);*/ - PopupManager.Instance.OnPlayerDied(); + PopupManager.NotifyPlayerDied(); } m_bEnterGame = true; }