B1: Harvesting and materials

Boathook swings harvest props. The client only presses fire with the
boathook selected; the server casts the swing from its own copy of the
player's eye and look, so range and swing rate are enforced by
construction. Each hit damages the prop and gives its material
(driftwood, stone or salvage iron), capped per material.

- Materials: material codes and add/spend helpers; carried stock lives
  on SimEntity.materials and is part of the state hash.
- Harvest: swing interval from the boathook's fire rate, reach from its
  range plus slack, nearest prop along the ray, blocked by terrain or
  other solids. Emits harvest and prop_destroyed events.
- Simulation: per-tick events list, a shared action cooldown, and fire
  with selection 0 outside build mode swings.
- Tuning: HARVEST_DAMAGE, HARVEST_REACH_SLACK, HARVEST_AIM_SLACK.
- 12 tests: yields per kind, rate limit, reach, blocking, nearest prop,
  caps, destruction clearing collision, state gating and determinism on
  a real island.

Closes #15

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-11 14:11:15 -05:00
co-authored by Claude Opus 5.5
parent 21559a637d
commit b847ba9695
12 changed files with 376 additions and 1 deletions
+8 -1
View File
@@ -152,7 +152,14 @@ Pieces snap to a grid of `GRID_CELL_METRES` cells.
`BUILD_PIECES` holds what each piece costs. `MATERIALS` holds each material's `health`
and `build_seconds`, and materials trade speed for strength. A piece goes up quickly but
reaches full health only after its `build_seconds` have passed. Pieces with no connection
to the ground collapse. Each boathook hit harvests `HARVEST_PER_HIT` material.
to the ground collapse.
**Harvesting.** Holding fire with the boathook swings once every `1 / fire_rate` seconds.
A swing reaches the boathook's `range_max` plus `HARVEST_REACH_SLACK` from the eye, and
hits the nearest standing prop it passes within `HARVEST_AIM_SLACK` of, unless terrain or
a solid is in the way. Each hit does `HARVEST_DAMAGE` to the prop and gives
`HARVEST_PER_HIT` of the prop's material, up to `MATERIAL_CAP`. A player at the cap still
damages props. The server works all of this out itself; a client only says "fire".
**Breakwaters.** Each holds up to `BREAKWATER_MAX_HEAD` metres of water above its base.
Every second under pressure it loses `BREAKWATER_WEAR_PER_METRE` health per metre of