Struct ProvinceQueryBuilder
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
provinceSystemProvinceSystemadjacencySystemAdjacencySystem
Methods
AdjacentTo(ushort)
Filter to provinces adjacent to a specific province. Requires AdjacencySystem.
public ProvinceQueryBuilder AdjacentTo(ushort provinceId)
Parameters
provinceIdushort
Returns
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
countryIdushort
Returns
ControlledBy(ushort)
Filter to provinces controlled by specific country.
public ProvinceQueryBuilder ControlledBy(ushort countryId)
Parameters
countryIdushort
Returns
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
allocatorAllocator
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
IsOcean()
Filter to ocean provinces only (terrain == 0).
public ProvinceQueryBuilder IsOcean()
Returns
IsOwned()
Filter to owned provinces only (owner != 0).
public ProvinceQueryBuilder IsOwned()
Returns
IsUnowned()
Filter to unowned provinces only (owner == 0).
public ProvinceQueryBuilder IsUnowned()
Returns
OwnedBy(ushort)
Filter to provinces owned by specific country.
public ProvinceQueryBuilder OwnedBy(ushort countryId)
Parameters
countryIdushort
Returns
WithTerrain(ushort)
Filter to provinces with specific terrain type.
public ProvinceQueryBuilder WithTerrain(ushort terrainType)
Parameters
terrainTypeushort
Returns
WithinDistance(ushort, byte)
Filter to provinces within N hops of source province. Requires AdjacencySystem.
public ProvinceQueryBuilder WithinDistance(ushort sourceProvinceId, byte maxDistance)
Parameters
sourceProvinceIdushortmaxDistancebyte