Log inGet started
Package

WorkpieceSystem.component

Newest version

README.md

WorkpieceSystem

Owns what gets cut. Attached to the workpieces entity in scenes/main.scene and needs nothing else beside it on that entity; it publishes game/workpieces/api for the saw.

At load in play it stocks the work zone at Config.yard.work with the piece the order asks for, and from then on:

  • 1 / 2 / 3 / 4 (input map piece_controls) pull a pine block, log, ice block or plank into the zone; it drops and settles onto the sawbuck at Config.workpieces.restY.
  • G held + mouse turns the standing piece under the eye; releasing sets it.
  • carve() takes bites out of it: voxels vanish where the bar passed, chips and shards come off in the material's colour, and Shift.state.pieceKey / pieceRemaining are kept current.
  • Past Config.workpieces.cutFraction of its starting mass the piece is retired — it shatters, Shift.addCut() ticks the order, and the next piece of the order's species is brought in.

A new order (Shift.on("order")) restocks the zone with that order's species. Everything it spawns is temporary and rebuilt at load, so a reload never doubles a piece.

Note for the next pass: the engine's GPU voxel mesher does not compile in this build, so pieces are meshed by game/workpieces/voxelMesh (the voxel package's CPU path) and drawn through renderer.mesh. The grids themselves are real voxel data (game/workpieces/shapes), not a picture of one.