Table of Contents

Class CountryQueries

Namespace
Core.Queries
Assembly
Core.dll

High-performance country data access layer Provides optimized queries for country/nation information Performance: All basic queries <0.01ms, cached complex queries

public class CountryQueries
Inheritance
object
CountryQueries

Constructors

CountryQueries(CountrySystem, ProvinceSystem, AdjacencySystem)

public CountryQueries(CountrySystem countrySystem, ProvinceSystem provinceSystem, AdjacencySystem adjacencySystem)

Parameters

countrySystem CountrySystem
provinceSystem ProvinceSystem
adjacencySystem AdjacencySystem

Methods

ClearCache()

Clear all cached data

public void ClearCache()

CompareProvinceCount(ushort, ushort)

Compare two countries by province count Performance target: <0.1ms

public int CompareProvinceCount(ushort countryId1, ushort countryId2)

Parameters

countryId1 ushort
countryId2 ushort

Returns

int

Dispose()

public void Dispose()

Exists(ushort)

Check if country exists Performance target: <0.001ms

public bool Exists(ushort countryId)

Parameters

countryId ushort

Returns

bool

GetAllCountryIds(Allocator)

Get all active country IDs Returns native array that must be disposed by caller Performance target: <1ms

public NativeArray<ushort> GetAllCountryIds(Allocator allocator = Allocator.TempJob)

Parameters

allocator Allocator

Returns

NativeArray<ushort>

GetBorderingCountries(ushort, Allocator)

Get all countries that share a border with the specified country. Returns native list that must be disposed by caller. Performance target: O(P × N) where P = provinces, N = ~6 neighbors. Target: less than 15ms.

public NativeList<ushort> GetBorderingCountries(ushort countryId, Allocator allocator)

Parameters

countryId ushort
allocator Allocator

Returns

NativeList<ushort>

GetBorderingCountries(ushort, NativeList<ushort>)

Get all countries that share a border with the specified country. Zero-allocation variant - fills existing buffer. Performance target: O(P × N) where P = provinces, N = ~6 neighbors. Target: less than 15ms.

public void GetBorderingCountries(ushort countryId, NativeList<ushort> resultBuffer)

Parameters

countryId ushort
resultBuffer NativeList<ushort>

GetBorderingCountryCount(ushort)

Get the number of countries that share a border with the specified country. Performance target: less than 15ms.

public int GetBorderingCountryCount(ushort countryId)

Parameters

countryId ushort

Returns

int

GetColdData(ushort)

Get country cold data (detailed information, lazy-loaded) Performance target: <0.1ms if cached, variable if loading

public CountryColdData GetColdData(ushort countryId)

Parameters

countryId ushort

Returns

CountryColdData

GetColor(ushort)

Get country color - most common query (must be ultra-fast) Performance target: <0.001ms

public Color32 GetColor(ushort countryId)

Parameters

countryId ushort

Returns

Color32

GetCountryStatistics()

Get country statistics for debugging/UI (engine-only data - no game-specific fields) Performance target: <50ms for 256 countries Note: Development statistics removed (game-specific). Use HegemonCountryQueries for game stats.

public CountryStatistics GetCountryStatistics()

Returns

CountryStatistics

GetGraphicalCulture(ushort)

Get graphical culture ID for unit graphics Performance target: <0.001ms

public byte GetGraphicalCulture(ushort countryId)

Parameters

countryId ushort

Returns

byte

GetHotData(ushort)

Get complete country hot data (8-byte struct) Performance target: <0.001ms

public CountryHotData GetHotData(ushort countryId)

Parameters

countryId ushort

Returns

CountryHotData

GetIdFromTag(string)

Get country ID from tag Performance target: <0.001ms

public ushort GetIdFromTag(string tag)

Parameters

tag string

Returns

ushort

GetLandProvinceCount(ushort)

Get total land area (non-ocean provinces) owned by this country Performance target: <0.01ms if cached, <5ms if calculating

public int GetLandProvinceCount(ushort countryId)

Parameters

countryId ushort

Returns

int

GetProvinceCount(ushort)

Get number of provinces owned by this country Performance target: <0.01ms if cached, <5ms if calculating

public int GetProvinceCount(ushort countryId)

Parameters

countryId ushort

Returns

int

GetProvinces(ushort, Allocator)

Get provinces owned by this country Returns native array that must be disposed by caller Performance target: <5ms for 10k provinces

public NativeArray<ushort> GetProvinces(ushort countryId, Allocator allocator = Allocator.TempJob)

Parameters

countryId ushort
allocator Allocator

Returns

NativeArray<ushort>

GetTag(ushort)

Get country tag (3-letter code like "ENG", "FRA") Performance target: <0.001ms

public string GetTag(ushort countryId)

Parameters

countryId ushort

Returns

string

GetTotalCountryCount()

Get total number of countries in the system Performance target: <0.001ms

public int GetTotalCountryCount()

Returns

int

HasFlag(ushort, byte)

Check if country has specific flag/feature Performance target: <0.001ms

public bool HasFlag(ushort countryId, byte flag)

Parameters

countryId ushort
flag byte

Returns

bool

InvalidateCache(ushort)

Clear cache for a specific country (call when country data changes)

public void InvalidateCache(ushort countryId)

Parameters

countryId ushort

SharesBorder(ushort, ushort)

Check if two countries share any border provinces. Uses AdjacencySystem to check if any province of country1 is adjacent to any province of country2. Performance target: O(P × N) where P = provinces, N = ~6 neighbors. Target: less than 10ms.

public bool SharesBorder(ushort countryId1, ushort countryId2)

Parameters

countryId1 ushort
countryId2 ushort

Returns

bool