@adatechnology/game-floorplan 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/MIGRATION.md +387 -0
- package/README.md +123 -2
- package/dist/index.d.ts +1054 -0
- package/dist/index.global.js +2770 -0
- package/dist/index.global.js.map +1 -0
- package/dist/index.js +2745 -0
- package/dist/index.js.map +1 -0
- package/package.json +53 -3
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,1054 @@
|
|
|
1
|
+
/** Seeded random helpers. Same seed and key always produce the same stream. */
|
|
2
|
+
type Rng = () => number;
|
|
3
|
+
declare function mulberry32(a: number): Rng;
|
|
4
|
+
declare function hashString(input: string | number): number;
|
|
5
|
+
/** Independent stream for a `(seed, key)` pair. */
|
|
6
|
+
declare const createRng: (seed: string | number, key: string) => Rng;
|
|
7
|
+
|
|
8
|
+
/** Axis-aligned rectangle `[u0, v0, u1, v1]`. `u` runs along the facade, `v` from the street to the back. */
|
|
9
|
+
type Rect = [number, number, number, number];
|
|
10
|
+
type Vec2 = [number, number];
|
|
11
|
+
type Weights = Record<string, number>;
|
|
12
|
+
type Json = any;
|
|
13
|
+
type MeshFront = '+z' | '-z' | '+x' | '-x';
|
|
14
|
+
type Mount = 'ceiling' | 'wall' | 'window' | 'support' | 'floor' | 'roof' | 'ground' | 'wall_top' | (string & {});
|
|
15
|
+
/** How an item is coloured: a palette role, a fixed colour, or a seeded pick from a list. */
|
|
16
|
+
type ItemColor = {
|
|
17
|
+
role: string;
|
|
18
|
+
} | {
|
|
19
|
+
hex: number;
|
|
20
|
+
} | {
|
|
21
|
+
pick: number[];
|
|
22
|
+
};
|
|
23
|
+
interface FurnitureDef {
|
|
24
|
+
type: string;
|
|
25
|
+
category: string;
|
|
26
|
+
w: number;
|
|
27
|
+
d: number;
|
|
28
|
+
h: number;
|
|
29
|
+
/** Local mesh axis that is the front (default `+z`). */
|
|
30
|
+
front: MeshFront;
|
|
31
|
+
/** May sit under a window (default: `h <= 0.95`). */
|
|
32
|
+
window: boolean;
|
|
33
|
+
/** Does not need a clearance in front (default: `h <= 0.5`). */
|
|
34
|
+
low: boolean;
|
|
35
|
+
/** Rugs, decks: ignores collisions. */
|
|
36
|
+
flat: boolean;
|
|
37
|
+
deck: boolean;
|
|
38
|
+
/** Keep-out margin around the item (pools). */
|
|
39
|
+
rim: number;
|
|
40
|
+
decor?: boolean;
|
|
41
|
+
/** Hangs a wall cabinet over the counter (y 1.55 to 2.15 m): it blocks a window unless the fill dropped the cabinet. */
|
|
42
|
+
overhead?: boolean;
|
|
43
|
+
/** Effective height that blocks a window when taller than `h` (a shower enclosure is 0.1 m tray plus 1.95 m glass). */
|
|
44
|
+
windowHeight?: number;
|
|
45
|
+
/** Plugs into a socket (lamps, appliances). */
|
|
46
|
+
powered?: boolean;
|
|
47
|
+
/** Only picked when a slot names its exact type (`=type`), never through its category. */
|
|
48
|
+
exactOnly?: boolean;
|
|
49
|
+
mount?: Mount;
|
|
50
|
+
equip?: string[];
|
|
51
|
+
color?: ItemColor;
|
|
52
|
+
}
|
|
53
|
+
type ItemInput = Pick<FurnitureDef, 'type' | 'category' | 'w' | 'd' | 'h'> & Partial<FurnitureDef>;
|
|
54
|
+
type Anchor = 'wall' | 'corner' | 'center' | 'window' | 'on' | 'inside';
|
|
55
|
+
type Side = 'left' | 'right' | 'front' | 'back' | 'any';
|
|
56
|
+
type FacingRule = 'center' | 'door' | 'target' | 'u+' | 'u-' | 'v+' | 'v-';
|
|
57
|
+
interface SlotDef {
|
|
58
|
+
id: string;
|
|
59
|
+
anchor: Anchor;
|
|
60
|
+
size?: number[];
|
|
61
|
+
cats: Weights;
|
|
62
|
+
side?: Side;
|
|
63
|
+
pos?: number;
|
|
64
|
+
shift?: number;
|
|
65
|
+
corner?: string;
|
|
66
|
+
fx?: number;
|
|
67
|
+
fz?: number;
|
|
68
|
+
dx?: number;
|
|
69
|
+
dz?: number;
|
|
70
|
+
on?: string;
|
|
71
|
+
n?: number;
|
|
72
|
+
part?: number;
|
|
73
|
+
required?: boolean;
|
|
74
|
+
chance?: number;
|
|
75
|
+
clearance?: number;
|
|
76
|
+
group?: string;
|
|
77
|
+
requires?: string;
|
|
78
|
+
facing?: FacingRule;
|
|
79
|
+
target?: string;
|
|
80
|
+
slide?: number;
|
|
81
|
+
[extra: string]: Json;
|
|
82
|
+
}
|
|
83
|
+
type SlotLibrary = SlotDef[] | ((room: {
|
|
84
|
+
w: number;
|
|
85
|
+
d: number;
|
|
86
|
+
}) => SlotDef[]);
|
|
87
|
+
interface SlotKit {
|
|
88
|
+
wall(id: string, side: Side, pos: number, size: number[], cats: Weights, o?: Partial<SlotDef>): SlotDef;
|
|
89
|
+
corner(id: string, corner: string, size: number[], cats: Weights, o?: Partial<SlotDef>): SlotDef;
|
|
90
|
+
center(id: string, fx: number, fz: number, size: number[], cats: Weights, o?: Partial<SlotDef>): SlotDef;
|
|
91
|
+
windowSlot(id: string, size: number[], cats: Weights, o?: Partial<SlotDef>): SlotDef;
|
|
92
|
+
on(id: string, parent: string, cats: Weights, o?: Partial<SlotDef>): SlotDef;
|
|
93
|
+
inside(id: string, parent: string, cats: Weights, o?: Partial<SlotDef>): SlotDef;
|
|
94
|
+
}
|
|
95
|
+
interface RoomDef {
|
|
96
|
+
id: string;
|
|
97
|
+
type: string;
|
|
98
|
+
label?: string;
|
|
99
|
+
rect: number[];
|
|
100
|
+
parts?: number[][];
|
|
101
|
+
library?: string;
|
|
102
|
+
without?: string[];
|
|
103
|
+
overrides?: Record<string, Json>;
|
|
104
|
+
extras?: SlotDef[];
|
|
105
|
+
slots?: SlotLibrary;
|
|
106
|
+
link?: number[];
|
|
107
|
+
outdoor?: boolean;
|
|
108
|
+
ceiling?: number;
|
|
109
|
+
seedKey?: string;
|
|
110
|
+
[extra: string]: Json;
|
|
111
|
+
}
|
|
112
|
+
interface DoorDef {
|
|
113
|
+
a: string;
|
|
114
|
+
b: string;
|
|
115
|
+
side?: string;
|
|
116
|
+
at?: number;
|
|
117
|
+
width: number;
|
|
118
|
+
opensTo?: string;
|
|
119
|
+
steel?: boolean;
|
|
120
|
+
/** Clear wall from the opening to a corner or junction; defaults to the template's `clearance.door`, else 0.12 m. */
|
|
121
|
+
clearance?: number;
|
|
122
|
+
/** Explicit position instead of a wall edge (a tent flap in the middle of the lot). */
|
|
123
|
+
edge?: {
|
|
124
|
+
axis: 'u' | 'v';
|
|
125
|
+
pos: number;
|
|
126
|
+
a0: number;
|
|
127
|
+
a1: number;
|
|
128
|
+
};
|
|
129
|
+
model?: string;
|
|
130
|
+
type?: string;
|
|
131
|
+
steps?: number;
|
|
132
|
+
[extra: string]: Json;
|
|
133
|
+
}
|
|
134
|
+
interface WindowDef {
|
|
135
|
+
room: string;
|
|
136
|
+
side: string;
|
|
137
|
+
at?: number;
|
|
138
|
+
n?: number;
|
|
139
|
+
width: number;
|
|
140
|
+
y0?: number;
|
|
141
|
+
y1?: number;
|
|
142
|
+
[extra: string]: Json;
|
|
143
|
+
}
|
|
144
|
+
interface FloorDef {
|
|
145
|
+
label?: string;
|
|
146
|
+
ceiling: number;
|
|
147
|
+
openPairs?: [string, string][];
|
|
148
|
+
rooms(w: number, d: number, options: FloorplanOptions): RoomDef[];
|
|
149
|
+
doors(w: number, d: number, options: FloorplanOptions): DoorDef[];
|
|
150
|
+
windows(w: number, d: number, options: FloorplanOptions): WindowDef[];
|
|
151
|
+
}
|
|
152
|
+
interface GateCfg {
|
|
153
|
+
u: number;
|
|
154
|
+
width: number;
|
|
155
|
+
to?: string;
|
|
156
|
+
}
|
|
157
|
+
interface LotConfig {
|
|
158
|
+
frontSetback: number;
|
|
159
|
+
marginLeft: number;
|
|
160
|
+
marginRight: number;
|
|
161
|
+
backyardDepth: number;
|
|
162
|
+
parking?: {
|
|
163
|
+
width: number;
|
|
164
|
+
};
|
|
165
|
+
garage?: GateCfg;
|
|
166
|
+
pedestrian?: {
|
|
167
|
+
u: number;
|
|
168
|
+
};
|
|
169
|
+
cargo?: GateCfg;
|
|
170
|
+
doorTarget?: {
|
|
171
|
+
a: string;
|
|
172
|
+
side: string;
|
|
173
|
+
};
|
|
174
|
+
libraries?: Record<string, string>;
|
|
175
|
+
/** Lot zones over the building area (a camp). */
|
|
176
|
+
extraZones?: {
|
|
177
|
+
id: string;
|
|
178
|
+
type: string;
|
|
179
|
+
label?: string;
|
|
180
|
+
parts: Rect[];
|
|
181
|
+
library?: string;
|
|
182
|
+
}[];
|
|
183
|
+
yardZones?: {
|
|
184
|
+
id: string;
|
|
185
|
+
type: string;
|
|
186
|
+
label?: string;
|
|
187
|
+
v0: number;
|
|
188
|
+
v1: number;
|
|
189
|
+
library?: string;
|
|
190
|
+
}[];
|
|
191
|
+
grounds?: Record<string, string>;
|
|
192
|
+
pool?: boolean;
|
|
193
|
+
}
|
|
194
|
+
interface TemplateDef {
|
|
195
|
+
id: string;
|
|
196
|
+
/** Declared use for zoning, e.g. `residential_single`. */
|
|
197
|
+
use?: string;
|
|
198
|
+
style: string | ((o: FloorplanOptions) => string);
|
|
199
|
+
limits: {
|
|
200
|
+
w: number[];
|
|
201
|
+
d: number[];
|
|
202
|
+
};
|
|
203
|
+
defaults: {
|
|
204
|
+
w: number;
|
|
205
|
+
d: number;
|
|
206
|
+
};
|
|
207
|
+
limitsFn?: (o: FloorplanOptions) => TemplateDef['limits'];
|
|
208
|
+
defaultsFn?: (o: FloorplanOptions) => TemplateDef['defaults'];
|
|
209
|
+
floors?: FloorDef[];
|
|
210
|
+
floorsFn?: (o: FloorplanOptions) => FloorDef[];
|
|
211
|
+
/** Highest floor count the template can reach (zoning); defaults to the generated floor count. */
|
|
212
|
+
/** Adjustable storey count `[min, max]` through `options.floors`; lets zoning clamp the plan. */
|
|
213
|
+
floorRange?: [number, number];
|
|
214
|
+
lot?: ((w: number, d: number, style: StyleDef, o: FloorplanOptions) => LotConfig) | null;
|
|
215
|
+
facade?: {
|
|
216
|
+
balcony?: boolean;
|
|
217
|
+
veranda?: boolean;
|
|
218
|
+
steelDoor?: boolean;
|
|
219
|
+
};
|
|
220
|
+
facadeExtra?: (facade: Json, rng: Rng, w: number, d: number, o: FloorplanOptions) => void;
|
|
221
|
+
building?: (w: number, d: number, o: FloorplanOptions) => Json;
|
|
222
|
+
singleFloor?: boolean;
|
|
223
|
+
/** Place tag of the building for finds (`house`, `pharmacy`...). */
|
|
224
|
+
place?: string;
|
|
225
|
+
/** Building system the structure pack builds (a reference registered there). */
|
|
226
|
+
construction?: string;
|
|
227
|
+
/** Region of the content (`br`...), chosen by the pack that registered the template. */
|
|
228
|
+
region?: string;
|
|
229
|
+
/** Clear wall around openings: from a door to a corner or junction, and from a window to a corner, junction or door. */
|
|
230
|
+
clearance?: {
|
|
231
|
+
door?: number;
|
|
232
|
+
window?: number;
|
|
233
|
+
};
|
|
234
|
+
/** No walls are built (a tent): rooms and openings stay. */
|
|
235
|
+
noWalls?: boolean;
|
|
236
|
+
/** Storey heights add up (a mezzanine with a different ceiling) instead of `index * ceiling`. */
|
|
237
|
+
cumulativeCeilings?: boolean;
|
|
238
|
+
/** Settings the packs read from the plan (`power`: `grid`, `offgrid` or `tap`; `solar`); it lands in `result.config`. */
|
|
239
|
+
config?: (o: FloorplanOptions, w: number, d: number) => Json;
|
|
240
|
+
/** Marks lot areas taken by the building (chimney, tank, tents) as keep-out zones for the lot fill. */
|
|
241
|
+
reservations?: (plan: Plan) => void;
|
|
242
|
+
/** Own paths from the doors that sit away from the building edge (tents); replaces the generated ones. */
|
|
243
|
+
paths?: (plan: Plan, context: {
|
|
244
|
+
gates: Json[];
|
|
245
|
+
setback: number;
|
|
246
|
+
marginLeft: number;
|
|
247
|
+
marginRight: number;
|
|
248
|
+
backyard: number;
|
|
249
|
+
w: number;
|
|
250
|
+
d: number;
|
|
251
|
+
}) => Json[];
|
|
252
|
+
/** Sides built against a neighbour (`left` / `right`): exempt from the side setback. */
|
|
253
|
+
partyWalls?: ('left' | 'right')[];
|
|
254
|
+
options?: Json;
|
|
255
|
+
[extra: string]: Json;
|
|
256
|
+
}
|
|
257
|
+
interface BoundaryRule {
|
|
258
|
+
type: Weights;
|
|
259
|
+
top: Weights;
|
|
260
|
+
}
|
|
261
|
+
interface StyleDef {
|
|
262
|
+
id: string;
|
|
263
|
+
/** Other ids resolving to this style. */
|
|
264
|
+
aliases?: string[];
|
|
265
|
+
/** Name of the legacy palette RNG stream (kept so old seeds still reproduce). */
|
|
266
|
+
seedKey?: string;
|
|
267
|
+
height: number;
|
|
268
|
+
/** Height of a fence boundary (default 2.0 m). */
|
|
269
|
+
fenceHeight?: number;
|
|
270
|
+
front: BoundaryRule;
|
|
271
|
+
sideYard: BoundaryRule;
|
|
272
|
+
back: BoundaryRule;
|
|
273
|
+
gate: {
|
|
274
|
+
garage: Weights;
|
|
275
|
+
};
|
|
276
|
+
facade: {
|
|
277
|
+
finish: Weights;
|
|
278
|
+
grilles: number;
|
|
279
|
+
roof: Weights;
|
|
280
|
+
};
|
|
281
|
+
/** Facade swatches `[labelKey, hex]`. */
|
|
282
|
+
swatches: [string, string][];
|
|
283
|
+
/** Ground type weights per lot zone type. */
|
|
284
|
+
grounds: Record<string, Weights>;
|
|
285
|
+
}
|
|
286
|
+
interface CarClearance {
|
|
287
|
+
/** Clear space beside the driver door (m). */
|
|
288
|
+
driver: number;
|
|
289
|
+
/** Clear space on the passenger side (m). */
|
|
290
|
+
side: number;
|
|
291
|
+
/** Clear space in front of and behind the car (m). */
|
|
292
|
+
end: number;
|
|
293
|
+
}
|
|
294
|
+
interface ResultExtensionContext {
|
|
295
|
+
plan: Plan;
|
|
296
|
+
/** The result built so far: the plan, the items, the state items and the extensions that ran before. */
|
|
297
|
+
result: Json;
|
|
298
|
+
seed: number | string;
|
|
299
|
+
/** Seeded stream of the extension: `createRng(seed, seedKey ?? name)`. */
|
|
300
|
+
rng: Rng;
|
|
301
|
+
options: FloorplanOptions;
|
|
302
|
+
}
|
|
303
|
+
type ResultExtensionRun = (context: ResultExtensionContext) => Json;
|
|
304
|
+
interface ResultExtensionOptions {
|
|
305
|
+
/** Extensions that must run first. */
|
|
306
|
+
after?: string[];
|
|
307
|
+
/** Name of the seeded stream; defaults to the extension name. A pack sets the name of the team's own flow to reproduce its seeds. */
|
|
308
|
+
seedKey?: string;
|
|
309
|
+
}
|
|
310
|
+
interface FindStack {
|
|
311
|
+
readonly itemId: string;
|
|
312
|
+
readonly count: number;
|
|
313
|
+
readonly data?: {
|
|
314
|
+
readonly ageDays?: number;
|
|
315
|
+
readonly condition?: number;
|
|
316
|
+
readonly charge?: number;
|
|
317
|
+
readonly fill?: number;
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
interface FindsQuery {
|
|
321
|
+
/** Kind of place (`TemplateDef.place`, a room type, a lot zone type). */
|
|
322
|
+
place: string;
|
|
323
|
+
/** Kind of container (a furniture category). */
|
|
324
|
+
container: string;
|
|
325
|
+
state: string;
|
|
326
|
+
rng: Rng;
|
|
327
|
+
/** Outbreak days; 0 is the normal world. */
|
|
328
|
+
day?: number;
|
|
329
|
+
region?: string;
|
|
330
|
+
/** Footprint of the place in m². */
|
|
331
|
+
footprint?: number;
|
|
332
|
+
key?: string;
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Answers what a container holds. Registered by an item pack; the engine only keeps the registry. An array is the answer, even an empty one (an abandoned
|
|
336
|
+
* cupboard that holds nothing); `null` means this provider does not know the container, and the next provider (or the default of the pack) answers.
|
|
337
|
+
*/
|
|
338
|
+
interface FindsProvider {
|
|
339
|
+
findsFor(query: FindsQuery): readonly FindStack[] | null;
|
|
340
|
+
}
|
|
341
|
+
interface FloorplanOptions {
|
|
342
|
+
/** Number of storeys, for templates that accept it. */
|
|
343
|
+
floors?: number;
|
|
344
|
+
/** Building system of the structure pack (`masonry`, `wood_frame`, ...). */
|
|
345
|
+
construction?: string;
|
|
346
|
+
/** How finely the structure pack splits the walls (`coarse`, `panels`, `units`). */
|
|
347
|
+
wallDetail?: 'coarse' | 'panels' | 'units';
|
|
348
|
+
/** Radius of the player body (m, default 0.24): a disc this wide must pass between doors and rooms once the furniture is placed. */
|
|
349
|
+
playerRadius?: number;
|
|
350
|
+
/** Space a parked car keeps from walls (default driver 0.8, side 0.6, end 0.6). */
|
|
351
|
+
carClearance?: Partial<CarClearance>;
|
|
352
|
+
seed?: number | string;
|
|
353
|
+
w?: number;
|
|
354
|
+
d?: number;
|
|
355
|
+
style?: string;
|
|
356
|
+
state?: string;
|
|
357
|
+
/** Quality tier used by some templates. */
|
|
358
|
+
tier?: string;
|
|
359
|
+
floor?: number;
|
|
360
|
+
/** Output language for names and messages (default `en`). */
|
|
361
|
+
locale?: string;
|
|
362
|
+
/** Urban zone id or definition to clamp the plan to. */
|
|
363
|
+
zone?: string | ZoneDef;
|
|
364
|
+
/** Outbreak days for the finds (`FindsQuery.day`); 0 or none is the normal world. */
|
|
365
|
+
day?: number;
|
|
366
|
+
/** Region of the world for the finds (`FindsQuery.region`), as the item pack names it. */
|
|
367
|
+
region?: string;
|
|
368
|
+
[extra: string]: Json;
|
|
369
|
+
}
|
|
370
|
+
interface Room {
|
|
371
|
+
id: string;
|
|
372
|
+
type: string;
|
|
373
|
+
label?: string;
|
|
374
|
+
floor: number;
|
|
375
|
+
parts: Rect[];
|
|
376
|
+
library: string | null;
|
|
377
|
+
without: string[];
|
|
378
|
+
overrides: Record<string, Json>;
|
|
379
|
+
extras: SlotDef[];
|
|
380
|
+
slots: SlotLibrary | null;
|
|
381
|
+
link: number[] | null;
|
|
382
|
+
outdoor: boolean;
|
|
383
|
+
ceiling: number | null;
|
|
384
|
+
seedKey?: string;
|
|
385
|
+
ground?: string;
|
|
386
|
+
}
|
|
387
|
+
interface Plan {
|
|
388
|
+
w: number;
|
|
389
|
+
d: number;
|
|
390
|
+
tpl: TemplateDef;
|
|
391
|
+
floorDefs: FloorDef[];
|
|
392
|
+
style: string;
|
|
393
|
+
floors: {
|
|
394
|
+
index: number;
|
|
395
|
+
name?: string;
|
|
396
|
+
number?: number;
|
|
397
|
+
y0: number;
|
|
398
|
+
ceiling: number;
|
|
399
|
+
}[];
|
|
400
|
+
rooms: Room[];
|
|
401
|
+
zones: Room[];
|
|
402
|
+
doors: Json[];
|
|
403
|
+
windows: Json[];
|
|
404
|
+
walls: Json[];
|
|
405
|
+
gates: Json[];
|
|
406
|
+
paths: Json[];
|
|
407
|
+
lot: Json;
|
|
408
|
+
facade?: Json;
|
|
409
|
+
openPairs: Record<number, [string, string][]>;
|
|
410
|
+
zoning?: ZoningReport;
|
|
411
|
+
/** Lot areas the building keeps out of the fill (set by `TemplateDef.reservations`). */
|
|
412
|
+
reservations: Rect[];
|
|
413
|
+
/** The options the plan was built with (seed included). */
|
|
414
|
+
options: FloorplanOptions;
|
|
415
|
+
/** Result of `TemplateDef.config`. */
|
|
416
|
+
config?: Json;
|
|
417
|
+
/** Cache of the wall bodies per storey, filled by the walkability grid. */
|
|
418
|
+
wallBodies?: Record<number, Rect[]>;
|
|
419
|
+
playerRadius: number;
|
|
420
|
+
carClearance: CarClearance;
|
|
421
|
+
}
|
|
422
|
+
interface Slot {
|
|
423
|
+
id: string;
|
|
424
|
+
room: string;
|
|
425
|
+
floor: number;
|
|
426
|
+
outdoor: boolean;
|
|
427
|
+
anchor: string;
|
|
428
|
+
side: string | null;
|
|
429
|
+
cats: Weights;
|
|
430
|
+
valid: boolean;
|
|
431
|
+
reason: string | null;
|
|
432
|
+
[extra: string]: Json;
|
|
433
|
+
}
|
|
434
|
+
interface PlacedItem {
|
|
435
|
+
id: string;
|
|
436
|
+
type: string;
|
|
437
|
+
category: string;
|
|
438
|
+
x: number;
|
|
439
|
+
z: number;
|
|
440
|
+
ry: number;
|
|
441
|
+
w: number;
|
|
442
|
+
d: number;
|
|
443
|
+
h: number;
|
|
444
|
+
y: number;
|
|
445
|
+
room: string | null;
|
|
446
|
+
floor: number;
|
|
447
|
+
outdoor: boolean;
|
|
448
|
+
aabb: Rect;
|
|
449
|
+
color?: number | string;
|
|
450
|
+
[extra: string]: Json;
|
|
451
|
+
}
|
|
452
|
+
interface ZoneDef {
|
|
453
|
+
id: string;
|
|
454
|
+
/** Generic use strings: `residential_single`, `residential_multi`, `commercial`, `mixed`, `industrial`... */
|
|
455
|
+
allowedUses: string[];
|
|
456
|
+
maxFloors: number;
|
|
457
|
+
/** Metres. */
|
|
458
|
+
maxHeight: number;
|
|
459
|
+
/** Minimum setbacks in metres. */
|
|
460
|
+
setbacks: {
|
|
461
|
+
front: number;
|
|
462
|
+
side: number;
|
|
463
|
+
back: number;
|
|
464
|
+
};
|
|
465
|
+
/** Maximum building footprint / lot area (taxa de ocupacao). */
|
|
466
|
+
maxCoverage: number;
|
|
467
|
+
/** Maximum total built area / lot area (coeficiente de aproveitamento). */
|
|
468
|
+
maxFar: number;
|
|
469
|
+
/** Minimum lot area in m2. */
|
|
470
|
+
minLot: number;
|
|
471
|
+
/** Minimum lot frontage in metres. */
|
|
472
|
+
minFrontage: number;
|
|
473
|
+
/** Minimum permeable fraction of the lot (taxa de permeabilidade). */
|
|
474
|
+
permeableMin: number;
|
|
475
|
+
}
|
|
476
|
+
interface ZoneViolation {
|
|
477
|
+
rule: 'use' | 'floors' | 'height' | 'setback_front' | 'setback_side' | 'setback_back' | 'coverage' | 'far' | 'min_lot' | 'min_frontage' | 'permeable';
|
|
478
|
+
actual: number | string;
|
|
479
|
+
limit: number | string;
|
|
480
|
+
message?: string;
|
|
481
|
+
}
|
|
482
|
+
interface ZoneAdjustment {
|
|
483
|
+
field: string;
|
|
484
|
+
from: number | string;
|
|
485
|
+
to: number | string;
|
|
486
|
+
reason: string;
|
|
487
|
+
}
|
|
488
|
+
interface ZoningReport {
|
|
489
|
+
zone: string;
|
|
490
|
+
adjustments: ZoneAdjustment[];
|
|
491
|
+
violations: ZoneViolation[];
|
|
492
|
+
}
|
|
493
|
+
interface StateContext {
|
|
494
|
+
plan: Plan;
|
|
495
|
+
items: PlacedItem[];
|
|
496
|
+
seed: number | string;
|
|
497
|
+
state: string;
|
|
498
|
+
rng: Rng;
|
|
499
|
+
/** Placement helpers shared with the decor passes. */
|
|
500
|
+
ctx: PlacementContext;
|
|
501
|
+
kit: PlacementKit;
|
|
502
|
+
catalog: Record<string, FurnitureDef>;
|
|
503
|
+
wallTopHeights: Record<string, number>;
|
|
504
|
+
}
|
|
505
|
+
interface StatePlugin {
|
|
506
|
+
/** Name of the legacy RNG stream (kept so old seeds still reproduce). */
|
|
507
|
+
seedKey?: string;
|
|
508
|
+
/** Applies the state and returns the state items (not part of `items`). */
|
|
509
|
+
apply(c: StateContext): PlacedItem[];
|
|
510
|
+
/** Adjusts the palette roles (HSL) before the contrast rules run. */
|
|
511
|
+
adjustPalette?(roles: Record<string, Hsl>): void;
|
|
512
|
+
}
|
|
513
|
+
interface PlacementContext {
|
|
514
|
+
make(room: Room, type: string, rect: Rect, front: Vec2, extra?: Json): PlacedItem;
|
|
515
|
+
add(item: PlacedItem): PlacedItem;
|
|
516
|
+
placeOnFloor(room: Room, type: string, rng: Rng, opts?: Json): Rect | null;
|
|
517
|
+
itemsOfRoom(room: Room): PlacedItem[];
|
|
518
|
+
solidsOfRoom(room: Room): Rect[];
|
|
519
|
+
gridOf(room: Room): Json;
|
|
520
|
+
extraSolids: Record<string, Rect[]>;
|
|
521
|
+
roomById(id: string): Room | undefined;
|
|
522
|
+
setIgnored(ids: Set<string> | null): void;
|
|
523
|
+
added: PlacedItem[];
|
|
524
|
+
}
|
|
525
|
+
interface PlacementKit {
|
|
526
|
+
MARGIN: number;
|
|
527
|
+
EPS: number;
|
|
528
|
+
r2(x: number): number;
|
|
529
|
+
clamp(x: number, a: number, b: number): number;
|
|
530
|
+
overlaps(a: Rect, b: Rect, e?: number): boolean;
|
|
531
|
+
inner(p: Rect): Rect;
|
|
532
|
+
inflate(r: Rect, e: number): Rect;
|
|
533
|
+
areaOf(r: Rect): number;
|
|
534
|
+
topOf(m: PlacedItem): number;
|
|
535
|
+
extent(size: Vec2, f: Vec2): Vec2;
|
|
536
|
+
insideUnion(r: Rect, inners: Rect[]): boolean;
|
|
537
|
+
usableParts(room: Room, extra?: number): Rect[];
|
|
538
|
+
zonesOfFloor(plan: Plan, floor: number): Rect[];
|
|
539
|
+
windowsOfRoom(plan: Plan, room: Room): Json[];
|
|
540
|
+
windowZone(j: Json, outside?: boolean): Rect;
|
|
541
|
+
roomAt(plan: Plan, u: number, v: number, floor: number): Room | null;
|
|
542
|
+
reachable(grid: Json, solids: Rect[], inflation: number): boolean;
|
|
543
|
+
createGrid(plan: Plan, room: Room, ignored?: Set<string> | null): Json;
|
|
544
|
+
clearRect(r: Rect, f: Vec2, clearance: number): Rect;
|
|
545
|
+
pickWeighted(rng: Rng, w: Weights): string;
|
|
546
|
+
createRng(seed: number | string, key: string): Rng;
|
|
547
|
+
/** Name of the room in seeded streams: the legacy key when the room id was renamed, else the id. */
|
|
548
|
+
roomSeedKey(room: Room): string;
|
|
549
|
+
shuffle<T>(a: T[], rng: Rng): T[];
|
|
550
|
+
facingRotation(f: Vec2, type: string): number;
|
|
551
|
+
cutIntervals(intervals: [number, number][], a: number, b: number): [number, number][];
|
|
552
|
+
blocksWindow(it: FurnitureDef, j: Json, overheadOff?: boolean): boolean;
|
|
553
|
+
}
|
|
554
|
+
interface DecorPassContext {
|
|
555
|
+
plan: Plan;
|
|
556
|
+
items: PlacedItem[];
|
|
557
|
+
seed: number | string;
|
|
558
|
+
rng: Rng;
|
|
559
|
+
ctx: PlacementContext;
|
|
560
|
+
kit: PlacementKit;
|
|
561
|
+
catalog: Record<string, FurnitureDef>;
|
|
562
|
+
/** Decor profiles registered per style id. */
|
|
563
|
+
profiles: Record<string, Json>;
|
|
564
|
+
}
|
|
565
|
+
type DecorPass = (c: DecorPassContext) => void;
|
|
566
|
+
interface GroundOverlayRule {
|
|
567
|
+
/** Item category that triggers the overlay (e.g. `pool`). */
|
|
568
|
+
category: string;
|
|
569
|
+
/** Ground type drawn around it. */
|
|
570
|
+
ground: string;
|
|
571
|
+
/** Metres added around the trigger footprint. */
|
|
572
|
+
inflate: number;
|
|
573
|
+
/** Skip when the zone already uses this ground type. */
|
|
574
|
+
unlessGround?: string;
|
|
575
|
+
/** Merge all triggers of the zone into one rectangle. */
|
|
576
|
+
merge?: boolean;
|
|
577
|
+
}
|
|
578
|
+
interface RoomColorDef {
|
|
579
|
+
type: string;
|
|
580
|
+
/** Position in the colour stream, so legacy seeds keep their draws. */
|
|
581
|
+
order: number;
|
|
582
|
+
/** Wall `[hue, lightness]` for a style context. */
|
|
583
|
+
wall(c: PaletteContext): [number, number];
|
|
584
|
+
/** Fixed floor base `[hue, saturation, lightness]`; falls back to the style's general floor. */
|
|
585
|
+
floor?: [number, number, number];
|
|
586
|
+
/** Neutral rooms are capped to low saturation. */
|
|
587
|
+
neutral?: boolean;
|
|
588
|
+
}
|
|
589
|
+
interface Hsl {
|
|
590
|
+
h: number;
|
|
591
|
+
s: number;
|
|
592
|
+
l: number;
|
|
593
|
+
}
|
|
594
|
+
interface FloorplanLocale {
|
|
595
|
+
labels?: Record<string, string>;
|
|
596
|
+
templates?: Record<string, string>;
|
|
597
|
+
styles?: Record<string, string>;
|
|
598
|
+
facadeColors?: Record<string, string>;
|
|
599
|
+
zones?: Record<string, string>;
|
|
600
|
+
reasons?: Record<string, string>;
|
|
601
|
+
messages?: Record<string, string>;
|
|
602
|
+
ui?: Record<string, string>;
|
|
603
|
+
}
|
|
604
|
+
interface ViewerLayerContext {
|
|
605
|
+
/** Canvas 2D context, already in CSS pixels. */
|
|
606
|
+
g: CanvasRenderingContext2D;
|
|
607
|
+
plan: Json;
|
|
608
|
+
/** Storey being drawn (0 when `all`). */
|
|
609
|
+
floor: number;
|
|
610
|
+
/** All storeys at once (the lot view). */
|
|
611
|
+
all: boolean;
|
|
612
|
+
/** Metres to pixels. */
|
|
613
|
+
scale: number;
|
|
614
|
+
X(u: number): number;
|
|
615
|
+
Z(v: number): number;
|
|
616
|
+
rect(r: Rect, fill?: string | null, stroke?: string | null, lineWidth?: number): void;
|
|
617
|
+
/** Tooltip area (metres) with its text. */
|
|
618
|
+
hit(r: Rect, text: string): void;
|
|
619
|
+
}
|
|
620
|
+
interface ViewerLayerLegendEntry {
|
|
621
|
+
label: string;
|
|
622
|
+
color: string;
|
|
623
|
+
shape: 'filled' | 'hollow' | 'dashed' | 'line';
|
|
624
|
+
}
|
|
625
|
+
/** A layer a pack adds to the 2D viewer (the structure pack draws pillars and beams); the viewer shows a checkbox for it. */
|
|
626
|
+
interface ViewerLayer {
|
|
627
|
+
id: string;
|
|
628
|
+
/** Checkbox text, or a key of the `ui` locale table. */
|
|
629
|
+
label: string;
|
|
630
|
+
defaultOn?: boolean;
|
|
631
|
+
draw(context: ViewerLayerContext): void;
|
|
632
|
+
legend?(plan: Json): ViewerLayerLegendEntry[];
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
/** Tools handed to a style recipe. `jit` and `rng` draw from the style's seeded stream: draw order is part of the contract. */
|
|
636
|
+
interface PaletteDraw {
|
|
637
|
+
rng: Rng;
|
|
638
|
+
base: [string, number, number, number];
|
|
639
|
+
H0: number;
|
|
640
|
+
H1: number;
|
|
641
|
+
H2: number;
|
|
642
|
+
jit(v: number, a: number): number;
|
|
643
|
+
hsl(h: number, s: number, l: number): Hsl;
|
|
644
|
+
}
|
|
645
|
+
interface PaletteEarly {
|
|
646
|
+
/** Accent mode: true saturates walls, false puts accents on objects. */
|
|
647
|
+
wallMode: boolean;
|
|
648
|
+
/** Maximum wall saturation. */
|
|
649
|
+
sMax: number;
|
|
650
|
+
/** Facade, wall, gate, roof, ceiling... in insertion order. */
|
|
651
|
+
roles: Record<string, Hsl>;
|
|
652
|
+
/** General floor `[h, s, l]` for room types that do not define their own. */
|
|
653
|
+
generalFloor: [number, number, number];
|
|
654
|
+
}
|
|
655
|
+
interface PaletteStyleDef {
|
|
656
|
+
/** Legacy stream suffix; defaults to the style id. */
|
|
657
|
+
seedKey?: string;
|
|
658
|
+
/** Facade colour table `[labelKey, h, s, l]`. */
|
|
659
|
+
facadeColors: [string, number, number, number][];
|
|
660
|
+
/** Draws up to the room colours (before the room loop). */
|
|
661
|
+
early(d: PaletteDraw): PaletteEarly;
|
|
662
|
+
/** Draws the object roles (wood, fabrics, metal, ground colours) after the room loop. */
|
|
663
|
+
late(d: PaletteDraw, e: PaletteEarly): Record<string, Hsl>;
|
|
664
|
+
}
|
|
665
|
+
interface PaletteContext extends PaletteDraw {
|
|
666
|
+
style: string;
|
|
667
|
+
sMax: number;
|
|
668
|
+
wallMode: boolean;
|
|
669
|
+
generalFloor: [number, number, number];
|
|
670
|
+
}
|
|
671
|
+
interface PaletteOptions {
|
|
672
|
+
seed?: number | string;
|
|
673
|
+
style?: string;
|
|
674
|
+
state?: string;
|
|
675
|
+
}
|
|
676
|
+
type Palette = {
|
|
677
|
+
meta: {
|
|
678
|
+
seed: number | string;
|
|
679
|
+
style: string;
|
|
680
|
+
state: string;
|
|
681
|
+
scheme: string;
|
|
682
|
+
base: string;
|
|
683
|
+
accentMode: 'wall' | 'object';
|
|
684
|
+
};
|
|
685
|
+
} & Record<string, number | object>;
|
|
686
|
+
/** Seeded colour-harmony palette: a facade base colour, a harmony scheme, role colours and contrast rules. */
|
|
687
|
+
declare function palette(o?: PaletteOptions): Palette;
|
|
688
|
+
|
|
689
|
+
/** What a container holds, from the first registered provider that answers (`null` passes to the next); none answering means nothing. */
|
|
690
|
+
declare function findsFor(query: FindsQuery): readonly FindStack[];
|
|
691
|
+
/** Like `findsFor`, but `null` when no provider answered, so a pack can fall back to its own default. */
|
|
692
|
+
declare function findsAnswer(query: FindsQuery): readonly FindStack[] | null;
|
|
693
|
+
|
|
694
|
+
declare function registerItem(def: ItemInput): FurnitureDef;
|
|
695
|
+
declare function registerItems(list: ItemInput[]): void;
|
|
696
|
+
declare function registerLibrary(id: string, library: SlotLibrary): void;
|
|
697
|
+
declare function registerLibraryAlias(alias: string, id: string): void;
|
|
698
|
+
declare function registerTemplate<T extends TemplateDef>(t: T): T;
|
|
699
|
+
declare function registerStyle(style: StyleDef): void;
|
|
700
|
+
declare function registerPaletteStyle(id: string, def: PaletteStyleDef): void;
|
|
701
|
+
declare function registerRoomColors(list: RoomColorDef[]): void;
|
|
702
|
+
declare function registerDecorProfile(styleId: string, profile: Json): void;
|
|
703
|
+
declare function registerPass(name: string, run: DecorPass): void;
|
|
704
|
+
declare function registerGroundOverlay(rule: GroundOverlayRule): void;
|
|
705
|
+
declare function registerWallTop(id: string, height: number): void;
|
|
706
|
+
/** Legacy RNG stream names for rooms and items, so seeds recorded before the English ids still reproduce. */
|
|
707
|
+
declare function registerSeedKeys(keys: {
|
|
708
|
+
rooms?: Record<string, string>;
|
|
709
|
+
items?: Record<string, string>;
|
|
710
|
+
}): void;
|
|
711
|
+
/** Registers a house state. The engine only ships `normal`. */
|
|
712
|
+
declare function registerState(name: string, plugin: StatePlugin): void;
|
|
713
|
+
/** Default state draw when `options.state` is absent: `{ state: weight }` on its own seeded stream. */
|
|
714
|
+
declare function setStateDistribution(weights: Record<string, number> | null, seedKey?: string): void;
|
|
715
|
+
declare const listStates: () => string[];
|
|
716
|
+
/** Adds a named piece to every result, after the state and before the zoning report; its output lands in `result[name]`. */
|
|
717
|
+
declare function registerResultExtension(name: string, run: ResultExtensionRun, options?: ResultExtensionOptions): void;
|
|
718
|
+
/** Registers who answers what a container holds (the item packs, from phase 3 on). */
|
|
719
|
+
declare function registerFindsProvider(provider: FindsProvider): void;
|
|
720
|
+
/** Adds (or replaces, by id) a layer of the 2D viewer; drawn after the items, before the labels. */
|
|
721
|
+
declare function registerViewerLayer(layer: ViewerLayer): void;
|
|
722
|
+
|
|
723
|
+
/** Recorded slots (resolved positions) of every storey and of the lot. */
|
|
724
|
+
declare function slots(template: string | TemplateDef, options?: FloorplanOptions): Json[];
|
|
725
|
+
/** Generates a plan: building, lot, seeded item fill, decor, house state and palette. */
|
|
726
|
+
declare function generate(template: string | TemplateDef, options?: FloorplanOptions): Json;
|
|
727
|
+
/** Validates a result of `generate`; returns a list of messages (empty when valid). */
|
|
728
|
+
declare function validate(result: Json, options?: {
|
|
729
|
+
locale?: string;
|
|
730
|
+
}): string[];
|
|
731
|
+
/** Size limits and default size of a template (they can depend on options such as `tier`). */
|
|
732
|
+
declare function limitsOf(template: string | TemplateDef, options?: FloorplanOptions): {
|
|
733
|
+
limits: {
|
|
734
|
+
w: number[];
|
|
735
|
+
d: number[];
|
|
736
|
+
};
|
|
737
|
+
defaults: {
|
|
738
|
+
w: number;
|
|
739
|
+
d: number;
|
|
740
|
+
};
|
|
741
|
+
};
|
|
742
|
+
declare function listTemplates(locale?: string): {
|
|
743
|
+
id: string;
|
|
744
|
+
name: string;
|
|
745
|
+
use: string;
|
|
746
|
+
style: string;
|
|
747
|
+
limits: {
|
|
748
|
+
w: number[];
|
|
749
|
+
d: number[];
|
|
750
|
+
};
|
|
751
|
+
defaults: {
|
|
752
|
+
w: number;
|
|
753
|
+
d: number;
|
|
754
|
+
};
|
|
755
|
+
floors: number;
|
|
756
|
+
floorRange: [number, number] | null;
|
|
757
|
+
lot: boolean;
|
|
758
|
+
options: any;
|
|
759
|
+
}[];
|
|
760
|
+
|
|
761
|
+
type Namespace = keyof FloorplanLocale;
|
|
762
|
+
/** Registers (or extends) the strings of a language. Packs call this with their JSON files. */
|
|
763
|
+
declare function registerLocale(code: string, table: FloorplanLocale): void;
|
|
764
|
+
declare const listLocales: () => string[];
|
|
765
|
+
/** Looks a key up in a namespace. Falls back to English, then to the key itself. `{n}`-style variables are replaced. */
|
|
766
|
+
declare function translate(ns: Namespace, key: string, locale?: string, vars?: Record<string, string | number>): string;
|
|
767
|
+
|
|
768
|
+
/** Builders for the slot definitions of a room library. */
|
|
769
|
+
declare const slotKit: SlotKit;
|
|
770
|
+
|
|
771
|
+
/** Registers an urban zone (zoning rules). Returns the stored definition. */
|
|
772
|
+
declare function defineZone(zone: ZoneDef): ZoneDef;
|
|
773
|
+
declare const getZone: (id: string) => ZoneDef | undefined;
|
|
774
|
+
declare const listZones: () => ZoneDef[];
|
|
775
|
+
/** Marks ground types (e.g. `lawn`, `dirt`) that count towards the permeable area of a lot. */
|
|
776
|
+
declare function registerPermeableGround(...types: string[]): void;
|
|
777
|
+
/**
|
|
778
|
+
* Checks a generated lot against a zone and returns the violations (empty when compliant).
|
|
779
|
+
* `lot` is `result.lot` (may be null for apartments), `plan` is the result of `generate`.
|
|
780
|
+
*/
|
|
781
|
+
declare function checkLot(zoneIn: string | ZoneDef, lot: Json, plan: Json): ZoneViolation[];
|
|
782
|
+
|
|
783
|
+
declare const overlaps: (a: Rect, b: Rect, e?: number) => boolean;
|
|
784
|
+
declare function openingZones(u: number, v: number, axis: 'u' | 'v', width: number, depth: number): Rect[];
|
|
785
|
+
|
|
786
|
+
/** Keep-out zone of a window (inside, or outside for the lot). */
|
|
787
|
+
declare function windowZone(j: Json, outside?: boolean): Rect;
|
|
788
|
+
/** `overheadOff`: the counter sits under the window without its wall cabinet. */
|
|
789
|
+
declare function blocksWindow(it: Pick<FurnitureDef, 'window' | 'overhead' | 'windowHeight'> & {
|
|
790
|
+
h: number;
|
|
791
|
+
}, win: Json, overheadOff?: boolean): boolean;
|
|
792
|
+
|
|
793
|
+
/** One primitive of a far-away silhouette. Parts are listed in creation order; `parent` is the index of a group part (`-1` is the root). */
|
|
794
|
+
type SilhouettePart = {
|
|
795
|
+
shape: 'group';
|
|
796
|
+
parent: number;
|
|
797
|
+
x: number;
|
|
798
|
+
y: number;
|
|
799
|
+
z: number;
|
|
800
|
+
ry: number;
|
|
801
|
+
} | {
|
|
802
|
+
shape: 'box';
|
|
803
|
+
parent: number;
|
|
804
|
+
x: number;
|
|
805
|
+
y: number;
|
|
806
|
+
z: number;
|
|
807
|
+
width: number;
|
|
808
|
+
height: number;
|
|
809
|
+
depth: number;
|
|
810
|
+
color: number;
|
|
811
|
+
emissive: boolean;
|
|
812
|
+
ry: number;
|
|
813
|
+
rz: number;
|
|
814
|
+
radius: number;
|
|
815
|
+
} | {
|
|
816
|
+
shape: 'prism';
|
|
817
|
+
parent: number;
|
|
818
|
+
x: number;
|
|
819
|
+
y: number;
|
|
820
|
+
z: number;
|
|
821
|
+
width: number;
|
|
822
|
+
height: number;
|
|
823
|
+
depth: number;
|
|
824
|
+
color: number;
|
|
825
|
+
ry: number;
|
|
826
|
+
} | {
|
|
827
|
+
shape: 'cylinder';
|
|
828
|
+
parent: number;
|
|
829
|
+
x: number;
|
|
830
|
+
y: number;
|
|
831
|
+
z: number;
|
|
832
|
+
radiusTop: number;
|
|
833
|
+
radiusBottom: number;
|
|
834
|
+
height: number;
|
|
835
|
+
color: number;
|
|
836
|
+
segments: number;
|
|
837
|
+
} | {
|
|
838
|
+
shape: 'line';
|
|
839
|
+
parent: number;
|
|
840
|
+
points: [number, number, number][];
|
|
841
|
+
color: number;
|
|
842
|
+
} | {
|
|
843
|
+
shape: 'sign';
|
|
844
|
+
parent: number;
|
|
845
|
+
x: number;
|
|
846
|
+
y: number;
|
|
847
|
+
z: number;
|
|
848
|
+
width: number;
|
|
849
|
+
height: number;
|
|
850
|
+
ry: number;
|
|
851
|
+
text: string;
|
|
852
|
+
background: string;
|
|
853
|
+
foreground: string;
|
|
854
|
+
};
|
|
855
|
+
/** A window the renderer draws as an instance (a lit one glows). `ry` is the facing; the size is width by height. */
|
|
856
|
+
type SilhouetteWindow = {
|
|
857
|
+
x: number;
|
|
858
|
+
y: number;
|
|
859
|
+
z: number;
|
|
860
|
+
ry: number;
|
|
861
|
+
width: number;
|
|
862
|
+
height: number;
|
|
863
|
+
isLit: boolean;
|
|
864
|
+
};
|
|
865
|
+
type Silhouette = {
|
|
866
|
+
parts: SilhouettePart[];
|
|
867
|
+
windows: SilhouetteWindow[];
|
|
868
|
+
/** Footprint on the ground: centre and size, for the LOD plan. */
|
|
869
|
+
footprint: {
|
|
870
|
+
x: number;
|
|
871
|
+
z: number;
|
|
872
|
+
width: number;
|
|
873
|
+
depth: number;
|
|
874
|
+
height: number;
|
|
875
|
+
};
|
|
876
|
+
};
|
|
877
|
+
type RandomSource = () => number;
|
|
878
|
+
|
|
879
|
+
/** The page's own seeded generator (mulberry32), so a silhouette drawn from the same seed has the same windows and colours. */
|
|
880
|
+
declare function createSilhouetteRandom(seed: number): RandomSource;
|
|
881
|
+
|
|
882
|
+
type CityBuildingParams = {
|
|
883
|
+
x: number;
|
|
884
|
+
z: number;
|
|
885
|
+
width: number;
|
|
886
|
+
depth: number;
|
|
887
|
+
height: number;
|
|
888
|
+
color: number;
|
|
889
|
+
/** Chance of a ground-floor shop on both long faces; omitted means none. */
|
|
890
|
+
shopChance?: number;
|
|
891
|
+
/** Chance that a window is lit. */
|
|
892
|
+
litChance?: number;
|
|
893
|
+
random?: RandomSource;
|
|
894
|
+
seed?: number;
|
|
895
|
+
};
|
|
896
|
+
/** City building: block, roof slab, maybe a vent, maybe a shop front, and window instances on the four faces. */
|
|
897
|
+
declare function createCityBuilding(p: CityBuildingParams): Silhouette;
|
|
898
|
+
|
|
899
|
+
type Seeded = {
|
|
900
|
+
random?: RandomSource;
|
|
901
|
+
seed?: number;
|
|
902
|
+
};
|
|
903
|
+
type TwoStoreyParams = Seeded & {
|
|
904
|
+
x: number;
|
|
905
|
+
z: number;
|
|
906
|
+
width: number;
|
|
907
|
+
depth: number;
|
|
908
|
+
color: number;
|
|
909
|
+
roofColor?: number;
|
|
910
|
+
ry?: number;
|
|
911
|
+
};
|
|
912
|
+
/** Two-storey house with a balcony slab, pitched roof and four windows. */
|
|
913
|
+
declare function createTwoStoreyHouse(p: TwoStoreyParams): Silhouette;
|
|
914
|
+
type SlabHouseParams = Seeded & {
|
|
915
|
+
x: number;
|
|
916
|
+
z: number;
|
|
917
|
+
width: number;
|
|
918
|
+
depth: number;
|
|
919
|
+
floors: number;
|
|
920
|
+
color: number;
|
|
921
|
+
};
|
|
922
|
+
/** Reinforced-concrete slab house of one to three floors, with water tank, side stair and sometimes rebar starters. */
|
|
923
|
+
declare function createSlabHouse(p: SlabHouseParams): Silhouette;
|
|
924
|
+
type ColonialParams = Seeded & {
|
|
925
|
+
x: number;
|
|
926
|
+
z: number;
|
|
927
|
+
width: number;
|
|
928
|
+
color: number;
|
|
929
|
+
hasDoor: boolean;
|
|
930
|
+
};
|
|
931
|
+
/** Colonial terrace house: parapet, roof behind it and a row of doors or windows. */
|
|
932
|
+
declare function createColonialHouse(p: ColonialParams): Silhouette;
|
|
933
|
+
type ChaletParams = Seeded & {
|
|
934
|
+
x: number;
|
|
935
|
+
z: number;
|
|
936
|
+
color?: number;
|
|
937
|
+
ry?: number;
|
|
938
|
+
};
|
|
939
|
+
/** Wooden chalet on a stone base with a steep roof and a chimney. */
|
|
940
|
+
declare function createChalet(p: ChaletParams): Silhouette;
|
|
941
|
+
type CompanyHouseParams = Seeded & {
|
|
942
|
+
x: number;
|
|
943
|
+
z: number;
|
|
944
|
+
color?: number;
|
|
945
|
+
};
|
|
946
|
+
/** Company-town house with a low front fence. */
|
|
947
|
+
declare function createCompanyHouse(p: CompanyHouseParams): Silhouette;
|
|
948
|
+
type StiltHouseParams = Seeded & {
|
|
949
|
+
x: number;
|
|
950
|
+
z: number;
|
|
951
|
+
color?: number;
|
|
952
|
+
};
|
|
953
|
+
/** House on stilts with a ramp-like entry platform. */
|
|
954
|
+
declare function createStiltHouse(p: StiltHouseParams): Silhouette;
|
|
955
|
+
type FarmhouseParams = Seeded & {
|
|
956
|
+
x: number;
|
|
957
|
+
z: number;
|
|
958
|
+
};
|
|
959
|
+
/** Farm house with a long covered porch on six posts. */
|
|
960
|
+
declare function createFarmhouse(p: FarmhouseParams): Silhouette;
|
|
961
|
+
type DetachedHouseParams = Seeded & {
|
|
962
|
+
x: number;
|
|
963
|
+
z: number;
|
|
964
|
+
width: number;
|
|
965
|
+
depth: number;
|
|
966
|
+
color: number;
|
|
967
|
+
roofColor?: number;
|
|
968
|
+
ry?: number;
|
|
969
|
+
isBoarded?: boolean;
|
|
970
|
+
};
|
|
971
|
+
/** One-storey detached house; boarded windows get two crossed planks each. */
|
|
972
|
+
declare function createDetachedHouse(p: DetachedHouseParams): Silhouette;
|
|
973
|
+
|
|
974
|
+
declare const version = "0.1.0";
|
|
975
|
+
/**
|
|
976
|
+
* The engine as a single object. Content packs take it as an argument (`register(engine)`), so that
|
|
977
|
+
* several bundles (ESM or IIFE) always fill the same registries.
|
|
978
|
+
*/
|
|
979
|
+
declare const engine: {
|
|
980
|
+
version: string;
|
|
981
|
+
generate: typeof generate;
|
|
982
|
+
slots: typeof slots;
|
|
983
|
+
validate: typeof validate;
|
|
984
|
+
palette: typeof palette;
|
|
985
|
+
limitsOf: typeof limitsOf;
|
|
986
|
+
listTemplates: typeof listTemplates;
|
|
987
|
+
listStates: () => string[];
|
|
988
|
+
registerItem: typeof registerItem;
|
|
989
|
+
registerItems: typeof registerItems;
|
|
990
|
+
registerLibrary: typeof registerLibrary;
|
|
991
|
+
registerLibraryAlias: typeof registerLibraryAlias;
|
|
992
|
+
registerTemplate: typeof registerTemplate;
|
|
993
|
+
registerStyle: typeof registerStyle;
|
|
994
|
+
registerPaletteStyle: typeof registerPaletteStyle;
|
|
995
|
+
registerRoomColors: typeof registerRoomColors;
|
|
996
|
+
registerDecorProfile: typeof registerDecorProfile;
|
|
997
|
+
registerPass: typeof registerPass;
|
|
998
|
+
registerGroundOverlay: typeof registerGroundOverlay;
|
|
999
|
+
registerWallTop: typeof registerWallTop;
|
|
1000
|
+
registerSeedKeys: typeof registerSeedKeys;
|
|
1001
|
+
registerState: typeof registerState;
|
|
1002
|
+
setStateDistribution: typeof setStateDistribution;
|
|
1003
|
+
registerLocale: typeof registerLocale;
|
|
1004
|
+
registerResultExtension: typeof registerResultExtension;
|
|
1005
|
+
registerFindsProvider: typeof registerFindsProvider;
|
|
1006
|
+
findsFor: typeof findsFor;
|
|
1007
|
+
findsAnswer: typeof findsAnswer;
|
|
1008
|
+
registerViewerLayer: typeof registerViewerLayer;
|
|
1009
|
+
viewerLayers: ViewerLayer[];
|
|
1010
|
+
blocksWindow: typeof blocksWindow;
|
|
1011
|
+
defineZone: typeof defineZone;
|
|
1012
|
+
getZone: (id: string) => ZoneDef | undefined;
|
|
1013
|
+
listZones: () => ZoneDef[];
|
|
1014
|
+
checkLot: typeof checkLot;
|
|
1015
|
+
registerPermeableGround: typeof registerPermeableGround;
|
|
1016
|
+
slotKit: SlotKit;
|
|
1017
|
+
translate: typeof translate;
|
|
1018
|
+
listLocales: () => string[];
|
|
1019
|
+
templates: Record<string, TemplateDef>;
|
|
1020
|
+
catalog: Record<string, FurnitureDef>;
|
|
1021
|
+
libraries: Record<string, SlotLibrary>;
|
|
1022
|
+
styles: Record<string, StyleDef>;
|
|
1023
|
+
paletteStyles: Record<string, PaletteStyleDef>;
|
|
1024
|
+
createRng: (seed: string | number, key: string) => Rng;
|
|
1025
|
+
mulberry32: typeof mulberry32;
|
|
1026
|
+
hashString: typeof hashString;
|
|
1027
|
+
overlaps: (a: Rect, b: Rect, e?: number) => boolean;
|
|
1028
|
+
windowZone: typeof windowZone;
|
|
1029
|
+
openingZones: typeof openingZones;
|
|
1030
|
+
color: {
|
|
1031
|
+
lstar: (n: number) => number;
|
|
1032
|
+
hex: (n: number) => string;
|
|
1033
|
+
hsl: (n: number) => Hsl;
|
|
1034
|
+
HIGH_SATURATION: number;
|
|
1035
|
+
MIN_WALL_FLOOR_CONTRAST: number;
|
|
1036
|
+
MIN_FABRIC_FLOOR_CONTRAST: number;
|
|
1037
|
+
};
|
|
1038
|
+
constants: {
|
|
1039
|
+
WALL_THICKNESS: number;
|
|
1040
|
+
DOOR_CLEARANCE: number;
|
|
1041
|
+
PLAYER_RADIUS: number;
|
|
1042
|
+
DOOR_EDGE_CLEARANCE: number;
|
|
1043
|
+
WINDOW_EDGE_CLEARANCE: number;
|
|
1044
|
+
OVERHEAD_TOP: number;
|
|
1045
|
+
CAR_CLEARANCE: {
|
|
1046
|
+
readonly driver: 0.8;
|
|
1047
|
+
readonly side: 0.6;
|
|
1048
|
+
readonly end: 0.6;
|
|
1049
|
+
};
|
|
1050
|
+
};
|
|
1051
|
+
};
|
|
1052
|
+
type FloorplanEngine = typeof engine;
|
|
1053
|
+
|
|
1054
|
+
export { type Anchor, type BoundaryRule, type CarClearance, type ChaletParams, type CityBuildingParams, type ColonialParams, type CompanyHouseParams, type DecorPass, type DecorPassContext, type DetachedHouseParams, type DoorDef, type FacingRule, type FarmhouseParams, type FindStack, type FindsProvider, type FindsQuery, type FloorDef, type FloorplanEngine, type FloorplanLocale, type FloorplanOptions, type FurnitureDef, type GateCfg, type GroundOverlayRule, type Hsl, type ItemColor, type ItemInput, type Json, type LotConfig, type MeshFront, type Mount, type PaletteDraw, type PaletteEarly, type PaletteStyleDef, type PlacedItem, type PlacementContext, type PlacementKit, type Plan, type RandomSource, type Rect, type ResultExtensionContext, type ResultExtensionOptions, type ResultExtensionRun, type Room, type RoomColorDef, type RoomDef, type Side, type Silhouette, type SilhouettePart, type SilhouetteWindow, type SlabHouseParams, type Slot, type SlotDef, type SlotKit, type SlotLibrary, type StateContext, type StatePlugin, type StiltHouseParams, type StyleDef, type TemplateDef, type TwoStoreyParams, type Vec2, type ViewerLayer, type ViewerLayerContext, type ViewerLayerLegendEntry, type Weights, type WindowDef, type ZoneAdjustment, type ZoneDef, type ZoneViolation, type ZoningReport, blocksWindow, checkLot, createChalet, createCityBuilding, createColonialHouse, createCompanyHouse, createDetachedHouse, createFarmhouse, createRng, createSilhouetteRandom, createSlabHouse, createStiltHouse, createTwoStoreyHouse, defineZone, engine, findsAnswer, findsFor, generate, getZone, hashString, limitsOf, listLocales, listStates, listTemplates, listZones, mulberry32, openingZones, overlaps, palette, registerDecorProfile, registerFindsProvider, registerGroundOverlay, registerItem, registerItems, registerLibrary, registerLibraryAlias, registerLocale, registerPaletteStyle, registerPass, registerPermeableGround, registerResultExtension, registerRoomColors, registerSeedKeys, registerState, registerStyle, registerTemplate, registerViewerLayer, registerWallTop, setStateDistribution, slotKit, slots, translate, validate, version, windowZone };
|