UI > Systems > Board Ghost System

UI system that manages the active board ghost. A ghost is a visual overlay that follows the cursor across tiles to indicate hover, placement validity, or targeting. Only one ghost is active at a time — switching modes destroys the previous ghost and creates the new one.

show() and hide() are driven by tile pointer events in GameBoardView. Validity is checked on show() against the viableTiles set when one is present.

set() is a no-op when the incoming ghost matches the current mode signature. Each type uses only the fields that would actually change the ghost visual:

set

Switches the active ghost mode. Destroys the current ghost and creates the appropriate replacement. No-ops if the mode signature has not changed.

move

Snaps the active ghost to the given tile and updates its validity state. Valid is true when no viableTiles set is present or the tile is in the set.

show

Shows the active ghost.

hide

Hides the active ghost.

setValid

Sets validity on the active ghost directly, bypassing the viableTiles check.

targetGhost

Returns the active ghost if it is a TargetGhost, otherwise null. TargetGhost is a special case - it supports a dual attack/move mode that requires direct access to toggle its visual state at the call site.

#setHover

Destroys the current ghost and replaces it with a default HoverGhost. Clears the viableTiles set.

#setTargetAttack

Destroys the current ghost and creates a TargetGhost with an optional AoE radius. Converts the TileData viable set to string keys once for O(1) show() lookups.




© Gamesanova 2026