Harvest driftwood, stone and scrap with a melee tool. Carry limits per material, shown through the simulation state.
Acceptance
Server-validated range and swing rate.
Yields and caps come from the tunable table.
Tests cover harvesting, caps and prop destruction.
**Depends on:** W5
Harvest driftwood, stone and scrap with a melee tool. Carry limits per material, shown through the simulation state.
**Acceptance**
- Server-validated range and swing rate.
- Yields and caps come from the tunable table.
- Tests cover harvesting, caps and prop destruction.
claude
added this to the v0.3 Building and Combat milestone 2026-11-09 05:26:54 +00:00
Materials (src/sim/materials.gd): driftwood, stone and salvage iron codes, with add/spend helpers. A player's stock is SimEntity.materials, capped at MATERIAL_CAP each and included in the state hash, so it's visible through the simulation state.
Harvest (src/sim/harvest.gd): holding fire with the boathook (selection 0, outside build mode) swings once every ceil(30 / fire_rate) = 20 ticks. The server casts the swing from its own copy of the player's eye and look, reaching the boathook's range_max plus HARVEST_REACH_SLACK. It hits the nearest standing prop within HARVEST_AIM_SLACK of the ray unless terrain or another solid is in the way. Each hit does HARVEST_DAMAGE (50) and gives HARVEST_PER_HIT (15) of the prop's material. A capped player still damages props.
The simulation now has a per-tick events list (harvest, prop_destroyed) and a shared action_cooldown that B2 placement and B6 weapons will reuse.
Tests:test/sim/test_harvest.gd, 12 tests: yields per prop kind, swing-rate enforcement while fire is held, reach limits, a wall blocking the swing, nearest prop, cap behaviour, destruction clearing collision (the player then walks through), no swinging in build mode, in other slots, swimming or falling, and determinism on a real island. make check passed: 163 tests, self-check, and smoke at p95 0.53 ms per tick.
Follow-ups: the boathook will be folded into B6's weapon framework, and B5 decides how selection maps to inventory slots. Hit feedback (sound, particles) belongs to v0.6.
Done in b847ba9.
**What changed**
- `Materials` (`src/sim/materials.gd`): driftwood, stone and salvage iron codes, with add/spend helpers. A player's stock is `SimEntity.materials`, capped at `MATERIAL_CAP` each and included in the state hash, so it's visible through the simulation state.
- `Harvest` (`src/sim/harvest.gd`): holding fire with the boathook (selection 0, outside build mode) swings once every `ceil(30 / fire_rate)` = 20 ticks. The server casts the swing from its own copy of the player's eye and look, reaching the boathook's `range_max` plus `HARVEST_REACH_SLACK`. It hits the nearest standing prop within `HARVEST_AIM_SLACK` of the ray unless terrain or another solid is in the way. Each hit does `HARVEST_DAMAGE` (50) and gives `HARVEST_PER_HIT` (15) of the prop's material. A capped player still damages props.
- The simulation now has a per-tick `events` list (`harvest`, `prop_destroyed`) and a shared `action_cooldown` that B2 placement and B6 weapons will reuse.
**Tests:** `test/sim/test_harvest.gd`, 12 tests: yields per prop kind, swing-rate enforcement while fire is held, reach limits, a wall blocking the swing, nearest prop, cap behaviour, destruction clearing collision (the player then walks through), no swinging in build mode, in other slots, swimming or falling, and determinism on a real island. `make check` passed: 163 tests, self-check, and smoke at p95 0.53 ms per tick.
**Follow-ups:** the boathook will be folded into B6's weapon framework, and B5 decides how selection maps to inventory slots. Hit feedback (sound, particles) belongs to v0.6.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Depends on: W5
Harvest driftwood, stone and scrap with a melee tool. Carry limits per material, shown through the simulation state.
Acceptance
Done in
b847ba9.What changed
Materials(src/sim/materials.gd): driftwood, stone and salvage iron codes, with add/spend helpers. A player's stock isSimEntity.materials, capped atMATERIAL_CAPeach and included in the state hash, so it's visible through the simulation state.Harvest(src/sim/harvest.gd): holding fire with the boathook (selection 0, outside build mode) swings once everyceil(30 / fire_rate)= 20 ticks. The server casts the swing from its own copy of the player's eye and look, reaching the boathook'srange_maxplusHARVEST_REACH_SLACK. It hits the nearest standing prop withinHARVEST_AIM_SLACKof the ray unless terrain or another solid is in the way. Each hit doesHARVEST_DAMAGE(50) and givesHARVEST_PER_HIT(15) of the prop's material. A capped player still damages props.eventslist (harvest,prop_destroyed) and a sharedaction_cooldownthat B2 placement and B6 weapons will reuse.Tests:
test/sim/test_harvest.gd, 12 tests: yields per prop kind, swing-rate enforcement while fire is held, reach limits, a wall blocking the swing, nearest prop, cap behaviour, destruction clearing collision (the player then walks through), no swinging in build mode, in other slots, swimming or falling, and determinism on a real island.make checkpassed: 163 tests, self-check, and smoke at p95 0.53 ms per tick.Follow-ups: the boathook will be folded into B6's weapon framework, and B5 decides how selection maps to inventory slots. Hit feedback (sound, particles) belongs to v0.6.