Log inGet started
World

PYRAMID — Tower Defense

Branchmain
Branchesmain
Commit82c25f40b2

README.md

BuildCursor

The Keeper's hand. There is no player body: the player builds by pointing at the causeway.

What it does

  • Casts a ray from the pointer (Physics.raycastScreen) and reads which of the ten plinths it hit — the plinth's own BoxCollider, or the click body of a tower raised on it.
  • Shows a see-through preview of State.selected on the free plinth and a ring of ground showing the tower's reach: turquoise when the pyramid can pay, blood red when it cannot. Over a tower that already stands the ring turns gold and shows that tower's actual reach.
  • Raises the tower on a left click, paying rules.TOWERS[kind].cost through State.spend — the spend is the refusal, and a refused click flashes the ring red and places nothing.
  • Raises a standing tower one level when the player clicks it instead.
  • Ignores the pointer while the HUD has it (uiWantsPointer / uiTookPress), and only builds in the build and wave phases.

Attaches to

The scene's empty BuildCursor entity (the entrypoint hangs it there at play start). Towers it raises are parented to it, so a scene unload takes them along.

Sibling components

Tower — the preview is a Tower with ghost = true, so the ghost is exactly the tower that will be placed, geometry and all. It reads pyramid.state for the phase, the stone, the selection and the plinths that are already taken.

Fields

fieldmeaning
armedwhether pointing at the causeway can raise a tower right now