@adatechnology/game-floorplan 0.2.2 → 0.3.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 +6 -0
- package/dist/index.d.ts +234 -171
- package/dist/index.global.js +352 -196
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +258 -194
- package/dist/index.js.map +1 -1
- package/package.json +5 -2
package/dist/index.global.js
CHANGED
|
@@ -30,11 +30,13 @@ var GameFloorplan = (() => {
|
|
|
30
30
|
createCompanyHouse: () => createCompanyHouse,
|
|
31
31
|
createDetachedHouse: () => createDetachedHouse,
|
|
32
32
|
createFarmhouse: () => createFarmhouse,
|
|
33
|
+
createFloorplan: () => createFloorplan,
|
|
33
34
|
createRng: () => createRng,
|
|
34
35
|
createSilhouetteRandom: () => createSilhouetteRandom,
|
|
35
36
|
createSlabHouse: () => createSlabHouse,
|
|
36
37
|
createStiltHouse: () => createStiltHouse,
|
|
37
38
|
createTwoStoreyHouse: () => createTwoStoreyHouse,
|
|
39
|
+
defaultFloorplan: () => defaultFloorplan,
|
|
38
40
|
defineZone: () => defineZone,
|
|
39
41
|
engine: () => engine,
|
|
40
42
|
findsAnswer: () => findsAnswer,
|
|
@@ -79,137 +81,123 @@ var GameFloorplan = (() => {
|
|
|
79
81
|
windowZone: () => windowZone
|
|
80
82
|
});
|
|
81
83
|
|
|
82
|
-
// src/constants.ts
|
|
83
|
-
var WALL_THICKNESS = 0.15;
|
|
84
|
-
var MARGIN = WALL_THICKNESS / 2;
|
|
85
|
-
var EPS = 1e-6;
|
|
86
|
-
var TOL = 1e-3;
|
|
87
|
-
var DOOR_CLEARANCE = 0.9;
|
|
88
|
-
var PLAYER_RADIUS = 0.24;
|
|
89
|
-
var DOOR_EDGE_CLEARANCE = 0.12;
|
|
90
|
-
var WINDOW_EDGE_CLEARANCE = 0.3;
|
|
91
|
-
var OVERHEAD_TOP = 2.15;
|
|
92
|
-
var WINDOWLESS_ROOM_TYPES = /* @__PURE__ */ new Set([
|
|
93
|
-
"stockroom",
|
|
94
|
-
"kitchen",
|
|
95
|
-
"laundry",
|
|
96
|
-
"bathroom",
|
|
97
|
-
"void",
|
|
98
|
-
"elevator",
|
|
99
|
-
"stairs",
|
|
100
|
-
"pantry",
|
|
101
|
-
"closet",
|
|
102
|
-
"corridor",
|
|
103
|
-
"hall",
|
|
104
|
-
"balcony",
|
|
105
|
-
"terrace",
|
|
106
|
-
"garage",
|
|
107
|
-
"storage",
|
|
108
|
-
"porch",
|
|
109
|
-
"tent",
|
|
110
|
-
"outhouse"
|
|
111
|
-
]);
|
|
112
|
-
var CAR_CLEARANCE = { driver: 0.8, side: 0.6, end: 0.6 };
|
|
113
|
-
|
|
114
84
|
// src/registry.ts
|
|
115
|
-
var
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
85
|
+
var createRegistries = () => ({
|
|
86
|
+
CATALOG: {},
|
|
87
|
+
LIBRARIES: {},
|
|
88
|
+
LIBRARY_ALIAS: {},
|
|
89
|
+
TEMPLATES: {},
|
|
90
|
+
STYLES: {},
|
|
91
|
+
STYLE_ALIAS: {},
|
|
92
|
+
PALETTE_STYLES: {},
|
|
93
|
+
ROOM_COLORS: [],
|
|
94
|
+
PASSES: [],
|
|
95
|
+
DECOR_PROFILES: {},
|
|
96
|
+
GROUND_OVERLAYS: [],
|
|
97
|
+
STATE_PLUGINS: { normal: { apply: () => [] } },
|
|
98
|
+
WALL_TOP_HEIGHTS: { none: 0 },
|
|
99
|
+
SEED_KEYS: { rooms: {}, items: {} },
|
|
100
|
+
stateDistribution: { weights: null, seedKey: "state" },
|
|
101
|
+
RESULT_EXTENSIONS: [],
|
|
102
|
+
FINDS_PROVIDERS: [],
|
|
103
|
+
VIEWER_LAYERS: [],
|
|
104
|
+
LOCALES: {},
|
|
105
|
+
ZONES: {},
|
|
106
|
+
PERMEABLE_GROUNDS: /* @__PURE__ */ new Set()
|
|
107
|
+
});
|
|
108
|
+
var defaultRegistries;
|
|
109
|
+
var activeRegistries;
|
|
110
|
+
var getDefaultRegistries = () => defaultRegistries ?? (defaultRegistries = createRegistries());
|
|
111
|
+
var registries = () => activeRegistries ?? getDefaultRegistries();
|
|
112
|
+
function withRegistries(scope, run) {
|
|
113
|
+
const previous = activeRegistries;
|
|
114
|
+
activeRegistries = scope;
|
|
115
|
+
try {
|
|
116
|
+
return run();
|
|
117
|
+
} finally {
|
|
118
|
+
activeRegistries = previous;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
130
121
|
function registerItem(def) {
|
|
131
122
|
const h = def.h;
|
|
132
123
|
const item = Object.assign({ front: "+z", window: h <= 0.95, low: h <= 0.5, flat: false, deck: false, rim: 0 }, def);
|
|
133
|
-
CATALOG[def.type] = item;
|
|
124
|
+
registries().CATALOG[def.type] = item;
|
|
134
125
|
return item;
|
|
135
126
|
}
|
|
136
127
|
function registerItems(list) {
|
|
137
128
|
for (const d of list) registerItem(d);
|
|
138
129
|
}
|
|
139
130
|
function registerLibrary(id, library) {
|
|
140
|
-
LIBRARIES[id] = library;
|
|
131
|
+
registries().LIBRARIES[id] = library;
|
|
141
132
|
}
|
|
142
133
|
function registerLibraryAlias(alias, id) {
|
|
143
|
-
LIBRARY_ALIAS[alias] = id;
|
|
134
|
+
registries().LIBRARY_ALIAS[alias] = id;
|
|
144
135
|
}
|
|
145
136
|
function registerTemplate(t) {
|
|
146
|
-
TEMPLATES[t.id] = t;
|
|
137
|
+
registries().TEMPLATES[t.id] = t;
|
|
147
138
|
return t;
|
|
148
139
|
}
|
|
149
140
|
function registerStyle(style) {
|
|
150
|
-
STYLES[style.id] = style;
|
|
151
|
-
for (const a of style.aliases || []) STYLE_ALIAS[a] = style.id;
|
|
141
|
+
registries().STYLES[style.id] = style;
|
|
142
|
+
for (const a of style.aliases || []) registries().STYLE_ALIAS[a] = style.id;
|
|
152
143
|
}
|
|
153
144
|
function registerPaletteStyle(id, def) {
|
|
154
|
-
PALETTE_STYLES[id] = def;
|
|
145
|
+
registries().PALETTE_STYLES[id] = def;
|
|
155
146
|
}
|
|
156
147
|
function registerRoomColors(list) {
|
|
157
148
|
for (const d of list) {
|
|
158
|
-
const i = ROOM_COLORS.findIndex((x) => x.type === d.type);
|
|
159
|
-
if (i >= 0) ROOM_COLORS.splice(i, 1);
|
|
160
|
-
ROOM_COLORS.push(d);
|
|
149
|
+
const i = registries().ROOM_COLORS.findIndex((x) => x.type === d.type);
|
|
150
|
+
if (i >= 0) registries().ROOM_COLORS.splice(i, 1);
|
|
151
|
+
registries().ROOM_COLORS.push(d);
|
|
161
152
|
}
|
|
162
|
-
ROOM_COLORS.sort((a, b) => a.order - b.order);
|
|
153
|
+
registries().ROOM_COLORS.sort((a, b) => a.order - b.order);
|
|
163
154
|
}
|
|
164
155
|
function registerDecorProfile(styleId, profile) {
|
|
165
|
-
DECOR_PROFILES[styleId] = profile;
|
|
156
|
+
registries().DECOR_PROFILES[styleId] = profile;
|
|
166
157
|
}
|
|
167
158
|
function registerPass(name, run) {
|
|
168
|
-
const i = PASSES.findIndex((p) => p.name === name);
|
|
169
|
-
if (i >= 0) PASSES[i] = { name, run };
|
|
170
|
-
else PASSES.push({ name, run });
|
|
159
|
+
const i = registries().PASSES.findIndex((p) => p.name === name);
|
|
160
|
+
if (i >= 0) registries().PASSES[i] = { name, run };
|
|
161
|
+
else registries().PASSES.push({ name, run });
|
|
171
162
|
}
|
|
172
163
|
function registerGroundOverlay(rule) {
|
|
173
|
-
GROUND_OVERLAYS.push(rule);
|
|
164
|
+
registries().GROUND_OVERLAYS.push(rule);
|
|
174
165
|
}
|
|
175
166
|
function registerWallTop(id, height) {
|
|
176
|
-
WALL_TOP_HEIGHTS[id] = height;
|
|
167
|
+
registries().WALL_TOP_HEIGHTS[id] = height;
|
|
177
168
|
}
|
|
178
169
|
function registerSeedKeys(keys) {
|
|
179
|
-
Object.assign(SEED_KEYS.rooms, keys.rooms);
|
|
180
|
-
Object.assign(SEED_KEYS.items, keys.items);
|
|
170
|
+
Object.assign(registries().SEED_KEYS.rooms, keys.rooms);
|
|
171
|
+
Object.assign(registries().SEED_KEYS.items, keys.items);
|
|
181
172
|
}
|
|
182
173
|
function registerState(name, plugin) {
|
|
183
|
-
STATE_PLUGINS[name] = plugin;
|
|
174
|
+
registries().STATE_PLUGINS[name] = plugin;
|
|
184
175
|
}
|
|
185
176
|
function setStateDistribution(weights, seedKey = "state") {
|
|
186
|
-
stateDistribution.weights = weights;
|
|
187
|
-
stateDistribution.seedKey = seedKey;
|
|
177
|
+
registries().stateDistribution.weights = weights;
|
|
178
|
+
registries().stateDistribution.seedKey = seedKey;
|
|
188
179
|
}
|
|
189
|
-
var listStates = () => Object.keys(STATE_PLUGINS);
|
|
180
|
+
var listStates = () => Object.keys(registries().STATE_PLUGINS);
|
|
190
181
|
function resolveStyleId(id) {
|
|
191
182
|
const s = id ?? "";
|
|
192
|
-
return STYLE_ALIAS[s] ?? s;
|
|
183
|
+
return registries().STYLE_ALIAS[s] ?? s;
|
|
193
184
|
}
|
|
194
185
|
function styleOf(id) {
|
|
195
|
-
return STYLES[id] || STYLES.budget || Object.values(STYLES)[0];
|
|
186
|
+
return registries().STYLES[id] || registries().STYLES.budget || Object.values(registries().STYLES)[0];
|
|
196
187
|
}
|
|
197
|
-
var RESULT_EXTENSIONS = [];
|
|
198
|
-
var FINDS_PROVIDERS = [];
|
|
199
188
|
function registerResultExtension(name, run, options = {}) {
|
|
200
189
|
const entry = { name, run, after: options.after || [], seedKey: options.seedKey ?? name };
|
|
201
|
-
const i = RESULT_EXTENSIONS.findIndex((x) => x.name === name);
|
|
202
|
-
if (i >= 0) RESULT_EXTENSIONS[i] = entry;
|
|
203
|
-
else RESULT_EXTENSIONS.push(entry);
|
|
190
|
+
const i = registries().RESULT_EXTENSIONS.findIndex((x) => x.name === name);
|
|
191
|
+
if (i >= 0) registries().RESULT_EXTENSIONS[i] = entry;
|
|
192
|
+
else registries().RESULT_EXTENSIONS.push(entry);
|
|
204
193
|
}
|
|
205
194
|
function registerFindsProvider(provider) {
|
|
206
|
-
FINDS_PROVIDERS.push(provider);
|
|
195
|
+
registries().FINDS_PROVIDERS.push(provider);
|
|
207
196
|
}
|
|
208
|
-
var VIEWER_LAYERS = [];
|
|
209
197
|
function registerViewerLayer(layer) {
|
|
210
|
-
const i = VIEWER_LAYERS.findIndex((x) => x.id === layer.id);
|
|
211
|
-
if (i >= 0) VIEWER_LAYERS[i] = layer;
|
|
212
|
-
else VIEWER_LAYERS.push(layer);
|
|
198
|
+
const i = registries().VIEWER_LAYERS.findIndex((x) => x.id === layer.id);
|
|
199
|
+
if (i >= 0) registries().VIEWER_LAYERS[i] = layer;
|
|
200
|
+
else registries().VIEWER_LAYERS.push(layer);
|
|
213
201
|
}
|
|
214
202
|
|
|
215
203
|
// src/rng.ts
|
|
@@ -289,7 +277,7 @@ var GameFloorplan = (() => {
|
|
|
289
277
|
return ordered;
|
|
290
278
|
}
|
|
291
279
|
function runResultExtensions(plan, result, seed, options) {
|
|
292
|
-
for (const extension of orderOf(RESULT_EXTENSIONS)) {
|
|
280
|
+
for (const extension of orderOf(registries().RESULT_EXTENSIONS)) {
|
|
293
281
|
result[extension.name] = extension.run({ plan, result, seed, rng: createRng(seed, extension.seedKey), options });
|
|
294
282
|
}
|
|
295
283
|
}
|
|
@@ -300,13 +288,45 @@ var GameFloorplan = (() => {
|
|
|
300
288
|
return answerOf(query);
|
|
301
289
|
}
|
|
302
290
|
function answerOf(query) {
|
|
303
|
-
for (const provider of FINDS_PROVIDERS) {
|
|
291
|
+
for (const provider of registries().FINDS_PROVIDERS) {
|
|
304
292
|
const stacks = provider.findsFor(query);
|
|
305
293
|
if (stacks !== null) return stacks;
|
|
306
294
|
}
|
|
307
295
|
return null;
|
|
308
296
|
}
|
|
309
297
|
|
|
298
|
+
// src/constants.ts
|
|
299
|
+
var WALL_THICKNESS = 0.15;
|
|
300
|
+
var MARGIN = WALL_THICKNESS / 2;
|
|
301
|
+
var EPS = 1e-6;
|
|
302
|
+
var TOL = 1e-3;
|
|
303
|
+
var DOOR_CLEARANCE = 0.9;
|
|
304
|
+
var PLAYER_RADIUS = 0.24;
|
|
305
|
+
var DOOR_EDGE_CLEARANCE = 0.12;
|
|
306
|
+
var WINDOW_EDGE_CLEARANCE = 0.3;
|
|
307
|
+
var OVERHEAD_TOP = 2.15;
|
|
308
|
+
var WINDOWLESS_ROOM_TYPES = /* @__PURE__ */ new Set([
|
|
309
|
+
"stockroom",
|
|
310
|
+
"kitchen",
|
|
311
|
+
"laundry",
|
|
312
|
+
"bathroom",
|
|
313
|
+
"void",
|
|
314
|
+
"elevator",
|
|
315
|
+
"stairs",
|
|
316
|
+
"pantry",
|
|
317
|
+
"closet",
|
|
318
|
+
"corridor",
|
|
319
|
+
"hall",
|
|
320
|
+
"balcony",
|
|
321
|
+
"terrace",
|
|
322
|
+
"garage",
|
|
323
|
+
"storage",
|
|
324
|
+
"porch",
|
|
325
|
+
"tent",
|
|
326
|
+
"outhouse"
|
|
327
|
+
]);
|
|
328
|
+
var CAR_CLEARANCE = { driver: 0.8, side: 0.6, end: 0.6 };
|
|
329
|
+
|
|
310
330
|
// src/geometry.ts
|
|
311
331
|
var r2 = (x) => Math.round(x * 100) / 100;
|
|
312
332
|
var clamp = (x, a, b) => Math.max(a, Math.min(b, x));
|
|
@@ -741,7 +761,7 @@ var GameFloorplan = (() => {
|
|
|
741
761
|
const out = [];
|
|
742
762
|
for (const [cat, weight] of Object.entries(cats)) {
|
|
743
763
|
const exact = cat[0] === "=";
|
|
744
|
-
const its = Object.values(CATALOG).filter((i) => !i.decor && (exact ? i.type === cat.slice(1) : !i.exactOnly && (i.category === cat || i.type === cat)));
|
|
764
|
+
const its = Object.values(registries().CATALOG).filter((i) => !i.decor && (exact ? i.type === cat.slice(1) : !i.exactOnly && (i.category === cat || i.type === cat)));
|
|
745
765
|
for (const it of its) out.push({ it, weight: weight / its.length });
|
|
746
766
|
}
|
|
747
767
|
return out;
|
|
@@ -832,7 +852,7 @@ var GameFloorplan = (() => {
|
|
|
832
852
|
low: it.low,
|
|
833
853
|
aabb: r.map(r2),
|
|
834
854
|
_r: r,
|
|
835
|
-
_seedId: SEED_KEYS.items[id] ?? id
|
|
855
|
+
_seedId: registries().SEED_KEYS.items[id] ?? id
|
|
836
856
|
};
|
|
837
857
|
if (it.overhead) m.overhead = !overheadOff;
|
|
838
858
|
if (it.category === "car") {
|
|
@@ -909,7 +929,7 @@ var GameFloorplan = (() => {
|
|
|
909
929
|
}
|
|
910
930
|
return null;
|
|
911
931
|
};
|
|
912
|
-
const
|
|
932
|
+
const process2 = (u) => {
|
|
913
933
|
const pr = u.members[0].chance;
|
|
914
934
|
const x = rng();
|
|
915
935
|
const arr = u.members.slice();
|
|
@@ -945,7 +965,7 @@ var GameFloorplan = (() => {
|
|
|
945
965
|
let i = pending.findIndex(ready);
|
|
946
966
|
if (i < 0) i = 0;
|
|
947
967
|
const u = pending.splice(i, 1)[0];
|
|
948
|
-
|
|
968
|
+
process2(u);
|
|
949
969
|
for (const m of u.members) done.add(m.id);
|
|
950
970
|
}
|
|
951
971
|
return { items, missing };
|
|
@@ -983,9 +1003,9 @@ var GameFloorplan = (() => {
|
|
|
983
1003
|
clearRect,
|
|
984
1004
|
pickWeighted,
|
|
985
1005
|
createRng,
|
|
986
|
-
roomSeedKey: (room) => room.seedKey ?? SEED_KEYS.rooms[room.id] ?? room.id,
|
|
1006
|
+
roomSeedKey: (room) => room.seedKey ?? registries().SEED_KEYS.rooms[room.id] ?? room.id,
|
|
987
1007
|
shuffle,
|
|
988
|
-
facingRotation: (f, type) => rotationFor(f, CATALOG[type].front),
|
|
1008
|
+
facingRotation: (f, type) => rotationFor(f, registries().CATALOG[type].front),
|
|
989
1009
|
cutIntervals,
|
|
990
1010
|
blocksWindow
|
|
991
1011
|
};
|
|
@@ -993,7 +1013,7 @@ var GameFloorplan = (() => {
|
|
|
993
1013
|
const added = [];
|
|
994
1014
|
const counters = {};
|
|
995
1015
|
const make = (room, type, r, f, o) => {
|
|
996
|
-
const it = CATALOG[type];
|
|
1016
|
+
const it = registries().CATALOG[type];
|
|
997
1017
|
const n = counters[room.id + type] = (counters[room.id + type] || 0) + 1;
|
|
998
1018
|
return Object.assign(
|
|
999
1019
|
{
|
|
@@ -1039,9 +1059,9 @@ var GameFloorplan = (() => {
|
|
|
1039
1059
|
const gridOf = (c) => gridCache[c.id] || (gridCache[c.id] = createGrid(plan, c, ignored));
|
|
1040
1060
|
function placeOnFloor(room, type, rng2, optsIn) {
|
|
1041
1061
|
const opts = Object.assign({}, optsIn || {});
|
|
1042
|
-
const it0 = CATALOG[type];
|
|
1062
|
+
const it0 = registries().CATALOG[type];
|
|
1043
1063
|
if (it0.flat) opts.flat = true;
|
|
1044
|
-
const it = CATALOG[type];
|
|
1064
|
+
const it = registries().CATALOG[type];
|
|
1045
1065
|
const inners = usableParts(room, 0);
|
|
1046
1066
|
const solidList = solidsOfRoom(room);
|
|
1047
1067
|
const zones = zonesOfFloor(plan, room.floor);
|
|
@@ -1120,7 +1140,7 @@ var GameFloorplan = (() => {
|
|
|
1120
1140
|
z.parts.forEach((p, i) => groundPiece(z, z.ground, p, 0, i));
|
|
1121
1141
|
let k = 0;
|
|
1122
1142
|
const clip = (r) => z.parts.map((p) => [Math.max(r[0], p[0]), Math.max(r[1], p[1]), Math.min(r[2], p[2]), Math.min(r[3], p[3])]).filter((q) => q[2] - q[0] > 0.3 && q[3] - q[1] > 0.3).sort((a, b) => areaOf(b) - areaOf(a))[0];
|
|
1123
|
-
for (const rule of GROUND_OVERLAYS) {
|
|
1143
|
+
for (const rule of registries().GROUND_OVERLAYS) {
|
|
1124
1144
|
const triggers = items.filter((m) => m.room === z.id && m.category === rule.category);
|
|
1125
1145
|
if (rule.merge) {
|
|
1126
1146
|
if (triggers.length && z.ground !== rule.unlessGround) {
|
|
@@ -1140,19 +1160,20 @@ var GameFloorplan = (() => {
|
|
|
1140
1160
|
function runPostProcess(plan, items, seed) {
|
|
1141
1161
|
const ctx = createPlacementContext(plan, items);
|
|
1142
1162
|
const rng = createRng(seed, STREAM.decor);
|
|
1143
|
-
for (const pass of PASSES) pass.run({ plan, items, seed, rng, ctx, kit: placementKit, catalog: CATALOG, profiles: DECOR_PROFILES });
|
|
1163
|
+
for (const pass of registries().PASSES) pass.run({ plan, items, seed, rng, ctx, kit: placementKit, catalog: registries().CATALOG, profiles: registries().DECOR_PROFILES });
|
|
1144
1164
|
groundCover(plan, items, ctx);
|
|
1145
1165
|
return ctx;
|
|
1146
1166
|
}
|
|
1147
1167
|
|
|
1148
1168
|
// src/locale.ts
|
|
1149
|
-
var locales = {};
|
|
1150
1169
|
function registerLocale(code, table) {
|
|
1170
|
+
const { LOCALES: locales } = registries();
|
|
1151
1171
|
const cur = locales[code] = locales[code] || {};
|
|
1152
1172
|
for (const ns of Object.keys(table)) cur[ns] = Object.assign(cur[ns] || {}, table[ns]);
|
|
1153
1173
|
}
|
|
1154
|
-
var listLocales = () => Object.keys(
|
|
1174
|
+
var listLocales = () => Object.keys(registries().LOCALES);
|
|
1155
1175
|
function translate(ns, key, locale = "en", vars) {
|
|
1176
|
+
const { LOCALES: locales } = registries();
|
|
1156
1177
|
const raw = locales[locale]?.[ns]?.[key] ?? locales.en?.[ns]?.[key] ?? key;
|
|
1157
1178
|
return vars ? raw.replace(/\{(\w+)\}/g, (m, k) => k in vars ? String(vars[k]) : m) : raw;
|
|
1158
1179
|
}
|
|
@@ -1281,22 +1302,20 @@ var GameFloorplan = (() => {
|
|
|
1281
1302
|
}
|
|
1282
1303
|
|
|
1283
1304
|
// src/zoning.ts
|
|
1284
|
-
var ZONES = {};
|
|
1285
|
-
var PERMEABLE_GROUNDS = /* @__PURE__ */ new Set();
|
|
1286
1305
|
function defineZone(zone) {
|
|
1287
1306
|
if (!zone || !zone.id) throw new Error("defineZone: id is required");
|
|
1288
|
-
ZONES[zone.id] = zone;
|
|
1307
|
+
registries().ZONES[zone.id] = zone;
|
|
1289
1308
|
return zone;
|
|
1290
1309
|
}
|
|
1291
|
-
var getZone = (id) => ZONES[id];
|
|
1292
|
-
var listZones = () => Object.values(ZONES);
|
|
1310
|
+
var getZone = (id) => registries().ZONES[id];
|
|
1311
|
+
var listZones = () => Object.values(registries().ZONES);
|
|
1293
1312
|
function registerPermeableGround(...types) {
|
|
1294
|
-
for (const t of types) PERMEABLE_GROUNDS.add(t);
|
|
1313
|
+
for (const t of types) registries().PERMEABLE_GROUNDS.add(t);
|
|
1295
1314
|
}
|
|
1296
1315
|
function resolveZone(z) {
|
|
1297
1316
|
if (!z) return null;
|
|
1298
1317
|
if (typeof z === "string") {
|
|
1299
|
-
const found = ZONES[z];
|
|
1318
|
+
const found = registries().ZONES[z];
|
|
1300
1319
|
if (!found) throw new Error("Unknown zone: " + z);
|
|
1301
1320
|
return found;
|
|
1302
1321
|
}
|
|
@@ -1342,7 +1361,7 @@ var GameFloorplan = (() => {
|
|
|
1342
1361
|
const far = m.built / area;
|
|
1343
1362
|
if (far > zone.maxFar + 1e-9) out.push({ rule: "far", actual: r2(far), limit: zone.maxFar });
|
|
1344
1363
|
let permeable = 0;
|
|
1345
|
-
for (const z of lot.zones) if (PERMEABLE_GROUNDS.has(z.ground)) for (const p of z.parts) permeable += (p[2] - p[0]) * (p[3] - p[1]);
|
|
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]);
|
|
1346
1365
|
const permeability = permeable / area;
|
|
1347
1366
|
if (permeability < zone.permeableMin - 1e-9) out.push({ rule: "permeable", actual: r2(permeability), limit: zone.permeableMin });
|
|
1348
1367
|
return out;
|
|
@@ -1380,14 +1399,14 @@ var GameFloorplan = (() => {
|
|
|
1380
1399
|
}
|
|
1381
1400
|
var ADJUSTABLE_ZONES = /* @__PURE__ */ new Set(["garden", "backyard", "side_yard"]);
|
|
1382
1401
|
function enforcePermeability(lot, zones, zone, adjustments) {
|
|
1383
|
-
const target = [...PERMEABLE_GROUNDS][0];
|
|
1402
|
+
const target = [...registries().PERMEABLE_GROUNDS][0];
|
|
1384
1403
|
if (!target) return;
|
|
1385
1404
|
const [u0, v0, u1, v1] = lot.rect;
|
|
1386
1405
|
const area = (u1 - u0) * (v1 - v0);
|
|
1387
1406
|
const areaOfZone = (z) => z.parts.reduce((s, p) => s + (p[2] - p[0]) * (p[3] - p[1]), 0);
|
|
1388
|
-
let permeable = zones.filter((z) => PERMEABLE_GROUNDS.has(z.ground)).reduce((s, z) => s + areaOfZone(z), 0);
|
|
1407
|
+
let permeable = zones.filter((z) => registries().PERMEABLE_GROUNDS.has(z.ground)).reduce((s, z) => s + areaOfZone(z), 0);
|
|
1389
1408
|
if (permeable / area >= zone.permeableMin) return;
|
|
1390
|
-
const candidates = zones.filter((z) => ADJUSTABLE_ZONES.has(z.type) && !PERMEABLE_GROUNDS.has(z.ground)).sort((a, b) => areaOfZone(b) - areaOfZone(a));
|
|
1409
|
+
const candidates = zones.filter((z) => ADJUSTABLE_ZONES.has(z.type) && !registries().PERMEABLE_GROUNDS.has(z.ground)).sort((a, b) => areaOfZone(b) - areaOfZone(a));
|
|
1391
1410
|
for (const z of candidates) {
|
|
1392
1411
|
if (permeable / area >= zone.permeableMin) break;
|
|
1393
1412
|
adjustments.push({ field: "ground:" + z.id, from: z.ground, to: target, reason: "permeable_min" });
|
|
@@ -1620,9 +1639,9 @@ var GameFloorplan = (() => {
|
|
|
1620
1639
|
paths: [],
|
|
1621
1640
|
pool: !!cfg.pool
|
|
1622
1641
|
};
|
|
1623
|
-
const
|
|
1642
|
+
const ZONES = [];
|
|
1624
1643
|
const libs = Object.assign({ garden: "garden", backyard: "backyard", parking: "parking", sideYard: "side_yard" }, cfg.libraries || {});
|
|
1625
|
-
const addZone = (id, type, label, parts, library) =>
|
|
1644
|
+
const addZone = (id, type, label, parts, library) => ZONES.push(Object.assign(normalizeRoom({ id, type, label, rect: parts[0], parts: parts.slice(1), library, outdoor: true }, -1), { floor: -1, outdoor: true }));
|
|
1626
1645
|
if (setback > 0) {
|
|
1627
1646
|
let parts = [[-marginL, -setback, w + marginR, 0]];
|
|
1628
1647
|
if (cfg.parking) {
|
|
@@ -1702,14 +1721,14 @@ var GameFloorplan = (() => {
|
|
|
1702
1721
|
}
|
|
1703
1722
|
}
|
|
1704
1723
|
if (tpl.paths) paths.push(...tpl.paths(plan, { gates, setback, marginLeft: marginL, marginRight: marginR, backyard: backDepth, w, d }));
|
|
1705
|
-
else addExteriorDoorPaths(plan, { gates, paths, zones:
|
|
1724
|
+
else addExteriorDoorPaths(plan, { gates, paths, zones: ZONES, setback, marginLeft: marginL, marginRight: marginR, backyard: backDepth, w, target: cfg.doorTarget });
|
|
1706
1725
|
plan.paths = paths;
|
|
1707
1726
|
lot.paths = paths;
|
|
1708
1727
|
const boundary = (rule) => {
|
|
1709
1728
|
const type = pickWeighted(rLot, rule.type);
|
|
1710
1729
|
const top = type === "railing" ? "none" : pickWeighted(rLot, rule.top);
|
|
1711
1730
|
const wallHeight = type === "railing" ? 1.2 : type === "fence" ? style.fenceHeight ?? 2 : style.height;
|
|
1712
|
-
return { type, material: type === "wall" ? "block" : type === "fence" ? "wire_mesh" : "iron", height: wallHeight, top, totalHeight: r2(wallHeight + WALL_TOP_HEIGHTS[top]), thickness: WALL_THICKNESS };
|
|
1731
|
+
return { type, material: type === "wall" ? "block" : type === "fence" ? "wire_mesh" : "iron", height: wallHeight, top, totalHeight: r2(wallHeight + registries().WALL_TOP_HEIGHTS[top]), thickness: WALL_THICKNESS };
|
|
1713
1732
|
};
|
|
1714
1733
|
const A = { front: boundary(style.front), left: boundary(style.sideYard), right: boundary(style.sideYard), back: boundary(style.back) };
|
|
1715
1734
|
const seg = (side, u0, v0, u1, v1) => {
|
|
@@ -1742,10 +1761,10 @@ var GameFloorplan = (() => {
|
|
|
1742
1761
|
else if (backDepth > 0) seg("left", 0, d, 0, d + backDepth);
|
|
1743
1762
|
if (marginR > 0.5) seg("right", w + marginR, vi, w + marginR, d + backDepth);
|
|
1744
1763
|
else if (backDepth > 0) seg("right", w, d, w, d + backDepth);
|
|
1745
|
-
for (const z of
|
|
1746
|
-
if (bc.zone) enforcePermeability(lot,
|
|
1747
|
-
plan.zones =
|
|
1748
|
-
lot.zones =
|
|
1764
|
+
for (const z of ZONES) z.ground = (cfg.grounds || {})[z.id] || (cfg.grounds || {})[z.type] || pickWeighted(rLot, style.grounds[z.type] || { concrete: 1 });
|
|
1765
|
+
if (bc.zone) enforcePermeability(lot, ZONES, bc.zone, bc.adjustments || []);
|
|
1766
|
+
plan.zones = ZONES;
|
|
1767
|
+
lot.zones = ZONES;
|
|
1749
1768
|
plan.lot = lot;
|
|
1750
1769
|
}
|
|
1751
1770
|
|
|
@@ -1795,8 +1814,8 @@ var GameFloorplan = (() => {
|
|
|
1795
1814
|
function palette(o) {
|
|
1796
1815
|
const opt = o || {};
|
|
1797
1816
|
let style = resolveStyleId(opt.style || "budget");
|
|
1798
|
-
if (!PALETTE_STYLES[style]) style = PALETTE_STYLES.mid ? "mid" : Object.keys(PALETTE_STYLES)[0];
|
|
1799
|
-
const def = PALETTE_STYLES[style];
|
|
1817
|
+
if (!registries().PALETTE_STYLES[style]) style = registries().PALETTE_STYLES.mid ? "mid" : Object.keys(registries().PALETTE_STYLES)[0];
|
|
1818
|
+
const def = registries().PALETTE_STYLES[style];
|
|
1800
1819
|
const state = opt.state || "normal";
|
|
1801
1820
|
const seed = opt.seed == null ? 1 : opt.seed;
|
|
1802
1821
|
const rng = createRng(seed, STREAM.palettePrefix + (def.seedKey ?? style));
|
|
@@ -1814,14 +1833,14 @@ var GameFloorplan = (() => {
|
|
|
1814
1833
|
const { wallMode, sMax } = early;
|
|
1815
1834
|
const R = Object.assign({}, early.roles);
|
|
1816
1835
|
const ctx = Object.assign({ style, sMax, wallMode, generalFloor: early.generalFloor }, draw);
|
|
1817
|
-
for (const c of ROOM_COLORS) {
|
|
1836
|
+
for (const c of registries().ROOM_COLORS) {
|
|
1818
1837
|
const [wh, wl] = c.wall(ctx);
|
|
1819
1838
|
R["wall_" + c.type] = hsl(wh, c.neutral ? Math.min(0.16, sMax) : clamp(jit(sMax * 0.75, sMax * 0.5), 0.03, sMax), jit(wl, 0.03));
|
|
1820
1839
|
const pi = c.floor || early.generalFloor;
|
|
1821
1840
|
R["floor_" + c.type] = hsl(pi[0], Math.min(pi[1], wallMode ? 0.18 : 0.3), jit(pi[2], 0.04));
|
|
1822
1841
|
}
|
|
1823
1842
|
Object.assign(R, def.late(draw, early));
|
|
1824
|
-
STATE_PLUGINS[state]?.adjustPalette?.(R);
|
|
1843
|
+
registries().STATE_PLUGINS[state]?.adjustPalette?.(R);
|
|
1825
1844
|
const adjust = (color, ref, min, preferredDir) => {
|
|
1826
1845
|
for (let i = 0; i < 60; i++) {
|
|
1827
1846
|
if (Math.abs(lstar(hslToInt(color.h, color.s, color.l)) - lstar(hslToInt(ref.h, ref.s, ref.l))) >= min) return;
|
|
@@ -1831,7 +1850,7 @@ var GameFloorplan = (() => {
|
|
|
1831
1850
|
color.l = clamp(color.l + dir * 0.015, 0.04, 0.96);
|
|
1832
1851
|
}
|
|
1833
1852
|
};
|
|
1834
|
-
const types = ROOM_COLORS.map((c) => c.type);
|
|
1853
|
+
const types = registries().ROOM_COLORS.map((c) => c.type);
|
|
1835
1854
|
for (const c of types) {
|
|
1836
1855
|
const w = R["wall_" + c];
|
|
1837
1856
|
const p = R["floor_" + c];
|
|
@@ -1885,8 +1904,8 @@ var GameFloorplan = (() => {
|
|
|
1885
1904
|
var WINDOW_SIDE = { front: "front", back: "back", left: "left", right: "right" };
|
|
1886
1905
|
function slotDefsOf(plan, room) {
|
|
1887
1906
|
const name = room.library || room.type;
|
|
1888
|
-
const key = LIBRARY_ALIAS[name] || name;
|
|
1889
|
-
const library = room.slots ? room.slots : LIBRARIES[key];
|
|
1907
|
+
const key = registries().LIBRARY_ALIAS[name] || name;
|
|
1908
|
+
const library = room.slots ? room.slots : registries().LIBRARIES[key];
|
|
1890
1909
|
if (!library) return [];
|
|
1891
1910
|
const R = inner(room.parts[0]);
|
|
1892
1911
|
let defs = typeof library === "function" ? library({ w: R[2] - R[0], d: R[3] - R[1] }) : library.slice();
|
|
@@ -2076,8 +2095,8 @@ var GameFloorplan = (() => {
|
|
|
2076
2095
|
// src/generate.ts
|
|
2077
2096
|
function templateOf(t) {
|
|
2078
2097
|
if (typeof t === "string") {
|
|
2079
|
-
if (!TEMPLATES[t]) throw new Error("Unknown template: " + t);
|
|
2080
|
-
return TEMPLATES[t];
|
|
2098
|
+
if (!registries().TEMPLATES[t]) throw new Error("Unknown template: " + t);
|
|
2099
|
+
return registries().TEMPLATES[t];
|
|
2081
2100
|
}
|
|
2082
2101
|
return t;
|
|
2083
2102
|
}
|
|
@@ -2095,10 +2114,10 @@ var GameFloorplan = (() => {
|
|
|
2095
2114
|
return resolveSlots(plan).map(cleanSlot).map((s) => s.reason ? Object.assign(s, { reason: translate("reasons", s.reason, locale) }) : s);
|
|
2096
2115
|
}
|
|
2097
2116
|
function pickState(requested, seed) {
|
|
2098
|
-
if (requested && STATE_PLUGINS[requested]) return requested;
|
|
2099
|
-
const dist = stateDistribution.weights;
|
|
2117
|
+
if (requested && registries().STATE_PLUGINS[requested]) return requested;
|
|
2118
|
+
const dist = registries().stateDistribution.weights;
|
|
2100
2119
|
if (!dist) return "normal";
|
|
2101
|
-
const x = createRng(seed, stateDistribution.seedKey)();
|
|
2120
|
+
const x = createRng(seed, registries().stateDistribution.seedKey)();
|
|
2102
2121
|
let acc = 0;
|
|
2103
2122
|
const keys = Object.keys(dist);
|
|
2104
2123
|
for (const k of keys) {
|
|
@@ -2108,13 +2127,13 @@ var GameFloorplan = (() => {
|
|
|
2108
2127
|
return keys[keys.length - 1];
|
|
2109
2128
|
}
|
|
2110
2129
|
function colorOf(m, seed) {
|
|
2111
|
-
const spec = m.colorSpec || CATALOG[m.type]?.color || { role: "wood" };
|
|
2130
|
+
const spec = m.colorSpec || registries().CATALOG[m.type]?.color || { role: "wood" };
|
|
2112
2131
|
if ("role" in spec) return spec.role;
|
|
2113
2132
|
if ("hex" in spec) return spec.hex;
|
|
2114
2133
|
return spec.pick[hashString(seed + "|" + (m._seedId ?? m.id)) % spec.pick.length];
|
|
2115
2134
|
}
|
|
2116
2135
|
function applyState(plan, items, ctx, seed, state) {
|
|
2117
|
-
const plugin = STATE_PLUGINS[state];
|
|
2136
|
+
const plugin = registries().STATE_PLUGINS[state];
|
|
2118
2137
|
if (!plugin || state === "normal") return [];
|
|
2119
2138
|
const c = {
|
|
2120
2139
|
plan,
|
|
@@ -2124,8 +2143,8 @@ var GameFloorplan = (() => {
|
|
|
2124
2143
|
rng: createRng(seed, plugin.seedKey ?? "state:" + state),
|
|
2125
2144
|
ctx,
|
|
2126
2145
|
kit: placementKit,
|
|
2127
|
-
catalog: CATALOG,
|
|
2128
|
-
wallTopHeights: WALL_TOP_HEIGHTS
|
|
2146
|
+
catalog: registries().CATALOG,
|
|
2147
|
+
wallTopHeights: registries().WALL_TOP_HEIGHTS
|
|
2129
2148
|
};
|
|
2130
2149
|
return plugin.apply(c);
|
|
2131
2150
|
}
|
|
@@ -2145,7 +2164,7 @@ var GameFloorplan = (() => {
|
|
|
2145
2164
|
const missing = [];
|
|
2146
2165
|
for (const room of plan.rooms.concat(plan.zones)) {
|
|
2147
2166
|
const sl = all.filter((s) => s.room === room.id && s.floor === room.floor);
|
|
2148
|
-
const r = fillRoom(plan, room, sl, createRng(seed, STREAM.roomPrefix + (room.seedKey ?? SEED_KEYS.rooms[room.id] ?? room.id)));
|
|
2167
|
+
const r = fillRoom(plan, room, sl, createRng(seed, STREAM.roomPrefix + (room.seedKey ?? registries().SEED_KEYS.rooms[room.id] ?? room.id)));
|
|
2149
2168
|
items.push(...r.items);
|
|
2150
2169
|
missing.push(...r.missing);
|
|
2151
2170
|
}
|
|
@@ -2258,7 +2277,7 @@ var GameFloorplan = (() => {
|
|
|
2258
2277
|
return { limits: tpl.limitsFn ? tpl.limitsFn(op) : tpl.limits, defaults: tpl.defaultsFn ? tpl.defaultsFn(op) : tpl.defaults };
|
|
2259
2278
|
}
|
|
2260
2279
|
function listTemplates(locale = "en") {
|
|
2261
|
-
return Object.values(TEMPLATES).map((t) => {
|
|
2280
|
+
return Object.values(registries().TEMPLATES).map((t) => {
|
|
2262
2281
|
const a = floorsOf(t, {});
|
|
2263
2282
|
return {
|
|
2264
2283
|
id: t.id,
|
|
@@ -2275,6 +2294,101 @@ var GameFloorplan = (() => {
|
|
|
2275
2294
|
});
|
|
2276
2295
|
}
|
|
2277
2296
|
|
|
2297
|
+
// ../game-contracts/dist/index.js
|
|
2298
|
+
var DEFAULT_COST_ALLOCATION_BYTES = 1024 * 1024;
|
|
2299
|
+
var DEFERRED_QUEUE_ID = {
|
|
2300
|
+
DESTRUCTION_EVENTS: "destruction.events",
|
|
2301
|
+
BREACH_PAINT: "floorplan.breach-paint",
|
|
2302
|
+
AUDIO_VOICES: "audio.voices",
|
|
2303
|
+
VEHICLE_CREASE: "vehicles.crease"
|
|
2304
|
+
};
|
|
2305
|
+
var DEFERRED_PRIORITY = {
|
|
2306
|
+
[DEFERRED_QUEUE_ID.DESTRUCTION_EVENTS]: { priority: 300, phase: "present" },
|
|
2307
|
+
[DEFERRED_QUEUE_ID.BREACH_PAINT]: { priority: 250, phase: "present" },
|
|
2308
|
+
[DEFERRED_QUEUE_ID.AUDIO_VOICES]: { priority: 200, phase: "idle", reserveMs: 1 },
|
|
2309
|
+
[DEFERRED_QUEUE_ID.VEHICLE_CREASE]: { priority: 100, phase: "idle" }
|
|
2310
|
+
};
|
|
2311
|
+
var WARNED_KEY = /* @__PURE__ */ Symbol.for("@adatechnology/game-contracts.warned");
|
|
2312
|
+
var warnedKeys = () => {
|
|
2313
|
+
const holder = globalThis;
|
|
2314
|
+
return holder[WARNED_KEY] ?? (holder[WARNED_KEY] = /* @__PURE__ */ new Set());
|
|
2315
|
+
};
|
|
2316
|
+
var isProduction = () => {
|
|
2317
|
+
try {
|
|
2318
|
+
return process.env.NODE_ENV === "production";
|
|
2319
|
+
} catch {
|
|
2320
|
+
return false;
|
|
2321
|
+
}
|
|
2322
|
+
};
|
|
2323
|
+
var isQuiet = () => globalThis.__GAME_KIT_QUIET__ === true;
|
|
2324
|
+
var warnOnce = (key, message) => {
|
|
2325
|
+
if (isQuiet() || isProduction()) return;
|
|
2326
|
+
const seen = warnedKeys();
|
|
2327
|
+
if (seen.has(key)) return;
|
|
2328
|
+
seen.add(key);
|
|
2329
|
+
console.warn(`[game-kit] ${message}`);
|
|
2330
|
+
};
|
|
2331
|
+
var UNSAFE_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
2332
|
+
var isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value) && Object.getPrototypeOf(value) === Object.prototype;
|
|
2333
|
+
var deepMerge = (base, patch) => {
|
|
2334
|
+
if (!patch) return base;
|
|
2335
|
+
const result = { ...base };
|
|
2336
|
+
for (const [key, value] of Object.entries(patch)) {
|
|
2337
|
+
if (value === void 0 || UNSAFE_KEYS.has(key)) continue;
|
|
2338
|
+
const current = result[key];
|
|
2339
|
+
result[key] = isPlainObject(current) && isPlainObject(value) ? deepMerge(current, value) : value;
|
|
2340
|
+
}
|
|
2341
|
+
return result;
|
|
2342
|
+
};
|
|
2343
|
+
var applyPatches = (entries, patches) => {
|
|
2344
|
+
for (const [id, patch] of Object.entries(patches ?? {})) {
|
|
2345
|
+
const entry = entries.get(id);
|
|
2346
|
+
if (entry) entries.set(id, deepMerge(entry, patch));
|
|
2347
|
+
else warnOnce(`registry.patch.${id}`, `patch for "${id}" ignored: no entry has that id`);
|
|
2348
|
+
}
|
|
2349
|
+
};
|
|
2350
|
+
var removeIds = (entries, ids) => {
|
|
2351
|
+
for (const id of ids ?? []) {
|
|
2352
|
+
if (!entries.delete(id)) warnOnce(`registry.remove.${id}`, `remove of "${id}" ignored: no entry has that id`);
|
|
2353
|
+
}
|
|
2354
|
+
};
|
|
2355
|
+
var SURFACE_IDS = ["concrete", "asphalt", "wood", "tile", "dirt", "grass", "gravel", "sand", "metal", "water", "glass", "carpet"];
|
|
2356
|
+
var GAIT_IDS = ["walk", "run"];
|
|
2357
|
+
var LANDING_IDS = ["light", "heavy"];
|
|
2358
|
+
var BODY_SOUND_IDS = [
|
|
2359
|
+
"jump",
|
|
2360
|
+
"cloth_rustle",
|
|
2361
|
+
"body_fall",
|
|
2362
|
+
"fall_damage",
|
|
2363
|
+
"player_hurt",
|
|
2364
|
+
"player_breath_run",
|
|
2365
|
+
"player_death",
|
|
2366
|
+
"bite",
|
|
2367
|
+
"grab",
|
|
2368
|
+
"punch_swing",
|
|
2369
|
+
"punch_hit_body",
|
|
2370
|
+
"punch_hit_face",
|
|
2371
|
+
"punch_hit_object",
|
|
2372
|
+
"kick_swing",
|
|
2373
|
+
"kick_hit",
|
|
2374
|
+
"kick_hit_object",
|
|
2375
|
+
"shove_two_hands",
|
|
2376
|
+
"knife_swing",
|
|
2377
|
+
"knife_stab",
|
|
2378
|
+
"knife_slash",
|
|
2379
|
+
"knife_hit_object",
|
|
2380
|
+
"blunt_swing",
|
|
2381
|
+
"blunt_hit",
|
|
2382
|
+
"blunt_hit_object",
|
|
2383
|
+
"axe_swing",
|
|
2384
|
+
"axe_chop",
|
|
2385
|
+
"axe_hit_object"
|
|
2386
|
+
];
|
|
2387
|
+
var footstepSoundId = (surface, gait) => `footstep_${surface}_${gait}`;
|
|
2388
|
+
var FOOTSTEP_SOUND_IDS = SURFACE_IDS.flatMap((surface) => GAIT_IDS.map((gait) => footstepSoundId(surface, gait)));
|
|
2389
|
+
var LAND_SOUND_IDS = SURFACE_IDS.flatMap((surface) => LANDING_IDS.map((landing) => `land_${surface}_${landing}`));
|
|
2390
|
+
var BODY_FOLEY_IDS = [...FOOTSTEP_SOUND_IDS, ...LAND_SOUND_IDS, ...BODY_SOUND_IDS];
|
|
2391
|
+
|
|
2278
2392
|
// src/ground-items.ts
|
|
2279
2393
|
function registerGroundItems() {
|
|
2280
2394
|
const flat = { category: "ground_cover", w: 1, d: 1, h: 0, decor: true, mount: "ground", flat: true };
|
|
@@ -2495,6 +2609,109 @@ var GameFloorplan = (() => {
|
|
|
2495
2609
|
}
|
|
2496
2610
|
};
|
|
2497
2611
|
|
|
2612
|
+
// src/instance.ts
|
|
2613
|
+
var version = "0.1.0";
|
|
2614
|
+
function editCatalog(catalog, patch, remove) {
|
|
2615
|
+
if (!patch && !remove) return;
|
|
2616
|
+
const entries = new Map(Object.entries(catalog).map(([key, definition]) => [key, { ...definition, id: key }]));
|
|
2617
|
+
applyPatches(entries, patch);
|
|
2618
|
+
removeIds(entries, remove);
|
|
2619
|
+
for (const key of Object.keys(catalog)) {
|
|
2620
|
+
const edited = entries.get(key);
|
|
2621
|
+
if (!edited) delete catalog[key];
|
|
2622
|
+
else if (patch && key in patch) {
|
|
2623
|
+
const hadId = "id" in catalog[key];
|
|
2624
|
+
const next = { ...edited };
|
|
2625
|
+
if (!hadId) delete next.id;
|
|
2626
|
+
catalog[key] = next;
|
|
2627
|
+
}
|
|
2628
|
+
}
|
|
2629
|
+
}
|
|
2630
|
+
function buildEngine(scope) {
|
|
2631
|
+
const scoped = (fn) => ((...args) => withRegistries(scope, () => fn(...args)));
|
|
2632
|
+
return {
|
|
2633
|
+
version,
|
|
2634
|
+
generate: scoped(generate),
|
|
2635
|
+
slots: scoped(slots),
|
|
2636
|
+
validate: scoped(validate),
|
|
2637
|
+
palette: scoped(palette),
|
|
2638
|
+
limitsOf: scoped(limitsOf),
|
|
2639
|
+
listTemplates: scoped(listTemplates),
|
|
2640
|
+
listStates: scoped(listStates),
|
|
2641
|
+
// content registration
|
|
2642
|
+
registerItem: scoped(registerItem),
|
|
2643
|
+
registerItems: scoped(registerItems),
|
|
2644
|
+
registerLibrary: scoped(registerLibrary),
|
|
2645
|
+
registerLibraryAlias: scoped(registerLibraryAlias),
|
|
2646
|
+
registerTemplate: scoped(registerTemplate),
|
|
2647
|
+
registerStyle: scoped(registerStyle),
|
|
2648
|
+
registerPaletteStyle: scoped(registerPaletteStyle),
|
|
2649
|
+
registerRoomColors: scoped(registerRoomColors),
|
|
2650
|
+
registerDecorProfile: scoped(registerDecorProfile),
|
|
2651
|
+
registerPass: scoped(registerPass),
|
|
2652
|
+
registerGroundOverlay: scoped(registerGroundOverlay),
|
|
2653
|
+
registerWallTop: scoped(registerWallTop),
|
|
2654
|
+
registerSeedKeys: scoped(registerSeedKeys),
|
|
2655
|
+
registerState: scoped(registerState),
|
|
2656
|
+
setStateDistribution: scoped(setStateDistribution),
|
|
2657
|
+
registerLocale: scoped(registerLocale),
|
|
2658
|
+
registerResultExtension: scoped(registerResultExtension),
|
|
2659
|
+
registerFindsProvider: scoped(registerFindsProvider),
|
|
2660
|
+
findsFor: scoped(findsFor),
|
|
2661
|
+
findsAnswer: scoped(findsAnswer),
|
|
2662
|
+
registerViewerLayer: scoped(registerViewerLayer),
|
|
2663
|
+
viewerLayers: scope.VIEWER_LAYERS,
|
|
2664
|
+
blocksWindow: scoped(blocksWindow),
|
|
2665
|
+
// zoning
|
|
2666
|
+
defineZone: scoped(defineZone),
|
|
2667
|
+
getZone: scoped(getZone),
|
|
2668
|
+
listZones: scoped(listZones),
|
|
2669
|
+
checkLot: scoped(checkLot),
|
|
2670
|
+
registerPermeableGround: scoped(registerPermeableGround),
|
|
2671
|
+
// kits and data
|
|
2672
|
+
slotKit,
|
|
2673
|
+
translate: scoped(translate),
|
|
2674
|
+
listLocales: scoped(listLocales),
|
|
2675
|
+
templates: scope.TEMPLATES,
|
|
2676
|
+
catalog: scope.CATALOG,
|
|
2677
|
+
libraries: scope.LIBRARIES,
|
|
2678
|
+
styles: scope.STYLES,
|
|
2679
|
+
paletteStyles: scope.PALETTE_STYLES,
|
|
2680
|
+
createRng,
|
|
2681
|
+
mulberry32,
|
|
2682
|
+
hashString,
|
|
2683
|
+
overlaps,
|
|
2684
|
+
windowZone,
|
|
2685
|
+
openingZones,
|
|
2686
|
+
color: { lstar, hex: hexString, hsl: intToHsl, HIGH_SATURATION, MIN_WALL_FLOOR_CONTRAST, MIN_FABRIC_FLOOR_CONTRAST },
|
|
2687
|
+
constants: { WALL_THICKNESS, DOOR_CLEARANCE, PLAYER_RADIUS, DOOR_EDGE_CLEARANCE, WINDOW_EDGE_CLEARANCE, OVERHEAD_TOP, CAR_CLEARANCE }
|
|
2688
|
+
};
|
|
2689
|
+
}
|
|
2690
|
+
function seedBase(scope) {
|
|
2691
|
+
withRegistries(scope, () => {
|
|
2692
|
+
registerGroundItems();
|
|
2693
|
+
registerPermeableGround("lawn", "dirt");
|
|
2694
|
+
registerLocale("en", en_default);
|
|
2695
|
+
registerLocale("pt-BR", pt_BR_default);
|
|
2696
|
+
});
|
|
2697
|
+
}
|
|
2698
|
+
function createFloorplan(options = {}) {
|
|
2699
|
+
const scope = createRegistries();
|
|
2700
|
+
seedBase(scope);
|
|
2701
|
+
const instance = buildEngine(scope);
|
|
2702
|
+
for (const pack of options.packs ?? []) (typeof pack === "function" ? pack : pack.register)(instance);
|
|
2703
|
+
editCatalog(scope.CATALOG, options.patch?.items, options.remove?.items);
|
|
2704
|
+
editCatalog(scope.TEMPLATES, options.patch?.templates, options.remove?.templates);
|
|
2705
|
+
return instance;
|
|
2706
|
+
}
|
|
2707
|
+
var defaultEngine;
|
|
2708
|
+
function defaultFloorplan() {
|
|
2709
|
+
if (defaultEngine) return defaultEngine;
|
|
2710
|
+
seedBase(getDefaultRegistries());
|
|
2711
|
+
defaultEngine = buildEngine(getDefaultRegistries());
|
|
2712
|
+
return defaultEngine;
|
|
2713
|
+
}
|
|
2714
|
+
|
|
2498
2715
|
// src/silhouettes/random.ts
|
|
2499
2716
|
function createSilhouetteRandom(seed) {
|
|
2500
2717
|
let state = seed;
|
|
@@ -2704,68 +2921,7 @@ var GameFloorplan = (() => {
|
|
|
2704
2921
|
}
|
|
2705
2922
|
|
|
2706
2923
|
// src/index.ts
|
|
2707
|
-
|
|
2708
|
-
registerPermeableGround("lawn", "dirt");
|
|
2709
|
-
registerLocale("en", en_default);
|
|
2710
|
-
registerLocale("pt-BR", pt_BR_default);
|
|
2711
|
-
var version = "0.1.0";
|
|
2712
|
-
var engine = {
|
|
2713
|
-
version,
|
|
2714
|
-
generate,
|
|
2715
|
-
slots,
|
|
2716
|
-
validate,
|
|
2717
|
-
palette,
|
|
2718
|
-
limitsOf,
|
|
2719
|
-
listTemplates,
|
|
2720
|
-
listStates,
|
|
2721
|
-
// content registration
|
|
2722
|
-
registerItem,
|
|
2723
|
-
registerItems,
|
|
2724
|
-
registerLibrary,
|
|
2725
|
-
registerLibraryAlias,
|
|
2726
|
-
registerTemplate,
|
|
2727
|
-
registerStyle,
|
|
2728
|
-
registerPaletteStyle,
|
|
2729
|
-
registerRoomColors,
|
|
2730
|
-
registerDecorProfile,
|
|
2731
|
-
registerPass,
|
|
2732
|
-
registerGroundOverlay,
|
|
2733
|
-
registerWallTop,
|
|
2734
|
-
registerSeedKeys,
|
|
2735
|
-
registerState,
|
|
2736
|
-
setStateDistribution,
|
|
2737
|
-
registerLocale,
|
|
2738
|
-
registerResultExtension,
|
|
2739
|
-
registerFindsProvider,
|
|
2740
|
-
findsFor,
|
|
2741
|
-
findsAnswer,
|
|
2742
|
-
registerViewerLayer,
|
|
2743
|
-
viewerLayers: VIEWER_LAYERS,
|
|
2744
|
-
blocksWindow,
|
|
2745
|
-
// zoning
|
|
2746
|
-
defineZone,
|
|
2747
|
-
getZone,
|
|
2748
|
-
listZones,
|
|
2749
|
-
checkLot,
|
|
2750
|
-
registerPermeableGround,
|
|
2751
|
-
// kits and data
|
|
2752
|
-
slotKit,
|
|
2753
|
-
translate,
|
|
2754
|
-
listLocales,
|
|
2755
|
-
templates: TEMPLATES,
|
|
2756
|
-
catalog: CATALOG,
|
|
2757
|
-
libraries: LIBRARIES,
|
|
2758
|
-
styles: STYLES,
|
|
2759
|
-
paletteStyles: PALETTE_STYLES,
|
|
2760
|
-
createRng,
|
|
2761
|
-
mulberry32,
|
|
2762
|
-
hashString,
|
|
2763
|
-
overlaps,
|
|
2764
|
-
windowZone,
|
|
2765
|
-
openingZones,
|
|
2766
|
-
color: { lstar, hex: hexString, hsl: intToHsl, HIGH_SATURATION, MIN_WALL_FLOOR_CONTRAST, MIN_FABRIC_FLOOR_CONTRAST },
|
|
2767
|
-
constants: { WALL_THICKNESS, DOOR_CLEARANCE, PLAYER_RADIUS, DOOR_EDGE_CLEARANCE, WINDOW_EDGE_CLEARANCE, OVERHEAD_TOP, CAR_CLEARANCE }
|
|
2768
|
-
};
|
|
2924
|
+
var engine = defaultFloorplan();
|
|
2769
2925
|
return __toCommonJS(index_exports);
|
|
2770
2926
|
})();
|
|
2771
2927
|
//# sourceMappingURL=index.global.js.map
|