PROCITY/web/js/core/registry.js
m3ultra 42350607a0 Lane C: keeper stand pose on the counter contract (Lane D/F integration)
Answers Lane F §8 (the counter is kind:'counter' in `places`) and closes the
keeper-spawn gap: buildInterior now returns room.counter = { mesh, pose, stand }
and tags the counter interactable with userData.keeperStand. `stand` = {x,z,ry}
where a shopkeeper stands (service side, facing the customer), in room-local
space, rig-front = local -Z per keepers.js. Deterministic; purely additive.

Verified in-browser: 36-build type sweep + 50-room soak — stand in-bounds,
faces customer (dot>0 all), carried on `places` (deep-equal), deterministic;
no change to existing placement, path, leaks, or perf (avg 3.6ms / worst 7.7ms,
geo/tex leak 0).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-14 13:37:26 +10:00

155 lines
7.3 KiB
JavaScript

// PROCITY shop-type registry — the shared vocabulary (CITY_SPEC §"Shop types v1").
// Lane A owns this file; EVERY other lane imports it read-only. Keep it flat data:
// no THREE, no prng, no side effects — just tables + tiny pure helpers.
//
// Facade filenames here MUST exist in web/assets/gen/ (Lane A selfcheck asserts this).
// ── enumerations (single source of truth for the CityPlan schema strings) ──────────
export const DISTRICT_KINDS = ['mainstreet', 'arcade', 'backstreets', 'warehouse', 'residential', 'market'];
export const EDGE_KINDS = ['main', 'side', 'lane', 'arcade'];
export const USE_KINDS = ['shop', 'anchor', 'house', 'yard', 'stall', 'infill'];
export const SHOP_TYPE_IDS = ['record', 'opshop', 'toy', 'book', 'video', 'pawn', 'milkbar', 'dept', 'stall'];
// ── the registry ──────────────────────────────────────────────────────────────────
// Per type:
// label human name (map legend / debug)
// facades facade-*.jpg skins in web/assets/gen/ (blank signboards; game overlays the name)
// sign colour/style hints for Lane B's canvas signage
// interior archetype id Lane C builds the room from
// fittings parametric fitting kit ids (90sDJsim fittings.js) Lane C fills the room with
// storeys [min,max] inclusive
// hours {open,close} default trading hours (24h); plan.js jitters + picks one weirdo
// weights district-kind -> spawn weight (0/absent = never in that district)
// footprint {fmin,fmax,dmin,dmax} preferred frontage/depth band in metres (plan.js hint)
export const SHOP_TYPES = {
record: {
label: 'Record Shop',
facades: ['facade-timber-teal.jpg', 'facade-arcade-tile.jpg', 'facade-djsim-record.jpg'],
sign: { bg: '#141428', fg: '#ff5470', accent: '#ffd23f', style: 'neon' },
interior: 'crates_and_bins',
fittings: ['record_bins', 'crates', 'counter', 'listening_corner'],
storeys: [1, 2],
hours: { open: 10, close: 18 },
weights: { mainstreet: 3, arcade: 4, backstreets: 1 },
footprint: { fmin: 6, fmax: 9, dmin: 12, dmax: 18 },
},
opshop: {
label: 'Op Shop',
facades: ['facade-weatherboard.jpg', 'facade-fibro-blue.jpg', 'facade-djsim-opshop.jpg'],
sign: { bg: '#3d6b4a', fg: '#f6efdc', accent: '#e4573a', style: 'painted' },
interior: 'racks_and_shelves',
fittings: ['clothes_racks', 'bricabrac_shelving', 'book_wall', 'counter'],
storeys: [1, 2],
hours: { open: 9, close: 17 },
weights: { mainstreet: 3, arcade: 1, backstreets: 2 },
footprint: { fmin: 7, fmax: 10, dmin: 12, dmax: 20 },
},
toy: {
label: 'Toy Shop',
facades: ['facade-stucco-pink.jpg', 'facade-deco-pastel.jpg', 'facade-boutique.jpg'],
sign: { bg: '#ffd23f', fg: '#d6336c', accent: '#2f9e44', style: 'bubbly' },
interior: 'shelves_and_case',
fittings: ['cube_shelves', 'display_tables', 'glass_case', 'counter'],
storeys: [1, 2],
hours: { open: 9, close: 17 },
weights: { mainstreet: 2, arcade: 2, backstreets: 1 },
footprint: { fmin: 6, fmax: 9, dmin: 12, dmax: 18 },
},
book: {
label: 'Book Barn',
facades: ['facade-federation.jpg', 'facade-sandstone.jpg', 'facade-redbrick.jpg'],
sign: { bg: '#2b3a2e', fg: '#e9d8a6', accent: '#bb7a3b', style: 'serif' },
interior: 'halls_of_shelves',
fittings: ['bookshelves', 'spinner_racks', 'armchair', 'counter'],
storeys: [1, 2],
hours: { open: 9, close: 17 },
weights: { mainstreet: 2, arcade: 2, backstreets: 1 },
footprint: { fmin: 7, fmax: 10, dmin: 14, dmax: 20 },
},
video: {
label: 'Video Rental',
facades: ['facade-stripmall.jpg', 'facade-djsim-video.jpg'],
sign: { bg: '#111111', fg: '#ffe14d', accent: '#e8412b', style: 'blocky' },
interior: 'aisle_shelves',
fittings: ['vhs_shelving', 'returns_slot', 'poster_wall', 'counter'],
storeys: [1, 1],
hours: { open: 11, close: 21 }, // rentals trade late
weights: { mainstreet: 2, arcade: 0, backstreets: 1 },
footprint: { fmin: 7, fmax: 10, dmin: 14, dmax: 20 },
},
pawn: {
label: 'Pawnbroker',
facades: ['facade-besser.jpg', 'facade-grimy.jpg', 'facade-djsim-pawn.jpg', 'facade-corrugated.jpg'],
sign: { bg: '#1c1c1c', fg: '#f4c430', accent: '#a8a8a8', style: 'goldbar' },
interior: 'counter_forward',
fittings: ['glass_cabinets', 'wall_hooks', 'barred_window', 'counter'],
storeys: [1, 2],
hours: { open: 9, close: 17 },
weights: { mainstreet: 1, backstreets: 2, warehouse: 1 },
footprint: { fmin: 6, fmax: 9, dmin: 12, dmax: 18 },
},
milkbar: {
label: 'Milk Bar',
facades: ['facade-djsim-milkbar.jpg', 'facade-brickveneer.jpg'],
sign: { bg: '#c92a2a', fg: '#fff5f5', accent: '#ffd23f', style: 'coke' },
interior: 'counter_and_freezer',
fittings: ['counter', 'fridge', 'magazine_rack', 'freezer'],
storeys: [1, 1],
hours: { open: 6, close: 20 }, // the corner shop opens early, closes late
weights: { residential: 1 }, // only ever a residential corner shop
footprint: { fmin: 9, fmax: 12, dmin: 12, dmax: 16 },
},
dept: {
label: 'Department Store',
facades: ['facade-terrazzo.jpg', 'facade-djsim-dept.jpg'],
sign: { bg: '#7b1e3a', fg: '#f6e7c1', accent: '#c9a227', style: 'grand' },
interior: 'grand_hall',
fittings: ['mixed_sections', 'escalator_prop', 'glass_case', 'counter'],
storeys: [2, 3],
hours: { open: 9, close: 17 },
weights: { market: 1 }, // the anchor on the market square's edge
footprint: { fmin: 22, fmax: 34, dmin: 24, dmax: 34 },
},
stall: {
label: 'Market Stall',
facades: ['facade-market.jpg', 'facade-corrugated.jpg'], // canvas market + corrugated shed backdrop (≥2 per Lane E)
sign: { bg: '#e8e2d0', fg: '#5c3b1e', accent: '#c0392b', style: 'handpainted' },
interior: 'open_stall',
fittings: ['trestle_tables', 'crates'],
storeys: [1, 1],
hours: { open: 8, close: 14 }, // market mornings
weights: { market: 1 },
footprint: { fmin: 3, fmax: 5, dmin: 3, dmax: 5 },
},
};
// ── pure helpers (no randomness — plan.js supplies the prng stream) ─────────────────
// Types that can spawn in a district, as a flat [{type,weight}] list (weight>0), stable order.
export function weightedTypes(districtKind) {
const out = [];
for (const type of SHOP_TYPE_IDS) {
const w = SHOP_TYPES[type].weights[districtKind] || 0;
if (w > 0) out.push({ type, weight: w });
}
return out;
}
// Sample one type by weight using a prng stream fn r()->[0,1). Returns null if none for district.
export function pickWeightedType(r, districtKind, exclude = null) {
let list = weightedTypes(districtKind);
if (exclude) { const f = list.filter(t => t.type !== exclude); if (f.length) list = f; }
if (!list.length) return null;
let total = 0; for (const t of list) total += t.weight;
let x = r() * total;
for (const t of list) { x -= t.weight; if (x < 0) return t.type; }
return list[list.length - 1].type;
}
// Every facade filename referenced anywhere (Lane A selfcheck asserts each exists on disk).
export function allFacadeSkins() {
const set = new Set();
for (const type of SHOP_TYPE_IDS) for (const f of SHOP_TYPES[type].facades) set.add(f);
return [...set];
}