Adding new Races, Main Menu -> Lobby flow, and what's needed to set up multiplayer testing.

This commit is contained in:
Matt F 2026-05-17 23:31:02 -07:00
parent 60fa58b07f
commit fdada6f132
29 changed files with 2581 additions and 176 deletions

View file

@ -75,20 +75,24 @@ The most architecturally significant pending system. This blocks the Phase 2 tow
- 4-connected, no diagonals (matches existing maze validation)
- Re-pathing on tower placement/removal events. Fire on: `TowerInstance` spawn/despawn, construction-start, construction-finish, shelved-tower despawn.
### 1.7 Lobby & Connection (CURRENT)
### 1.7 Lobby & Connection (COMPLETE — 2026-05-17)
Replaces the current bare "Start Host" button with a proper main menu → lobby → match flow.
Replaced the bare "Start Host" button with a proper main menu → lobby → match flow.
Lobby is its own scene; players gather, pick races, ready up, and the host starts the match.
**v1 scope (Direct IP, Option A host-leaves-closes-lobby):**
**v1 shipped (Direct IP, Option A host-leaves-closes-lobby):**
- `MainMenu` scene — Host / Join (with IP+port field) / Quit
- `Lobby` scene — player list, per-player race picker, ready toggle, host-only Start button, Leave button
- `MainMenu` scene — Host / Join (with IP+port field) / Quit / **Quick Start** (dev shortcut)
- `Lobby` scene — player list, per-player **Select Race** button opening the race-selection overlay, ready toggle, host-only Start button, Leave button
- `LobbyService` `NetworkBehaviour` scene singleton — Start Match RPC, Return to Lobby RPC
- `NetworkBootstrap` static — wraps `UnityTransport` host/join/disconnect. Designed for the Steam swap-out below: same call sites, different transport.
- `PlayerMatchState` extended with `IsReady` NetworkVariable and `SetReadyRpc` / `SetRaceRpc` for client → server submissions
- `SessionFlow` DontDestroyOnLoad singleton — routes disconnected peers back to MainMenu on host loss
- `PlayerMatchState` extended with `IsReady` NetworkVariable and `SubmitRaceRpc` / `SubmitReadyRpc` for client → server submissions
- `PlayerBuilderSpawner` refactored to spawn on `NetworkSceneManager.OnLoadEventCompleted` for the Match scene, not on initial player spawn. Pulls race-specific `BuilderPrefab` from `RaceRegistry` when available, falls back to the inspector default. Re-spawns cleanly across Match → Lobby → Match cycles.
- Match-end overlay extended: **Retry** (back to lobby) AND **Return to Main Menu** (this player only)
- Host leaves → server raises a "lobby closed" RPC; all clients shutdown + return to main menu. Same applies if the host clicks "Return to Main Menu" after a match — session ends for everyone, each player returns independently to their own main menu.
- Host leaves → all clients return to main menu via `SessionFlow.OnClientDisconnectCallback` (Option A). Same applies if the host clicks "Return to Main Menu" after a match.
- **Race data + selection UI** delivered as part of 1.7 (originally scoped for 1.8): `RaceId` enum expanded to 16 slots, `RaceDefinition` ScriptableObject (Id, DisplayName, Icon, BuilderName, BuilderDescription, LoreText, BuilderPrefab, Towers stub), `RaceRegistry` (DontDestroyOnLoad singleton in MainMenu — single source of truth across all scenes), `RaceSelectionOverlay` (4×4 grid + detail panel, taken-race greying with picker badge, Esc/X close, server-side exclusivity enforced via `SubmitRaceRpc`).
- **Quick Start dev button** in MainMenu — bypasses lobby: hosts → waits for `PlayerMatchState.Local` → sets Race1 + ready → loads Match scene directly. Coroutine in `MainMenuController.QuickStartCoroutine`.
### 1.7-Future Steam Lobby Migration (Option C — DEFERRED)
@ -119,16 +123,29 @@ Decision deferred per existing context document; Builder code is already terrain
Options previously discussed: Unity Terrain, mesh-based (Blender), ProBuilder, per-tile heights via volumes.
### 1.8 Race system (Path E)
### 1.8 Race system (Path E) — PARTIALLY COMPLETE
The largest content-shaped piece of Phase 1. Required before Phase 2 because the prototype tower (Space Marine) is conceptually a unit of the Adeptus Astartes race, and the data model needs to reflect that.
Data model and lobby selection UI shipped as part of 1.7 (2026-05-17). Remaining work is gameplay-side integration of the race payload during a match.
- `RaceDefinition` `ScriptableObject` — race content bundle (tower roster, race-specific units, builder variants, starting bonuses)
- Race-pick UI (in-match overlay) — grid of race cards, timer-based auto-lock. First concrete `MatchState` consumer.
- Multi-builder race support — revisit `PlayerBuilderSpawner` to spawn N builders
- `TowerRegistry` filtering by active match's race rosters
- Auto-discovery of `RaceDefinition` assets (mirror the `Resources.LoadAll` pattern from `TowerRegistry`)
**Already done (delivered with 1.7):**
- `RaceDefinition` ScriptableObject with Identity / Builder / Lore / Gameplay-payload sections
- `RaceRegistry` DontDestroyOnLoad singleton (placed in MainMenu, persists into Lobby + Match)
- `RaceId` enum (None + Race1..Race16) — 16-slot grid reserved
- Lobby race-selection overlay (4×4 grid + detail panel + exclusivity enforcement)
- `PlayerMatchState.RaceSelection` NetworkVariable + `SubmitRaceRpc`
- `PlayerBuilderSpawner` reads race-specific `BuilderPrefab` when available
- Two placeholder RaceDefinition assets configured with the default builder (proves the data path works without race-specific content)
**Still pending:**
- Replace lobby race-pick with in-match race-pick overlay (timer-based auto-lock, `MatchState.RacePickTimer`) — OR retain lobby pick and remove the in-match flow concept. **Open decision** (see 1.10 reconciliation question).
- Multi-builder race support — revisit `PlayerBuilderSpawner` to spawn N builders for races that need them
- `TowerRegistry` filtering by active match's race rosters (currently shows all registered towers regardless of race)
- Auto-discovery of `RaceDefinition` assets (today's flow: drag each asset into `RaceRegistry.Definitions` manually)
- Replace `TowerPlacementManager.towerDefinitions[]` inspector array with race-driven discovery
- Race-specific builder prefabs (currently every race uses the same default builder)
- Real race content (display names, lore, icons, distinct builder visuals) — placeholder races exist but are interchangeable
### 1.9 Camera polish