Table of Contents

Class GameState

Namespace
Core
Assembly
Core.dll

Central hub for all game data access - follows hub-and-spoke architecture Provides unified access to all game systems without owning the data Performance: All queries should be <0.01ms, zero allocations during gameplay

ARCHITECTURE: Engine-Game Separation

  • Core systems (Provinces, Countries, Time) are owned by Engine
  • Game layer systems (Economy, Buildings, etc.) register themselves via RegisterGameSystem
  • Engine provides mechanism (registration), Game provides policy (specific systems)
public class GameState : MonoBehaviour
Inheritance
object
GameState

Properties

Adjacencies

public AdjacencySystem Adjacencies { get; }

Property Value

AdjacencySystem

CommandProcessor

public CommandProcessor CommandProcessor { get; }

Property Value

CommandProcessor

Countries

public CountrySystem Countries { get; }

Property Value

CountrySystem

CountryQueries

public CountryQueries CountryQueries { get; }

Property Value

CountryQueries

Diplomacy

public DiplomacySystem Diplomacy { get; }

Property Value

DiplomacySystem

EventBus

public EventBus EventBus { get; }

Property Value

EventBus

Instance

Singleton access for global game state

public static GameState Instance { get; }

Property Value

GameState

IsInitialized

public bool IsInitialized { get; }

Property Value

bool

IsLoading

public bool IsLoading { get; }

Property Value

bool

LoadingProgress

public float LoadingProgress { get; }

Property Value

float

Modifiers

public ModifierSystem Modifiers { get; }

Property Value

ModifierSystem

Pathfinding

public PathfindingSystem Pathfinding { get; }

Property Value

PathfindingSystem

ProvinceQueries

public ProvinceQueries ProvinceQueries { get; }

Property Value

ProvinceQueries

Provinces

public ProvinceSystem Provinces { get; }

Property Value

ProvinceSystem

Registries

public GameRegistries Registries { get; }

Property Value

GameRegistries

Resources

public ResourceSystem Resources { get; }

Property Value

ResourceSystem

Time

public TimeManager Time { get; }

Property Value

TimeManager

Units

public UnitSystem Units { get; }

Property Value

UnitSystem

Methods

GetAllRegisteredGameSystems()

Get all registered Game layer systems (for save/load) Returns only systems that inherit from GameSystem

public IEnumerable<GameSystem> GetAllRegisteredGameSystems()

Returns

IEnumerable<GameSystem>

GetCountryColor(ushort)

Get basic country information - most common query

public Color32 GetCountryColor(ushort countryId)

Parameters

countryId ushort

Returns

Color32

GetCountryProvinces(ushort)

Complex cross-system query - get all provinces owned by a country

public NativeArray<ushort> GetCountryProvinces(ushort countryId)

Parameters

countryId ushort

Returns

NativeArray<ushort>

GetGameSystem<T>()

Get a registered Game layer system for command execution Returns null if system not registered (allows graceful degradation)

public T GetGameSystem<T>() where T : class

Returns

T

Type Parameters

T

GetProvinceOwner(ushort)

Get basic province information - most common query

public ushort GetProvinceOwner(ushort provinceId)

Parameters

provinceId ushort

Returns

ushort

HasGameSystem<T>()

Check if a Game layer system is registered

public bool HasGameSystem<T>() where T : class

Returns

bool

Type Parameters

T

InitializeSystems()

Initialize all core systems in correct dependency order

public void InitializeSystems()

RegisterGameSystem<T>(T)

Register a Game layer system for command access ARCHITECTURE: Engine provides mechanism (registration), Game provides policy (specific systems) Engine doesn't know about EconomySystem, BuildingSystem, etc. - they register themselves

public void RegisterGameSystem<T>(T system) where T : class

Parameters

system T

Type Parameters

T

SetRegistries(GameRegistries)

Set game registries (called by EngineInitializer during loading)

public void SetRegistries(GameRegistries registries)

Parameters

registries GameRegistries

TryExecuteCommand<T>(T)

Unified command execution - all game state changes go through here Provides validation, event emission, and multiplayer sync

public bool TryExecuteCommand<T>(T command) where T : ICommand

Parameters

command T

Returns

bool

Type Parameters

T

TryExecuteCommand<T>(T, out string)

Execute a command with detailed result message (for console/UI feedback). In multiplayer, routes through CommandProcessor for network synchronization.

public bool TryExecuteCommand<T>(T command, out string resultMessage) where T : ICommand

Parameters

command T
resultMessage string

Returns

bool

Type Parameters

T