# CinderPylon
One survey pylon on the crown. Six instances, one per `pylon_N` entity, each
carrying its own `index`.
While the local player stands inside `cinder.CFG.pylonRadius` of the pylon's
site — and within `verticalReach` of its height, so somebody on the flank
directly below it does not count — the survey charges. At full charge the pylon
arms itself for good, swaps to `cinder.MATERIALS.pylonArmed`, and emits
`pylon.armed` once.
## Committing
Stepping out does not throw the survey away immediately. `holdSeconds` of grace
run first, so ducking a lava bomb and coming straight back costs almost
nothing. Past that the charge bleeds at `bleedRate` of the fill rate, so
walking away costs everything. Committing to a pylon is what it pays for.
## What it reports
`pylon.charging` fires every tick the charge MOVES, with
`{ index, charge, rising }` — `rising = true` while filling, `false` while
bleeding — so a charge indicator both fills and drains without polling.
`pylon.armed` fires once, with `{ index, x, y, z }`.
`cinder.state.pylonCharge[index]` carries the same number for anything that
would rather read state than subscribe.
## Fields
| Field | Default | Meaning |
|---|---|---|
| `index` | `1` | Which pylon this is, 1..`CFG.pylonCount`. Set in the scene. |
| `charge` | `0` | 0..1, replicated. |
| `armed` | `false` | True once the survey is complete, replicated. |
| `holdSeconds` | `0.55` | Grace after stepping out, before the bleed starts. |
| `bleedRate` | `0.55` | Bleed speed as a fraction of the fill speed. |
| `verticalReach` | `6.0` | How far above or below the pylon still counts as in it. |
## Resetting
Nothing here listens for a new run. `CinderDirector.beginRun()` resets every
pylon directly — charge, armed flag and material — so a restart has one owner
and cannot half-happen.
# CinderDirector
The run. One instance, on `GameRoot`. It owns `cinder.state` and is the only
thing that writes it.
Every tick it advances the eruption clock, drives the lava lake up the crater,
lets the hazard throw lava bombs, keeps the player on the surface of the
mountain, and decides when the run is won or lost.
## Public API
| Call | What it does |
|---|---|
| `beginRun()` | Start or restart a run from the top, from any phase. Resets the clock, the lava, the pylons, the heat and every hazard, and puts the player back at `cinder.spawnPoint()`. No scene reload. |
| `finish(result)` | End the run — `"won"`, `"lost:lava"` or `"lost:bombs"`. Clears the sky of bombs and emits `run.end`. |
| `damage(cause)` | Take one heat point. Ignored during i-frames. Emits `player.hit`, and `player.died` + `finish` at zero. |
| `countArmed()` | How many pylons are armed, counted from the pylons themselves. |
| `placePlayer(x, z)` | Put the local avatar on the ground at a world XZ, at rest. |
## Restarting
The `restart` control on the `cinderRun` input map (`R` on a keyboard, `Start`
on a pad, an on-screen button on a phone) calls `beginRun()`. Any other slice
can call `beginRun()` directly for its own restart affordance — it is safe from
`idle`, `running`, `won` and `lost` alike, and two calls in a row are the same
as one.
## Fields
| Field | Default | Meaning |
|---|---|---|
| `autoStart` | `true` | Begin a run the moment play starts. |
| `lavaEntity` | `lava_lake` | The entity whose top face is the lava surface. |
| `inputMap` | `@me::hazard.cinderRun` | Where the restart control comes from. |
| `drownGrace` | `1.5` | Seconds into a run before the lava can drown anyone. |
| `fallRescueY` | `-25` | Below this world Y the player has left the mountain. |
## Losing
- **Drowned** — the player is under the lava surface, inside the lake's own
horizontal extent (read from the lake entity, so it follows whatever the lake
is scaled to). The test arms only once the player has been seen *above* the
lava, so the frames before the avatar reaches its spawn can never read as a
drowning at the world origin.
- **Out of time** — the eruption reaches 1.0. By then the lake is over the rim
crest, so the crown is under it either way; both report `lost:lava`.
- **Out of heat** — three bomb impacts inside `CFG.bombRadius`.
## The mountain is solid
`cinder.groundHeight` is this game's single definition of where the ground is —
the terrain heightmap was baked from it. The director enforces that definition:
a player below the surface at their own XZ is put back onto it, and one who has
left the terrain entirely is put back at their last XZ on the mountain. Neither
costs heat, and neither fires while the character controller is standing on the
terrain by itself. This runs in every phase, before the phase gate, so the
player is on the mountain on the won card and the lost card too.
## Hot reload
The bus subscriptions are parked in `@me::hazard.cinderRuntime` under the key
`CinderDirector`, so a reload takes the previous incarnation's handlers down
and leaves every other slice's alone. The armed-pylon count is recomputed from
the pylons rather than incremented, so a duplicated event cannot inflate it.