Add lobby/match-start matchmaking flow with additive scene management
Replace the connection-approval role selection with a server-authoritative match flow built on NGO additive scene management: - Scenes: Main is the persistent foundation (NetworkManager, GameModeManager, cameras, HUD); Lobby and Test Map load/unload additively. Add Lobby + Test Map to the build settings; remove the obsolete SampleScene. - MatchManager (plain MonoBehaviour singleton): loads Lobby on server start, StartMatchTrigger lets the host start the match, rolls one random Hunter (rest Hider), swaps Lobby -> Test Map (strictly serialized per NGO), respawns each player as its role variant. Forces additive client sync mode so clients keep Main instead of single-loading it (fixes "Destination scene is not valid"). - Server-driven spawning: null out NetworkConfig.PlayerPrefab at runtime to disable auto-spawn, then spawn players after the lobby floor exists (fixes falling through the floor) with double-spawn and transition guards. - StartMatchTrigger: server-gated OnTriggerEnter, only the host's own player starts the match. - NetworkBootstrap: drop role selection / connection approval; everyone spawns as the neutral Player prefab. Host/Client/Server/Shutdown buttons stay. - NetworkPlayerSetup.ScopedModes flag (baked on Hunter/Hider prefabs): lobby avatar gets the full mode set, match variants get the role-scoped set. - GameModeManager.BindLocalPlayer reads ScopedModes and rebinds the painter unconditionally (fixes stale painter binding on respawn -> brush painting in every mode). - MeshPainter.PaintingEnabled defaults to false (unbound/pre-spawn/remote never paints); PaintHud visibility now also gates on a bound painter (fixes the HUD showing at startup before any avatar exists). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
301f7e64cb
commit
bd70f3b8b9
18 files changed
+1813
-997
No files matched your search
@@ -137,8 +137,12 @@ public class GameModeManager : MonoBehaviour
|
||||
if (!localPlayer) return;
|
||||
player = localPlayer;
|
||||
|
||||
// The painter lives on the player (per-avatar), so bind the local one.
|
||||
if (!painter) painter = localPlayer.GetComponentInChildren<MeshPainter>(true);
|
||||
// The painter lives on the player (per-avatar), so bind the local one - UNCONDITIONALLY. On a
|
||||
// lobby->match respawn the previous avatar is despawned and the role variant spawned in the same
|
||||
// server frame; the old painter is Destroy-pending (still non-null) when this runs, so a
|
||||
// `if (!painter)` guard would keep the stale reference and the new avatar's painter would never be
|
||||
// mode-toggled - it would paint in every mode. Always re-point to the freshly spawned avatar.
|
||||
painter = localPlayer.GetComponentInChildren<MeshPainter>(true);
|
||||
PainterChanged?.Invoke(painter);
|
||||
|
||||
Transform camTarget = localPlayer.transform.Find("CameraTarget");
|
||||
@@ -157,11 +161,16 @@ public class GameModeManager : MonoBehaviour
|
||||
ActiveMode?.Exit();
|
||||
_activeIndex = -1;
|
||||
|
||||
// Lobby/neutral avatar (base Player prefab) -> full mode set; match avatar (Hunter/Hider
|
||||
// variant) -> only its role's modes. Baked per prefab, so no replicated-phase timing race.
|
||||
var setup = localPlayer.GetComponent<NetworkPlayerSetup>();
|
||||
PlayerRole role = setup ? setup.Role : PlayerRole.Hider;
|
||||
BuildModes(role);
|
||||
if (setup && setup.ScopedModes)
|
||||
BuildModes(setup.Role);
|
||||
else
|
||||
BuildModes(null);
|
||||
|
||||
// Each role list is ordered so index 0 is its start mode (Hunter -> First Person, Hider -> Player Control).
|
||||
// Role lists are ordered so index 0 is the start mode (Hunter -> First Person, Hider -> Player
|
||||
// Control); the full lobby set starts at Player Control too.
|
||||
SwitchTo(0);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user