# GameModeBase API

## Reality GameMode Base

Base class for all Reality Game Modes.

Handles:

* Game lifecycle
* Player flow (join, leave, spawn, death)
* Respawn & spectating
* Game phases
* Gameplay events

***

## Game Lifecycle

| Name                        | Type     | Description                                | Inputs                | Outputs |
| --------------------------- | -------- | ------------------------------------------ | --------------------- | ------- |
| Begin Game                  | Callable | Starts the game immediately                | —                     | —       |
| End Game                    | Callable | Ends the current game                      | —                     | —       |
| Has Game Started            | Pure     | Returns true if the game has started       | —                     | Boolean |
| Has Game Ended              | Pure     | Returns true if the game has ended         | —                     | Boolean |
| Wait For Players And Start  | Callable | Waits for players before starting the game | Min Players (Integer) | —       |
| Cancel Wait For Players     | Callable | Stops waiting for players                  | —                     | —       |
| Is Waiting For Players      | Pure     | Returns if waiting for players             | —                     | Boolean |
| Get Players Needed To Start | Pure     | Returns how many players are still needed  | —                     | Integer |
| Force Next Phase            | Callable | Forces transition to next phase            | —                     | —       |

***

## Player Management

| Name           | Type             | Description                    | Inputs            | Outputs |
| -------------- | ---------------- | ------------------------------ | ----------------- | ------- |
| On Player Join | Event            | Called when a player joins     | Player Controller | —       |
| On Player Exit | Event            | Called when a player leaves    | Player Controller | —       |
| On Post Login  | Event Dispatcher | Triggered after player login   | Player Controller | —       |
| On Pre Logout  | Event Dispatcher | Triggered before player leaves | Player Controller | —       |

***

## Player Spawn & Respawn

| Name                     | Type     | Description                               | Inputs                                                               | Outputs             |
| ------------------------ | -------- | ----------------------------------------- | -------------------------------------------------------------------- | ------------------- |
| Auto Spawn Player        | Callable | Automatically spawns or respawns a player | Player Controller, Spawn Type, Start Point Type, As Spectator (Bool) | Player Character    |
| Spawn Player At          | Callable | Spawns a player at a specific transform   | Player Controller, Transform, As Spectator (Bool)                    | Player Character    |
| Set Player To Spectating | Callable | Sets player as spectator                  | Player Controller                                                    | Spectator Character |
| Add Pending Respawn      | Callable | Adds a delayed respawn                    | Player Controller, Time (Float)                                      | Boolean             |
| Has Pending Respawn      | Callable | Checks if player has pending respawn      | Player Controller                                                    | Boolean             |
| Remove Pending Respawn   | Callable | Removes pending respawn                   | Player Controller                                                    | —                   |
| Force Respawn Player     | Callable | Forces immediate respawn                  | Player Controller                                                    | —                   |

***

## Player Events

| Name                      | Type     | Description                          | Inputs                                          | Outputs |
| ------------------------- | -------- | ------------------------------------ | ----------------------------------------------- | ------- |
| On Player Spawn           | Event    | Called when a player spawns          | Player Controller, Player Character             | —       |
| On Player Die             | Event    | Called when a player dies            | Player Controller, Kill Info                    | —       |
| On Player Kill Player     | Event    | Called when a player kills another   | Killer Controller, Victim Controller, Kill Info | —       |
| On Player Spectating      | Event    | Called when player becomes spectator | Player Controller                               | —       |
| On Player Request Respawn | Event    | Called when player requests respawn  | Player Controller                               | —       |
| Kill Player               | Callable | Instantly kills player               | Player Controller                               | —       |

***

## Event Dispatchers

### Game Events

| Name          | Description                    |
| ------------- | ------------------------------ |
| On Game Start | Triggered when the game starts |
| On Game End   | Triggered when the game ends   |

***

### Player Events

| Name                       | Description                         |
| -------------------------- | ----------------------------------- |
| On Player Die              | Fired when a player dies            |
| On Player Kill             | Fired when a player kills another   |
| On Player Spawn            | Fired when a player spawns          |
| On Player Join             | Fired when a player joins           |
| On Player Exit             | Fired when a player exits           |
| On Player Became Spectator | Fired when player becomes spectator |
| On Player Request Respawn  | Fired on respawn request            |

***

### Preload

| Name                 | Description                  |
| -------------------- | ---------------------------- |
| On Preload Completed | Called when preload finishes |

***

## Game Phase System

| Name                   | Type     | Description               | Inputs | Outputs            |
| ---------------------- | -------- | ------------------------- | ------ | ------------------ |
| Get Game Phase Manager | Callable | Returns the phase manager | —      | Game Phase Manager |
| Get Current Phase      | Callable | Returns the current phase | —      | Game Phase         |

***

## Execution System

| Name                   | Type     | Description                   | Inputs              | Outputs |
| ---------------------- | -------- | ----------------------------- | ------------------- | ------- |
| Execute Player Event   | Callable | Executes a player event       | Event, Context      | —       |
| Execute GameMode Event | Callable | Executes a GameMode event     | Event, Context      | —       |
| Execute Custom Event   | Callable | Executes a custom named event | Event Name, Context | —       |

***

## Data & Settings

| Name         | Type     | Description               | Inputs | Outputs   |
| ------------ | -------- | ------------------------- | ------ | --------- |
| Get Data     | Callable | Returns GameMode data     | —      | Game Data |
| Get Settings | Pure     | Returns GameMode settings | —      | Settings  |

***

### Properties

| Name                     | Description                     |
| ------------------------ | ------------------------------- |
| Data                     | Core GameMode data (required)   |
| Default Player Data      | Default player configuration    |
| Default Spectator Data   | Default spectator configuration |
| Player Controller Class  | Controller class used           |
| Game State Class         | Game state class                |
| Player State Class       | Player state class              |
| Support Restart Game     | Enables restart functionality   |
| Game Settings Data Class | Settings class used             |

***

## Utility

| Name                      | Type     | Description              | Inputs        | Outputs  |
| ------------------------- | -------- | ------------------------ | ------------- | -------- |
| Get Reality GameMode Base | Pure     | Returns current GameMode | World Context | GameMode |
| Log Info                  | Callable | Logs info message        | String        | —        |
| Log Warning               | Callable | Logs warning message     | String        | —        |
| Log Error                 | Callable | Logs error message       | String        | —        |

***

## Initialization Events

| Name                 | Type  | Description                 |
| -------------------- | ----- | --------------------------- |
| Post Init Game       | Event | Called after game init      |
| Post Init Settings   | Event | Called after settings init  |
| Post Init Game State | Event | Called after GameState init |

***

## Game Events

| Name          | Type  | Description             |
| ------------- | ----- | ----------------------- |
| On Game Start | Event | Called when game starts |
| On Game End   | Event | Called when game ends   |

***

## Travel & Restart

| Name                | Type  | Description               |
| ------------------- | ----- | ------------------------- |
| On Pre Restart Game | Event | Called before restart     |
| On Post Travel      | Event | Called after level travel |

***

## Misc

| Name                   | Type     | Description                    | Outputs |
| ---------------------- | -------- | ------------------------------ | ------- |
| Preload Completed      | Callable | Returns preload state          | Boolean |
| Character Die Callback | Event    | Called when any character dies | —       |

***

## Summary

`Reality GameMode Base` is the **core gameplay controller**.

It provides:

* Player lifecycle control
* Event-driven gameplay system
* Spawn & respawn management
* Phase-based architecture


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://beyond-sandbox.gitbook.io/realitysdk/documentation/gamemode/gamemode-api/gamemodebase-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
