@adatechnology/game-urban 0.3.13 → 0.5.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/README.md +95 -1
- package/dist/index.d.ts +5 -998
- package/dist/index.global.js +365 -151
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +92 -18
- package/dist/index.js.map +1 -1
- package/dist/networks/index.d.ts +647 -0
- package/dist/networks/index.js +2070 -0
- package/dist/networks/index.js.map +1 -0
- package/dist/types-mY6VwZgN.d.ts +1087 -0
- package/package.json +11 -7
package/dist/index.d.ts
CHANGED
|
@@ -1,562 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
export { RandomSource, Silhouette, SilhouettePart, SilhouetteWindow } from '@adatechnology/game-floorplan';
|
|
1
|
+
import { L as LightAllowance, U as UrbanBuilder, D as DistrictKindDef, C as CityPlanInput, T as TowerPreset, F as FillBlockOptions, B as BlockBuilding, a as CityPlanDef, b as LayoutOptions, c as CityLayout, K as KindStats, d as Block, e as FillBlockCityOptions, f as ComposeOptions, g as UrbanKitCore, N as NeighbourhoodPattern, h as Composer, i as UrbanPlan, j as Locale, P as Point, R as Rect, k as TerrainOptions, l as TerrainGrid, m as PoleDef, n as PoleOptions, o as PoleShapeBuilder, p as TowerOptions, q as BuildingOptions, S as SilhouetteFactory, H as HouseProvider, r as PlantRequest, V as VehicleRequest, s as PlantProvider, t as VehicleProvider } from './types-mY6VwZgN.js';
|
|
2
|
+
export { u as BarSpec, v as BlockUse, w as CityScale, x as ColorRule, y as ComposeContext, z as ConePart, A as CrossarmSpec, E as CrownPart, G as DEFAULT_FACADES, I as DEFAULT_POLES, J as DEFAULT_STOREY_PRESETS, M as DEFAULT_TOWER_PRESETS, O as DistributionPoleDef, Q as DistributionSpec, W as DistrictKindText, X as DoubleArmSpec, Y as Flatten, Z as Flickering, _ as FloodTowerSpec, $ as ForestOptions, a0 as HouseRequest, a1 as ItemBox, a2 as LabelPart, a3 as Lake, a4 as LampLightSpec, a5 as LampShares, a6 as LampSpec, a7 as LampState, a8 as LampStateParams, a9 as LanternSpec, aa as LensSpec, ab as LightBudget, ac as LightPart, ad as MastSpec, ae as POLE_SHAPES, af as PartStyle, ag as PatternText, ah as PlacementPart, ai as PlanDistrict, aj as PlanLandmark, ak as PlanLine, al as PlanPoint, am as PlanRect, an as PlanePart, ao as PoleSlotBand, ap as PoleSlots, aq as Providers, ar as Ramp, as as ResolvedDistrict, at as River, au as RiverBed, av as SingleArmSpec, aw as TOWER_DEFAULTS, ax as TerrainLayer, ay as TerrainPart, az as TowerProvider, aA as TowerRequest, aB as Trig, aC as UrbanBuilderOptions, aD as UrbanPart, aE as UrbanScene, aF as VaultPart, aG as Wave, aH as WorldFrame, aI as assertLampShares, aJ as createTowerDrawer, aK as createUrbanBuilder, aL as drawBuilding, aM as drawTower, aN as fillBlock, aO as flickerPhaseOf, aP as lampStateOf, aQ as pickTowerPreset, aR as towerPresetOf, aS as towerStoreys } from './types-mY6VwZgN.js';
|
|
4
3
|
import { DeepPartial } from '@adatechnology/game-contracts';
|
|
4
|
+
import { RandomSource } from '@adatechnology/game-floorplan';
|
|
5
|
+
export { RandomSource, Silhouette, SilhouettePart, SilhouetteWindow } from '@adatechnology/game-floorplan';
|
|
5
6
|
import { Region } from '@adatechnology/game-vegetation-species';
|
|
6
7
|
|
|
7
|
-
type Trig = 'sin' | 'cos';
|
|
8
|
-
type Point = readonly [number, number];
|
|
9
|
-
type Rect = readonly [number, number, number, number];
|
|
10
|
-
/** One term of a rolling surface. `product`: `fx(kx·px) · fy(ky·py) · amplitude`. `diagonal`: `sin(kx·px + ky·py) · amplitude`. */
|
|
11
|
-
type Wave = {
|
|
12
|
-
kind: 'product';
|
|
13
|
-
x: readonly [Trig, number];
|
|
14
|
-
y: readonly [Trig, number];
|
|
15
|
-
amplitude: number;
|
|
16
|
-
} | {
|
|
17
|
-
kind: 'diagonal';
|
|
18
|
-
kx: number;
|
|
19
|
-
ky: number;
|
|
20
|
-
amplitude: number;
|
|
21
|
-
};
|
|
22
|
-
/** A factor of a mask: a smoothstep along one axis. With `fullUntil`, everything before that value counts as 1. */
|
|
23
|
-
type Ramp = {
|
|
24
|
-
axis: 'x' | 'y';
|
|
25
|
-
from: number;
|
|
26
|
-
to: number;
|
|
27
|
-
fullUntil?: number;
|
|
28
|
-
};
|
|
29
|
-
/** A region that adds relief: `mask · (level + waves)`. The mask is the product of its ramps. */
|
|
30
|
-
type TerrainLayer = {
|
|
31
|
-
id: string;
|
|
32
|
-
mask: readonly Ramp[];
|
|
33
|
-
level: number;
|
|
34
|
-
waves: readonly Wave[];
|
|
35
|
-
};
|
|
36
|
-
/** Levels a rectangle (a city) towards `level`, from `margin` outside it to the inside, by a smoothstep of the distance to its nearest edge. */
|
|
37
|
-
type Flatten = {
|
|
38
|
-
id: string;
|
|
39
|
-
rect: Rect;
|
|
40
|
-
margin: number;
|
|
41
|
-
edge: readonly [number, number];
|
|
42
|
-
level: number;
|
|
43
|
-
};
|
|
44
|
-
/** The bed of a river: a fixed height, or `below` the surrounding ground but never lower than `floor`. */
|
|
45
|
-
type RiverBed = {
|
|
46
|
-
fixed: number;
|
|
47
|
-
} | {
|
|
48
|
-
below: number;
|
|
49
|
-
floor: number;
|
|
50
|
-
};
|
|
51
|
-
/** A river as a polyline; the ground eases from the bed to the land between the two distances of `width`. */
|
|
52
|
-
type River = {
|
|
53
|
-
id: string;
|
|
54
|
-
points: readonly Point[];
|
|
55
|
-
width: readonly [number, number];
|
|
56
|
-
bed: RiverBed;
|
|
57
|
-
};
|
|
58
|
-
/** A lake as an ellipse; the ground eases from `level` to the land between the two fractions of `edge` and is untouched past `reach`. */
|
|
59
|
-
type Lake = {
|
|
60
|
-
id: string;
|
|
61
|
-
center: Point;
|
|
62
|
-
radius: Point;
|
|
63
|
-
level: number;
|
|
64
|
-
edge: readonly [number, number];
|
|
65
|
-
reach: number;
|
|
66
|
-
};
|
|
67
|
-
/** Where trees grow: the strongest of the masked zones and a patchy noise. */
|
|
68
|
-
type ForestOptions = {
|
|
69
|
-
zones: readonly {
|
|
70
|
-
mask: readonly Ramp[];
|
|
71
|
-
}[];
|
|
72
|
-
patch?: {
|
|
73
|
-
waves: readonly Wave[];
|
|
74
|
-
edge: readonly [number, number];
|
|
75
|
-
weight: number;
|
|
76
|
-
};
|
|
77
|
-
};
|
|
78
|
-
/** What colours a vertex, tried in this order; the first rule that matches wins. */
|
|
79
|
-
type ColorRule = {
|
|
80
|
-
kind: 'below';
|
|
81
|
-
height: number;
|
|
82
|
-
color: number;
|
|
83
|
-
} | {
|
|
84
|
-
kind: 'above';
|
|
85
|
-
height: number;
|
|
86
|
-
color: number;
|
|
87
|
-
} | {
|
|
88
|
-
kind: 'ellipse';
|
|
89
|
-
center: Point;
|
|
90
|
-
radius: Point;
|
|
91
|
-
color: number;
|
|
92
|
-
} | {
|
|
93
|
-
kind: 'rects';
|
|
94
|
-
rects: readonly Rect[];
|
|
95
|
-
margin: number;
|
|
96
|
-
color: number;
|
|
97
|
-
} | {
|
|
98
|
-
kind: 'forest';
|
|
99
|
-
above: number;
|
|
100
|
-
color: number;
|
|
101
|
-
};
|
|
102
|
-
/** Map coordinates (the ground plan) to world metres: `world = map · scale + origin`. The mesh is a square of `size` metres with `segments` cells a side. */
|
|
103
|
-
type WorldFrame = {
|
|
104
|
-
size: number;
|
|
105
|
-
scale: number;
|
|
106
|
-
origin: number;
|
|
107
|
-
segments: number;
|
|
108
|
-
};
|
|
109
|
-
/** Everything that makes a terrain; the numbers of a place live in the game, not here. */
|
|
110
|
-
type TerrainOptions = {
|
|
111
|
-
world: WorldFrame;
|
|
112
|
-
base: {
|
|
113
|
-
level: number;
|
|
114
|
-
waves: readonly Wave[];
|
|
115
|
-
};
|
|
116
|
-
layers: readonly TerrainLayer[];
|
|
117
|
-
flatten: readonly Flatten[];
|
|
118
|
-
rivers: readonly River[];
|
|
119
|
-
lakes: readonly Lake[];
|
|
120
|
-
forest: ForestOptions;
|
|
121
|
-
colors: readonly ColorRule[];
|
|
122
|
-
/** Colours of the open ground, picked by a hash of the map cell. */
|
|
123
|
-
fields: {
|
|
124
|
-
colors: readonly number[];
|
|
125
|
-
cell: Point;
|
|
126
|
-
};
|
|
127
|
-
/** The water plane under the whole terrain. */
|
|
128
|
-
water: {
|
|
129
|
-
level: number;
|
|
130
|
-
color: number;
|
|
131
|
-
roughness: number;
|
|
132
|
-
metalness: number;
|
|
133
|
-
};
|
|
134
|
-
/** Shape of the last touch: changes the height after every layer, river and lake. */
|
|
135
|
-
custom?: (px: number, py: number, height: number) => number;
|
|
136
|
-
};
|
|
137
|
-
/** The ground as numbers a drawer turns into a mesh: a grid of `segments + 1` vertices a side, rows along z. */
|
|
138
|
-
type TerrainGrid = {
|
|
139
|
-
segments: number;
|
|
140
|
-
size: number;
|
|
141
|
-
/** x and z of each vertex in world metres. */
|
|
142
|
-
x: Float32Array;
|
|
143
|
-
z: Float32Array;
|
|
144
|
-
heights: Float32Array;
|
|
145
|
-
/** Colour of each vertex as 0xRRGGBB. */
|
|
146
|
-
colors: Uint32Array;
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
/** How a drawer treats a part when the default (standard material, rough 0.9, shadows on) is not what the team's page does. */
|
|
150
|
-
type PartStyle = {
|
|
151
|
-
/** Metal and paint of the standard material. */
|
|
152
|
-
roughness?: number;
|
|
153
|
-
metalness?: number;
|
|
154
|
-
/** Shadows: boxes, cylinders, cones and prisms cast and receive by default, planes only receive, crowns only cast, signs and lines neither. */
|
|
155
|
-
castShadow?: boolean;
|
|
156
|
-
receiveShadow?: boolean;
|
|
157
|
-
};
|
|
158
|
-
type Styled<TPart> = TPart & {
|
|
159
|
-
style?: PartStyle;
|
|
160
|
-
};
|
|
161
|
-
/** A cone (pointed cap of an iron pole, pine foliage); `y` is the centre. Flat shaded. */
|
|
162
|
-
type ConePart = {
|
|
163
|
-
shape: 'cone';
|
|
164
|
-
parent: number;
|
|
165
|
-
x: number;
|
|
166
|
-
y: number;
|
|
167
|
-
z: number;
|
|
168
|
-
radius: number;
|
|
169
|
-
height: number;
|
|
170
|
-
color: number;
|
|
171
|
-
segments: number;
|
|
172
|
-
style?: PartStyle;
|
|
173
|
-
};
|
|
174
|
-
/** A rough ball of leaves (a dodecahedron of the given radius). Casts shadows only. */
|
|
175
|
-
type CrownPart = {
|
|
176
|
-
shape: 'crown';
|
|
177
|
-
parent: number;
|
|
178
|
-
x: number;
|
|
179
|
-
y: number;
|
|
180
|
-
z: number;
|
|
181
|
-
radius: number;
|
|
182
|
-
color: number;
|
|
183
|
-
style?: PartStyle;
|
|
184
|
-
};
|
|
185
|
-
/** Half (or any arc) of a cylinder lying down, for a barrel-vault roof. Casts shadows only. `rotation` and `scale` are the mesh's own. */
|
|
186
|
-
type VaultPart = {
|
|
187
|
-
shape: 'vault';
|
|
188
|
-
parent: number;
|
|
189
|
-
x: number;
|
|
190
|
-
y: number;
|
|
191
|
-
z: number;
|
|
192
|
-
radius: number;
|
|
193
|
-
length: number;
|
|
194
|
-
arc: number;
|
|
195
|
-
segments: number;
|
|
196
|
-
color: number;
|
|
197
|
-
rotation: {
|
|
198
|
-
x: number;
|
|
199
|
-
y: number;
|
|
200
|
-
z: number;
|
|
201
|
-
};
|
|
202
|
-
scale: {
|
|
203
|
-
x: number;
|
|
204
|
-
y: number;
|
|
205
|
-
z: number;
|
|
206
|
-
};
|
|
207
|
-
style?: PartStyle;
|
|
208
|
-
};
|
|
209
|
-
/** The ground: a square mesh of the grid's vertices with a colour each, flat shaded, that casts and receives shadows. */
|
|
210
|
-
type TerrainPart = {
|
|
211
|
-
shape: 'terrain';
|
|
212
|
-
parent: number;
|
|
213
|
-
grid: TerrainGrid;
|
|
214
|
-
style?: PartStyle;
|
|
215
|
-
};
|
|
216
|
-
/** A flat rectangle lying on the ground (`y` is its height). */
|
|
217
|
-
type PlanePart = {
|
|
218
|
-
shape: 'plane';
|
|
219
|
-
parent: number;
|
|
220
|
-
x: number;
|
|
221
|
-
y: number;
|
|
222
|
-
z: number;
|
|
223
|
-
width: number;
|
|
224
|
-
depth: number;
|
|
225
|
-
color: number;
|
|
226
|
-
style?: PartStyle;
|
|
227
|
-
};
|
|
228
|
-
/** Text over one or more lines on a canvas texture (street names, strip labels). */
|
|
229
|
-
type LabelPart = {
|
|
230
|
-
shape: 'label';
|
|
231
|
-
parent: number;
|
|
232
|
-
x: number;
|
|
233
|
-
y: number;
|
|
234
|
-
z: number;
|
|
235
|
-
width: number;
|
|
236
|
-
height: number;
|
|
237
|
-
ry: number;
|
|
238
|
-
lines: string[];
|
|
239
|
-
background: string;
|
|
240
|
-
foreground: string;
|
|
241
|
-
font: string;
|
|
242
|
-
canvas: {
|
|
243
|
-
width: number;
|
|
244
|
-
height: number;
|
|
245
|
-
};
|
|
246
|
-
};
|
|
247
|
-
/** A real light. A lamp that did not get one from the budget keeps its glowing lens and has no part like this. */
|
|
248
|
-
type LightPart = {
|
|
249
|
-
shape: 'light';
|
|
250
|
-
kind: 'point';
|
|
251
|
-
parent: number;
|
|
252
|
-
x: number;
|
|
253
|
-
y: number;
|
|
254
|
-
z: number;
|
|
255
|
-
color: number;
|
|
256
|
-
intensity: number;
|
|
257
|
-
distance: number;
|
|
258
|
-
decay: number;
|
|
259
|
-
flicker: boolean;
|
|
260
|
-
} | {
|
|
261
|
-
shape: 'light';
|
|
262
|
-
kind: 'spot';
|
|
263
|
-
parent: number;
|
|
264
|
-
x: number;
|
|
265
|
-
y: number;
|
|
266
|
-
z: number;
|
|
267
|
-
color: number;
|
|
268
|
-
intensity: number;
|
|
269
|
-
distance: number;
|
|
270
|
-
decay: number;
|
|
271
|
-
angle: number;
|
|
272
|
-
penumbra: number;
|
|
273
|
-
/** Where the beam points at rest. */
|
|
274
|
-
target: {
|
|
275
|
-
x: number;
|
|
276
|
-
y: number;
|
|
277
|
-
z: number;
|
|
278
|
-
};
|
|
279
|
-
/** When set the target circles the light: `target = (x + sin(t·speed + x)·radius, 0, z + cos(t·speed + x)·radius)`. */
|
|
280
|
-
sweep?: {
|
|
281
|
-
speed: number;
|
|
282
|
-
radius: number;
|
|
283
|
-
};
|
|
284
|
-
};
|
|
285
|
-
/**
|
|
286
|
-
* A thing another package draws where the scene says: a vehicle of the fleet or a plant of the species pack. The scene keeps only
|
|
287
|
-
* what to put and where; the drawer asks the resolver of that kind for an object (nothing is drawn when it has none).
|
|
288
|
-
* `y` is the base on the ground, `color` the body paint of a vehicle (omitted: the palette of its group by `seed`).
|
|
289
|
-
*/
|
|
290
|
-
type PlacementPart = {
|
|
291
|
-
shape: 'placement';
|
|
292
|
-
parent: number;
|
|
293
|
-
kind: 'vehicle' | 'plant';
|
|
294
|
-
/** Id of the vehicle in the fleet or of the species in the pack. */
|
|
295
|
-
id: string;
|
|
296
|
-
x: number;
|
|
297
|
-
y: number;
|
|
298
|
-
z: number;
|
|
299
|
-
ry: number;
|
|
300
|
-
scale: number;
|
|
301
|
-
color?: number;
|
|
302
|
-
seed: number | string;
|
|
303
|
-
};
|
|
304
|
-
/** The parts of an urban scene: the silhouette vocabulary of game-floorplan plus what streets and poles need. */
|
|
305
|
-
type UrbanPart = Styled<SilhouettePart> | ConePart | CrownPart | PlanePart | VaultPart | TerrainPart | LabelPart | LightPart | PlacementPart;
|
|
306
|
-
/** One small box drawn as an instance of a single mesh (dashes of a road, sandbags). `y` is the base. */
|
|
307
|
-
type ItemBox = {
|
|
308
|
-
x: number;
|
|
309
|
-
y: number;
|
|
310
|
-
z: number;
|
|
311
|
-
width: number;
|
|
312
|
-
height: number;
|
|
313
|
-
depth: number;
|
|
314
|
-
color: number;
|
|
315
|
-
rx: number;
|
|
316
|
-
ry: number;
|
|
317
|
-
rz: number;
|
|
318
|
-
};
|
|
319
|
-
/** Everything a pole, a street, a block or a prop adds to a scene, in the order the team's page adds it. */
|
|
320
|
-
type UrbanScene = {
|
|
321
|
-
parts: UrbanPart[];
|
|
322
|
-
items: ItemBox[];
|
|
323
|
-
windows: {
|
|
324
|
-
lit: SilhouetteWindow[];
|
|
325
|
-
dark: SilhouetteWindow[];
|
|
326
|
-
};
|
|
327
|
-
};
|
|
328
|
-
/**
|
|
329
|
-
* How many lights a scene may spend (a counter, not the render budget of `@adatechnology/game-render-three`). Every lamp that is on takes one, and the first ones win; the rest keep only their
|
|
330
|
-
* glowing lens.
|
|
331
|
-
*/
|
|
332
|
-
type LightAllowance = {
|
|
333
|
-
/** Lights left. It goes below zero when more lamps ask than the budget had, as the team's counter does. */
|
|
334
|
-
left: number;
|
|
335
|
-
/** True while the budget lasts (spends one either way). */
|
|
336
|
-
take(): boolean;
|
|
337
|
-
};
|
|
338
|
-
/** @deprecated Renamed `LightAllowance`: `LightBudget` is the name of the render budget of `@adatechnology/game-render-three`. Removed in the next major. */
|
|
339
|
-
type LightBudget = LightAllowance;
|
|
340
|
-
|
|
341
8
|
/** The team's counter: `take()` is `left-- > 0`, so the count keeps falling after the allowance is spent. */
|
|
342
9
|
declare function createLightAllowance(count: number): LightAllowance;
|
|
343
10
|
/** @deprecated Renamed `createLightAllowance`: `LightBudget` is the name of the render budget of `@adatechnology/game-render-three`. Removed in the next major. */
|
|
344
11
|
declare const createLightBudget: typeof createLightAllowance;
|
|
345
12
|
|
|
346
|
-
type BoxOptions = {
|
|
347
|
-
parent?: number;
|
|
348
|
-
ry?: number;
|
|
349
|
-
rz?: number;
|
|
350
|
-
emissive?: boolean;
|
|
351
|
-
style?: PartStyle;
|
|
352
|
-
};
|
|
353
|
-
type UrbanBuilderOptions = {
|
|
354
|
-
/** Lights the scene may spend; omitted means no limit. */
|
|
355
|
-
budget?: LightAllowance;
|
|
356
|
-
};
|
|
357
|
-
/**
|
|
358
|
-
* Collects the parts of an urban scene the way the team's page adds them to its root: every helper appends in call order, so a
|
|
359
|
-
* scene drawn with the same seeded random has the same parts, the same instances and the same windows.
|
|
360
|
-
* Heights follow the page: `y` is the base of a box, a cylinder, a cone and a prism, and the centre of a crown.
|
|
361
|
-
*/
|
|
362
|
-
declare function createUrbanBuilder(random: RandomSource, options?: UrbanBuilderOptions): {
|
|
363
|
-
random: RandomSource;
|
|
364
|
-
pick: <TEntry>(list: readonly TEntry[]) => TEntry;
|
|
365
|
-
lights: LightAllowance;
|
|
366
|
-
parts: UrbanPart[];
|
|
367
|
-
items: ItemBox[];
|
|
368
|
-
windows: {
|
|
369
|
-
lit: _adatechnology_game_floorplan.SilhouetteWindow[];
|
|
370
|
-
dark: _adatechnology_game_floorplan.SilhouetteWindow[];
|
|
371
|
-
};
|
|
372
|
-
group: (x: number, y: number, z: number, ry?: number, parent?: number) => number;
|
|
373
|
-
box: (x: number, y: number, z: number, width: number, height: number, depth: number, color: number, o?: BoxOptions) => void;
|
|
374
|
-
cylinder: (x: number, y: number, z: number, radiusTop: number, radiusBottom: number, height: number, color: number, parent?: number, segments?: number, style?: PartStyle) => void;
|
|
375
|
-
cone: (x: number, y: number, z: number, radius: number, height: number, color: number, parent?: number, segments?: number) => void;
|
|
376
|
-
prism: (x: number, y: number, z: number, width: number, height: number, depth: number, color: number, parent?: number, ry?: number) => void;
|
|
377
|
-
plane: (x: number, y: number, z: number, width: number, depth: number, color: number, style?: PartStyle, parent?: number) => void;
|
|
378
|
-
vault: (part: Omit<Extract<UrbanPart, {
|
|
379
|
-
shape: "vault";
|
|
380
|
-
}>, "shape" | "parent"> & {
|
|
381
|
-
parent?: number;
|
|
382
|
-
}) => void;
|
|
383
|
-
terrain: (grid: TerrainGrid, parent?: number) => void;
|
|
384
|
-
crown: (x: number, y: number, z: number, radius: number, color: number, parent?: number) => void;
|
|
385
|
-
line: (points: [number, number, number][], color: number, parent?: number) => void;
|
|
386
|
-
label: (lines: string[], x: number, y: number, z: number, width: number, height: number, ry: number, o: {
|
|
387
|
-
background: string;
|
|
388
|
-
foreground: string;
|
|
389
|
-
font?: string;
|
|
390
|
-
canvas?: {
|
|
391
|
-
width: number;
|
|
392
|
-
height: number;
|
|
393
|
-
};
|
|
394
|
-
}, parent?: number) => void;
|
|
395
|
-
light: (part: Omit<Extract<LightPart, {
|
|
396
|
-
kind: "point";
|
|
397
|
-
}>, "shape" | "kind" | "parent" | "decay" | "flicker"> & {
|
|
398
|
-
flicker?: boolean;
|
|
399
|
-
decay?: number;
|
|
400
|
-
}) => void;
|
|
401
|
-
spot: (part: Omit<Extract<LightPart, {
|
|
402
|
-
kind: "spot";
|
|
403
|
-
}>, "shape" | "kind" | "parent">) => void;
|
|
404
|
-
place: (kind: PlacementPart["kind"], id: string, x: number, z: number, o?: {
|
|
405
|
-
y?: number;
|
|
406
|
-
ry?: number;
|
|
407
|
-
scale?: number;
|
|
408
|
-
color?: number;
|
|
409
|
-
seed?: number | string;
|
|
410
|
-
parent?: number;
|
|
411
|
-
}) => void;
|
|
412
|
-
item: (x: number, y: number, z: number, width: number, height: number, depth: number, color: number, ry?: number, rx?: number, rz?: number) => void;
|
|
413
|
-
fence: (x0: number, z0: number, x1: number, z1: number, height: number, color?: number) => void;
|
|
414
|
-
add: (silhouette: Silhouette) => void;
|
|
415
|
-
scene: () => UrbanScene;
|
|
416
|
-
};
|
|
417
|
-
type UrbanBuilder = ReturnType<typeof createUrbanBuilder>;
|
|
418
|
-
|
|
419
|
-
/** The pole that carries the lamp: a tapered cylinder. */
|
|
420
|
-
type MastSpec = {
|
|
421
|
-
radiusTop: number;
|
|
422
|
-
radiusBottom: number;
|
|
423
|
-
height: number;
|
|
424
|
-
color: number;
|
|
425
|
-
segments?: number;
|
|
426
|
-
style?: PartStyle;
|
|
427
|
-
};
|
|
428
|
-
/** A bar or a box of the pole, placed by its base `y`. `reach` is how far from the mast its centre sits. */
|
|
429
|
-
type BarSpec = {
|
|
430
|
-
reach: number;
|
|
431
|
-
y: number;
|
|
432
|
-
width: number;
|
|
433
|
-
height: number;
|
|
434
|
-
depth: number;
|
|
435
|
-
color: number;
|
|
436
|
-
};
|
|
437
|
-
/** The box of a lamp head: its colour is the lens, lit or unlit. */
|
|
438
|
-
type LampSpec = {
|
|
439
|
-
reach: number;
|
|
440
|
-
y: number;
|
|
441
|
-
width: number;
|
|
442
|
-
height: number;
|
|
443
|
-
depth: number;
|
|
444
|
-
};
|
|
445
|
-
/** Colour of the lamp lens when the lamp is on (it glows) and when it is off. */
|
|
446
|
-
type LensSpec = {
|
|
447
|
-
lit: number;
|
|
448
|
-
unlit: number;
|
|
449
|
-
};
|
|
450
|
-
/** The real light a lamp that is on may get from the budget. `reach` moves it along the arm. */
|
|
451
|
-
type LampLightSpec = {
|
|
452
|
-
color: number;
|
|
453
|
-
intensity: number;
|
|
454
|
-
distance: number;
|
|
455
|
-
y: number;
|
|
456
|
-
reach?: number;
|
|
457
|
-
z?: number;
|
|
458
|
-
};
|
|
459
|
-
/** Double arm with two LED heads (the avenue pole of the downtown pattern). */
|
|
460
|
-
type DoubleArmSpec = {
|
|
461
|
-
mast: MastSpec;
|
|
462
|
-
arm: BarSpec;
|
|
463
|
-
lamp: LampSpec;
|
|
464
|
-
lens: LensSpec;
|
|
465
|
-
light: LampLightSpec;
|
|
466
|
-
};
|
|
467
|
-
/** Concrete pole with one arm and a sodium lamp, with an optional transformer drum. */
|
|
468
|
-
type SingleArmSpec = {
|
|
469
|
-
mast: MastSpec;
|
|
470
|
-
arm: BarSpec;
|
|
471
|
-
lamp: LampSpec;
|
|
472
|
-
lens: LensSpec;
|
|
473
|
-
light: LampLightSpec;
|
|
474
|
-
transformer: {
|
|
475
|
-
offset: number;
|
|
476
|
-
y: number;
|
|
477
|
-
radius: number;
|
|
478
|
-
height: number;
|
|
479
|
-
color: number;
|
|
480
|
-
segments: number;
|
|
481
|
-
};
|
|
482
|
-
};
|
|
483
|
-
/** Short iron post with a lantern box and a pointed cap. */
|
|
484
|
-
type LanternSpec = {
|
|
485
|
-
mast: MastSpec;
|
|
486
|
-
lamp: LampSpec;
|
|
487
|
-
cap: {
|
|
488
|
-
y: number;
|
|
489
|
-
radius: number;
|
|
490
|
-
height: number;
|
|
491
|
-
color: number;
|
|
492
|
-
segments: number;
|
|
493
|
-
};
|
|
494
|
-
lens: LensSpec;
|
|
495
|
-
light: LampLightSpec;
|
|
496
|
-
};
|
|
497
|
-
/** Wooden pole with a crossarm and a hanging lamp. */
|
|
498
|
-
type CrossarmSpec = {
|
|
499
|
-
mast: MastSpec;
|
|
500
|
-
arm: BarSpec;
|
|
501
|
-
lamp: LampSpec;
|
|
502
|
-
lens: LensSpec;
|
|
503
|
-
light: LampLightSpec;
|
|
504
|
-
};
|
|
505
|
-
/** Four-legged tower with a deck and a row of floodlights. */
|
|
506
|
-
type FloodTowerSpec = {
|
|
507
|
-
legs: {
|
|
508
|
-
offset: number;
|
|
509
|
-
height: number;
|
|
510
|
-
size: number;
|
|
511
|
-
color: number;
|
|
512
|
-
};
|
|
513
|
-
deck: BarSpec;
|
|
514
|
-
heads: {
|
|
515
|
-
count: number;
|
|
516
|
-
start: number;
|
|
517
|
-
spacing: number;
|
|
518
|
-
y: number;
|
|
519
|
-
z: number;
|
|
520
|
-
width: number;
|
|
521
|
-
height: number;
|
|
522
|
-
depth: number;
|
|
523
|
-
};
|
|
524
|
-
lens: LensSpec;
|
|
525
|
-
light: LampLightSpec;
|
|
526
|
-
};
|
|
527
|
-
/** What a game says when it places a pole. */
|
|
528
|
-
type PoleOptions = {
|
|
529
|
-
x: number;
|
|
530
|
-
z: number;
|
|
531
|
-
/** Lit lamp (glowing lens and, while the budget lasts, a real light). Default true. */
|
|
532
|
-
on?: boolean;
|
|
533
|
-
/** Turns the whole pole (the double arm only; the others are placed by their arm direction). */
|
|
534
|
-
ry?: number;
|
|
535
|
-
/** The real light flickers (a failing lamp). */
|
|
536
|
-
flicker?: boolean;
|
|
537
|
-
/** Which way the arm points, 1 or -1 (single arm). Default 1. */
|
|
538
|
-
dir?: number;
|
|
539
|
-
/** Adds the transformer drum (single arm). */
|
|
540
|
-
transformer?: boolean;
|
|
541
|
-
};
|
|
542
|
-
/** Draws a pole from its `spec`. Declared as a method so the registry can hold each builder with its own spec type (the `PoleDef` names the builder that reads its spec). */
|
|
543
|
-
type PoleShapeBuilder<TSpec extends object = object> = {
|
|
544
|
-
build(b: UrbanBuilder, spec: TSpec, o: PoleOptions): void;
|
|
545
|
-
}['build'];
|
|
546
|
-
type PoleDef = {
|
|
547
|
-
id: string;
|
|
548
|
-
/** Key of the shape builder that reads `spec`. */
|
|
549
|
-
shape: string;
|
|
550
|
-
spec: object;
|
|
551
|
-
};
|
|
552
|
-
/** The shape builders the five default poles use; a game adds its own through `createUrban({ shapes })`. */
|
|
553
|
-
declare const POLE_SHAPES: Readonly<Record<string, PoleShapeBuilder>>;
|
|
554
|
-
/**
|
|
555
|
-
* The five poles of the neighbourhood patterns, with the numbers of the Galeria (heights, arms, lens colours, the colour,
|
|
556
|
-
* strength and reach of the real light). A game patches a number by id or adds a pole with its own shape.
|
|
557
|
-
*/
|
|
558
|
-
declare const DEFAULT_POLES: readonly PoleDef[];
|
|
559
|
-
|
|
560
13
|
/** Look of the road surface and its centre line; the defaults are the Galeria's. */
|
|
561
14
|
type RoadStyle = {
|
|
562
15
|
color: number;
|
|
@@ -596,141 +49,6 @@ declare function drawGround(b: UrbanBuilder, color?: number, size?: number): voi
|
|
|
596
49
|
*/
|
|
597
50
|
declare function drawStreetGrid(b: UrbanBuilder, block: number, count: number, width: number, options?: StreetOptions): void;
|
|
598
51
|
|
|
599
|
-
/**
|
|
600
|
-
* One kind of tower the city can put on a tall lot: the numbers of a typology of `game-floorplan-commercial` (office) or `game-floorplan-residential`
|
|
601
|
-
* (residential), which the tests keep equal to theirs. The city only draws the outside; the plan of the inside is the typology's.
|
|
602
|
-
*/
|
|
603
|
-
type TowerPreset = {
|
|
604
|
-
id: string;
|
|
605
|
-
/** Chance weight among the presets (the one the random picks). */
|
|
606
|
-
weight: number;
|
|
607
|
-
/** Floor to floor in metres: the clear height of the typology plus its slab. */
|
|
608
|
-
storeyHeight: number;
|
|
609
|
-
/** A plant floor (darker band, no windows) every this many storeys; `false` none. */
|
|
610
|
-
mechanicalEvery: number | false;
|
|
611
|
-
/** A glass curtain wall (a ribbon of tall windows on a tinted skin) or a punched facade (a window in each bay of the masonry). */
|
|
612
|
-
glass: boolean;
|
|
613
|
-
/** Fewest and most storeys this preset's towers have (the lot height is raised or cut to it); omitted: no minimum, and `TowerOptions.maxStoreys` for the top. */
|
|
614
|
-
minStoreys?: number;
|
|
615
|
-
maxStoreys?: number;
|
|
616
|
-
/** Colour of the skin; omitted: the facade colour the block drew for the lot (glass: a blue tint of it). */
|
|
617
|
-
color?: number;
|
|
618
|
-
};
|
|
619
|
-
/** The two typologies: the office tower (4.0 m storeys: 3.6 clear and 0.4 slab, a plant floor every 20, glass) and the residential tower (3.1 m, every 25, masonry). */
|
|
620
|
-
declare const DEFAULT_TOWER_PRESETS: readonly TowerPreset[];
|
|
621
|
-
/**
|
|
622
|
-
* A preset from the layout of a typology (`officeTowerLayout(opts)`, `residentialTowerLayout(opts)`), so the city draws the tower the game configured:
|
|
623
|
-
* the storey pitch and the facade come from the layout, the storey range from its `range` when given.
|
|
624
|
-
*/
|
|
625
|
-
declare const towerPresetOf: (id: string, weight: number, layout: {
|
|
626
|
-
pitch: number;
|
|
627
|
-
facade: "curtain" | "punched";
|
|
628
|
-
}, extra?: Partial<Omit<TowerPreset, "id" | "weight" | "storeyHeight" | "glass">>) => TowerPreset;
|
|
629
|
-
/** What a game asks a tower provider to put on the ground: the lot, the height, the preset the random chose and the facade colour. */
|
|
630
|
-
type TowerRequest = {
|
|
631
|
-
x: number;
|
|
632
|
-
z: number;
|
|
633
|
-
width: number;
|
|
634
|
-
depth: number;
|
|
635
|
-
height: number;
|
|
636
|
-
color: number;
|
|
637
|
-
preset: TowerPreset;
|
|
638
|
-
lit: number;
|
|
639
|
-
use?: string;
|
|
640
|
-
storeys?: number;
|
|
641
|
-
};
|
|
642
|
-
/** Draws a tower in place of the default one (the game's own model, or the plan of the typology rendered by `game-floorplan-three`). */
|
|
643
|
-
type TowerProvider = (request: TowerRequest, b: UrbanBuilder) => void;
|
|
644
|
-
type TowerOptions = {
|
|
645
|
-
/** A building at least this tall (metres) is drawn as a tower. Default 60. */
|
|
646
|
-
minHeight?: number;
|
|
647
|
-
/** Kinds of tower and their weights. Default `DEFAULT_TOWER_PRESETS`. */
|
|
648
|
-
presets?: readonly TowerPreset[];
|
|
649
|
-
/** Replaces the default drawing. */
|
|
650
|
-
provider?: TowerProvider;
|
|
651
|
-
/** The crown: height of the mast over the roof as a share of the tower (default 0.06, at most 25 m), 0 for none. */
|
|
652
|
-
mast?: number;
|
|
653
|
-
/** Most storeys a tower may have (default 60, the structural limit of the kit): a taller lot is drawn at this many storeys of its preset. */
|
|
654
|
-
maxStoreys?: number;
|
|
655
|
-
/** Chance that a window is lit when the block did not say (default 0.12). */
|
|
656
|
-
lit?: number;
|
|
657
|
-
};
|
|
658
|
-
declare const TOWER_DEFAULTS: {
|
|
659
|
-
readonly minHeight: 60;
|
|
660
|
-
readonly maxStoreys: 60;
|
|
661
|
-
readonly mast: 0.06;
|
|
662
|
-
readonly lit: 0.12;
|
|
663
|
-
};
|
|
664
|
-
/** The preset the random picks by weight; draws once. */
|
|
665
|
-
declare function pickTowerPreset(b: UrbanBuilder, presets: readonly TowerPreset[]): TowerPreset;
|
|
666
|
-
/** Storeys of a tower of this height, the podium (a taller ground storey) included. */
|
|
667
|
-
declare const towerStoreys: (height: number, preset: TowerPreset) => number;
|
|
668
|
-
/**
|
|
669
|
-
* A tower: a podium with a taller ground storey, the shaft with a row of windows on every storey of its four faces, darker bands where the plant
|
|
670
|
-
* floors are (no windows), the top plant floor set back, the parapet and the mast. Draws one random per window (lit or not), after the preset's.
|
|
671
|
-
*/
|
|
672
|
-
declare function drawTower(b: UrbanBuilder, request: TowerRequest, options?: Pick<TowerOptions, 'mast'>): BlockBuilding;
|
|
673
|
-
/** The drawer a kit uses for a building of the block or the avenue: a tower from the minimum height up, the plain city building under it. */
|
|
674
|
-
declare function createTowerDrawer(towers: TowerOptions, plain: (b: UrbanBuilder, x: number, z: number, width: number, depth: number, height: number, color: number, o?: BuildingOptions) => BlockBuilding): (b: UrbanBuilder, x: number, z: number, width: number, depth: number, height: number, color: number, o?: BuildingOptions) => BlockBuilding;
|
|
675
|
-
|
|
676
|
-
/** Facade colours of the city buildings (the Galeria's `FAC`). */
|
|
677
|
-
declare const DEFAULT_FACADES: readonly number[];
|
|
678
|
-
type FillBlockOptions = {
|
|
679
|
-
/** The block is split into `k x k` lots. Default 2. */
|
|
680
|
-
k?: number;
|
|
681
|
-
/** Chance that a lot stays empty. Default 0.08. */
|
|
682
|
-
gap?: number;
|
|
683
|
-
/** Chance that a window is lit. */
|
|
684
|
-
lit?: number;
|
|
685
|
-
/** Chance of a ground-floor shop on a building. */
|
|
686
|
-
shop?: number;
|
|
687
|
-
/** Facade colours. Default `DEFAULT_FACADES`. */
|
|
688
|
-
palette?: readonly number[];
|
|
689
|
-
/**
|
|
690
|
-
* Storeys of each building, a number or `[min, max]` (the same name and shape as a city block's `building.floors`). Given, the height is storeys times the
|
|
691
|
-
* storey height of the use's preset instead of `minHeight..maxHeight`; the random draws are the same.
|
|
692
|
-
*/
|
|
693
|
-
floors?: number | readonly [number, number];
|
|
694
|
-
/** Share of the buildings by use (`commercial`, `residential`, ...); each building picks one (one more random draw). Needs no `floors`. */
|
|
695
|
-
uses?: Readonly<Record<string, number>>;
|
|
696
|
-
/** Which tower preset gives the storey height of a use. Default `{ commercial: 'office', residential: 'residential' }`. */
|
|
697
|
-
storeyPresets?: Readonly<Record<string, string>>;
|
|
698
|
-
/** The presets whose storey heights are used (default `DEFAULT_TOWER_PRESETS`; the kit passes its `towers.presets`). */
|
|
699
|
-
presets?: readonly TowerPreset[];
|
|
700
|
-
/** Storey height when no preset applies, metres. Default the residential preset's. */
|
|
701
|
-
storeyHeight?: number;
|
|
702
|
-
/** Draws each building (default `drawBuilding`): the kit passes its own to put towers on the tall lots. */
|
|
703
|
-
draw?: (b: UrbanBuilder, x: number, z: number, width: number, depth: number, height: number, color: number, options: BuildingOptions) => BlockBuilding;
|
|
704
|
-
};
|
|
705
|
-
/** A building a block ended up with, for the game's own bookkeeping (collisions, minimap). */
|
|
706
|
-
type BlockBuilding = {
|
|
707
|
-
x: number;
|
|
708
|
-
z: number;
|
|
709
|
-
width: number;
|
|
710
|
-
depth: number;
|
|
711
|
-
height: number;
|
|
712
|
-
color: number;
|
|
713
|
-
};
|
|
714
|
-
type BuildingOptions = {
|
|
715
|
-
lit?: number;
|
|
716
|
-
shop?: number;
|
|
717
|
-
/** Use of the building (`commercial`, `residential`...), when the block gave `uses`. */
|
|
718
|
-
use?: string;
|
|
719
|
-
/** Storeys of the building, when the block gave `floors`; the height is already storeys times the storey height. */
|
|
720
|
-
storeys?: number;
|
|
721
|
-
/** Id of the tower preset the use maps to; a tower drawer with that preset uses it instead of picking at random. */
|
|
722
|
-
preset?: string;
|
|
723
|
-
};
|
|
724
|
-
declare const DEFAULT_STOREY_PRESETS: Readonly<Record<string, string>>;
|
|
725
|
-
/** One city building: block, roof slab, maybe a vent on the roof, maybe a shop front on both long faces, windows on the four faces. Draws from the builder's random. */
|
|
726
|
-
declare function drawBuilding(b: UrbanBuilder, x: number, z: number, width: number, depth: number, height: number, color: number, options?: BuildingOptions): BlockBuilding;
|
|
727
|
-
/**
|
|
728
|
-
* Fills a square block with city buildings: a `k x k` split of the block less 2 m of street, each lot maybe empty, each building a
|
|
729
|
-
* little smaller than its lot and as tall as `lerp(min, max, random^1.6)` (more low buildings than tall ones). Draws from the
|
|
730
|
-
* builder's random in the page's order: gap, width, depth, height, facade, then the building's own.
|
|
731
|
-
*/
|
|
732
|
-
declare function fillBlock(b: UrbanBuilder, cx: number, cz: number, size: number, minHeight: number, maxHeight: number, options?: FillBlockOptions): BlockBuilding[];
|
|
733
|
-
|
|
734
52
|
/** Colours of the props; a game replaces the ones it wants. */
|
|
735
53
|
type PropColors = {
|
|
736
54
|
tent: number;
|
|
@@ -770,317 +88,6 @@ declare function drawStripLabel(b: UrbanBuilder, x: number, z: number, title: st
|
|
|
770
88
|
/** Wires between poles: a polyline at one height. */
|
|
771
89
|
declare function drawWires(b: UrbanBuilder, points: readonly (readonly [number, number])[], y: number, color?: number, c?: Partial<PropColors>): void;
|
|
772
90
|
|
|
773
|
-
/** What a game asks a house provider to put on the ground. Fields a typology does not use are ignored. */
|
|
774
|
-
type HouseRequest = {
|
|
775
|
-
x: number;
|
|
776
|
-
z: number;
|
|
777
|
-
/** Turn of the whole house; the default provider turns the group. */
|
|
778
|
-
ry?: number;
|
|
779
|
-
width?: number;
|
|
780
|
-
depth?: number;
|
|
781
|
-
floors?: number;
|
|
782
|
-
color?: number;
|
|
783
|
-
roofColor?: number;
|
|
784
|
-
hasDoor?: boolean;
|
|
785
|
-
isBoarded?: boolean;
|
|
786
|
-
};
|
|
787
|
-
/** Draws a house of the given typology into the builder (and may add vehicles, plants or anything else around it). */
|
|
788
|
-
type HouseProvider = (typology: string, request: HouseRequest, b: UrbanBuilder) => void;
|
|
789
|
-
/** Draws a vehicle where the pattern parks one. A pattern parks none unless a provider is given. */
|
|
790
|
-
type VehicleRequest = {
|
|
791
|
-
x: number;
|
|
792
|
-
z: number;
|
|
793
|
-
ry: number;
|
|
794
|
-
color: number;
|
|
795
|
-
};
|
|
796
|
-
type VehicleProvider = (request: VehicleRequest, b: UrbanBuilder) => void;
|
|
797
|
-
/** Draws a tree where the pattern plants one. The default is the cone pine and the ball tree of the street props. */
|
|
798
|
-
type PlantRequest = {
|
|
799
|
-
kind: 'pine' | 'tree';
|
|
800
|
-
x: number;
|
|
801
|
-
z: number;
|
|
802
|
-
scale: number;
|
|
803
|
-
};
|
|
804
|
-
type PlantProvider = (request: PlantRequest, b: UrbanBuilder) => void;
|
|
805
|
-
type Providers = {
|
|
806
|
-
house?: HouseProvider;
|
|
807
|
-
vehicle?: VehicleProvider;
|
|
808
|
-
plant?: PlantProvider;
|
|
809
|
-
};
|
|
810
|
-
/** The cell of the sample sheet and what was put there, as data. */
|
|
811
|
-
type UrbanPlan = {
|
|
812
|
-
id: string;
|
|
813
|
-
origin: {
|
|
814
|
-
x: number;
|
|
815
|
-
z: number;
|
|
816
|
-
};
|
|
817
|
-
houses: {
|
|
818
|
-
typology: string;
|
|
819
|
-
x: number;
|
|
820
|
-
z: number;
|
|
821
|
-
ry: number;
|
|
822
|
-
}[];
|
|
823
|
-
buildings: BlockBuilding[];
|
|
824
|
-
poles: {
|
|
825
|
-
pole: string;
|
|
826
|
-
x: number;
|
|
827
|
-
z: number;
|
|
828
|
-
on: boolean;
|
|
829
|
-
}[];
|
|
830
|
-
vehicles: VehicleRequest[];
|
|
831
|
-
plants: PlantRequest[];
|
|
832
|
-
};
|
|
833
|
-
type Locale = 'pt-BR' | 'en';
|
|
834
|
-
type PatternText = {
|
|
835
|
-
label: string;
|
|
836
|
-
title: string;
|
|
837
|
-
caption: string;
|
|
838
|
-
detail: string;
|
|
839
|
-
};
|
|
840
|
-
/**
|
|
841
|
-
* A neighbourhood pattern: numbers a game can change and a key into the registry of composers, which draw the street.
|
|
842
|
-
* `params` are the numbers of that composer (counts, pitch, palettes, positions of the poles).
|
|
843
|
-
*/
|
|
844
|
-
type NeighbourhoodPattern<TParams = Record<string, unknown>> = {
|
|
845
|
-
id: string;
|
|
846
|
-
/** Width of the main paved strip (a road, a cobbled street, a yard or a boardwalk). */
|
|
847
|
-
streetWidth: number;
|
|
848
|
-
/** Width of the sidewalks; 0 when the pattern has none. */
|
|
849
|
-
walkWidth: number;
|
|
850
|
-
/** House and building typologies the pattern places (ids of the house provider). */
|
|
851
|
-
typologies: readonly string[];
|
|
852
|
-
/** Id of the kind of pole the pattern uses; empty when it has no public lighting. */
|
|
853
|
-
pole: string;
|
|
854
|
-
/** Colour of the light the lamps give. */
|
|
855
|
-
lightColor: number;
|
|
856
|
-
/** Metres between poles (0 when it has none). */
|
|
857
|
-
spacing: number;
|
|
858
|
-
/** Share of the lamps that are on; the rest are burnt out. 1 means all, without drawing from the random. */
|
|
859
|
-
lit: number;
|
|
860
|
-
/** Key into the composers. */
|
|
861
|
-
compose: string;
|
|
862
|
-
/** Where a map marker stands over the sample: its height and its shift in z from the origin. */
|
|
863
|
-
marker: {
|
|
864
|
-
height: number;
|
|
865
|
-
dz?: number;
|
|
866
|
-
};
|
|
867
|
-
/** Title, caption under the sample and marker text, by locale. */
|
|
868
|
-
text: Record<Locale, PatternText>;
|
|
869
|
-
params: TParams;
|
|
870
|
-
};
|
|
871
|
-
/** The parts of the kit a composer draws with: poles, streets, blocks and props. */
|
|
872
|
-
interface UrbanKitCore {
|
|
873
|
-
poles: {
|
|
874
|
-
get(id: string): {
|
|
875
|
-
build(b: UrbanBuilder, options: PoleOptions): void;
|
|
876
|
-
};
|
|
877
|
-
};
|
|
878
|
-
streets: {
|
|
879
|
-
road(b: UrbanBuilder, x: number, z: number, w: number, l: number, along: 'x' | 'z'): void;
|
|
880
|
-
walk(b: UrbanBuilder, x: number, z: number, w: number, d: number): void;
|
|
881
|
-
ground(b: UrbanBuilder, color?: number, size?: number): void;
|
|
882
|
-
grid(b: UrbanBuilder, g: {
|
|
883
|
-
block: number;
|
|
884
|
-
count: number;
|
|
885
|
-
width: number;
|
|
886
|
-
}): void;
|
|
887
|
-
};
|
|
888
|
-
block: {
|
|
889
|
-
facades: readonly number[];
|
|
890
|
-
building(b: UrbanBuilder, x: number, z: number, width: number, depth: number, height: number, color: number, o?: BuildingOptions): BlockBuilding;
|
|
891
|
-
fill(b: UrbanBuilder, g: {
|
|
892
|
-
cx: number;
|
|
893
|
-
cz: number;
|
|
894
|
-
size: number;
|
|
895
|
-
minHeight: number;
|
|
896
|
-
maxHeight: number;
|
|
897
|
-
} & FillBlockOptions): BlockBuilding[];
|
|
898
|
-
};
|
|
899
|
-
props: {
|
|
900
|
-
fence(b: UrbanBuilder, x0: number, z0: number, x1: number, z1: number, height: number, color?: number): void;
|
|
901
|
-
tent(b: UrbanBuilder, x: number, z: number, ry: number, w: number, d: number, color?: number): void;
|
|
902
|
-
pine(b: UrbanBuilder, x: number, z: number, scale?: number, y?: number): void;
|
|
903
|
-
tree(b: UrbanBuilder, x: number, z: number, scale?: number): void;
|
|
904
|
-
container(b: UrbanBuilder, x: number, y: number, z: number, ry: number, color: number): void;
|
|
905
|
-
watchtower(b: UrbanBuilder, x: number, z: number, searchlight?: boolean): void;
|
|
906
|
-
sandbags(b: UrbanBuilder, x: number, z: number, length: number, along: 'x' | 'z', rows?: number): void;
|
|
907
|
-
label(b: UrbanBuilder, x: number, z: number, title: string, subtitle: string): void;
|
|
908
|
-
wires(b: UrbanBuilder, points: readonly (readonly [number, number])[], y: number, color?: number): void;
|
|
909
|
-
};
|
|
910
|
-
}
|
|
911
|
-
type ComposeContext<TParams = Record<string, unknown>> = {
|
|
912
|
-
kit: UrbanKitCore;
|
|
913
|
-
b: UrbanBuilder;
|
|
914
|
-
pattern: NeighbourhoodPattern<TParams>;
|
|
915
|
-
params: TParams;
|
|
916
|
-
x0: number;
|
|
917
|
-
z0: number;
|
|
918
|
-
plan: UrbanPlan;
|
|
919
|
-
/** True with the probability `share`; draws from the random unless the share is 1. */
|
|
920
|
-
isLit(share: number): boolean;
|
|
921
|
-
pole(options: PoleOptions & {
|
|
922
|
-
id?: string;
|
|
923
|
-
}): void;
|
|
924
|
-
house(typology: string, request: HouseRequest): void;
|
|
925
|
-
vehicle(request: VehicleRequest): void;
|
|
926
|
-
plant(request: PlantRequest): void;
|
|
927
|
-
building(x: number, z: number, width: number, depth: number, height: number, color: number, options?: {
|
|
928
|
-
lit?: number;
|
|
929
|
-
shop?: number;
|
|
930
|
-
}): void;
|
|
931
|
-
};
|
|
932
|
-
/**
|
|
933
|
-
* Draws a pattern from its params. Declared as a method so a registry of composers can hold each with its own params type
|
|
934
|
-
* (the pattern that names the composer carries the matching params).
|
|
935
|
-
*/
|
|
936
|
-
type Composer<TParams = Record<string, unknown>> = {
|
|
937
|
-
compose(context: ComposeContext<TParams>): void;
|
|
938
|
-
}['compose'];
|
|
939
|
-
type ComposeOptions = {
|
|
940
|
-
locale?: Locale;
|
|
941
|
-
providers?: Providers;
|
|
942
|
-
};
|
|
943
|
-
type SilhouetteFactory = (request: HouseRequest, random: () => number) => Silhouette;
|
|
944
|
-
|
|
945
|
-
type DistrictKindText = {
|
|
946
|
-
name: string;
|
|
947
|
-
description: string;
|
|
948
|
-
};
|
|
949
|
-
/**
|
|
950
|
-
* A kind of district: what a patch of the city is. Numbers a game can change; the ids of `zone` and `pattern` point into other catalogues.
|
|
951
|
-
*/
|
|
952
|
-
type DistrictKindDef = {
|
|
953
|
-
id: string;
|
|
954
|
-
/** Colour on the map (css hex). */
|
|
955
|
-
color: string;
|
|
956
|
-
/** Id of a zone of `game-floorplan-residential` / `game-floorplan-commercial` (`zt`, `zc`, `zr1`, ...); null for ground that is not built. */
|
|
957
|
-
zone: string | null;
|
|
958
|
-
/** Id of a neighbourhood pattern of `urban.neighbourhoods` (or `financial_district` of `TOWER_PATTERNS`); null for ground that is not built. */
|
|
959
|
-
pattern: string | null;
|
|
960
|
-
/** Storeys of the buildings, `[min, max]`. */
|
|
961
|
-
floors: readonly [number, number];
|
|
962
|
-
/** Share of the buildings by use (`commercial`, `residential`, `industrial`, `institutional`, `agricultural`, ...). */
|
|
963
|
-
uses: Readonly<Record<string, number>>;
|
|
964
|
-
/** Size of a block in metres; 0 means the kind has no blocks. */
|
|
965
|
-
block: number;
|
|
966
|
-
text: Record<Locale, DistrictKindText>;
|
|
967
|
-
};
|
|
968
|
-
type PlanRect = readonly [x0: number, z0: number, x1: number, z1: number];
|
|
969
|
-
type PlanPoint = readonly [x: number, z: number];
|
|
970
|
-
type PlanDistrict = {
|
|
971
|
-
id: string;
|
|
972
|
-
/** Id of a `DistrictKindDef`. */
|
|
973
|
-
kind: string;
|
|
974
|
-
rect: PlanRect;
|
|
975
|
-
/** Replaces the name of the kind; a string or one string by locale. */
|
|
976
|
-
name?: string | Partial<Record<Locale, string>>;
|
|
977
|
-
/** Replaces the storeys of the kind. */
|
|
978
|
-
floors?: readonly [number, number];
|
|
979
|
-
/** Replaces the shares of use of the kind. */
|
|
980
|
-
uses?: Readonly<Record<string, number>>;
|
|
981
|
-
};
|
|
982
|
-
type PlanLine = {
|
|
983
|
-
id: string;
|
|
984
|
-
/** `avenue`, `street`, `highway`, `rail`, `river` or any string a drawer knows. */
|
|
985
|
-
kind: string;
|
|
986
|
-
width: number;
|
|
987
|
-
points: readonly PlanPoint[];
|
|
988
|
-
};
|
|
989
|
-
type PlanLandmark = {
|
|
990
|
-
kind: string;
|
|
991
|
-
at: PlanPoint;
|
|
992
|
-
name?: string | Partial<Record<Locale, string>>;
|
|
993
|
-
};
|
|
994
|
-
type CityScale = 'metropolis' | 'city' | 'town' | 'village' | (string & {});
|
|
995
|
-
/**
|
|
996
|
-
* A city plan: districts painted on a map of metres (centre 0,0; x east, z south), roads, rails and rivers, and landmarks.
|
|
997
|
-
* Districts are listed from the outer to the inner one: the LAST district that contains a point wins.
|
|
998
|
-
*/
|
|
999
|
-
type CityPlanDef = {
|
|
1000
|
-
id: string;
|
|
1001
|
-
scale: CityScale;
|
|
1002
|
-
/** Width and depth of the map in metres. */
|
|
1003
|
-
size: readonly [w: number, d: number];
|
|
1004
|
-
text: Record<Locale, {
|
|
1005
|
-
name: string;
|
|
1006
|
-
description: string;
|
|
1007
|
-
}>;
|
|
1008
|
-
/** Id of another plan to start from: its districts, lines and landmarks come first; a district or line of the same id replaces, a new one appends. */
|
|
1009
|
-
extends?: string;
|
|
1010
|
-
districts: readonly PlanDistrict[];
|
|
1011
|
-
lines: readonly PlanLine[];
|
|
1012
|
-
landmarks: readonly PlanLandmark[];
|
|
1013
|
-
};
|
|
1014
|
-
/** A plan as a game writes it: with `extends`, everything but the id is optional and comes from the parent. */
|
|
1015
|
-
type CityPlanInput = {
|
|
1016
|
-
id: string;
|
|
1017
|
-
extends?: string;
|
|
1018
|
-
} & Partial<Omit<CityPlanDef, 'id' | 'extends'>>;
|
|
1019
|
-
type BlockUse = {
|
|
1020
|
-
floors: readonly [number, number];
|
|
1021
|
-
uses: Readonly<Record<string, number>>;
|
|
1022
|
-
zone: string | null;
|
|
1023
|
-
pattern: string | null;
|
|
1024
|
-
};
|
|
1025
|
-
type ResolvedDistrict = {
|
|
1026
|
-
id: string;
|
|
1027
|
-
kind: string;
|
|
1028
|
-
rect: PlanRect;
|
|
1029
|
-
name: string;
|
|
1030
|
-
description: string;
|
|
1031
|
-
color: string;
|
|
1032
|
-
zone: string | null;
|
|
1033
|
-
pattern: string | null;
|
|
1034
|
-
/** Storeys after the district's override, clamped to `[0, maxFloors]`. */
|
|
1035
|
-
floors: readonly [number, number];
|
|
1036
|
-
uses: Readonly<Record<string, number>>;
|
|
1037
|
-
block: number;
|
|
1038
|
-
};
|
|
1039
|
-
/** A block of a district: its centre, its dimensions less the street, and the config a building generator takes. */
|
|
1040
|
-
type Block = {
|
|
1041
|
-
x: number;
|
|
1042
|
-
z: number;
|
|
1043
|
-
size: readonly [w: number, d: number];
|
|
1044
|
-
district: string;
|
|
1045
|
-
building: BlockUse;
|
|
1046
|
-
};
|
|
1047
|
-
type CityLayout = {
|
|
1048
|
-
id: string;
|
|
1049
|
-
scale: string;
|
|
1050
|
-
size: readonly [number, number];
|
|
1051
|
-
name: string;
|
|
1052
|
-
description: string;
|
|
1053
|
-
districts: ResolvedDistrict[];
|
|
1054
|
-
lines: PlanLine[];
|
|
1055
|
-
landmarks: (Omit<PlanLandmark, 'name'> & {
|
|
1056
|
-
name?: string;
|
|
1057
|
-
})[];
|
|
1058
|
-
/** The district at a point; the last one in the list that contains it. */
|
|
1059
|
-
districtAt(x: number, z: number): ResolvedDistrict | undefined;
|
|
1060
|
-
/** The grid of blocks of a district (by the kind's block size), less the cells another district was painted over. */
|
|
1061
|
-
blocks(districtId: string, options?: {
|
|
1062
|
-
street?: number;
|
|
1063
|
-
}): Block[];
|
|
1064
|
-
};
|
|
1065
|
-
type LayoutOptions = {
|
|
1066
|
-
maxFloors?: number;
|
|
1067
|
-
locale?: Locale;
|
|
1068
|
-
};
|
|
1069
|
-
type KindStats = {
|
|
1070
|
-
kind: string;
|
|
1071
|
-
area: number;
|
|
1072
|
-
share: number;
|
|
1073
|
-
districts: number;
|
|
1074
|
-
};
|
|
1075
|
-
type FillBlockCityOptions = Omit<FillBlockOptions, 'shop'> & {
|
|
1076
|
-
/** Chance of a ground-floor shop; default the commercial share of the block. */
|
|
1077
|
-
shop?: number;
|
|
1078
|
-
/** Which tower preset gives the storey height of a use: default `{ commercial: 'office', residential: 'residential' }`. */
|
|
1079
|
-
storeyPresets?: Readonly<Record<string, string>>;
|
|
1080
|
-
/** Storey height when no preset applies, metres. Default the residential preset's. */
|
|
1081
|
-
storeyHeight?: number;
|
|
1082
|
-
};
|
|
1083
|
-
|
|
1084
91
|
/** Highest storey count a district may have unless the game raises it. */
|
|
1085
92
|
declare const DEFAULT_MAX_FLOORS = 60;
|
|
1086
93
|
declare const DEFAULT_STREET = 10;
|
|
@@ -1792,4 +799,4 @@ declare const TOWER_SAMPLE_CELLS: Readonly<Record<string, {
|
|
|
1792
799
|
z: number;
|
|
1793
800
|
}>>;
|
|
1794
801
|
|
|
1795
|
-
export {
|
|
802
|
+
export { Block, BlockBuilding, type BuilderOptions, BuildingOptions, COMPOSERS, type Cities, type CitiesOptions, CityLayout, CityPlanDef, CityPlanInput, ComposeOptions, Composer, DEFAULT_CITY_PLANS, DEFAULT_DISTRICT_KINDS, DEFAULT_LIGHT_ALLOWANCE, DEFAULT_LIGHT_BUDGET, DEFAULT_MAX_FLOORS, DEFAULT_PATTERNS, DEFAULT_PLANT_CONTEXTS, DEFAULT_PROP_COLORS, DEFAULT_ROAD_STYLE, DEFAULT_STREET, DEFAULT_URBAN_SEED, DEFAULT_WALK_STYLE, DistrictKindDef, type DowntownParams, FillBlockCityOptions, FillBlockOptions, type HistoricParams, HouseProvider, type IndustrialParams, KindStats, LayoutOptions, LightAllowance, Locale, type MilitaryParams, type MountainParams, NeighbourhoodPattern, type Origin, PARKED_VEHICLE_IDS, PlantProvider, type PlantProviderOptions, PlantRequest, Point, type Pole, PoleDef, PoleOptions, PoleShapeBuilder, type PropColors, type RailwayParams, Rect, type RoadStyle, type RuralParams, SAMPLE_CELLS, SILHOUETTE_TYPOLOGIES, type SampleSheetOptions, SilhouetteFactory, type StiltParams, type StreetOptions, type SuburbParams, TOWER_PATTERNS, TOWER_SAMPLE_CELLS, type Terrain, TerrainGrid, TerrainOptions, TowerOptions, TowerPreset, UrbanBuilder, type UrbanKit, UrbanKitCore, type UrbanOptions, UrbanPlan, VehicleProvider, type VehicleProviderOptions, VehicleRequest, type WalkStyle, type WorkingClassParams, clamp, composePattern, createCities, createLightAllowance, createLightBudget, createPlantProvider, createSilhouetteHouses, createTerrain, createUrban, createVehicleProvider, distanceToPolyline, drawContainer, drawFence, drawGround, drawPine, drawRoad, drawSandbags, drawStreetGrid, drawStripLabel, drawTent, drawTerrain, drawTree, drawWalk, drawWatchtower, drawWires, hash2, insideEllipse, insideRect, lerp, patternMarker, smoothstep };
|