blocks
Where the block city stands, and what each building is made of. Pure geometry: this module spawns nothing, reads no entity and touches no physics, so a layout can be inspected and counted without a running simulation.
blocks
Where the block city stands, and what each building is made of. Pure geometry: this module spawns nothing, reads no entity and touches no physics, so a layout can be inspected and counted without a running simulation.
local Blocks = require("game.city.blocks")
local plan = Blocks.layout(7)
print(plan.blockCount, plan.jointCount)
for _, s in ipairs(plan.structures) do
print(s.kind, s.x, s.z, s.height, s.tier, #s.blocks)
end
Archetypes
| kind | what it is | needs |
|---|---|---|
skyscraper | a tapering stack of banded storeys under a slate cap | 2.3 m |
officeSlab | a wide low block with a setback penthouse | 4.2 m |
waterTower | four legs, a platform, a tank, a chrome cap | 3.0 m |
antennaMast | a broad footing under a thin tapering column and a spire | 2.0 m |
bridge | two piers with a three-block deck laid across them | 7.2 m |
gate | two piers, a lintel over them, a clock on top | 5.0 m |
Blocks.layout(seed, opts) deals them across four streets of sites, widest
archetype first so each appears at least once, then fills the rest by weight.
Sites are shares of the table's own half-width and of the band the city is
allowed to stand in, so the same layout scales with the table rather than
walking off it.
The one joint rule
An entity carries at most one Joint component, so a structure's edges form a
tree in which every block is the HOLDER of at most one edge. That is what makes
Physics.jointReaction(blockId) unambiguous, which is what lets the break
thresholds be measured instead of guessed. Blocks.validate(structure) checks it
and the City component refuses to build a structure that fails.
The rule is why the piers of a bridge and a gate are chained in opposite directions: the free end of each chain is what the deck or the lintel hangs from.
What a block is
{ x, y, z, sx, sy, sz, ry, paint, mass } — a world centre, full extents, a yaw
about Y, an index into the painted-wood palette, and a mass from its own volume,
clamped into the envelope Rules.PHYS allows. No dimension is thinner than
Rules.PHYS.blockMinThickness, so nothing in the city can be tunnelled through
at 60 Hz — which matters, because CCD is forbidden on every body in this game.
Scoped to this part · feeds back into the world's score.