hex-world
    Preparing search index...

    Class HexUnit

    Index

    Constructors

    Properties

    col: number

    Current logical cell column (updates as unit enters each new cell).

    row: number

    Current logical cell row (updates as unit enters each new cell).

    travelSpeed: number
    heightOffset: number
    fogRevealRange: number
    surfaceOptions: CellSurfaceOptions
    isLiquid: ((terrain: number) => boolean) | null
    embarked: boolean = false

    True while the unit stands on a liquid cell — afloat. Set from the start cell on the first update and flipped as the unit crosses a shoreline, with onEmbark / onDisembark fired at the crossing. Always false for a unit with no isLiquid predicate.

    worldX: number = 0

    Smoothly interpolated world-space X. Read by UnitManager each frame.

    worldY: number = 0

    Smoothly interpolated world-space Y (terrain elevation + heightOffset).

    worldZ: number = 0

    Smoothly interpolated world-space Z.

    facing: number = 0

    Facing direction in radians around the Y axis. Applied to Object3D.rotation.y.

    isMoving: boolean = false
    onMoveStart?: () => void

    Called when the unit starts following a new path. Use this to trigger a walk/run animation on your GLTF model.

    onCellEnter?: (col: number, row: number) => void

    Called each time the unit enters a new hex cell during movement. Use this to trigger footstep sounds, update fog, etc.

    onMoveEnd?: (completed: boolean) => void

    Called when the unit stops moving — either because it walked its path to the end (completed: true) or because stop cut the move short (completed: false). Use this to return to an idle animation; check the flag when "arrived" has to mean arrived (turn resolution, triggers).

    onEmbark?: (col: number, row: number) => void

    Called when the unit steps from land onto a liquid cell — swap the walker for the boat here. Fires before onCellEnter for that cell.

    onDisembark?: (col: number, row: number) => void

    Called when the unit steps from a liquid cell onto land. Fires before onCellEnter.

    Methods

    • Starts the unit moving along a path. path[0] should be the unit's current position (it is used as the segment start but the unit does not fire onCellEnter for it). Pass a path returned by findPath().

      Parameters

      Returns void

    • Immediately halts movement at the current interpolated position.

      Returns void