Game State Machine
The game state system uses a scoreboard to track the current state and dispatches handlers when the state matches.
It is a good fit for lobbies, round systems, multi-phase boss fights, tutorials, or any flow that repeatedly switches between a known set of named states.
Registering states
This generates a load function that creates the kore_state objective and sets the initial state.
Typical lifecycle
Keeping transitions explicit like this makes it easier to reason about which setup code belongs to each phase.
Transitioning and reacting
Game state actions
Helper functions integrate states with other OOP systems:
Best practices
- Keep the state list small and meaningful (
lobby,playing,ended, etc.). - Reserve
whenState(...)for behavior that should only run in one phase. - Use the integration helpers when a state change should also start a timer, consume a cooldown, or trigger a spawn.
