@adatechnology/game-floorplan 0.3.13 → 0.4.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/dist/index.d.ts +27 -2
- package/dist/index.global.js +97 -21
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +56 -18
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -254,6 +254,8 @@ interface LotConfig {
|
|
|
254
254
|
}
|
|
255
255
|
interface TemplateDef {
|
|
256
256
|
id: string;
|
|
257
|
+
/** Thickness of the plan's walls, metres (default `WALL_THICKNESS`); a pack may derive it from what the walls are built of. */
|
|
258
|
+
wallThickness?: number;
|
|
257
259
|
/** Declared use for zoning, e.g. `residential_single`. */
|
|
258
260
|
use?: string;
|
|
259
261
|
style: string | ((o: FloorplanOptions) => string);
|
|
@@ -284,6 +286,8 @@ interface TemplateDef {
|
|
|
284
286
|
/** Place tag of the building for finds (`house`, `pharmacy`...). */
|
|
285
287
|
place?: string;
|
|
286
288
|
/** Building system the structure pack builds (a reference registered there). */
|
|
289
|
+
/** The masonry unit a structure pack lays the walls of (its catalog); the pack derives the walls' thickness from it. */
|
|
290
|
+
masonryUnit?: string;
|
|
287
291
|
construction?: string;
|
|
288
292
|
/** Region of the content (`br`...), chosen by the pack that registered the template. */
|
|
289
293
|
region?: string;
|
|
@@ -362,6 +366,8 @@ interface ResultExtensionContext {
|
|
|
362
366
|
options: FloorplanOptions;
|
|
363
367
|
}
|
|
364
368
|
type ResultExtensionRun = (context: ResultExtensionContext) => unknown;
|
|
369
|
+
/** Turns a pack's own options of a plan into the engine's (it returns the options to lay the plan out with). */
|
|
370
|
+
type OptionResolver = (template: TemplateDef, options: FloorplanOptions) => FloorplanOptions;
|
|
365
371
|
interface ResultExtensionOptions {
|
|
366
372
|
/** Extensions that must run first. */
|
|
367
373
|
after?: string[];
|
|
@@ -400,6 +406,8 @@ interface FindsProvider {
|
|
|
400
406
|
findsFor(query: FindsQuery): readonly FindStack[] | null;
|
|
401
407
|
}
|
|
402
408
|
interface FloorplanOptions {
|
|
409
|
+
/** Thickness of the plan's walls, metres: wins over the template's. */
|
|
410
|
+
wallThickness?: number;
|
|
403
411
|
/** Number of storeys, for templates that accept it. */
|
|
404
412
|
floors?: number;
|
|
405
413
|
/** Building system of the structure pack (`masonry`, `wood_frame`, ...). */
|
|
@@ -510,7 +518,14 @@ interface PlanWindow {
|
|
|
510
518
|
side: string;
|
|
511
519
|
/** Boarded up (set by a house state). */
|
|
512
520
|
boards?: boolean;
|
|
513
|
-
|
|
521
|
+
/**
|
|
522
|
+
* What holds the glass: a wooden frame (splinters), an aluminium one (dents and bends) or none, a pane of tempered glass fixed by its fittings (`frameless`, blindex:
|
|
523
|
+
* it holds more and, when it goes, crumbles all at once into small blunt cubes). Default: by the house's standard (wood in a budget house, aluminium above it).
|
|
524
|
+
*/
|
|
525
|
+
frame?: WindowFrame;
|
|
526
|
+
}
|
|
527
|
+
/** What holds the glass of a window (`PlanWindow.frame`). */
|
|
528
|
+
type WindowFrame = 'wood' | 'aluminium' | 'frameless';
|
|
514
529
|
/** A gate in the lot boundary (`Plan.gates`). */
|
|
515
530
|
interface PlanGate {
|
|
516
531
|
id: string;
|
|
@@ -596,6 +611,8 @@ interface Facade extends FacadeFields {
|
|
|
596
611
|
[extra: string]: unknown;
|
|
597
612
|
}
|
|
598
613
|
interface Plan {
|
|
614
|
+
/** Thickness its walls were laid with. */
|
|
615
|
+
wallThickness: number;
|
|
599
616
|
w: number;
|
|
600
617
|
d: number;
|
|
601
618
|
tpl: TemplateDef;
|
|
@@ -1136,6 +1153,11 @@ type Registries = {
|
|
|
1136
1153
|
seedKey: string;
|
|
1137
1154
|
};
|
|
1138
1155
|
RESULT_EXTENSIONS: ResultExtension[];
|
|
1156
|
+
/** Run in order on the options of every plan before it is laid out (a pack turning its own option into the engine's, e.g. a masonry unit into `wallThickness`). */
|
|
1157
|
+
OPTION_RESOLVERS: {
|
|
1158
|
+
name: string;
|
|
1159
|
+
resolve: OptionResolver;
|
|
1160
|
+
}[];
|
|
1139
1161
|
FINDS_PROVIDERS: FindsProvider[];
|
|
1140
1162
|
VIEWER_LAYERS: ViewerLayer[];
|
|
1141
1163
|
LOCALES: Record<string, FloorplanLocale>;
|
|
@@ -1171,6 +1193,8 @@ interface ResultExtension {
|
|
|
1171
1193
|
seedKey: string;
|
|
1172
1194
|
}
|
|
1173
1195
|
/** Adds a named piece to every result, after the state and before the zoning report; its output lands in `result[name]`. */
|
|
1196
|
+
/** Adds (or replaces, by `name`) a resolver of the options of every plan, run before the plan is laid out. */
|
|
1197
|
+
declare function registerOptionResolver(name: string, resolve: OptionResolver): void;
|
|
1174
1198
|
declare function registerResultExtension(name: string, run: ResultExtensionRun, options?: ResultExtensionOptions): void;
|
|
1175
1199
|
/** Registers who answers what a container holds (the item packs, from phase 3 on). */
|
|
1176
1200
|
declare function registerFindsProvider(provider: FindsProvider): void;
|
|
@@ -1261,6 +1285,7 @@ declare function buildEngine(scope: Registries): {
|
|
|
1261
1285
|
registerState: typeof registerState;
|
|
1262
1286
|
setStateDistribution: typeof setStateDistribution;
|
|
1263
1287
|
registerLocale: typeof registerLocale;
|
|
1288
|
+
registerOptionResolver: typeof registerOptionResolver;
|
|
1264
1289
|
registerResultExtension: typeof registerResultExtension;
|
|
1265
1290
|
registerFindsProvider: typeof registerFindsProvider;
|
|
1266
1291
|
findsFor: typeof findsFor;
|
|
@@ -1508,4 +1533,4 @@ declare function createDetachedHouse(p: DetachedHouseParams): Silhouette;
|
|
|
1508
1533
|
*/
|
|
1509
1534
|
declare const engine: FloorplanEngine;
|
|
1510
1535
|
|
|
1511
|
-
export { type Anchor, type BoundaryRule, type CarClearance, type ChaletParams, type CityBuildingParams, type ColonialParams, type CompanyHouseParams, type CreateFloorplanOptions, type DecorPass, type DecorPassContext, type DetachedHouseParams, type DoorDef, type Facade, type FacadeFields, type FacingRule, type FarmhouseParams, type FindStack, type FindsProvider, type FindsQuery, type FloorDef, type FloorplanEngine, type FloorplanLocale, type FloorplanOptions, type FloorplanPack, type FloorplanResult, type FloorplanResultFields, type FurnitureDef, type GateCfg, type GroundOverlayRule, type Hsl, type ItemColor, type ItemInput, type Json, type Lot, type LotBoundary, type LotConfig, type LotPath, type LotPerimeterPiece, type MeshFront, type Mount, type PaletteDraw, type PaletteEarly, type PaletteStyleDef, type PlaceOnFloorOptions, type PlacedItem, type PlacedItemFields, type PlacementContext, type PlacementKit, type Plan, type PlanAxis, type PlanDoor, type PlanGate, type PlanOpening, type PlanWall, type PlanWindow, type RandomSource, type RecordedSlot, type Rect, type ResultExtensionContext, type ResultExtensionOptions, type ResultExtensionRun, type ResultFacade, type ResultFloor, type ResultGate, type ResultItem, type ResultLot, type ResultRoom, type Room, type RoomColorDef, type RoomDef, type Side, type Silhouette, type SilhouettePart, type SilhouetteWindow, type SlabHouseParams, type Slot, type SlotCell, type SlotDef, type SlotFields, 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 WalkGrid, type Weights, type WindowDef, type ZoneAdjustment, type ZoneCheckedLot, type ZoneCheckedPlan, type ZoneDef, type ZoneViolation, type ZoningReport, blocksWindow, boxRadius, checkLot, createChalet, createCityBuilding, createColonialHouse, createCompanyHouse, createDetachedHouse, createFarmhouse, createFloorplan, createRng, createSilhouetteRandom, createSlabHouse, createStiltHouse, createTwoStoreyHouse, defaultFloorplan, 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 };
|
|
1536
|
+
export { type Anchor, type BoundaryRule, type CarClearance, type ChaletParams, type CityBuildingParams, type ColonialParams, type CompanyHouseParams, type CreateFloorplanOptions, type DecorPass, type DecorPassContext, type DetachedHouseParams, type DoorDef, type Facade, type FacadeFields, type FacingRule, type FarmhouseParams, type FindStack, type FindsProvider, type FindsQuery, type FloorDef, type FloorplanEngine, type FloorplanLocale, type FloorplanOptions, type FloorplanPack, type FloorplanResult, type FloorplanResultFields, type FurnitureDef, type GateCfg, type GroundOverlayRule, type Hsl, type ItemColor, type ItemInput, type Json, type Lot, type LotBoundary, type LotConfig, type LotPath, type LotPerimeterPiece, type MeshFront, type Mount, type OptionResolver, type PaletteDraw, type PaletteEarly, type PaletteStyleDef, type PlaceOnFloorOptions, type PlacedItem, type PlacedItemFields, type PlacementContext, type PlacementKit, type Plan, type PlanAxis, type PlanDoor, type PlanGate, type PlanOpening, type PlanWall, type PlanWindow, type RandomSource, type RecordedSlot, type Rect, type ResultExtensionContext, type ResultExtensionOptions, type ResultExtensionRun, type ResultFacade, type ResultFloor, type ResultGate, type ResultItem, type ResultLot, type ResultRoom, type Room, type RoomColorDef, type RoomDef, type Side, type Silhouette, type SilhouettePart, type SilhouetteWindow, type SlabHouseParams, type Slot, type SlotCell, type SlotDef, type SlotFields, 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 WalkGrid, type Weights, type WindowDef, type WindowFrame, type ZoneAdjustment, type ZoneCheckedLot, type ZoneCheckedPlan, type ZoneDef, type ZoneViolation, type ZoningReport, blocksWindow, boxRadius, checkLot, createChalet, createCityBuilding, createColonialHouse, createCompanyHouse, createDetachedHouse, createFarmhouse, createFloorplan, createRng, createSilhouetteRandom, createSlabHouse, createStiltHouse, createTwoStoreyHouse, defaultFloorplan, defineZone, engine, findsAnswer, findsFor, generate, getZone, hashString, limitsOf, listLocales, listStates, listTemplates, listZones, mulberry32, openingZones, overlaps, palette, registerDecorProfile, registerFindsProvider, registerGroundOverlay, registerItem, registerItems, registerLibrary, registerLibraryAlias, registerLocale, registerOptionResolver, registerPaletteStyle, registerPass, registerPermeableGround, registerResultExtension, registerRoomColors, registerSeedKeys, registerState, registerStyle, registerTemplate, registerViewerLayer, registerWallTop, setStateDistribution, slotKit, slots, translate, validate, version, windowZone };
|
package/dist/index.global.js
CHANGED
|
@@ -61,6 +61,7 @@ var GameFloorplan = (() => {
|
|
|
61
61
|
registerLibrary: () => registerLibrary,
|
|
62
62
|
registerLibraryAlias: () => registerLibraryAlias,
|
|
63
63
|
registerLocale: () => registerLocale,
|
|
64
|
+
registerOptionResolver: () => registerOptionResolver,
|
|
64
65
|
registerPaletteStyle: () => registerPaletteStyle,
|
|
65
66
|
registerPass: () => registerPass,
|
|
66
67
|
registerPermeableGround: () => registerPermeableGround,
|
|
@@ -99,6 +100,7 @@ var GameFloorplan = (() => {
|
|
|
99
100
|
SEED_KEYS: { rooms: {}, items: {} },
|
|
100
101
|
stateDistribution: { weights: null, seedKey: "state" },
|
|
101
102
|
RESULT_EXTENSIONS: [],
|
|
103
|
+
OPTION_RESOLVERS: [],
|
|
102
104
|
FINDS_PROVIDERS: [],
|
|
103
105
|
VIEWER_LAYERS: [],
|
|
104
106
|
LOCALES: {},
|
|
@@ -185,6 +187,12 @@ var GameFloorplan = (() => {
|
|
|
185
187
|
function styleOf(id) {
|
|
186
188
|
return registries().STYLES[id] || registries().STYLES.budget || Object.values(registries().STYLES)[0];
|
|
187
189
|
}
|
|
190
|
+
function registerOptionResolver(name, resolve) {
|
|
191
|
+
const list = registries().OPTION_RESOLVERS;
|
|
192
|
+
const i = list.findIndex((x) => x.name === name);
|
|
193
|
+
if (i >= 0) list[i] = { name, resolve };
|
|
194
|
+
else list.push({ name, resolve });
|
|
195
|
+
}
|
|
188
196
|
function registerResultExtension(name, run, options = {}) {
|
|
189
197
|
const entry = { name, run, after: options.after || [], seedKey: options.seedKey ?? name };
|
|
190
198
|
const i = registries().RESULT_EXTENSIONS.findIndex((x) => x.name === name);
|
|
@@ -327,11 +335,28 @@ var GameFloorplan = (() => {
|
|
|
327
335
|
]);
|
|
328
336
|
var CAR_CLEARANCE = { driver: 0.8, side: 0.6, end: 0.6 };
|
|
329
337
|
|
|
338
|
+
// src/wall-thickness.ts
|
|
339
|
+
var active = WALL_THICKNESS;
|
|
340
|
+
var wallThickness = () => active;
|
|
341
|
+
var wallMargin = () => active / 2;
|
|
342
|
+
var wallThicknessFor = (tpl, op) => op.wallThickness ?? tpl.wallThickness ?? WALL_THICKNESS;
|
|
343
|
+
function withWallThickness(thickness, fn) {
|
|
344
|
+
const previous = active;
|
|
345
|
+
active = thickness;
|
|
346
|
+
try {
|
|
347
|
+
return fn();
|
|
348
|
+
} finally {
|
|
349
|
+
active = previous;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
var roomMargin = (room) => room.outdoor ? WALL_THICKNESS / 2 : wallMargin();
|
|
353
|
+
|
|
330
354
|
// src/geometry.ts
|
|
331
355
|
var r2 = (x) => Math.round(x * 100) / 100;
|
|
332
356
|
var clamp = (x, a, b) => Math.max(a, Math.min(b, x));
|
|
333
357
|
var overlaps = (a, b, e = EPS) => a[0] < b[2] - e && a[2] > b[0] + e && a[1] < b[3] - e && a[3] > b[1] + e;
|
|
334
|
-
var inner = (p) =>
|
|
358
|
+
var inner = (p) => insetBy(p, wallMargin());
|
|
359
|
+
var insetBy = (p, margin) => [p[0] + margin, p[1] + margin, p[2] - margin, p[3] - margin];
|
|
335
360
|
var eq = (a, b) => Math.abs(a - b) < TOL;
|
|
336
361
|
var inflate = (r, e) => [r[0] - e, r[1] - e, r[2] + e, r[3] + e];
|
|
337
362
|
var areaOf = (r) => (r[2] - r[0]) * (r[3] - r[1]);
|
|
@@ -404,7 +429,7 @@ var GameFloorplan = (() => {
|
|
|
404
429
|
const h = width / 2;
|
|
405
430
|
return axis === "u" ? [[u - h, v - depth, u + h, v], [u - h, v, u + h, v + depth]] : [[u - depth, v - h, u, v + h], [u, v - h, u + depth, v + h]];
|
|
406
431
|
}
|
|
407
|
-
var openingDepth = (width, leaf) => Math.max(0.9, leaf) +
|
|
432
|
+
var openingDepth = (width, leaf) => Math.max(0.9, leaf) + wallMargin();
|
|
408
433
|
function entryPoints(ab) {
|
|
409
434
|
return ab.axis === "u" ? [[ab.u, ab.v - 0.55], [ab.u, ab.v + 0.55]] : [[ab.u - 0.55, ab.v], [ab.u + 0.55, ab.v]];
|
|
410
435
|
}
|
|
@@ -428,7 +453,7 @@ var GameFloorplan = (() => {
|
|
|
428
453
|
};
|
|
429
454
|
}
|
|
430
455
|
function usableParts(room, extra) {
|
|
431
|
-
const m =
|
|
456
|
+
const m = roomMargin(room) + (extra || 0);
|
|
432
457
|
const out = [];
|
|
433
458
|
for (const p of room.parts) {
|
|
434
459
|
out.push([p[0] + m, p[1] + m, p[2] - m, p[3] - m]);
|
|
@@ -526,7 +551,7 @@ var GameFloorplan = (() => {
|
|
|
526
551
|
v0: g.axis === "u" ? g.pos : x,
|
|
527
552
|
u1: g.axis === "u" ? y : g.pos,
|
|
528
553
|
v1: g.axis === "u" ? g.pos : y,
|
|
529
|
-
thickness:
|
|
554
|
+
thickness: wallThickness(),
|
|
530
555
|
sides: [s.A, s.B],
|
|
531
556
|
exterior: s.A === "outside" || s.B === "outside",
|
|
532
557
|
type: railing ? "railing" : "wall",
|
|
@@ -600,8 +625,9 @@ var GameFloorplan = (() => {
|
|
|
600
625
|
if (outside) n = [-n[0], -n[1]];
|
|
601
626
|
const u = j.u;
|
|
602
627
|
const v = j.v;
|
|
603
|
-
|
|
604
|
-
return n[
|
|
628
|
+
const MARGIN2 = wallMargin();
|
|
629
|
+
if (j.axis === "u") return n[1] > 0 ? [u - h, v - MARGIN2, u + h, v + depth] : [u - h, v - depth, u + h, v + MARGIN2];
|
|
630
|
+
return n[0] > 0 ? [u - MARGIN2, v - h, u + depth, v + h] : [u - depth, v - h, u + MARGIN2, v + h];
|
|
605
631
|
}
|
|
606
632
|
function blocksWindow(it, win, overheadOff) {
|
|
607
633
|
const height = Math.max(it.h, it.windowHeight || 0, it.overhead && !overheadOff ? OVERHEAD_TOP : 0);
|
|
@@ -635,14 +661,15 @@ var GameFloorplan = (() => {
|
|
|
635
661
|
const cache = plan.wallBodies = plan.wallBodies || {};
|
|
636
662
|
if (cache[floor]) return cache[floor];
|
|
637
663
|
const doors = plan.doors.filter((p) => p.floor === floor);
|
|
664
|
+
const MARGIN2 = plan.wallThickness / 2;
|
|
638
665
|
return cache[floor] = plan.walls.filter((p) => p.floor === floor && (p.type === "wall" || p.type === "railing")).map((p) => {
|
|
639
666
|
const a0 = p.axis === "u" ? p.u0 : p.v0;
|
|
640
667
|
const a1 = p.axis === "u" ? p.u1 : p.v1;
|
|
641
668
|
const pos = p.axis === "u" ? p.v0 : p.u0;
|
|
642
669
|
const atDoor = (x) => doors.some((q) => q.axis === p.axis && eq(q.pos, pos) && (eq(q.at - q.width / 2, x) || eq(q.at + q.width / 2, x)));
|
|
643
|
-
const e0 = atDoor(a0) ? 0 :
|
|
644
|
-
const e1 = atDoor(a1) ? 0 :
|
|
645
|
-
return p.axis === "u" ? [a0 - e0, pos -
|
|
670
|
+
const e0 = atDoor(a0) ? 0 : MARGIN2;
|
|
671
|
+
const e1 = atDoor(a1) ? 0 : MARGIN2;
|
|
672
|
+
return p.axis === "u" ? [a0 - e0, pos - MARGIN2, a1 + e1, pos + MARGIN2] : [pos - MARGIN2, a0 - e0, pos + MARGIN2, a1 + e1];
|
|
646
673
|
});
|
|
647
674
|
}
|
|
648
675
|
function createGrid(plan, room, ignored, radius = plan.playerRadius) {
|
|
@@ -984,7 +1011,9 @@ var GameFloorplan = (() => {
|
|
|
984
1011
|
|
|
985
1012
|
// src/context.ts
|
|
986
1013
|
var placementKit = {
|
|
987
|
-
MARGIN
|
|
1014
|
+
get MARGIN() {
|
|
1015
|
+
return wallMargin();
|
|
1016
|
+
},
|
|
988
1017
|
EPS,
|
|
989
1018
|
r2,
|
|
990
1019
|
clamp,
|
|
@@ -1433,6 +1462,7 @@ var GameFloorplan = (() => {
|
|
|
1433
1462
|
const FLOOR_DEFS = floorsOf(tpl, op);
|
|
1434
1463
|
const style = styleOf(styleId);
|
|
1435
1464
|
const plan = {
|
|
1465
|
+
wallThickness: wallThickness(),
|
|
1436
1466
|
w,
|
|
1437
1467
|
d,
|
|
1438
1468
|
tpl,
|
|
@@ -1909,7 +1939,7 @@ var GameFloorplan = (() => {
|
|
|
1909
1939
|
const key = registries().LIBRARY_ALIAS[name] || name;
|
|
1910
1940
|
const library = room.slots ? room.slots : registries().LIBRARIES[key];
|
|
1911
1941
|
if (!library) return [];
|
|
1912
|
-
const R =
|
|
1942
|
+
const R = insetBy(room.parts[0], roomMargin(room));
|
|
1913
1943
|
let defs = typeof library === "function" ? library({ w: R[2] - R[0], d: R[3] - R[1] }) : library.slice();
|
|
1914
1944
|
defs = defs.map((x) => Object.assign({}, x));
|
|
1915
1945
|
for (const id of room.without || []) defs = defs.filter((x) => x.id !== id);
|
|
@@ -1975,7 +2005,7 @@ var GameFloorplan = (() => {
|
|
|
1975
2005
|
}
|
|
1976
2006
|
const size = def.size;
|
|
1977
2007
|
const roomCenter = (() => {
|
|
1978
|
-
const R0 =
|
|
2008
|
+
const R0 = insetBy(room.parts[0], roomMargin(room));
|
|
1979
2009
|
return [(R0[0] + R0[2]) / 2, (R0[1] + R0[3]) / 2];
|
|
1980
2010
|
})();
|
|
1981
2011
|
const openings = openingsOfFloor(plan, room.floor);
|
|
@@ -2001,7 +2031,7 @@ var GameFloorplan = (() => {
|
|
|
2001
2031
|
};
|
|
2002
2032
|
const free = (rect) => !!def.floorFree || !zones.some((z) => overlaps(rect, z, room.type === "stairs" ? -0.011 : EPS));
|
|
2003
2033
|
const rule = def.facing || "center";
|
|
2004
|
-
let R =
|
|
2034
|
+
let R = insetBy(room.parts[Math.min(def.part || 0, room.parts.length - 1)], roomMargin(room));
|
|
2005
2035
|
if (def.anchor === "wall" || def.anchor === "window") {
|
|
2006
2036
|
let side = def.side;
|
|
2007
2037
|
let a = null;
|
|
@@ -2013,7 +2043,7 @@ var GameFloorplan = (() => {
|
|
|
2013
2043
|
const found2 = win;
|
|
2014
2044
|
side = room.outdoor ? SIDE_OPPOSITE[win.side] : WINDOW_SIDE[win.side];
|
|
2015
2045
|
const cand = room.parts.map(inner).find(
|
|
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 +
|
|
2046
|
+
(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 + roomMargin(room)) || side === "right" && eq(r[2], found2.pos - roomMargin(room)) || side === "front" && eq(r[1], found2.pos + roomMargin(room)) || side === "back" && eq(r[3], found2.pos - roomMargin(room)))
|
|
2017
2047
|
);
|
|
2018
2048
|
if (!cand) return invalid("window_outside_room");
|
|
2019
2049
|
R = cand;
|
|
@@ -2030,7 +2060,7 @@ var GameFloorplan = (() => {
|
|
|
2030
2060
|
const hw = Math.min(size[0], len) / 2;
|
|
2031
2061
|
const cell = (ac) => side === "left" ? [R[0], ac - hw, R[0] + depth, ac + hw] : side === "right" ? [R[2] - depth, ac - hw, R[2], ac + hw] : side === "front" ? [ac - hw, R[1], ac + hw, R[1] + depth] : [ac - hw, R[3] - depth, ac + hw, R[3]];
|
|
2032
2062
|
const nominal = a != null ? a : a0 + hw + (def.pos == null ? 0.5 : def.pos) * Math.max(0, len - 2 * hw) + (def.shift || 0);
|
|
2033
|
-
const wp = side === "left" ? R[0] -
|
|
2063
|
+
const wp = side === "left" ? R[0] - roomMargin(room) : side === "right" ? R[2] + roomMargin(room) : side === "front" ? R[1] - roomMargin(room) : R[3] + roomMargin(room);
|
|
2034
2064
|
const pa = clamp(nominal, a0 + hw, a1 - hw);
|
|
2035
2065
|
let found = null;
|
|
2036
2066
|
const steps = [0];
|
|
@@ -2069,7 +2099,7 @@ var GameFloorplan = (() => {
|
|
|
2069
2099
|
if (extentU > R[2] - R[0] + EPS || extentV > R[3] - R[1] + EPS) return invalid("larger_than_room");
|
|
2070
2100
|
const rect = [cornerU === "left" ? R[0] : R[2] - extentU, cornerV === "front" ? R[1] : R[3] - extentV, cornerU === "left" ? R[0] + extentU : R[2], cornerV === "front" ? R[1] + extentV : R[3]];
|
|
2071
2101
|
if (!free(rect)) return invalid("blocked_by_door");
|
|
2072
|
-
for (const sp of [[kx - normalU[0] * (
|
|
2102
|
+
for (const sp of [[kx - normalU[0] * (roomMargin(room) + 0.1), (rect[1] + rect[3]) / 2], [(rect[0] + rect[2]) / 2, kz - normalV[1] * (roomMargin(room) + 0.1)]]) if (isOpenSide(plan, room, sp[0], sp[1])) return invalid("open_wall");
|
|
2073
2103
|
return Object.assign(base, { x: r2((rect[0] + rect[2]) / 2), z: r2((rect[1] + rect[3]) / 2), frontU: f[0], frontV: f[1], ry: r2(Math.atan2(f[0], f[1])), w: size[0], d: size[1], aabb: rect.map(r2), _cell: { rect, f, enclosed: [cornerU, cornerV], R, size } });
|
|
2074
2104
|
}
|
|
2075
2105
|
if (def.anchor === "center") {
|
|
@@ -2111,7 +2141,10 @@ var GameFloorplan = (() => {
|
|
|
2111
2141
|
};
|
|
2112
2142
|
function slots(template, options) {
|
|
2113
2143
|
const tpl = templateOf(template);
|
|
2114
|
-
const o = options || {};
|
|
2144
|
+
const o = resolveOptions(tpl, options || {});
|
|
2145
|
+
return withWallThickness(wallThicknessFor(tpl, o), () => slotsWith(tpl, o));
|
|
2146
|
+
}
|
|
2147
|
+
function slotsWith(tpl, o) {
|
|
2115
2148
|
const plan = buildPlan(tpl, o.w, o.d, o);
|
|
2116
2149
|
const locale = o.locale || "en";
|
|
2117
2150
|
return resolveSlots(plan).map(cleanSlot).map((s) => s.reason ? Object.assign(s, { reason: translate("reasons", s.reason, locale) }) : s);
|
|
@@ -2154,7 +2187,11 @@ var GameFloorplan = (() => {
|
|
|
2154
2187
|
var loc = (key, locale, ns = "labels", vars) => key ? translate(ns, key, locale, vars) : key;
|
|
2155
2188
|
function generate(template, options) {
|
|
2156
2189
|
const tpl = templateOf(template);
|
|
2157
|
-
const o = options || {};
|
|
2190
|
+
const o = resolveOptions(tpl, options || {});
|
|
2191
|
+
return withWallThickness(wallThicknessFor(tpl, o), () => generateWith(tpl, o));
|
|
2192
|
+
}
|
|
2193
|
+
var resolveOptions = (tpl, options) => registries().OPTION_RESOLVERS.reduce((op, r) => r.resolve(tpl, op), options);
|
|
2194
|
+
function generateWith(tpl, o) {
|
|
2158
2195
|
const seed = o.seed == null ? 1 : o.seed;
|
|
2159
2196
|
const locale = o.locale || "en";
|
|
2160
2197
|
let op = Object.assign({}, o, { seed });
|
|
@@ -2303,15 +2340,37 @@ var GameFloorplan = (() => {
|
|
|
2303
2340
|
var DEFERRED_QUEUE_ID = {
|
|
2304
2341
|
DESTRUCTION_EVENTS: "destruction.events",
|
|
2305
2342
|
BREACH_PAINT: "floorplan.breach-paint",
|
|
2343
|
+
BREACH_CUT: "floorplan.breach-cut",
|
|
2306
2344
|
AUDIO_VOICES: "audio.voices",
|
|
2307
|
-
VEHICLE_CREASE: "vehicles.crease"
|
|
2345
|
+
VEHICLE_CREASE: "vehicles.crease",
|
|
2346
|
+
AUDIO_OCCLUSION: "audio.occlusion",
|
|
2347
|
+
FLUID_FILM: "fluids.film",
|
|
2348
|
+
VEHICLE_LOD_BATCH: "vehicles.lod-batch",
|
|
2349
|
+
SETTLED_BATCH: "destruction.settled-batch",
|
|
2350
|
+
STATIC_BATCH: "render.static-batch",
|
|
2351
|
+
ANIMALS_STATIC_BATCH: "animals.static-batch",
|
|
2352
|
+
CHARACTERS_STATIC_BATCH: "characters.static-batch",
|
|
2353
|
+
HOUSE_SHADOW_BATCH: "floorplan.shadow-batch",
|
|
2354
|
+
DESTRUCTION_PREFIT: "destruction.prefit"
|
|
2308
2355
|
};
|
|
2309
2356
|
var DEFERRED_PRIORITY = {
|
|
2310
2357
|
[DEFERRED_QUEUE_ID.DESTRUCTION_EVENTS]: { priority: 300, phase: "present" },
|
|
2311
|
-
|
|
2358
|
+
// every frame: the walls cut since the last frame are painted once each, and a hole must show in the frame of the blast
|
|
2359
|
+
[DEFERRED_QUEUE_ID.BREACH_CUT]: { priority: 260, phase: "present", minEveryFrames: 1 },
|
|
2360
|
+
[DEFERRED_QUEUE_ID.BREACH_PAINT]: { priority: 250, phase: "present", minEveryFrames: 1 },
|
|
2312
2361
|
[DEFERRED_QUEUE_ID.AUDIO_VOICES]: { priority: 200, phase: "idle", reserveMs: 1 },
|
|
2313
|
-
[DEFERRED_QUEUE_ID.
|
|
2362
|
+
[DEFERRED_QUEUE_ID.AUDIO_OCCLUSION]: { priority: 190, phase: "idle", minEveryFrames: 8 },
|
|
2363
|
+
[DEFERRED_QUEUE_ID.FLUID_FILM]: { priority: 120, phase: "idle", minEveryFrames: 2 },
|
|
2364
|
+
[DEFERRED_QUEUE_ID.VEHICLE_CREASE]: { priority: 100, phase: "idle" },
|
|
2365
|
+
[DEFERRED_QUEUE_ID.VEHICLE_LOD_BATCH]: { priority: 90, phase: "idle", minEveryFrames: 4 },
|
|
2366
|
+
[DEFERRED_QUEUE_ID.SETTLED_BATCH]: { priority: 70, phase: "idle", minEveryFrames: 8 },
|
|
2367
|
+
[DEFERRED_QUEUE_ID.STATIC_BATCH]: { priority: 60, phase: "idle", minEveryFrames: 8 },
|
|
2368
|
+
[DEFERRED_QUEUE_ID.ANIMALS_STATIC_BATCH]: { priority: 60, phase: "idle", minEveryFrames: 8 },
|
|
2369
|
+
[DEFERRED_QUEUE_ID.CHARACTERS_STATIC_BATCH]: { priority: 60, phase: "idle", minEveryFrames: 8 },
|
|
2370
|
+
[DEFERRED_QUEUE_ID.HOUSE_SHADOW_BATCH]: { priority: 50, phase: "idle", minEveryFrames: 8 },
|
|
2371
|
+
[DEFERRED_QUEUE_ID.DESTRUCTION_PREFIT]: { priority: 40, phase: "idle", minEveryFrames: 30 }
|
|
2314
2372
|
};
|
|
2373
|
+
var MUST_DRAIN_QUEUE_IDS = /* @__PURE__ */ new Set([DEFERRED_QUEUE_ID.DESTRUCTION_EVENTS, DEFERRED_QUEUE_ID.BREACH_CUT]);
|
|
2315
2374
|
var WARNED_KEY = /* @__PURE__ */ Symbol.for("@adatechnology/game-contracts.warned");
|
|
2316
2375
|
var warnedKeys = () => {
|
|
2317
2376
|
const holder = globalThis;
|
|
@@ -2392,6 +2451,22 @@ var GameFloorplan = (() => {
|
|
|
2392
2451
|
var FOOTSTEP_SOUND_IDS = SURFACE_IDS.flatMap((surface) => GAIT_IDS.map((gait) => footstepSoundId(surface, gait)));
|
|
2393
2452
|
var LAND_SOUND_IDS = SURFACE_IDS.flatMap((surface) => LANDING_IDS.map((landing) => `land_${surface}_${landing}`));
|
|
2394
2453
|
var BODY_FOLEY_IDS = [...FOOTSTEP_SOUND_IDS, ...LAND_SOUND_IDS, ...BODY_SOUND_IDS];
|
|
2454
|
+
var WORKER_KIND_ID = {
|
|
2455
|
+
GROUND_TILES: "destruction.ground-tiles",
|
|
2456
|
+
CROWD_PHYSICS: "crowd.physics",
|
|
2457
|
+
PIECE_BOXES: "destruction.piece-boxes",
|
|
2458
|
+
STATIC_COLLIDERS: "destruction.static-colliders",
|
|
2459
|
+
SHAPES_GENERATE: "shapes.generate",
|
|
2460
|
+
WORLD_REGION: "world.region"
|
|
2461
|
+
};
|
|
2462
|
+
var WORKER_KIND_DEFAULTS = {
|
|
2463
|
+
[WORKER_KIND_ID.GROUND_TILES]: { lane: "sim", priority: 300, latencyFrames: 2, late: "sync" },
|
|
2464
|
+
[WORKER_KIND_ID.CROWD_PHYSICS]: { lane: "sim", priority: 250, latencyFrames: 1, late: "sync" },
|
|
2465
|
+
[WORKER_KIND_ID.PIECE_BOXES]: { lane: "sim", priority: 200, latencyFrames: 2, late: "sync" },
|
|
2466
|
+
[WORKER_KIND_ID.STATIC_COLLIDERS]: { lane: "build", priority: 150, late: "sync" },
|
|
2467
|
+
[WORKER_KIND_ID.SHAPES_GENERATE]: { lane: "build", priority: 100, late: "sync" },
|
|
2468
|
+
[WORKER_KIND_ID.WORLD_REGION]: { lane: "background", priority: 10, latencyFrames: 10, late: "drop" }
|
|
2469
|
+
};
|
|
2395
2470
|
|
|
2396
2471
|
// src/ground-items.ts
|
|
2397
2472
|
function registerGroundItems() {
|
|
@@ -2659,6 +2734,7 @@ var GameFloorplan = (() => {
|
|
|
2659
2734
|
registerState: scoped(registerState),
|
|
2660
2735
|
setStateDistribution: scoped(setStateDistribution),
|
|
2661
2736
|
registerLocale: scoped(registerLocale),
|
|
2737
|
+
registerOptionResolver: scoped(registerOptionResolver),
|
|
2662
2738
|
registerResultExtension: scoped(registerResultExtension),
|
|
2663
2739
|
registerFindsProvider: scoped(registerFindsProvider),
|
|
2664
2740
|
findsFor: scoped(findsFor),
|