Refactor Party Game flow and UI state management#121
Open
Shombith03 wants to merge 7 commits into
Open
Conversation
- Fix initial Lobby phase callback not firing (NetworkVariable.OnValueChanged skips when default matches initial value) by manually invoking it - Fix SetPhase for re-entering same phase (force callback on same-value set) - Add CSDebug logging to all silent failure paths in ready system (OnLocalPlayerReady, OnPlayerReady_ServerRpc, CheckAllPlayersReady) - Add max player limit check in OnPlayerJoined for solo mode - Fix ready count tracking: pass server-authoritative count to UI instead of accumulating on the client (SetReadyCount/ResetReadyCount on PartyRoundTab) - Add ResetReadyStates_ClientRpc so UI resets between 1st→2nd ready phases - Add partyComponentsRoot field for disabling party UI during gameplay and re-enabling after cinematic completes - Fix PartyEndGameHandler: explicit using for XPRewardService, re-enable party components after cinematic sequence - Fix PartyPauseButton: null-safe access to InputStatus and InputController - Fix ResetGameDataForRound_ClientRpc: guard against empty RoundStatsList on first round - Add ReinitializePanelWithPlayers_ClientRpc for proper panel refresh after lobby fills https://claude.ai/code/session_01NWZJqFYbashBgydLxkmGub
…tion B flow - Disable MiniGameControllerBase components on environments at startup and when activating them, preventing KeyNotFoundException from RPC dispatch and InitializeAfterDelay interference - Remove free flight lobby phase (Option B: UI-only entry, wait for players) - PartyEndGameHandler intercepts scoreboard, shows party panel instead - PartyGameController now drives all game flow with controllers disabled https://claude.ai/code/session_01NWZJqFYbashBgydLxkmGub
…tsRoot - Delete PartyEndGameHandler — each environment has its own end-game handler; PartyGameController just listens for gameData events - Remove partyComponentsRoot field — was set to PartyGameManager itself, which would disable the controller during gameplay. Panel show/hide is sufficient. - Collapse HidePartyUI/ShowPartyUI into simple ShowPanel/HidePanel RPCs - Strip redundant logging and comments for cleaner code https://claude.ai/code/session_01NWZJqFYbashBgydLxkmGub
- Guard ServerPlayerVesselInitializer.OnNetworkSpawn against null/empty _playerOrigins — disables itself instead of crashing - Register human player directly in StartSoloLobby if SPVI didn't spawn one (covers party mode where SPVI may be absent) - Fix OnLocalPlayerReady to fall back to _playerStates when gameData.LocalPlayer is null (no vessel needed for Ready) - Call CheckAllPlayersReady after ResetReadyStates for auto-progress when all players are AI/already ready https://claude.ai/code/session_01NWZJqFYbashBgydLxkmGub
…d guard Four fixes: 1. MiniGameControllerBase.OnReadyClicked now checks `enabled` before delegating — prevents NPE when environment buttons are clicked but controllers are disabled in party mode 2. Solo and multiplayer lobbies now transition to WaitingForReady instead of auto-starting rounds. Player must click Ready to begin. 3. ActivateMiniGameEnvironment disables environment Canvas components to prevent the mini-game's Ready button, cameras, and scoreboard from overlapping party UI 4. UpdateSpawnPositionsFromEnv no longer calls gameData.ResetPlayers() which was NPE-ing on players without vessels (spawned by environment SPVIs before PartyGameController could disable them) https://claude.ai/code/session_01NWZJqFYbashBgydLxkmGub
In party mode, environment SPVIs spawn Player objects during the scene sweep before PartyGameController can disable them. These players have no vessel linked, causing NPEs in StartPlayer (Vessel.StartVessel) and ResetForPlay (Vessel.ResetForPlay). Early-return when Vessel is null — safe for normal games where Vessel is always assigned. https://claude.ai/code/session_01NWZJqFYbashBgydLxkmGub
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR refactors the Party Game controller and UI to improve state management, fix phase transition bugs, and clarify the game flow. The main changes involve fixing the ready state tracking, improving phase callbacks, adding a party components root for better UI control, and enhancing logging throughout.
Key Changes
PartyGameController.cs
OnNetPhaseChangedwhen re-entering the same phase (e.g.,WaitingForReady→WaitingForReady), sinceNetworkVariable.OnValueChangeddoesn't fire when the value doesn't change_readyPlayerCountwith dynamic calculation via_playerStates.Count(p => p.IsReady)to avoid sync issuesDiscoverMiniGameControllers()method and_miniGameControllerslist as they were unusedCheckAllPlayersReady()to use a switch statement with explicit logging for each phase transitionReinitializePanelWithPlayers_ClientRpc()to sync panel state when all players are knownHideMiniGameHUD_ClientRpc()intoHidePartyUI_ClientRpc()andShowPartyUI_ClientRpc()to properly manage party components rootCSDebug.Logcalls throughout for better debugging and flow visibilityPartyPausePanel.cs
OnPlayerReadyChanged()to acceptreadyCountandtotalCountparameters for server-authoritative updatesOnReadyStatesReset()method to handle UI updates when ready states are reset between phasesPartyRoundTab.cs
SetPlayerReady()withSetReadyCount()for direct server-authoritative updatesResetReadyCount()to clear ready count when transitioning between ready phasesPartyPauseButton.cs
gameDataandlocalPlayerreferences_ = SetInputPauseDelayed()to.Forget()for clarityPartyEndGameHandler.cs
XPRewardServiceNotable Implementation Details
partyComponentsRootprovides clean control over all party UI elements, preventing interference during active gameplayhttps://claude.ai/code/session_01NWZJqFYbashBgydLxkmGub