@adatechnology/game-urban 0.2.8 → 0.3.1
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 +3 -3
- package/dist/index.d.ts +46 -20
- package/dist/index.global.js +2452 -135
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +13 -9
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
// src/budget.ts
|
|
2
|
-
function
|
|
3
|
-
const
|
|
2
|
+
function createLightAllowance(count) {
|
|
3
|
+
const allowance = {
|
|
4
4
|
left: count,
|
|
5
5
|
take() {
|
|
6
|
-
return
|
|
6
|
+
return allowance.left-- > 0;
|
|
7
7
|
}
|
|
8
8
|
};
|
|
9
|
-
return
|
|
9
|
+
return allowance;
|
|
10
10
|
}
|
|
11
|
+
var createLightBudget = createLightAllowance;
|
|
11
12
|
|
|
12
13
|
// src/scene.ts
|
|
13
14
|
import { boxRadius } from "@adatechnology/game-floorplan";
|
|
@@ -21,7 +22,7 @@ function createUrbanBuilder(random, options = {}) {
|
|
|
21
22
|
const parts = [];
|
|
22
23
|
const items = [];
|
|
23
24
|
const windows = { lit: [], dark: [] };
|
|
24
|
-
const lights = options.budget ??
|
|
25
|
+
const lights = options.budget ?? createLightAllowance(Number.POSITIVE_INFINITY);
|
|
25
26
|
const pick = (list) => list[Math.floor(random() * list.length)];
|
|
26
27
|
const group = (x, y, z, ry = 0, parent = ROOT) => parts.push({ shape: "group", parent, x, y, z, ry }) - 1;
|
|
27
28
|
const box = (x, y, z, width, height, depth, color, o = {}) => {
|
|
@@ -1391,7 +1392,8 @@ function drawTerrain(b, terrain, segments) {
|
|
|
1391
1392
|
}
|
|
1392
1393
|
|
|
1393
1394
|
// src/kit.ts
|
|
1394
|
-
var
|
|
1395
|
+
var DEFAULT_LIGHT_ALLOWANCE = 16;
|
|
1396
|
+
var DEFAULT_LIGHT_BUDGET = DEFAULT_LIGHT_ALLOWANCE;
|
|
1395
1397
|
var DEFAULT_URBAN_SEED = 7;
|
|
1396
1398
|
function createUrban(options = {}) {
|
|
1397
1399
|
const entries = mergeById2(DEFAULT_POLES, options.packs?.poles);
|
|
@@ -1402,7 +1404,7 @@ function createUrban(options = {}) {
|
|
|
1402
1404
|
applyPatches2(patterns, options.patch?.neighbourhoods);
|
|
1403
1405
|
removeIds2(patterns, options.remove?.neighbourhoods);
|
|
1404
1406
|
const composers = { ...COMPOSERS, ...options.composers };
|
|
1405
|
-
const lightBudget = options.lights?.budget ??
|
|
1407
|
+
const lightBudget = options.lights?.budget ?? DEFAULT_LIGHT_ALLOWANCE;
|
|
1406
1408
|
const facades = options.facades ?? DEFAULT_FACADES;
|
|
1407
1409
|
const propColors = { ...DEFAULT_PROP_COLORS, ...options.props };
|
|
1408
1410
|
const towers = options.towers ? options.towers === true ? {} : options.towers : null;
|
|
@@ -1444,7 +1446,7 @@ function createUrban(options = {}) {
|
|
|
1444
1446
|
wires: (b, points, y, color) => drawWires(b, points, y, color, propColors)
|
|
1445
1447
|
}
|
|
1446
1448
|
};
|
|
1447
|
-
const builder = (o = {}) => createUrbanBuilder(o.random ?? createSilhouetteRandom(o.seed ?? DEFAULT_URBAN_SEED), { budget:
|
|
1449
|
+
const builder = (o = {}) => createUrbanBuilder(o.random ?? createSilhouetteRandom(o.seed ?? DEFAULT_URBAN_SEED), { budget: createLightAllowance(o.budget ?? lightBudget) });
|
|
1448
1450
|
const neighbourhoods = {
|
|
1449
1451
|
ids: () => [...patterns.keys()],
|
|
1450
1452
|
get(id) {
|
|
@@ -1515,7 +1517,7 @@ function createPlantProvider(options = {}) {
|
|
|
1515
1517
|
return (request, b) => {
|
|
1516
1518
|
const context = contexts[request.kind];
|
|
1517
1519
|
const key = `${seed}:${request.kind}:${request.x}:${request.z}`;
|
|
1518
|
-
const id = options.pick ? options.pick(request, context, key) : pickForContext(region, context, key);
|
|
1520
|
+
const id = options.pick ? options.pick(request, context, key) : (options.pickSpecies ?? ((table, spot) => pickForContext(region, table, spot)))(context, key);
|
|
1519
1521
|
b.place("plant", id, request.x, request.z, { scale: request.scale, seed: key });
|
|
1520
1522
|
};
|
|
1521
1523
|
}
|
|
@@ -1553,6 +1555,7 @@ export {
|
|
|
1553
1555
|
DEFAULT_CITY_PLANS,
|
|
1554
1556
|
DEFAULT_DISTRICT_KINDS,
|
|
1555
1557
|
DEFAULT_FACADES,
|
|
1558
|
+
DEFAULT_LIGHT_ALLOWANCE,
|
|
1556
1559
|
DEFAULT_LIGHT_BUDGET,
|
|
1557
1560
|
DEFAULT_MAX_FLOORS,
|
|
1558
1561
|
DEFAULT_PATTERNS,
|
|
@@ -1575,6 +1578,7 @@ export {
|
|
|
1575
1578
|
clamp,
|
|
1576
1579
|
composePattern,
|
|
1577
1580
|
createCities,
|
|
1581
|
+
createLightAllowance,
|
|
1578
1582
|
createLightBudget,
|
|
1579
1583
|
createPlantProvider,
|
|
1580
1584
|
createSilhouetteHouses,
|