Class TerrainMovementCostCalculator
ENGINE LAYER: Movement cost calculator based on terrain types.
Provides MECHANISM only - looks up terrain costs from registry. Does NOT decide what's passable (that's GAME layer policy).
Usage: // ENGINE: Just terrain costs, everything passable var calculator = new TerrainMovementCostCalculator(provinceSystem, terrainRegistry);
// GAME: Wrap with game-specific traversability rules var gameCalculator = new LandUnitCostCalculator(calculator); // blocks water var navalCalculator = new NavalUnitCostCalculator(calculator); // blocks land
GAME layer implements IMovementCostCalculator with:
- Unit type checks (land/naval/amphibious)
- Ownership penalties (enemy territory)
- Supply/attrition considerations
public class TerrainMovementCostCalculator : IMovementCostCalculator
- Inheritance
-
objectTerrainMovementCostCalculator
- Implements
Constructors
TerrainMovementCostCalculator(ProvinceSystem, Registry<TerrainData>)
public TerrainMovementCostCalculator(ProvinceSystem provinceSystem, Registry<TerrainData> terrainRegistry)
Parameters
provinceSystemProvinceSystemterrainRegistryRegistry<TerrainData>
Methods
CanTraverse(ushort, PathContext)
ENGINE: All provinces are traversable. GAME layer wraps this and adds policy (water/land restrictions, etc.)
public bool CanTraverse(ushort provinceId, PathContext context)
Parameters
provinceIdushortcontextPathContext
Returns
- bool
GetHeuristic(ushort, ushort)
Get heuristic estimate (for A*). Returns zero (Dijkstra) - safe but not optimal. GAME layer can provide distance-based heuristics if coordinates available.
public FixedPoint64 GetHeuristic(ushort fromProvinceId, ushort goalProvinceId)
Parameters
fromProvinceIdushortgoalProvinceIdushort
Returns
GetMovementCost(ushort, ushort, PathContext)
Get movement cost based on destination terrain. Cost is determined by the terrain of the province being entered.
public FixedPoint64 GetMovementCost(ushort fromProvinceId, ushort toProvinceId, PathContext context)
Parameters
fromProvinceIdushorttoProvinceIdushortcontextPathContext
Returns
GetProvinceTerrain(ushort)
Get terrain ID for a province. Useful for GAME layer to make policy decisions.
public ushort GetProvinceTerrain(ushort provinceId)
Parameters
provinceIdushort
Returns
- ushort
GetTerrainCost(ushort)
Get the movement cost for a specific terrain type. Useful for GAME layer wrappers that need raw terrain costs.
public FixedPoint64 GetTerrainCost(ushort terrainId)
Parameters
terrainIdushort
Returns
IsProvinceWater(ushort)
Check if a province is water terrain. Convenience method combining GetProvinceTerrain and IsTerrainWater.
public bool IsProvinceWater(ushort provinceId)
Parameters
provinceIdushort
Returns
- bool
IsTerrainWater(ushort)
Check if a terrain type is water. Useful for GAME layer to implement land/naval unit restrictions.
public bool IsTerrainWater(ushort terrainId)
Parameters
terrainIdushort
Returns
- bool