# BP_CoreGameMode — Asset Implementation

> **UE5 Asset:** `/Game/Framework/Core/BP_CoreGameMode`
> **Parent Class:** `GM_CoreGameMode` (C++) or `GameModeBase`
> **Asset Type:** Blueprint Class (GameMode)

---

## Create This Asset

### Step 1: Create Blueprint
1. Content Browser → `Content/Framework/Core/`
2. Right-click → **Blueprint Class**
3. Parent: `GM_CoreGameMode` (C++) OR `GameModeBase`
4. Name: `BP_CoreGameMode`

### Step 2: Set as Default GameMode
**Project Settings → Maps & Modes → Default GameMode** → `BP_CoreGameMode`

### Step 3: Configure Class Defaults
| Variable | Type | Value |
|----------|------|-------|
| `GameState Class` | `AGS_CoreGameState` | `BP_CoreGameState` |
| `Player Controller Class` | `APlayerController` | Your `BP_CorePlayerController` |
| `Default Pawn Class` | `APawn` | Your GASP player pawn |
| `HUD Class` | `AHUD` | `WBP_HUDController` |

---

## What to Wire

### Function: TransitionToChapter
```
Input: ChapterTag (GameplayTag)

[BlueprintCallable]
  ├─ Branch: CurrentGamePhase == Loading?
  │   True → Print Warning: "Already loading" → Return
  ├─ Set CurrentChapterTag = ChapterTag
  ├─ Switch HasAuthority → True:
  │   ├─ Get GameInstance → Cast to GI_GameFramework
  │   ├─ SetGamePhase(Loading)
  │   ├─ Get GameState → Cast to GS_CoreGameState → SetChapter(ChapterTag)
  │   ├─ Open Level (by ChapterTag mapping — use Data Asset lookup)
  │   └─ On level loaded → SetGamePhase(InGame)
  └─ Call OnChapterTransition(ChapterTag)
```

### Function: HandlePlayerDead
```
Input: DeadController (AController)

[BlueprintCallable]
  ├─ IsValid(DeadController)? → False: Return
  ├─ Set bPauseAllowed = false
  ├─ Get GameInstance → Cast to GI_GameFramework → SetGamePhase(DeathLoop)
  └─ TODO: Route to respawn or AltDeathSpace
```

### Event Dispatchers to Create
| Dispatcher | Parameters |
|------------|-----------|
| `OnChapterTransition` | `NewChapter` (GameplayTag) |
| `OnGameOverTriggered` | `EndingTag` (GameplayTag) |

---

## Test It
- [ ] PIE: check output log for "GM_CoreGameMode::InitGame"
- [ ] Check that player spawns with correct pawn
- [ ] Call `TransitionToChapter` → phase changes to Loading → level loads
