Table of Contents

Struct ProvinceQueryBuilder

Namespace
Core.Queries
Assembly
Core.dll

Fluent query builder for province filtering. Lazy evaluation - filters are applied when terminal operation is called.

Usage: using var results = new ProvinceQueryBuilder(provinceSystem) .OwnedBy(countryId) .IsLand() .Execute(Allocator.Temp);

Performance: O(P) where P = provinces, single pass with combined filters.

public struct ProvinceQueryBuilder

Constructors

ProvinceQueryBuilder(ProvinceSystem, AdjacencySystem)

public ProvinceQueryBuilder(ProvinceSystem provinceSystem, AdjacencySystem adjacencySystem = null)

Parameters

provinceSystem ProvinceSystem
adjacencySystem AdjacencySystem

Methods

AdjacentTo(ushort)

Filter to provinces adjacent to a specific province. Requires AdjacencySystem.

public ProvinceQueryBuilder AdjacentTo(ushort provinceId)

Parameters

provinceId ushort

Returns

ProvinceQueryBuilder

Any()

Check if any province matches the filters.

public bool Any()

Returns

bool

BorderingCountry(ushort)

Filter to provinces that border a specific country (owned by different country but adjacent). Requires AdjacencySystem.

public ProvinceQueryBuilder BorderingCountry(ushort countryId)

Parameters

countryId ushort

Returns

ProvinceQueryBuilder

ControlledBy(ushort)

Filter to provinces controlled by specific country.

public ProvinceQueryBuilder ControlledBy(ushort countryId)

Parameters

countryId ushort

Returns

ProvinceQueryBuilder

Count()

Count matching provinces without allocating result list.

public int Count()

Returns

int

Dispose()

Disposes resources allocated during query execution. Call this (or use 'using' statement) after Execute() if WithinDistance() filter was used, as it allocates a GraphDistanceCalculator internally.

public void Dispose()

Execute(Allocator)

Execute query and return matching province IDs. Caller must dispose the returned NativeList.

public NativeList<ushort> Execute(Allocator allocator)

Parameters

allocator Allocator

Returns

NativeList<ushort>

FirstOrDefault()

Get first matching province, or default if none.

public ushort FirstOrDefault()

Returns

ushort

IsLand()

Filter to land provinces only (terrain != 0).

public ProvinceQueryBuilder IsLand()

Returns

ProvinceQueryBuilder

IsOcean()

Filter to ocean provinces only (terrain == 0).

public ProvinceQueryBuilder IsOcean()

Returns

ProvinceQueryBuilder

IsOwned()

Filter to owned provinces only (owner != 0).

public ProvinceQueryBuilder IsOwned()

Returns

ProvinceQueryBuilder

IsUnowned()

Filter to unowned provinces only (owner == 0).

public ProvinceQueryBuilder IsUnowned()

Returns

ProvinceQueryBuilder

OwnedBy(ushort)

Filter to provinces owned by specific country.

public ProvinceQueryBuilder OwnedBy(ushort countryId)

Parameters

countryId ushort

Returns

ProvinceQueryBuilder

WithTerrain(ushort)

Filter to provinces with specific terrain type.

public ProvinceQueryBuilder WithTerrain(ushort terrainType)

Parameters

terrainType ushort

Returns

ProvinceQueryBuilder

WithinDistance(ushort, byte)

Filter to provinces within N hops of source province. Requires AdjacencySystem.

public ProvinceQueryBuilder WithinDistance(ushort sourceProvinceId, byte maxDistance)

Parameters

sourceProvinceId ushort
maxDistance byte

Returns

ProvinceQueryBuilder