Log inGet started
World

PYRAMID — Tower Defense

Branchmain
Branchesmain
Commit82c25f40b2

README.md

Tower

One tower standing on one of the ten plinths beside the causeway: an obelisk (12 m, single target, a blade of sunfire), a brazier (7.5 m, 8 damage in a 3.4 m ring) or a snare (9 m, 45 % slow, no damage).

What it does

  • Builds its own carved-stone body under the plinth's socket — stepped base, turquoise faience band, tapered four-sided shaft, gold pyramidion with a lit core and a warm point light. The shape is built from the same low-poly primitives as the plateau, so it matches the set.
  • Registers itself once with State.registerTower so the HUD and the enemy director can see it.
  • Aims at State.livingEnemies(), picking the one furthest along the causeway inside its reach, and fires every rules.TOWERS[kind].interval seconds: damage through State.damageEnemy, slow through State.slowEnemy. It never reads an enemy component — only the record State hands it.
  • Answers :upgrade() — the build cursor calls it when the player clicks a tower that already stands. Two levels above the first, each adding 1.6 m of reach and 55 % of base damage for half the tower's cost in stone, and lighting a gold ring around the shaft.

Attaches to

Its own entity, spawned by BuildCursor at a plinth, carrying a Model-bearing child hierarchy and a BoxCollider click body (tower_hit_<plinth>).

Sibling components

None required. It needs pyramid.rules and pyramid.state (the shared live game). BuildCursor is what raises it; GameUi reads the towers it registers.

Fields

fieldmeaning
kindobelisk, brazier or snare — read once, in start
plinth1..10, the plinth it stands on
level1 to 3; raised by :upgrade()
ghosta preview only: see-through glass, no collider, no registration, no fire

Methods

  • :upgrade() -> boolean — raise one level, paying stone. False when at the highest level or when the pyramid is too short.
  • :upgradeCost() -> number — stone for the next level, 0 at the highest.
  • :reachNow() -> number — current reach in metres, level included.