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
-
objectGameState
Properties
Adjacencies
public AdjacencySystem Adjacencies { get; }
Property Value
CommandProcessor
public CommandProcessor CommandProcessor { get; }
Property Value
Countries
public CountrySystem Countries { get; }
Property Value
CountryQueries
public CountryQueries CountryQueries { get; }
Property Value
Diplomacy
public DiplomacySystem Diplomacy { get; }
Property Value
EventBus
public EventBus EventBus { get; }
Property Value
Instance
Singleton access for global game state
public static GameState Instance { get; }
Property Value
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
Pathfinding
public PathfindingSystem Pathfinding { get; }
Property Value
ProvinceQueries
public ProvinceQueries ProvinceQueries { get; }
Property Value
Provinces
public ProvinceSystem Provinces { get; }
Property Value
Registries
public GameRegistries Registries { get; }
Property Value
Resources
public ResourceSystem Resources { get; }
Property Value
Time
public TimeManager Time { get; }
Property Value
Units
public UnitSystem Units { get; }
Property Value
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
countryIdushort
Returns
GetCountryProvinces(ushort)
Complex cross-system query - get all provinces owned by a country
public NativeArray<ushort> GetCountryProvinces(ushort countryId)
Parameters
countryIdushort
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
provinceIdushort
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
systemT
Type Parameters
T
SetRegistries(GameRegistries)
Set game registries (called by EngineInitializer during loading)
public void SetRegistries(GameRegistries registries)
Parameters
registriesGameRegistries
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
commandT
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
commandTresultMessagestring
Returns
- bool
Type Parameters
T