feat: isolate lobby during minigames

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
ud18010
2026-07-29 15:26:54 +08:00
co-authored by Claude Opus 4.8
parent 31afce6882
commit 6a5e534d00
9 changed files with 1408 additions and 8 deletions
@@ -12,6 +12,7 @@ namespace XGame.MiniGame
public string GatewayUrl = "ws://127.0.0.1:5005/ws?pid=1";
public string CdnBase = "";
public bool AutoStart;
public MiniGameStageIsolation StageIsolation;
private readonly List<GameInfoMsg> _games = new List<GameInfoMsg>();
private string _status = "idle";
@@ -141,10 +142,12 @@ namespace XGame.MiniGame
{
_lobbyActive = false;
_lobbyNet = null;
SuspendLobbyStage();
_gameHost = gameObject.GetComponent<MiniGameHost>();
if (_gameHost == null) _gameHost = gameObject.AddComponent<MiniGameHost>();
_gameHost.OnGameExited = () =>
{
ResumeLobbyStage();
_status = "returned to lobby";
_matching = false;
_lobbyNet = new MiniGameNetChannel(_socket);
@@ -155,6 +158,35 @@ namespace XGame.MiniGame
_gameHost.EnterGame(ResolvedCdnBase(), gameId, version, _socket, false);
}
private MiniGameStageIsolation ResolveStageIsolation()
{
if (StageIsolation != null)
{
return StageIsolation;
}
StageIsolation = GetComponent<MiniGameStageIsolation>();
return StageIsolation;
}
private void SuspendLobbyStage()
{
MiniGameStageIsolation isolation = ResolveStageIsolation();
if (isolation != null)
{
isolation.SuspendLobbyForMiniGame();
}
}
private void ResumeLobbyStage()
{
MiniGameStageIsolation isolation = ResolveStageIsolation();
if (isolation != null)
{
isolation.ResumeLobbyAfterMiniGame();
}
}
private string ResolvedCdnBase()
{
#if XW_DEVTEST