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
+9
View File
@@ -177,8 +177,17 @@ const TIDE_PHASES: Array[Dictionary] = [
# Building
const GRID_CELL_METRES: float = 4.0
## The most of each material a player can carry.
const MATERIAL_CAP: int = 500
## Material gained per boathook hit on a prop, whatever the prop.
const HARVEST_PER_HIT: int = 15
## Damage a boathook hit does to a prop. Players take the boathook's `damage` instead.
const HARVEST_DAMAGE: int = 50
## A swing reaches this far past the boathook's range, from the eye, so a prop the body
## is touching is always in reach.
const HARVEST_REACH_SLACK: float = 0.4
## Props are hit if the swing passes within this distance of their box.
const HARVEST_AIM_SLACK: float = 0.25
## Material units each piece costs. Health and build time come from MATERIALS.
const BUILD_PIECES: Dictionary = {
"wall": {"cost": 10},