From 5c7c2e3e81843a78c86b2ae8b7d8ea96c2aaa23f Mon Sep 17 00:00:00 2001 From: wuwenbo Date: Wed, 14 Jan 2026 19:15:20 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=8E=89=E7=BA=BF?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E9=80=80=E5=87=BA=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Unity/Assets/Scripts/TH1_Logic/Core/GameLogic.cs | 10 ++++++++++ Unity/Assets/Scripts/TH1_Logic/Net/ILobby.cs | 2 +- .../Assets/Scripts/TH1_Logic/Steam/GameNetReceiver.cs | 3 +-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Unity/Assets/Scripts/TH1_Logic/Core/GameLogic.cs b/Unity/Assets/Scripts/TH1_Logic/Core/GameLogic.cs index 3d56162df..5b127b1cd 100644 --- a/Unity/Assets/Scripts/TH1_Logic/Core/GameLogic.cs +++ b/Unity/Assets/Scripts/TH1_Logic/Core/GameLogic.cs @@ -13,6 +13,7 @@ using Logic.AI; using Logic.Audio; using Logic.CrashSight; using RuntimeData; +using TH1_Core.Events; using TH1_Core.Managers; using TH1_Logic.AITrain; using TH1_Logic.Core; @@ -223,6 +224,15 @@ namespace Logic if (!LobbyManager.Instance.Lobby.IsLobbyOwner()) return; GameNetSender.Instance.ForceUpdate(memberId); } + + // 与房主断开时 + public void OnDisconnectToHost() + { + if (_curState == GameState.Menu) return; + if (Main.MapData.Net.Mode != NetMode.Multi) return; + if (LobbyManager.Instance.Lobby.IsLobbyOwner()) return; + EventManager.Publish(new ExecuteUIBottomBottomBarQuit()); + } } diff --git a/Unity/Assets/Scripts/TH1_Logic/Net/ILobby.cs b/Unity/Assets/Scripts/TH1_Logic/Net/ILobby.cs index 5550d9ca1..5af252112 100644 --- a/Unity/Assets/Scripts/TH1_Logic/Net/ILobby.cs +++ b/Unity/Assets/Scripts/TH1_Logic/Net/ILobby.cs @@ -76,7 +76,7 @@ namespace TH1_Logic.Net // 获取自己在不在房间中 public bool IsInLobby(); - + // 检查和房主的连接状态, 断开需要重连 public void CheckConnectionStatus(); diff --git a/Unity/Assets/Scripts/TH1_Logic/Steam/GameNetReceiver.cs b/Unity/Assets/Scripts/TH1_Logic/Steam/GameNetReceiver.cs index ac1c48033..76467dfa5 100644 --- a/Unity/Assets/Scripts/TH1_Logic/Steam/GameNetReceiver.cs +++ b/Unity/Assets/Scripts/TH1_Logic/Steam/GameNetReceiver.cs @@ -349,7 +349,7 @@ namespace TH1_Logic.Steam // 判断是否游戏已经结束而我还在等待 if (Main.MapData != null && !Main.MapData.CheckIfGameEnd(out _) && message.State == GameState.Menu) { - + EventManager.Publish(new ExecuteUIBottomBottomBarQuit()); return; } @@ -366,7 +366,6 @@ namespace TH1_Logic.Steam LogSystem.LogWarning($"OnReceivedMemberStateSync 检测状态错误"); GameNetSender.Instance.SendRequestForceUpdate(); } - } // 只有房主会收到 From 3fbf0576a3b891ee59c6af7b7075773eb80238eb Mon Sep 17 00:00:00 2001 From: wuwenbo Date: Wed, 14 Jan 2026 19:23:30 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E8=A1=A5=E9=BD=90=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Unity/Assets/Scripts/TH1_Logic/Steam/SteamLobbyManager.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Unity/Assets/Scripts/TH1_Logic/Steam/SteamLobbyManager.cs b/Unity/Assets/Scripts/TH1_Logic/Steam/SteamLobbyManager.cs index 49073e9b9..ddbdafa23 100644 --- a/Unity/Assets/Scripts/TH1_Logic/Steam/SteamLobbyManager.cs +++ b/Unity/Assets/Scripts/TH1_Logic/Steam/SteamLobbyManager.cs @@ -130,6 +130,7 @@ namespace TH1_Logic.Steam //RefreshSteamGUI(); RefreshLoginStatus(); RefreshLobbyStatus(); + RefreshSteamGUI(); } // 刷新 Steam @@ -727,6 +728,10 @@ namespace TH1_Logic.Steam private void OnP2PPeerDisconnected(CSteamID steamID) { + if (!IsLobbyOwner()) + { + if (steamID.m_SteamID == GetLobbyOwnerId()) Main.Instance.GameLogic.OnDisconnectToHost(); + } LogSystem.LogInfo($"P2P connection lost with: {steamID}"); }