Log inGet started
◇
component · drop-in viewer
asset⌬ componentcomponentprimary: init.luau·originates fromworld af925970-0…

NeedleField

The mechanic of THE LAST STRAW. Attaches to the `NeedleField` director entity in `scenes/main.scene`. It needs nothing from another slice: it reads and writes `game.shared.game`'s state and event bus, and the HUD, the hands and the audio listen to it there.

by◐Deata·posted 1mo ago
What it does

NeedleField

The mechanic of THE LAST STRAW. Attaches to the NeedleField director entity in scenes/main.scene. It needs nothing from another slice: it reads and writes game.shared.game's state and event bus, and the HUD, the hands and the audio listen to it there.

What it draws

All 5600 needles are one mesh in one instanced draw (renderer.mesh.drawInstanced) placed by a GPU buffer of mat4s (substrate.createBuffer, type = "mat4", len = 5600). Nothing here is an entity per needle. Two further one-instance draws reuse the same mesh: a golden sleeve marking the needle under the crosshair, and the Last Straw itself. A needle moves by rewriting the 16 floats that belong to it; the buffer is only written when something actually changed, so a still field costs no copy per frame (renderer.uploadStats() stays flat while nothing moves).

The needle mesh is generated in game.field.field (six-sided shaft, ground point, pierced eye) rather than with mesh_gen: a needle has no detail a generator would add, and 5600 copies of a cheap mesh is what keeps the draw inside its budget.

What it decides

  • Target — one ray from the player camera, intersected with each bale's face plane, resolved to a (col, row) cell with a 9 cm aim tolerance, then walked from the front layer inward to the first needle still seated. Ten cheap tests a frame, no physics. Written to GAME.state.target.
  • Grip — LMB pulls the target along its axis over 0.3 s, then it is in the hand (GAME.state.held, "needle.held"). Release drops it to a resting place on the floor that is deterministic in the needle's index (so a save restores every one exactly), emits "needle.dropped" and "needle.pulled", and raises GAME.state.moved.
  • Codex — a witness needle unlocks its fragment on the pull that removes it ("codex.unlocked").
  • Proximity — camera distance to GAME.strawSite(seed), smoothed into GAME.state.attunement. Nothing is emitted per frame; the HUD polls.
  • The straw — seated at the far layer of its cell, so the needles in front of it must come out before it shows. Pulling it sets found, phase = "found" and fires "straw.found".
  • Save — runtime_data.player(runtime_data.localId()) under save/seed, save/moved, save/found, save/codex, save/removed (run-length encoded) and save/at. Written on every eighth pull, on straw.found, and on the way out of the world, so a needle pulled in a short session is still a needle pulled. "save.changed" tells the HUD to blink SAVED.

Input is accepted only while GAME.state.phase == "playing".

How it reads the player

The camera is camera.main() (falling back to the entity named CameraRig), whose pose gives the ray. LMB is Zin.state.mouseButtonPressed("left") / mouseButtonReleased("left"), the documented per-frame snapshot read. It never activates an input map of its own, so it cannot take the pointer from the camera controller.

A note on GAME.strawSite

strawSite(seed) names the bale and cell the straw is buried in and returns the cell's front layer. This component keeps the cell and seats the straw at the far layer of it through the module's own needleSeat, which is what the spec asks for ("buried", "every needle in front of it must come out first"). If strawSite itself starts returning the back layer, game.field.field's strawSeat is the one place to change.

Interface

What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.

conforms to

zero/source-extract/v2

game.parts.NeedleField — the mechanic of THE LAST STRAW. The whole field of 5600 needles is ONE mesh drawn in ONE instanced call: two GPU transform buffers (the field, and a single-instance golden highlight) hold every placement, and a needle moves by rewriting the 16 floats that belong to it. Nothing here is an entity per needle. What it owns, per the spec: what is under the crosshair (GAME.state.target), what is in the hand (GAME.state.held), the count of needles pulled, the Codex fragments etched on witness needles, the buried straw, proximity and the per-player save. Everything else reads GAME.state and the bus.

store( ) → void

Progress is GLOBAL: everyone in the vault shares one count of straws found, one Codex, and one field. A shared win only means something if the ledger is shared too.

clamp01(v: ?) → void

argtypedescription
v?

putMatrix(index: ?, m: ?) → void

argtypedescription
index?
m?

hideInstance(buf: ?) → void

A draw cannot be switched off by setting its instance count to zero, so a hidden instance is parked far below the floor at a scale of nothing.

argtypedescription
buf?

putSeated(index: ?) → void

A needle as it sits in the pile: along the bale's normal, with a small deterministic tilt so the field reads as bristles and not as a print.

argtypedescription
index?

putFallen(index: ?, scale: ?) → void

Where a needle comes to rest. Deterministic in its index, so a restored save puts every one of them back exactly where it lay.

argtypedescription
index?
scale?

hideSlot(index: ?) → void

The needle that lives at the straw's slot is the straw itself: it is never drawn as steel, so it gets a degenerate transform and no one can target it.

argtypedescription
index?

currentAxis(index: ?) → void

argtypedescription
index?

cameraPose( ) → void

rot(vx: ?, vy: ?, vz: ?) → void

argtypedescription
vx?
vy?
vz?

frontmostAt(bale: ?, col: ?, row: ?) → void

argtypedescription
bale?
col?
row?

strawCellOpen( ) → void

resolveTarget(pose: ?) → void

argtypedescription
pose?

setTarget(index: ?, isStraw: ?) → void

argtypedescription
index?
isStraw?

placeHeld(pose: ?) → void

argtypedescription
pose?

startGrip( ) → void

unlockFragment(index: ?) → void

argtypedescription
index?

recordRemoved(index: ?) → void

argtypedescription
index?

noteDug(index: ?) → void

One needle's worth of warmth. Only needles near the straw count, and one at the straw itself counts most, so the meter fills as you clear the ground around the right cell and stays flat everywhere else.

argtypedescription
index?

releaseGrip( ) → void

saveState( ) → void

(forward declared above, because the hand's release path is what triggers it)

buildField( ) → void

seatStraw( ) → void

loadSeed( ) → void

restoreProgress( ) → void

The rest of the save. Reads the straw's slot, so it runs after seatStraw.

start( ) → void

update(dt: ?) → void

argtypedescription
dt?

onDestroy( ) → void

Problems

Everything affecting this asset right now: its own problems, anything wrong inside it, and problems on its direct dependencies.

0problems
No problems reported. This asset, its contents, and its direct deps are clean as of the latest commit.
⌬ZeroMind agent review · awaiting first pass
Findings
Reviewer findings (handle · model · tag · quoted note) appear here once the per-pass review log lands. Today only the rolled-up agent_score is exposed.
usability—
did it work as advertised
quality—
authoring polish + cohesion
performance—
frame & memory budget held
agent review score
—
/ 100
awaiting first pass
usability × 0.40
+ quality × 0.35
+ performance × 0.25
± compat factor

Usability ratings

Did the part work as advertised when consumers tried to drop it in. Separate from upvotes: those are taste; this is "did it function".

—%no reports yet
Sign in to report whether this part worked for you.
Discussion

Scoped to this part · feeds back into the world's score.

0comments
Sign in to post.sign in
No comments yet. Be the first.