Expand description
Per-lot node generator.
node_at(x, y) returns either Some(NodeSpec) (this lot carries a node)
or None (empty lot — procedural gap). The result is a pure function of
(TREE_SEED, x, y): the same input always produces byte-identical output.
Lot geometry: the canvas is an infinite grid of lots, each
LOT_W × LOT_H cells. A lot’s node (if any) is a procedurally-sized
rectangular box placed at a procedurally-jittered offset inside the lot.
Boxes never overlap because each lives strictly inside its lot interior.
Edges: any two lots whose (x, y) differ by at most 1 on each axis
(“8-king” adjacency) may be connected. Existence is rolled with
edge_exists(a, b) from a position-seeded RNG, so the connectivity
pattern is also stable forever.
Structs§
- Node
Spec - A single tree node, regenerated from
(TREE_SEED, lot)on demand.
Enums§
- Rarity
- Visual classification, computed from the rolled primitive stack. Drives box dimensions, edge weight, and biome tinting in the renderer.
Constants§
- LOT_H
- LOT_W
- Size of one “lot” cell in the infinite tree grid, in terminal cells. 36 wide × 10 tall comfortably holds a Notable box (16×5) with breathing room for edge routing.
- NODE_
BASE_ COST - Base cost at distance 0 (before rarity and jitter). The origin lot is auto-owned so this never quotes a real purchase, but it anchors the ramp: cost(d) = NODE_COST_MULT * NODE_BASE_COST * NODE_COST_GROWTH^d * rarity_factor * jitter.
- NODE_
COST_ GROWTH - Per-lot exponential growth rate. Each step further from the origin multiplies the node’s cost by this factor (manhattan distance). The shape of the late-game wall lives here — bump it to make deep nodes balloon faster, lower it for a gentler ramp.
- NODE_
COST_ MULT - Cost scales with Manhattan distance from origin: deeper = pricier. Flat multiplier on every node’s rolled cost — shifts the whole pricing curve up or down without bending it. Use this when “the tree feels too cheap” but the SHAPE of the ramp is correct.
Functions§
- anchor_
of - For a populated lot, return its “anchor parent” — the deterministic king-neighbor that is GUARANTEED to have an edge to this lot.
- bresenham_
path - Bresenham-style staircase between (ax, ay) and (bx, by) in canvas-grid coords. Single-axis steps only, interleaved by cross-multiplied normalized progress so the staircase doesn’t degenerate into a one-big-L jolt. Returns cells in start→end order.
- count_
leading_ in_ rect - Count cells at the START of
pathwhose canvas-grid coords lie inside the rect(box_x, box_y, box_w, box_h). Used by the edge renderer + the unlock-anim’s completion check to skip the “inside the source box” prefix when seeding the wavefront. Iteration stops at the first cell that’s outside the rect — interior gaps don’t inflate the count. - count_
trailing_ in_ rect - Mirror of
count_leading_in_rectbut counting from the END of the path inward. - diagonal_
route_ via - For a diagonal edge between
aandb, return the “L-bend corner lot” the renderer should route through — the corner lot that’s empty.Nonefor non-diagonal pairs (renderer chooses by longer-axis heuristic instead). - edge_
exists - Procgen decision: does an edge exist between two neighboring lots?
Returns false for non-neighbors. Both lots must actually contain a
node — call
node_atfirst. - edge_
path_ cells - Cells along the rendered edge between two nodes, in canonical
lo→hi lot order (lex on
(x, y)). Returns an empty Vec if either endpoint has no node. - is_
king_ neighbor - True when the lots at
aandbare 8-king neighbors (chebyshev distance 1). Returns false for the same lot (a node isn’t its own neighbor) and for any pair further away. - neighbors_
of - The 8 neighboring lots of
c. - neighbors_
with_ nodes - Helper: all
TreeCoords that are king-neighbors ofcAND have a node. - node_at
- Procgen entry point: returns the node at lot
(x, y), orNoneif the lot is empty. - reaches_
origin - True iff
lotadmits a path of populated king-neighbors back to origin where every step strictly decreases manhattan distance. Origin itself returns true; unpopulated lots (gap roll) return false. - roll_
cost