@adatechnology/game-floorplan 0.3.0 → 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/dist/index.d.ts +424 -33
- package/dist/index.global.js +17 -14
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +17 -14
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.global.js
CHANGED
|
@@ -543,6 +543,7 @@ var GameFloorplan = (() => {
|
|
|
543
543
|
var MAX_CANDIDATES = 80;
|
|
544
544
|
function carCandidates(slot, item, car) {
|
|
545
545
|
const front = [slot.frontU, slot.frontV];
|
|
546
|
+
if (!slot._cell) throw new Error("Slot without a cell: " + slot.id);
|
|
546
547
|
const zone = slot._cell.R;
|
|
547
548
|
const alongV = Math.abs(front[1]) === 1;
|
|
548
549
|
const [extentU, extentV] = extent([item.w, item.d], front);
|
|
@@ -768,6 +769,7 @@ var GameFloorplan = (() => {
|
|
|
768
769
|
}
|
|
769
770
|
function itemRect(slot, it, shift) {
|
|
770
771
|
const c = slot._cell;
|
|
772
|
+
if (!c) throw new Error("Slot without a cell: " + slot.id);
|
|
771
773
|
const f = c.f;
|
|
772
774
|
const [extentU, extentV] = extent([it.w, it.d], f);
|
|
773
775
|
const R = c.R;
|
|
@@ -872,7 +874,7 @@ var GameFloorplan = (() => {
|
|
|
872
874
|
if (!parent) return null;
|
|
873
875
|
for (const { it } of cands) {
|
|
874
876
|
if (it.w > parent.w + EPS || it.d > parent.d + EPS) continue;
|
|
875
|
-
const f = [parent.frontU, parent.frontV];
|
|
877
|
+
const f = [parent.frontU ?? 0, parent.frontV ?? 1];
|
|
876
878
|
const r = parent.aabb;
|
|
877
879
|
const [extentU, extentV] = extent([it.w, it.d], f);
|
|
878
880
|
const cu = (r[0] + r[2]) / 2 - f[0] * (parent.d / 2 - it.d / 2);
|
|
@@ -906,7 +908,7 @@ var GameFloorplan = (() => {
|
|
|
906
908
|
if (!car && !relax && s.clearance > 0 && !it.low) {
|
|
907
909
|
cl2 = clearRect(r3, f, s.clearance);
|
|
908
910
|
if (!insideUnion(cl2, inners)) continue;
|
|
909
|
-
if (items.some((m2) => !m2.low && !m2.flat && !m2.on && overlaps(cl2, m2._r))) continue;
|
|
911
|
+
if (items.some((m2) => !m2.low && !m2.flat && !m2.on && overlaps(cl2, m2._r ?? m2.aabb))) continue;
|
|
910
912
|
}
|
|
911
913
|
if (!it.low && reserves.some((q) => overlaps(r3, q))) continue;
|
|
912
914
|
let rimRect2 = null;
|
|
@@ -1094,7 +1096,7 @@ var GameFloorplan = (() => {
|
|
|
1094
1096
|
if (!(opts.without && opts.without(r))) return r;
|
|
1095
1097
|
continue;
|
|
1096
1098
|
}
|
|
1097
|
-
if (occupied.some((m) => !m.low && !m.flat && !m.on && !m.decor && m.clearance > 0 && overlaps(r, clearRect(m._r, [m.frontU, m.frontV], m.clearance)))) continue;
|
|
1099
|
+
if (occupied.some((m) => !m.low && !m.flat && !m.on && !m.decor && (m.clearance ?? 0) > 0 && overlaps(r, clearRect(m._r, [m.frontU ?? 0, m.frontV ?? 1], m.clearance ?? 0)))) continue;
|
|
1098
1100
|
if (opts.without && opts.without(r)) continue;
|
|
1099
1101
|
if (!reachable(opts.railing || gridOf(room), solidList.concat([r]), room.outdoor ? 0.16 : plan.playerRadius)) continue;
|
|
1100
1102
|
return r;
|
|
@@ -1361,7 +1363,7 @@ var GameFloorplan = (() => {
|
|
|
1361
1363
|
const far = m.built / area;
|
|
1362
1364
|
if (far > zone.maxFar + 1e-9) out.push({ rule: "far", actual: r2(far), limit: zone.maxFar });
|
|
1363
1365
|
let permeable = 0;
|
|
1364
|
-
for (const z of lot.zones) if (registries().PERMEABLE_GROUNDS.has(z.ground)) for (const p of z.parts) permeable += (p[2] - p[0]) * (p[3] - p[1]);
|
|
1366
|
+
for (const z of lot.zones) if (z.ground && registries().PERMEABLE_GROUNDS.has(z.ground)) for (const p of z.parts) permeable += (p[2] - p[0]) * (p[3] - p[1]);
|
|
1365
1367
|
const permeability = permeable / area;
|
|
1366
1368
|
if (permeability < zone.permeableMin - 1e-9) out.push({ rule: "permeable", actual: r2(permeability), limit: zone.permeableMin });
|
|
1367
1369
|
return out;
|
|
@@ -1404,12 +1406,12 @@ var GameFloorplan = (() => {
|
|
|
1404
1406
|
const [u0, v0, u1, v1] = lot.rect;
|
|
1405
1407
|
const area = (u1 - u0) * (v1 - v0);
|
|
1406
1408
|
const areaOfZone = (z) => z.parts.reduce((s, p) => s + (p[2] - p[0]) * (p[3] - p[1]), 0);
|
|
1407
|
-
let permeable = zones.filter((z) => registries().PERMEABLE_GROUNDS.has(z.ground)).reduce((s, z) => s + areaOfZone(z), 0);
|
|
1409
|
+
let permeable = zones.filter((z) => z.ground != null && registries().PERMEABLE_GROUNDS.has(z.ground)).reduce((s, z) => s + areaOfZone(z), 0);
|
|
1408
1410
|
if (permeable / area >= zone.permeableMin) return;
|
|
1409
|
-
const candidates = zones.filter((z) => ADJUSTABLE_ZONES.has(z.type) && !registries().PERMEABLE_GROUNDS.has(z.ground)).sort((a, b) => areaOfZone(b) - areaOfZone(a));
|
|
1411
|
+
const candidates = zones.filter((z) => ADJUSTABLE_ZONES.has(z.type) && !(z.ground != null && registries().PERMEABLE_GROUNDS.has(z.ground))).sort((a, b) => areaOfZone(b) - areaOfZone(a));
|
|
1410
1412
|
for (const z of candidates) {
|
|
1411
1413
|
if (permeable / area >= zone.permeableMin) break;
|
|
1412
|
-
adjustments.push({ field: "ground:" + z.id, from: z.ground, to: target, reason: "permeable_min" });
|
|
1414
|
+
adjustments.push({ field: "ground:" + z.id, from: z.ground ?? "", to: target, reason: "permeable_min" });
|
|
1413
1415
|
z.ground = target;
|
|
1414
1416
|
permeable += areaOfZone(z);
|
|
1415
1417
|
}
|
|
@@ -1678,9 +1680,9 @@ var GameFloorplan = (() => {
|
|
|
1678
1680
|
height: type === "pedestrian" ? style.height : Math.min(style.height, 2.2),
|
|
1679
1681
|
side,
|
|
1680
1682
|
to: toTarget || null,
|
|
1681
|
-
material: "iron"
|
|
1683
|
+
material: "iron",
|
|
1684
|
+
zones: openingZones(u, v, "u", width, openingDepth(width, type === "pedestrian" ? width : 0))
|
|
1682
1685
|
};
|
|
1683
|
-
g.zones = openingZones(u, v, "u", width, openingDepth(width, type === "pedestrian" ? width : 0));
|
|
1684
1686
|
gates.push(g);
|
|
1685
1687
|
return g;
|
|
1686
1688
|
};
|
|
@@ -1967,7 +1969,7 @@ var GameFloorplan = (() => {
|
|
|
1967
1969
|
};
|
|
1968
1970
|
const invalid = (m) => Object.assign(base, { valid: false, reason: m, x: 0, z: 0, ry: 0, w: 0, d: 0, frontU: 0, frontV: 1, aabb: [0, 0, 0, 0], _cell: null });
|
|
1969
1971
|
if (def.anchor === "on" || def.anchor === "inside") {
|
|
1970
|
-
const parent = byId[def.parent];
|
|
1972
|
+
const parent = def.parent ? byId[def.parent] : void 0;
|
|
1971
1973
|
if (!parent || !parent.valid) return invalid("invalid_parent");
|
|
1972
1974
|
return Object.assign(base, { x: parent.x, z: parent.z, ry: parent.ry, w: parent.w, d: parent.d, frontU: parent.frontU, frontV: parent.frontV, aabb: parent.aabb, _cell: parent._cell });
|
|
1973
1975
|
}
|
|
@@ -2008,9 +2010,10 @@ var GameFloorplan = (() => {
|
|
|
2008
2010
|
const windowList = windowsOfRoom(plan, room);
|
|
2009
2011
|
win = windowList[def.n];
|
|
2010
2012
|
if (!win) return invalid("no_window");
|
|
2013
|
+
const found2 = win;
|
|
2011
2014
|
side = room.outdoor ? SIDE_OPPOSITE[win.side] : WINDOW_SIDE[win.side];
|
|
2012
2015
|
const cand = room.parts.map(inner).find(
|
|
2013
|
-
(r) => (
|
|
2016
|
+
(r) => (found2.axis === "u" ? found2.u >= r[0] - TOL && found2.u <= r[2] + TOL : found2.v >= r[1] - TOL && found2.v <= r[3] + TOL) && (side === "left" && eq(r[0], found2.pos + MARGIN) || side === "right" && eq(r[2], found2.pos - MARGIN) || side === "front" && eq(r[1], found2.pos + MARGIN) || side === "back" && eq(r[3], found2.pos - MARGIN))
|
|
2014
2017
|
);
|
|
2015
2018
|
if (!cand) return invalid("window_outside_room");
|
|
2016
2019
|
R = cand;
|
|
@@ -2204,7 +2207,7 @@ var GameFloorplan = (() => {
|
|
|
2204
2207
|
if (m.category) out.color = colorOf(m, seed);
|
|
2205
2208
|
return out;
|
|
2206
2209
|
});
|
|
2207
|
-
const
|
|
2210
|
+
const base = {
|
|
2208
2211
|
template: tpl.id,
|
|
2209
2212
|
name: translate("templates", tpl.id, locale),
|
|
2210
2213
|
use: useOf(tpl),
|
|
@@ -2241,8 +2244,8 @@ var GameFloorplan = (() => {
|
|
|
2241
2244
|
building: tpl.building ? tpl.building(plan.w, plan.d, op) : null,
|
|
2242
2245
|
missing
|
|
2243
2246
|
};
|
|
2244
|
-
if (tpl.singleFloor)
|
|
2245
|
-
result.partyWalls
|
|
2247
|
+
if (tpl.singleFloor) base.floorNumber = op.floor || 3;
|
|
2248
|
+
const result = Object.assign(base, { partyWalls: tpl.partyWalls || [] });
|
|
2246
2249
|
if (plan.config) result.config = plan.config;
|
|
2247
2250
|
runResultExtensions(plan, result, seed, op);
|
|
2248
2251
|
if (zone) {
|