Table of Contents

Class TerrainMovementCostCalculator

Namespace
Core.Systems
Assembly
Core.dll

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
object
TerrainMovementCostCalculator
Implements

Constructors

TerrainMovementCostCalculator(ProvinceSystem, Registry<TerrainData>)

public TerrainMovementCostCalculator(ProvinceSystem provinceSystem, Registry<TerrainData> terrainRegistry)

Parameters

provinceSystem ProvinceSystem
terrainRegistry Registry<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

provinceId ushort
context PathContext

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

fromProvinceId ushort
goalProvinceId ushort

Returns

FixedPoint64

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

fromProvinceId ushort
toProvinceId ushort
context PathContext

Returns

FixedPoint64

GetProvinceTerrain(ushort)

Get terrain ID for a province. Useful for GAME layer to make policy decisions.

public ushort GetProvinceTerrain(ushort provinceId)

Parameters

provinceId ushort

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

terrainId ushort

Returns

FixedPoint64

IsProvinceWater(ushort)

Check if a province is water terrain. Convenience method combining GetProvinceTerrain and IsTerrainWater.

public bool IsProvinceWater(ushort provinceId)

Parameters

provinceId ushort

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

terrainId ushort

Returns

bool