Buildings
Decision #101. Stage 2 of building the world (docs/world-atlas.md): a generator that plans
buildings the way an architect would, from the object catalog (#50, #60). Towns place them
(docs/towns.md, #103).
Code: crates/uo-buildings. Run:
cargo run --release -p uo-buildings -- --out /tmp/buildings --per 6 # plan sheets per kind, report, missing sprites
cargo run --release -p uo-client -- --building-gallery inn --focus 44,46 --roofs ground-floor # look at them in the game
cargo test -p uo-buildings # every kind, style and front passes its checks
How a building is planned
A Spec (kind, style, plot w × h, front, seed) becomes a Building, deterministically:
- Shape (weighted per kind):
I,L,T,U(yard open to the street),H(two yards),Z,Plus(temples),O(closed courtyard), made of disjoint rectangular wings. - Storeys: the main wing (on the street, biggest) gets the kind's storeys (towers 3, plus a crenellated platform 60 % of the time), the other wings fewer or as many.
- Rooms: per storey the kind's program, e.g. inn: taproom, kitchen, storage, bedroom; upstairs a corridor with guest rooms. Wings are cut along their long axis into strips of 3–6 tiles; the main room grows over strips at the front until it has its share, the others take the nearest strips, spare strips become filler rooms. Upper storeys of manors, inns and barracks are laid out as a 2-tile corridor along the biggest wing with rooms off it.
- Stairs: a straight flight of 4 tiles (
step_srising north orstep_erising west) in one room, against a wall, under one room of the storey above that also holds the landing; hubs (halls, corridors) preferred. The run is a stairwell hole on the storey above. - Front door (user directive): the camera looks north-west and never turns, so the front
door goes on the south side (the street) or else the east side, never north or west,
never at a corner or onto stairs, near the middle of the facade. Plots that face east are
planned as south fronts and flipped across the diagonal (
transform.rs:_x↔_y, south ↔ east facings,_s↔_evariants, stairs rising north ↔ west), so their door is on the east. A back door (kitchen, storage, barn, forge) sometimes, on any side. - Doors inside: a tree grown from the front door (or the landing upstairs), hubs first, each door off the wall junctions; bedrooms get doors, vaults metal doors.
- Windows: on outside walls, every 3rd tile (Karrak every 4th), off the corners, none in vaults, cellars and storage; arrow slits instead on barracks and towers.
- Cut corners and bays: visible convex corners are cut diagonally (Free cities 35 %, Aelwyn 25 %, Karrak 10 %, towers 85 %: octagonal towers); houses, manors, inns, shops, guildhalls and banks may grow a bay window (three tiles out of the front, both outer corners cut, glazed diagonals).
- Terraces and balconies: a lower wing against a taller one may get a flat roof with a parapet of low walls instead of a hip roof, with a door from the storey above (and a few pots, a bench, a table). Tower tops are crenellated platforms.
- Furniture from room templates (catalog sprites): against a wall facing into the room,
_s/_emulti-tile pieces backed onto a north or west wall (fireplaces, beds, troughs), wall mounts on north and west walls (lanterns, paintings, tapestries), tables with chairs facing them and small things on top, counter runs with room for the keeper, pews in rows with an aisle. A blocking piece is kept only when the room's walkable tiles stay connected and no door, stair or landing is covered. - Pieces: floors per room and style, walls per edge (outside walls in the outer set, inside ones in the inner set; corners, posts at junctions and wall ends), doors, stairs (blocks and steps), furniture, a hip roof per roofed wing at its own height.
- Checks (
check.rs): from the front door every room, door and stair approach of the ground floor is reachable on foot, and from each landing everything upstairs; problems make the generator try another variant of the same spec (up to 24).
Styles (style.rs): Karrak stone and fieldstone, slate, iron-bound doors, few windows;
Aelwyn timber, plaster and logs, thatch or shingles, light wood; Free brick and
plaster, tile roofs; Isles timber and logs. Temples are marble, stone or sandstone, towers
stone or sandstone; rich buildings (manors, banks, temples, towers) have carpets and fancy
furniture.
Kinds (program.rs): cottage, house, manor, farmhouse, inn, shop, smithy, workshop, warehouse,
temple, bank, barracks, tower, guildhall, with 25 room kinds.
Numbers
cargo test -p uo-buildings: 14 kinds × 4 styles × 2 fronts × 12 seeds, every plan passes its
checks (96/96 per kind), 81–96 distinct layouts of 96 per kind (shape, size, rooms and furniture),
no front door faces north or west. A building plans in well under a millisecond.
Missing sprites (asset requests)
Sprites the generator needs and the catalog lacks are ordered in assets/requests/ with their
geometry contract; until baked the client draws placeholders, and uo-buildings lists what a
run used but the catalog lacks (missing-sprites.md). The first request,
assets/requests/wall-pieces.md (diagonal walls, low walls, arrow slits and crenellations for
the nine full wall sets), is delivered (#102; pieces in docs/uo-objects.md › walls).
Not done yet
- Walking upstairs. The plans are full 3D (storeys, stairs, terraces) and every storey is
checked for walking, but movement in the game is 2D on the ground: upper storeys are drawn
and hide with the roofs (
Overhead), you can't climb the stairs yet. Multi-level movement is its own task (multi-level-movement). - A building hides its roof while the player stands anywhere in its bounding box, so the yard of a U or O building counts as inside.
- Hip roofs of two wings meet without valley pieces.
- Towns place them in the baked world (
docs/towns.md, #103).