1681-engine 0.5.9 → 0.5.10
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/CHANGELOG.md +42 -0
- package/README.md +3 -0
- package/dist/1681-engine.js +501 -438
- package/dist/ambient/life/Birds.js +73 -0
- package/dist/ambient/life/Butterflies.js +43 -0
- package/dist/ambient/life/ChimneySmoke.js +50 -0
- package/dist/ambient/life/Drift.js +75 -0
- package/dist/ambient/life/Fireflies.js +52 -0
- package/dist/ambient/life/lifeMotion.js +49 -0
- package/dist/assets/AssetLoader.js +115 -70
- package/dist/assets/Prepainter.js +61 -0
- package/dist/assets/workerPainter.js +39 -0
- package/dist/cjs/electron/electronLike.d.ts +55 -0
- package/dist/cjs/electron/electronLike.js +7 -0
- package/dist/cjs/electron/index.d.ts +14 -0
- package/dist/cjs/electron/index.js +20 -0
- package/dist/cjs/electron/lockdown.d.ts +33 -0
- package/dist/cjs/electron/lockdown.js +69 -0
- package/dist/cjs/electron/lockdownRules.d.ts +28 -0
- package/dist/cjs/electron/lockdownRules.js +61 -0
- package/dist/cjs/electron/sessionStore.d.ts +40 -0
- package/dist/cjs/electron/sessionStore.js +77 -0
- package/dist/cjs/electron/shellId.d.ts +22 -0
- package/dist/cjs/electron/shellId.js +31 -0
- package/dist/cjs/electron/webFiles.d.ts +13 -0
- package/dist/cjs/electron/webFiles.js +52 -0
- package/dist/cjs/electron/webPatcher.d.ts +80 -0
- package/dist/cjs/electron/webPatcher.js +216 -0
- package/dist/cjs/electron/webPointers.d.ts +19 -0
- package/dist/cjs/electron/webPointers.js +35 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/updates/index.d.ts +8 -0
- package/dist/cjs/updates/index.js +21 -0
- package/dist/cjs/updates/manifest.d.ts +73 -0
- package/dist/cjs/updates/manifest.js +67 -0
- package/dist/cjs/updates/pickUpdate.d.ts +42 -0
- package/dist/cjs/updates/pickUpdate.js +52 -0
- package/dist/cjs/updates/webPlan.d.ts +20 -0
- package/dist/cjs/updates/webPlan.js +34 -0
- package/dist/electron/lockdown.js +31 -0
- package/dist/electron/lockdownRules.js +42 -0
- package/dist/electron/sessionStore.js +48 -0
- package/dist/electron/shellId.js +18 -0
- package/dist/electron/webFiles.js +36 -0
- package/dist/electron/webPatcher.js +147 -0
- package/dist/electron/webPointers.js +25 -0
- package/dist/electron.js +19 -0
- package/dist/input/haptics.js +50 -0
- package/dist/net/ApiClient.js +96 -0
- package/dist/pixel/lifeArt.js +83 -0
- package/dist/pixel.js +63 -58
- package/dist/react/ConfirmButton.js +24 -0
- package/dist/react/baseCss.js +1 -0
- package/dist/react/labels.js +7 -6
- package/dist/react/useJsonSelector.js +13 -0
- package/dist/react.js +73 -68
- package/dist/tilemap/TilemapView.js +57 -32
- package/dist/tilemap/autotile.js +103 -0
- package/dist/tilemap/collision.js +29 -18
- package/dist/tilemap/ldtk.js +21 -0
- package/dist/tilemap/ldtkParse.js +191 -0
- package/dist/types/ambient/life/Birds.d.ts +50 -0
- package/dist/types/ambient/life/Birds.d.ts.map +1 -0
- package/dist/types/ambient/life/Butterflies.d.ts +32 -0
- package/dist/types/ambient/life/Butterflies.d.ts.map +1 -0
- package/dist/types/ambient/life/ChimneySmoke.d.ts +37 -0
- package/dist/types/ambient/life/ChimneySmoke.d.ts.map +1 -0
- package/dist/types/ambient/life/Drift.d.ts +58 -0
- package/dist/types/ambient/life/Drift.d.ts.map +1 -0
- package/dist/types/ambient/life/Fireflies.d.ts +43 -0
- package/dist/types/ambient/life/Fireflies.d.ts.map +1 -0
- package/dist/types/ambient/life/lifeMotion.d.ts +63 -0
- package/dist/types/ambient/life/lifeMotion.d.ts.map +1 -0
- package/dist/types/assets/AssetLoader.d.ts +20 -0
- package/dist/types/assets/AssetLoader.d.ts.map +1 -1
- package/dist/types/assets/Prepainter.d.ts +64 -0
- package/dist/types/assets/Prepainter.d.ts.map +1 -0
- package/dist/types/assets/workerPainter.d.ts +21 -0
- package/dist/types/assets/workerPainter.d.ts.map +1 -0
- package/dist/types/electron/electronLike.d.ts +56 -0
- package/dist/types/electron/electronLike.d.ts.map +1 -0
- package/dist/types/electron/index.d.ts +15 -0
- package/dist/types/electron/index.d.ts.map +1 -0
- package/dist/types/electron/lockdown.d.ts +34 -0
- package/dist/types/electron/lockdown.d.ts.map +1 -0
- package/dist/types/electron/lockdownRules.d.ts +29 -0
- package/dist/types/electron/lockdownRules.d.ts.map +1 -0
- package/dist/types/electron/sessionStore.d.ts +41 -0
- package/dist/types/electron/sessionStore.d.ts.map +1 -0
- package/dist/types/electron/shellId.d.ts +23 -0
- package/dist/types/electron/shellId.d.ts.map +1 -0
- package/dist/types/electron/webFiles.d.ts +14 -0
- package/dist/types/electron/webFiles.d.ts.map +1 -0
- package/dist/types/electron/webPatcher.d.ts +81 -0
- package/dist/types/electron/webPatcher.d.ts.map +1 -0
- package/dist/types/electron/webPointers.d.ts +20 -0
- package/dist/types/electron/webPointers.d.ts.map +1 -0
- package/dist/types/index.d.ts +15 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/input/haptics.d.ts +42 -0
- package/dist/types/input/haptics.d.ts.map +1 -0
- package/dist/types/net/ApiClient.d.ts +74 -0
- package/dist/types/net/ApiClient.d.ts.map +1 -0
- package/dist/types/pixel/index.d.ts +1 -0
- package/dist/types/pixel/index.d.ts.map +1 -1
- package/dist/types/pixel/lifeArt.d.ts +63 -0
- package/dist/types/pixel/lifeArt.d.ts.map +1 -0
- package/dist/types/react/ConfirmButton.d.ts +26 -0
- package/dist/types/react/ConfirmButton.d.ts.map +1 -0
- package/dist/types/react/baseCss.d.ts +1 -1
- package/dist/types/react/baseCss.d.ts.map +1 -1
- package/dist/types/react/index.d.ts +2 -0
- package/dist/types/react/index.d.ts.map +1 -1
- package/dist/types/react/labels.d.ts +2 -0
- package/dist/types/react/labels.d.ts.map +1 -1
- package/dist/types/react/useJsonSelector.d.ts +13 -0
- package/dist/types/react/useJsonSelector.d.ts.map +1 -0
- package/dist/types/tilemap/TilemapView.d.ts +17 -0
- package/dist/types/tilemap/TilemapView.d.ts.map +1 -1
- package/dist/types/tilemap/autotile.d.ts +95 -0
- package/dist/types/tilemap/autotile.d.ts.map +1 -0
- package/dist/types/tilemap/collision.d.ts +8 -0
- package/dist/types/tilemap/collision.d.ts.map +1 -1
- package/dist/types/tilemap/ldtk.d.ts +97 -0
- package/dist/types/tilemap/ldtk.d.ts.map +1 -0
- package/dist/types/tilemap/ldtkParse.d.ts +26 -0
- package/dist/types/tilemap/ldtkParse.d.ts.map +1 -0
- package/dist/types/updates/index.d.ts +9 -0
- package/dist/types/updates/index.d.ts.map +1 -0
- package/dist/types/updates/manifest.d.ts +74 -0
- package/dist/types/updates/manifest.d.ts.map +1 -0
- package/dist/types/updates/pickUpdate.d.ts +43 -0
- package/dist/types/updates/pickUpdate.d.ts.map +1 -0
- package/dist/types/updates/webPlan.d.ts +21 -0
- package/dist/types/updates/webPlan.d.ts.map +1 -0
- package/dist/updates/manifest.js +35 -0
- package/dist/updates/pickUpdate.js +27 -0
- package/dist/updates/webPlan.js +14 -0
- package/dist/updates.js +15 -0
- package/package.json +31 -3
|
@@ -1,24 +1,35 @@
|
|
|
1
|
-
import { createCollisionGrid as
|
|
2
|
-
import { gidOf as
|
|
3
|
-
function
|
|
4
|
-
if (
|
|
5
|
-
const
|
|
6
|
-
if (typeof
|
|
7
|
-
const
|
|
8
|
-
if (!
|
|
9
|
-
for (let
|
|
1
|
+
import { createCollisionGrid as h } from "../net/movement.js";
|
|
2
|
+
import { gidOf as u, tileAt as a } from "./tiled.js";
|
|
3
|
+
function g(e, l = {}) {
|
|
4
|
+
if (e.tileWidth !== e.tileHeight) throw new Error(`Tiled map: collision needs square tiles, not ${e.tileWidth}x${e.tileHeight}`);
|
|
5
|
+
const n = l.solid ?? (e.layers.some((t) => t.kind === "tiles" && t.name === "collision") ? "collision" : { property: "solid" }), r = e.width * e.height, s = new Uint8Array(r);
|
|
6
|
+
if (typeof n == "string") {
|
|
7
|
+
const t = e.layers.find((i) => i.kind === "tiles" && i.name === n);
|
|
8
|
+
if (!t || t.kind !== "tiles") throw new Error(`Tiled map: no tile layer named "${n}"`);
|
|
9
|
+
for (let i = 0; i < r; i++) u(t.data[i]) !== 0 && (s[i] = 1);
|
|
10
10
|
} else
|
|
11
|
-
for (const
|
|
12
|
-
if (
|
|
13
|
-
for (let
|
|
14
|
-
const
|
|
15
|
-
|
|
11
|
+
for (const t of e.layers)
|
|
12
|
+
if (t.kind === "tiles")
|
|
13
|
+
for (let i = 0; i < r; i++) {
|
|
14
|
+
const f = a(e, t.data[i]);
|
|
15
|
+
f && f.tileset.tileProperties.get(f.local)?.[n.property] === !0 && (s[i] = 1);
|
|
16
16
|
}
|
|
17
17
|
let d = "";
|
|
18
|
-
for (let
|
|
19
|
-
const { solid:
|
|
20
|
-
return
|
|
18
|
+
for (let t = 0; t < r; t++) d += s[t] ? "1" : "0";
|
|
19
|
+
const { solid: c, ...o } = l;
|
|
20
|
+
return h(e.width, e.height, e.tileWidth, d, o);
|
|
21
|
+
}
|
|
22
|
+
function k(e, l, n = {}) {
|
|
23
|
+
const r = typeof l == "function" ? l : (c) => l.includes(c), s = /* @__PURE__ */ new Map();
|
|
24
|
+
let d = "";
|
|
25
|
+
for (let c = 0; c < e.values.length; c++) {
|
|
26
|
+
const o = e.values[c];
|
|
27
|
+
let t = s.get(o);
|
|
28
|
+
t === void 0 && s.set(o, t = o !== 0 && r(o, e.names.get(o))), d += t ? "1" : "0";
|
|
29
|
+
}
|
|
30
|
+
return h(e.width, e.height, e.gridSize, d, n);
|
|
21
31
|
}
|
|
22
32
|
export {
|
|
23
|
-
|
|
33
|
+
k as collisionFromIntGrid,
|
|
34
|
+
g as collisionFromTiled
|
|
24
35
|
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
function o(i, t) {
|
|
2
|
+
return i.levels.find((e) => e.identifier === t || e.iid === t);
|
|
3
|
+
}
|
|
4
|
+
function l(i, t, e, r) {
|
|
5
|
+
for (const n of i)
|
|
6
|
+
if (!(r !== void 0 && n.worldDepth !== r) && t >= n.worldX && e >= n.worldY && t < n.worldX + n.pxWidth && e < n.worldY + n.pxHeight)
|
|
7
|
+
return n;
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
function u(i, t, e) {
|
|
11
|
+
return t < 0 || e < 0 || t >= i.width || e >= i.height ? 0 : i.values[e * i.width + t];
|
|
12
|
+
}
|
|
13
|
+
function f(i, t) {
|
|
14
|
+
return t === void 0 ? i.entities : i.entities.filter((e) => e.identifier === t);
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
f as entitiesOf,
|
|
18
|
+
u as intGridAt,
|
|
19
|
+
l as levelAt,
|
|
20
|
+
o as levelByName
|
|
21
|
+
};
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { FLIP_H as z, FLIP_V as M } from "./tiled.js";
|
|
2
|
+
class G extends Error {
|
|
3
|
+
constructor(n) {
|
|
4
|
+
super(`LDtk project: ${n}`);
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
function c(e, n) {
|
|
8
|
+
if (typeof e != "number" || !Number.isFinite(e)) throw new G(`${n} must be a number`);
|
|
9
|
+
return e;
|
|
10
|
+
}
|
|
11
|
+
function L(e) {
|
|
12
|
+
const n = {};
|
|
13
|
+
if (Array.isArray(e))
|
|
14
|
+
for (const r of e) r && typeof r.__identifier == "string" && (n[r.__identifier] = r.__value ?? null);
|
|
15
|
+
return n;
|
|
16
|
+
}
|
|
17
|
+
function N(e) {
|
|
18
|
+
const n = {};
|
|
19
|
+
for (const [r, o] of Object.entries(e)) (typeof o == "string" || typeof o == "number" || typeof o == "boolean") && (n[r] = o);
|
|
20
|
+
return n;
|
|
21
|
+
}
|
|
22
|
+
function W(e) {
|
|
23
|
+
return Array.isArray(e.worlds) && e.worlds.length ? e.worlds : [{ identifier: "World", iid: "", worldLayout: e.worldLayout, worldGridWidth: e.worldGridWidth, worldGridHeight: e.worldGridHeight, levels: e.levels ?? [] }];
|
|
24
|
+
}
|
|
25
|
+
function R(e) {
|
|
26
|
+
const n = e;
|
|
27
|
+
if (!n || typeof n != "object") return [];
|
|
28
|
+
const r = [];
|
|
29
|
+
for (const o of W(n)) for (const t of o.levels ?? []) typeof t.externalRelPath == "string" && !Array.isArray(t.layerInstances) && r.push(t.externalRelPath);
|
|
30
|
+
return r;
|
|
31
|
+
}
|
|
32
|
+
function A(e) {
|
|
33
|
+
const n = [], r = /* @__PURE__ */ new Map();
|
|
34
|
+
let o = 1;
|
|
35
|
+
for (const t of e?.tilesets ?? []) {
|
|
36
|
+
if (typeof t.relPath != "string") continue;
|
|
37
|
+
const a = c(t.tileGridSize, `tileset "${t.identifier}" tileGridSize`), d = c(t.__cWid, `tileset "${t.identifier}" __cWid`), s = d * c(t.__cHei, `tileset "${t.identifier}" __cHei`), l = /* @__PURE__ */ new Map(), p = (i) => l.get(i) ?? (l.set(i, {}), l.get(i));
|
|
38
|
+
for (const i of t.customData ?? []) typeof i.tileId == "number" && typeof i.data == "string" && (p(i.tileId).data = i.data);
|
|
39
|
+
for (const i of t.enumTags ?? []) for (const g of i.tileIds ?? []) typeof i.enumValueId == "string" && (p(g)[i.enumValueId] = !0);
|
|
40
|
+
const u = {
|
|
41
|
+
name: String(t.identifier ?? `tileset${t.uid}`),
|
|
42
|
+
firstGid: o,
|
|
43
|
+
image: t.relPath,
|
|
44
|
+
imageWidth: c(t.pxWid, `tileset "${t.identifier}" pxWid`),
|
|
45
|
+
imageHeight: c(t.pxHei, `tileset "${t.identifier}" pxHei`),
|
|
46
|
+
tileWidth: a,
|
|
47
|
+
tileHeight: a,
|
|
48
|
+
columns: d,
|
|
49
|
+
tileCount: s,
|
|
50
|
+
margin: Number(t.padding ?? 0),
|
|
51
|
+
spacing: Number(t.spacing ?? 0),
|
|
52
|
+
tileProperties: l,
|
|
53
|
+
animations: /* @__PURE__ */ new Map(),
|
|
54
|
+
properties: {}
|
|
55
|
+
};
|
|
56
|
+
n.push(u), r.set(c(t.uid, "tileset uid"), u), o += s;
|
|
57
|
+
}
|
|
58
|
+
return { tilesets: n, byUid: r };
|
|
59
|
+
}
|
|
60
|
+
function T(e, n, r, o, t, a, d) {
|
|
61
|
+
const s = [], l = (u) => {
|
|
62
|
+
for (; s.length <= u; )
|
|
63
|
+
s.push({
|
|
64
|
+
kind: "tiles",
|
|
65
|
+
name: s.length ? `${n}#${s.length}` : n,
|
|
66
|
+
data: new Uint32Array(t * a),
|
|
67
|
+
visible: e.visible !== !1,
|
|
68
|
+
opacity: typeof e.__opacity == "number" ? e.__opacity : 1,
|
|
69
|
+
offsetX: Number(e.__pxTotalOffsetX ?? 0),
|
|
70
|
+
offsetY: Number(e.__pxTotalOffsetY ?? 0),
|
|
71
|
+
properties: {}
|
|
72
|
+
});
|
|
73
|
+
return s[u];
|
|
74
|
+
}, p = new Uint8Array(t * a);
|
|
75
|
+
for (const u of r) {
|
|
76
|
+
const i = Math.floor(c(u.px?.[0], `layer "${n}" tile px`) / d), g = Math.floor(c(u.px?.[1], `layer "${n}" tile px`) / d);
|
|
77
|
+
if (i < 0 || g < 0 || i >= t || g >= a) continue;
|
|
78
|
+
const h = c(u.t, `layer "${n}" tile id`);
|
|
79
|
+
if (h < 0 || h >= o.tileCount) continue;
|
|
80
|
+
const m = g * t + i, b = Number(u.f ?? 0), y = (o.firstGid + h | (b & 1 ? z : 0) | (b & 2 ? M : 0)) >>> 0;
|
|
81
|
+
l(p[m]).data[m] = y, p[m] = Math.min(255, p[m] + 1);
|
|
82
|
+
}
|
|
83
|
+
return s.length || l(0), s;
|
|
84
|
+
}
|
|
85
|
+
function X(e, n) {
|
|
86
|
+
const r = /* @__PURE__ */ new Map(), o = (e?.layers ?? []).find((t) => t.uid === n);
|
|
87
|
+
for (const t of o?.intGridValues ?? []) typeof t.value == "number" && typeof t.identifier == "string" && t.identifier && r.set(t.value, t.identifier);
|
|
88
|
+
return r;
|
|
89
|
+
}
|
|
90
|
+
function Y(e, n, r, o, t) {
|
|
91
|
+
const a = n.filter((i) => i.__type !== "Entities"), d = a.length ? c(a[0].__gridSize, "layer __gridSize") : t;
|
|
92
|
+
for (const i of a)
|
|
93
|
+
if (i.__gridSize !== d) throw new G(`level "${e.identifier}" layer "${i.__identifier}" has a ${i.__gridSize} px grid, not ${d}: every tile and IntGrid layer of a level must share one grid`);
|
|
94
|
+
const s = a.length ? Math.max(...a.map((i) => c(i.__cWid, "layer __cWid"))) : Math.ceil(e.pxWidth / d), l = a.length ? Math.max(...a.map((i) => c(i.__cHei, "layer __cHei"))) : Math.ceil(e.pxHeight / d), p = [];
|
|
95
|
+
let u = 1;
|
|
96
|
+
for (const i of [...n].reverse()) {
|
|
97
|
+
const g = String(i.__identifier ?? ""), h = i.__type, m = Number(i.__pxTotalOffsetX ?? 0), b = Number(i.__pxTotalOffsetY ?? 0);
|
|
98
|
+
if (h === "IntGrid") {
|
|
99
|
+
const y = c(i.__cWid, "layer __cWid"), f = c(i.__cHei, "layer __cHei"), _ = i.intGridCsv;
|
|
100
|
+
if (!Array.isArray(_) || _.length !== y * f) throw new G(`layer "${g}" must hold ${y * f} IntGrid cells`);
|
|
101
|
+
const w = { name: g, width: y, height: f, gridSize: d, values: Int32Array.from(_), names: X(r, i.layerDefUid), offsetX: m, offsetY: b };
|
|
102
|
+
e.intGrids.set(g, w);
|
|
103
|
+
}
|
|
104
|
+
if (h === "IntGrid" || h === "AutoLayer" || h === "Tiles") {
|
|
105
|
+
const y = h === "Tiles" ? i.gridTiles ?? [] : i.autoLayerTiles ?? [], f = i.overrideTilesetUid ?? i.__tilesetDefUid, _ = typeof f == "number" ? o.get(f) : void 0;
|
|
106
|
+
_ && (h !== "IntGrid" || y.length) && p.push(...T(i, g, y, _, s, l, d));
|
|
107
|
+
} else if (h === "Entities") {
|
|
108
|
+
const y = [];
|
|
109
|
+
for (const f of i.entityInstances ?? []) {
|
|
110
|
+
const _ = L(f.fieldInstances), w = Number(f.width ?? 0), x = Number(f.height ?? 0), $ = Number(f.__pivot?.[0] ?? 0), I = Number(f.__pivot?.[1] ?? 0), v = c(f.px?.[0], `entity "${f.__identifier}" px`) + m, H = c(f.px?.[1], `entity "${f.__identifier}" px`) + b, S = {
|
|
111
|
+
iid: String(f.iid ?? ""),
|
|
112
|
+
identifier: String(f.__identifier ?? ""),
|
|
113
|
+
x: v,
|
|
114
|
+
y: H,
|
|
115
|
+
width: w,
|
|
116
|
+
height: x,
|
|
117
|
+
pivotX: $,
|
|
118
|
+
pivotY: I,
|
|
119
|
+
cx: Number(f.__grid?.[0] ?? Math.floor(v / d)),
|
|
120
|
+
cy: Number(f.__grid?.[1] ?? Math.floor(H / d)),
|
|
121
|
+
tags: Array.isArray(f.__tags) ? f.__tags.map(String) : [],
|
|
122
|
+
fields: _,
|
|
123
|
+
layer: g
|
|
124
|
+
};
|
|
125
|
+
e.entities.push(S), y.push({ id: u++, name: S.identifier, type: S.identifier, x: v - $ * w, y: H - I * x, width: w, height: x, rotation: 0, point: w === 0 && x === 0, ellipse: !1, properties: N(_) });
|
|
126
|
+
}
|
|
127
|
+
p.push({ kind: "objects", name: g, objects: y, visible: i.visible !== !1, properties: {} });
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
e.map.width = s, e.map.height = l, e.map.tileWidth = d, e.map.tileHeight = d, e.map.layers = p;
|
|
131
|
+
}
|
|
132
|
+
function P(e, n, r, o, t) {
|
|
133
|
+
const a = String(e.identifier ?? ""), d = String(e.__bgColor ?? e.bgColor ?? n.bgColor), s = {
|
|
134
|
+
identifier: a,
|
|
135
|
+
iid: String(e.iid ?? ""),
|
|
136
|
+
uid: Number(e.uid ?? 0),
|
|
137
|
+
worldX: Number(e.worldX ?? 0),
|
|
138
|
+
worldY: Number(e.worldY ?? 0),
|
|
139
|
+
worldDepth: Number(e.worldDepth ?? 0),
|
|
140
|
+
pxWidth: c(e.pxWid, `level "${a}" pxWid`),
|
|
141
|
+
pxHeight: c(e.pxHei, `level "${a}" pxHei`),
|
|
142
|
+
bgColor: d,
|
|
143
|
+
fields: L(e.fieldInstances),
|
|
144
|
+
map: { width: 0, height: 0, tileWidth: n.defaultGridSize, tileHeight: n.defaultGridSize, layers: [], tilesets: n.tilesets, properties: {}, backgroundColor: d },
|
|
145
|
+
intGrids: /* @__PURE__ */ new Map(),
|
|
146
|
+
entities: [],
|
|
147
|
+
loaded: !1
|
|
148
|
+
};
|
|
149
|
+
typeof e.externalRelPath == "string" && (s.externalRelPath = e.externalRelPath);
|
|
150
|
+
let l = e;
|
|
151
|
+
return !Array.isArray(e.layerInstances) && s.externalRelPath && (l = t(s.externalRelPath)), l && Array.isArray(l.layerInstances) && (s.fields = { ...s.fields, ...L(l.fieldInstances) }, s.map.properties = N(s.fields), Y(s, l.layerInstances, r, o, n.defaultGridSize), s.loaded = !0), s;
|
|
152
|
+
}
|
|
153
|
+
function k(e, n) {
|
|
154
|
+
let r = 0;
|
|
155
|
+
for (const o of e)
|
|
156
|
+
n === "LinearHorizontal" ? (o.worldX = r, o.worldY = 0, r += o.pxWidth) : (o.worldX = 0, o.worldY = r, r += o.pxHeight);
|
|
157
|
+
}
|
|
158
|
+
function j(e, n = {}) {
|
|
159
|
+
const r = e;
|
|
160
|
+
if (!r || typeof r != "object" || !r.defs) throw new G('not an LDtk project (no "defs")');
|
|
161
|
+
const o = n.levels, t = typeof o == "function" ? o : (l) => o?.[l], { tilesets: a, byUid: d } = A(r.defs), s = {
|
|
162
|
+
jsonVersion: String(r.jsonVersion ?? ""),
|
|
163
|
+
defaultGridSize: Number(r.defaultGridSize ?? 16),
|
|
164
|
+
bgColor: String(r.bgColor ?? "#000000"),
|
|
165
|
+
tilesets: a,
|
|
166
|
+
worlds: [],
|
|
167
|
+
levels: []
|
|
168
|
+
};
|
|
169
|
+
for (const l of W(r)) {
|
|
170
|
+
const p = l.worldLayout ?? "Free", u = {
|
|
171
|
+
identifier: String(l.identifier ?? ""),
|
|
172
|
+
iid: String(l.iid ?? ""),
|
|
173
|
+
layout: p,
|
|
174
|
+
gridWidth: Number(l.worldGridWidth ?? 0),
|
|
175
|
+
gridHeight: Number(l.worldGridHeight ?? 0),
|
|
176
|
+
levels: (l.levels ?? []).map((i) => P(i, s, r.defs, d, t))
|
|
177
|
+
};
|
|
178
|
+
(p === "LinearHorizontal" || p === "LinearVertical") && k(u.levels, p), s.worlds.push(u), s.levels.push(...u.levels);
|
|
179
|
+
}
|
|
180
|
+
return s;
|
|
181
|
+
}
|
|
182
|
+
function O(e, n, r, o) {
|
|
183
|
+
const t = n, { byUid: a } = A(t?.defs), d = P({ ...o, worldX: r.worldX, worldY: r.worldY, externalRelPath: r.externalRelPath }, e, t?.defs, a, () => {
|
|
184
|
+
});
|
|
185
|
+
return Object.assign(r, { map: d.map, intGrids: d.intGrids, entities: d.entities, fields: d.fields, loaded: d.loaded }), r;
|
|
186
|
+
}
|
|
187
|
+
export {
|
|
188
|
+
R as ldtkExternalLevels,
|
|
189
|
+
O as loadLdtkLevel,
|
|
190
|
+
j as parseLdtk
|
|
191
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { ViewRect } from '../../core/Camera.js';
|
|
2
|
+
import type { Stage } from '../../core/Stage.js';
|
|
3
|
+
import { type LifeAir } from './lifeMotion.js';
|
|
4
|
+
export interface BirdsOptions {
|
|
5
|
+
/** Birds in a flock, [least, most]; never more than `maxFlock`. */
|
|
6
|
+
flock: readonly [number, number];
|
|
7
|
+
/** Seconds between flocks, [least, most]. */
|
|
8
|
+
everyS: readonly [number, number];
|
|
9
|
+
/** The two frames, seen from above: wings raised (a V), then the downstroke. */
|
|
10
|
+
frames: readonly [string, string];
|
|
11
|
+
/** A small shadow on the ground far below each bird: it is what tells the eye how high they are. */
|
|
12
|
+
shadow?: string;
|
|
13
|
+
/** The pool's size (default 6). */
|
|
14
|
+
maxFlock?: number;
|
|
15
|
+
/** Depth of the birds (default 950_000: over every prop and body, under the names). */
|
|
16
|
+
depth?: number;
|
|
17
|
+
/** Depth of their shadows (default -999_980: on the ground, under the bodies). */
|
|
18
|
+
shadowDepth?: number;
|
|
19
|
+
/** Past this `night` no flock sets off (default 0.5). */
|
|
20
|
+
maxNight?: number;
|
|
21
|
+
/** The first flock comes this many ms after the first update, [least, most] (default [3000, 9000]). */
|
|
22
|
+
firstMs?: readonly [number, number];
|
|
23
|
+
snap?: boolean;
|
|
24
|
+
random?: () => number;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* A flock crossing the sky now and then: a few painted birds in a loose V flying straight across the camera's view,
|
|
28
|
+
* wings beating on their own clocks, each with its shadow on the ground below. Not at night.
|
|
29
|
+
*/
|
|
30
|
+
export declare class Birds {
|
|
31
|
+
private readonly options;
|
|
32
|
+
private readonly birds;
|
|
33
|
+
private readonly snap;
|
|
34
|
+
private readonly random;
|
|
35
|
+
private active;
|
|
36
|
+
private nextAt;
|
|
37
|
+
private x;
|
|
38
|
+
private y;
|
|
39
|
+
private vx;
|
|
40
|
+
private vy;
|
|
41
|
+
private altitude;
|
|
42
|
+
constructor(stage: Stage, options: BirdsOptions);
|
|
43
|
+
/** Whether a flock is crossing now. */
|
|
44
|
+
get flying(): boolean;
|
|
45
|
+
update(now: number, dt: number, view: ViewRect, air: LifeAir, enabled?: boolean): void;
|
|
46
|
+
destroy(): void;
|
|
47
|
+
private launch;
|
|
48
|
+
private land;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=Birds.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Birds.d.ts","sourceRoot":"","sources":["../../../../src/ambient/life/Birds.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAElD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAwB,KAAK,OAAO,EAAE,MAAM,cAAc,CAAC;AAElE,MAAM,WAAW,YAAY;IAC3B,mEAAmE;IACnE,KAAK,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,6CAA6C;IAC7C,MAAM,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,gFAAgF;IAChF,MAAM,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,oGAAoG;IACpG,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,mCAAmC;IACnC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,uFAAuF;IACvF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kFAAkF;IAClF,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yDAAyD;IACzD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,uGAAuG;IACvG,OAAO,CAAC,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,MAAM,CAAC;CACvB;AAUD;;;GAGG;AACH,qBAAa,KAAK;IAcd,OAAO,CAAC,QAAQ,CAAC,OAAO;IAb1B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAc;IACpC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAU;IAC/B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAe;IACtC,OAAO,CAAC,MAAM,CAAK;IACnB,OAAO,CAAC,MAAM,CAAc;IAC5B,OAAO,CAAC,CAAC,CAAK;IACd,OAAO,CAAC,CAAC,CAAK;IACd,OAAO,CAAC,EAAE,CAAK;IACf,OAAO,CAAC,EAAE,CAAK;IACf,OAAO,CAAC,QAAQ,CAAM;gBAGpB,KAAK,EAAE,KAAK,EACK,OAAO,EAAE,YAAY;IAcxC,uCAAuC;IACvC,IAAI,MAAM,IAAI,OAAO,CAEpB;IAED,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,UAAO,GAAG,IAAI;IA4BnF,OAAO,IAAI,IAAI;IASf,OAAO,CAAC,MAAM;IAwBd,OAAO,CAAC,IAAI;CAOb"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ViewRect } from '../../core/Camera.js';
|
|
2
|
+
import type { Stage } from '../../core/Stage.js';
|
|
3
|
+
import type { LifeAir, LifeSource } from './lifeMotion.js';
|
|
4
|
+
export interface ButterfliesOptions {
|
|
5
|
+
count: number;
|
|
6
|
+
/** Each tone's two frames, wings open then shut; butterfly `i` wears `looks[i % looks.length]`. */
|
|
7
|
+
looks: readonly (readonly [open: string, shut: string])[];
|
|
8
|
+
/** A flower patch in view to settle round, or null when none is on screen. */
|
|
9
|
+
home: LifeSource;
|
|
10
|
+
/** Depth in the world layer (default 900_000). */
|
|
11
|
+
depth?: number;
|
|
12
|
+
/** Past this `night` they are gone (default 0.4). */
|
|
13
|
+
maxNight?: number;
|
|
14
|
+
snap?: boolean;
|
|
15
|
+
random?: () => number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Butterflies by day round the flowers on screen: each settles on a patch in view and wanders round it in short
|
|
19
|
+
* jinks, wings opening and shutting on their own beat, bobbing a pixel over the bloom. They leave when the night
|
|
20
|
+
* comes in, and where `home` finds nothing they are simply not drawn.
|
|
21
|
+
*/
|
|
22
|
+
export declare class Butterflies {
|
|
23
|
+
private readonly options;
|
|
24
|
+
private readonly flies;
|
|
25
|
+
private readonly snap;
|
|
26
|
+
private readonly random;
|
|
27
|
+
constructor(stage: Stage, options: ButterfliesOptions);
|
|
28
|
+
update(now: number, dt: number, view: ViewRect, air: LifeAir, enabled?: boolean): void;
|
|
29
|
+
destroy(): void;
|
|
30
|
+
private settle;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=Butterflies.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Butterflies.d.ts","sourceRoot":"","sources":["../../../../src/ambient/life/Butterflies.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAElD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAExD,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,mGAAmG;IACnG,KAAK,EAAE,SAAS,CAAC,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC;IAC1D,8EAA8E;IAC9E,IAAI,EAAE,UAAU,CAAC;IACjB,kDAAkD;IAClD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qDAAqD;IACrD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,MAAM,CAAC;CACvB;AAgBD;;;;GAIG;AACH,qBAAa,WAAW;IAOpB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAN1B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAmB;IACzC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAU;IAC/B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAe;gBAGpC,KAAK,EAAE,KAAK,EACK,OAAO,EAAE,kBAAkB;IAY9C,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,UAAO,GAAG,IAAI;IA8BnF,OAAO,IAAI,IAAI;IAKf,OAAO,CAAC,MAAM;CAUf"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { ViewRect } from '../../core/Camera.js';
|
|
2
|
+
import type { Stage } from '../../core/Stage.js';
|
|
3
|
+
import { type LifeAir, type LifePoint } from './lifeMotion.js';
|
|
4
|
+
export interface ChimneySmokeOptions {
|
|
5
|
+
/** The chimneys' mouths in world pixels. */
|
|
6
|
+
mouths: readonly LifePoint[];
|
|
7
|
+
/** The puff's frames from young to old (it grows through them and dithers away). */
|
|
8
|
+
frames: readonly string[];
|
|
9
|
+
/** Puffs in each chimney's pool (default 7). */
|
|
10
|
+
puffs?: number;
|
|
11
|
+
/** A puff every this many ms, give or take 30% (default 650). */
|
|
12
|
+
puffEveryMs?: number;
|
|
13
|
+
/** A puff's life (ms, default 4600). */
|
|
14
|
+
lifeMs?: number;
|
|
15
|
+
/** World px a second it climbs (default 7). */
|
|
16
|
+
rise?: number;
|
|
17
|
+
/** World px a second the wind leans it (default 9). */
|
|
18
|
+
drift?: number;
|
|
19
|
+
/** Depth in the world layer (default 900_000). */
|
|
20
|
+
depth?: number;
|
|
21
|
+
snap?: boolean;
|
|
22
|
+
random?: () => number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Smoke rising from chimneys: each mouth lets out a puff every so often that climbs, grows through its frames, leans
|
|
26
|
+
* downwind and is gone. Only mouths on screen puff; a mouth that leaves the view drops its puffs at once.
|
|
27
|
+
*/
|
|
28
|
+
export declare class ChimneySmoke {
|
|
29
|
+
private readonly options;
|
|
30
|
+
private readonly chimneys;
|
|
31
|
+
private readonly snap;
|
|
32
|
+
private readonly random;
|
|
33
|
+
constructor(stage: Stage, options: ChimneySmokeOptions);
|
|
34
|
+
update(now: number, view: ViewRect, air: LifeAir, enabled?: boolean): void;
|
|
35
|
+
destroy(): void;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=ChimneySmoke.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChimneySmoke.d.ts","sourceRoot":"","sources":["../../../../src/ambient/life/ChimneySmoke.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAElD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAc,KAAK,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAExE,MAAM,WAAW,mBAAmB;IAClC,4CAA4C;IAC5C,MAAM,EAAE,SAAS,SAAS,EAAE,CAAC;IAC7B,oFAAoF;IACpF,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1B,gDAAgD;IAChD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iEAAiE;IACjE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,wCAAwC;IACxC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,+CAA+C;IAC/C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,uDAAuD;IACvD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kDAAkD;IAClD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,MAAM,CAAC;CACvB;AAeD;;;GAGG;AACH,qBAAa,YAAY;IAOrB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAN1B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAiB;IAC1C,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAU;IAC/B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAe;gBAGpC,KAAK,EAAE,KAAK,EACK,OAAO,EAAE,mBAAmB;IAgB/C,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,UAAO,GAAG,IAAI;IAwCvE,OAAO,IAAI,IAAI;CAIhB"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { ViewRect } from '../../core/Camera.js';
|
|
2
|
+
import type { Stage } from '../../core/Stage.js';
|
|
3
|
+
import type { LifeAir, LifeSource } from './lifeMotion.js';
|
|
4
|
+
/**
|
|
5
|
+
* How a drift moves:
|
|
6
|
+
* - `leaf`: tumbles down through its frames, lands, lies a moment and is gone;
|
|
7
|
+
* - `seed`: blown across the view on a slow wobble (dandelion seed, spores, ash on the wind);
|
|
8
|
+
* - `ember`: rises, cooling through its frames, and goes out within a tile or three;
|
|
9
|
+
* - `mote`: hangs in the air, barely moving, and winks out now and then (underground dust);
|
|
10
|
+
* - `ash`: blown across like a seed, but from a source it lifts off the ground instead.
|
|
11
|
+
*/
|
|
12
|
+
export type DriftKind = 'leaf' | 'seed' | 'ember' | 'mote' | 'ash';
|
|
13
|
+
export interface DriftOptions {
|
|
14
|
+
kind: DriftKind;
|
|
15
|
+
/** Bodies in the pool; a body off screen is hidden and re-used, never freed. */
|
|
16
|
+
count: number;
|
|
17
|
+
/**
|
|
18
|
+
* The looks, each a list of frames; body `i` wears `looks[i % looks.length]`. A leaf tumbles through its frames and
|
|
19
|
+
* lies on the first; an ember cools from its first to its last; the others wear the first.
|
|
20
|
+
*/
|
|
21
|
+
looks: readonly (readonly string[])[];
|
|
22
|
+
/**
|
|
23
|
+
* Where a body sets off from, if anywhere in particular: a canopy on screen a leaf falls from (and lands just under),
|
|
24
|
+
* a patch of ground ash or embers lift off. Null when there is none in view now.
|
|
25
|
+
*/
|
|
26
|
+
from?: LifeSource;
|
|
27
|
+
/**
|
|
28
|
+
* Only from `from` (a drift over certain ground): a body waits rather than drift in from the view's edge. Default
|
|
29
|
+
* false — a leaf with no canopy in view still blows in from the edge.
|
|
30
|
+
*/
|
|
31
|
+
sourceOnly?: boolean;
|
|
32
|
+
/** Depth in the world layer (default 900_000: over the bodies and props, under the weather and the names). */
|
|
33
|
+
depth?: number;
|
|
34
|
+
/** Positions on whole world pixels (default true). */
|
|
35
|
+
snap?: boolean;
|
|
36
|
+
random?: () => number;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* One kind of thing on the air: a fixed pool that lives only inside the camera's view, each body on whole world
|
|
40
|
+
* pixels and flipped between painted frames rather than rotated (a rotated pixel leaf reads as a different art style).
|
|
41
|
+
* Feed it the frame's view and the air; `enabled` false hides it (a reduced-effects setting).
|
|
42
|
+
*/
|
|
43
|
+
export declare class Drift {
|
|
44
|
+
private readonly options;
|
|
45
|
+
private readonly motes;
|
|
46
|
+
private readonly kind;
|
|
47
|
+
private readonly snap;
|
|
48
|
+
private readonly random;
|
|
49
|
+
constructor(stage: Stage, options: DriftOptions);
|
|
50
|
+
/** `now` and `dt` in ms. */
|
|
51
|
+
update(now: number, dt: number, view: ViewRect, air: LifeAir, enabled?: boolean): void;
|
|
52
|
+
destroy(): void;
|
|
53
|
+
/** `anywhere`: a first fill lands bodies all over the view, not only at its edge, so a scene opens already alive. */
|
|
54
|
+
private spawn;
|
|
55
|
+
private spawnFrom;
|
|
56
|
+
private step;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=Drift.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Drift.d.ts","sourceRoot":"","sources":["../../../../src/ambient/life/Drift.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAElD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,KAAK,EAAE,OAAO,EAAW,UAAU,EAAE,MAAM,cAAc,CAAC;AAEjE;;;;;;;GAOG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,KAAK,CAAC;AAEnE,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,SAAS,CAAC;IAChB,gFAAgF;IAChF,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,KAAK,EAAE,SAAS,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,CAAC;IACtC;;;OAGG;IACH,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,8GAA8G;IAC9G,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sDAAsD;IACtD,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,MAAM,CAAC;CACvB;AAuBD;;;;GAIG;AACH,qBAAa,KAAK;IAQd,OAAO,CAAC,QAAQ,CAAC,OAAO;IAP1B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAc;IACpC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAY;IACjC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAU;IAC/B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAe;gBAGpC,KAAK,EAAE,KAAK,EACK,OAAO,EAAE,YAAY;IAaxC,4BAA4B;IAC5B,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,UAAO,GAAG,IAAI;IAuBnF,OAAO,IAAI,IAAI;IAKf,qHAAqH;IACrH,OAAO,CAAC,KAAK;IA2Bb,OAAO,CAAC,SAAS;IAwBjB,OAAO,CAAC,IAAI;CAwCb"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Container } from 'pixi.js';
|
|
2
|
+
import type { ViewRect } from '../../core/Camera.js';
|
|
3
|
+
import type { Stage } from '../../core/Stage.js';
|
|
4
|
+
import { type LifeAir, type LifeSource } from './lifeMotion.js';
|
|
5
|
+
export interface FirefliesOptions {
|
|
6
|
+
count: number;
|
|
7
|
+
/** The two frames: a dim pixel, and the glow. */
|
|
8
|
+
frames: readonly [dim: string, lit: string];
|
|
9
|
+
/** Somewhere in view to hover round (the water's edge, the feet of trees), or null when none is on screen. */
|
|
10
|
+
home: LifeSource;
|
|
11
|
+
/**
|
|
12
|
+
* Where the layer goes. Default `'screen'`: on the screen layer, following the camera, so it can be laid **over** a
|
|
13
|
+
* darkness drawn there (`NightShade`, `Darkness`) instead of being darkened with the world under it — add it after
|
|
14
|
+
* the darkness. `'world'`: in the world layer at `depth`, for a game with no darkness over its world.
|
|
15
|
+
*/
|
|
16
|
+
layer?: 'screen' | 'world';
|
|
17
|
+
/** World-layer depth when `layer` is `'world'` (default 900_000). */
|
|
18
|
+
depth?: number;
|
|
19
|
+
snap?: boolean;
|
|
20
|
+
random?: () => number;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Fireflies at night: single pixels drifting slowly round homes on screen, each lighting up and going out on its own
|
|
24
|
+
* clock. How many are out grows with the dark (none before night 0.5, all by 0.85). They are a light, so by default
|
|
25
|
+
* their layer sits on the screen and follows the camera (`Camera.follow` copies the world layer's transform, shake
|
|
26
|
+
* included, once the frame's camera is known).
|
|
27
|
+
*/
|
|
28
|
+
export declare class Fireflies {
|
|
29
|
+
private readonly stage;
|
|
30
|
+
private readonly options;
|
|
31
|
+
readonly layer: Container<import("pixi.js").ContainerChild>;
|
|
32
|
+
private readonly flies;
|
|
33
|
+
private readonly dim;
|
|
34
|
+
private readonly lit;
|
|
35
|
+
private readonly onScreen;
|
|
36
|
+
private readonly snap;
|
|
37
|
+
private readonly random;
|
|
38
|
+
constructor(stage: Stage, options: FirefliesOptions);
|
|
39
|
+
update(now: number, view: ViewRect, air: LifeAir, enabled?: boolean): void;
|
|
40
|
+
destroy(): void;
|
|
41
|
+
private settle;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=Fireflies.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Fireflies.d.ts","sourceRoot":"","sources":["../../../../src/ambient/life/Fireflies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAwB,MAAM,SAAS,CAAC;AAC1D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAA4C,KAAK,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAEvG,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,iDAAiD;IACjD,MAAM,EAAE,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;IAC5C,8GAA8G;IAC9G,IAAI,EAAE,UAAU,CAAC;IACjB;;;;OAIG;IACH,KAAK,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC;IAC3B,qEAAqE;IACrE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,MAAM,CAAC;CACvB;AAUD;;;;;GAKG;AACH,qBAAa,SAAS;IAUlB,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAV1B,QAAQ,CAAC,KAAK,8CAAmB;IACjC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAa;IACnC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAU;IAC9B,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAU;IAC9B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAU;IACnC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAU;IAC/B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAe;gBAGnB,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,gBAAgB;IAwB5C,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,UAAO,GAAG,IAAI;IA8BvE,OAAO,IAAI,IAAI;IAMf,OAAO,CAAC,MAAM;CAQf"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { ViewRect } from '../../core/Camera.js';
|
|
2
|
+
/** A point in world pixels. */
|
|
3
|
+
export interface LifePoint {
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
}
|
|
7
|
+
/** A box in world pixels (a canopy leaves fall from, a tile ash lifts off); a point is a box of no size. */
|
|
8
|
+
export interface LifeBox extends LifePoint {
|
|
9
|
+
w?: number;
|
|
10
|
+
h?: number;
|
|
11
|
+
}
|
|
12
|
+
/** The air the life reads: how dark it is and how hard the wind blows. */
|
|
13
|
+
export interface LifeAir {
|
|
14
|
+
/** 0 by day, 1 at full night (birds and butterflies keep away from the dark, fireflies come out of it). */
|
|
15
|
+
night: number;
|
|
16
|
+
/** 0 still air, 1 a gale: leans the drift, hastens a flock, bends smoke. */
|
|
17
|
+
wind: number;
|
|
18
|
+
}
|
|
19
|
+
/** Hands back somewhere to be: inside the camera's view, or null when there is nowhere there now. */
|
|
20
|
+
export type LifeSource<T extends LifeBox = LifeBox> = (view: ViewRect, random: () => number) => T | null;
|
|
21
|
+
/** Whether the box touches the view grown by `margin` on every side. */
|
|
22
|
+
export declare function boxInView(b: LifeBox, view: ViewRect, margin?: number): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* One of `items` in view, tried `tries` times at random rather than filtered: a forest's thousands of tiles cost the
|
|
25
|
+
* same few reads as a hamlet's dozen, and a miss only means the body waits a frame to try again.
|
|
26
|
+
*/
|
|
27
|
+
export declare function pickInView<T extends LifeBox>(items: readonly T[], view: ViewRect, random: () => number, tries?: number): T | null;
|
|
28
|
+
/** A `LifeSource` over a fixed list (flower beds, the water's edge, tiles of burnt ground). */
|
|
29
|
+
export declare function sourceOf<T extends LifeBox>(items: readonly T[], tries?: number): LifeSource<T>;
|
|
30
|
+
/** A bird's frame: a few beats (0, 1, 0, 1, 0), then a glide on raised wings (0) for three, each bird on its clock. */
|
|
31
|
+
export declare function birdFrame(now: number, offset: number, beatMs?: number): 0 | 1;
|
|
32
|
+
/**
|
|
33
|
+
* Where the `i`-th bird of a flock flies behind the leader: a loose V trailing back along `dirX` (its sign), ranks
|
|
34
|
+
* alternating side to side. `jitter` (0..1 each) loosens it so no two flocks are drawn alike.
|
|
35
|
+
*/
|
|
36
|
+
export declare function flockSlot(i: number, dirX: number, jitterX: number, jitterY: number): {
|
|
37
|
+
dx: number;
|
|
38
|
+
dy: number;
|
|
39
|
+
};
|
|
40
|
+
/** A firefly's blink at `t` seconds: 0 dark most of the time, 2 a glow for a beat, 1 a dim pixel either side of it. */
|
|
41
|
+
export declare function fireflyGlow(t: number): 0 | 1 | 2;
|
|
42
|
+
/** A firefly's slow wander about its home at `t` seconds: two sines across, one up and down. */
|
|
43
|
+
export declare function fireflyOffset(t: number): {
|
|
44
|
+
dx: number;
|
|
45
|
+
dy: number;
|
|
46
|
+
};
|
|
47
|
+
/** How many of a pool of `count` fireflies are out at `night`: none before 0.5, all by 0.85. */
|
|
48
|
+
export declare function firefliesOut(count: number, night: number): number;
|
|
49
|
+
export interface PuffMotion {
|
|
50
|
+
/** World px a second it climbs. */
|
|
51
|
+
rise: number;
|
|
52
|
+
/** World px a second the wind leans it at full age. */
|
|
53
|
+
drift: number;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Where a puff of smoke is `sec` seconds after it left a chimney's mouth, `age` the share of its life gone: it climbs
|
|
57
|
+
* straight out of the pot, then the wind takes it more the higher it gets. `seed` (0..1) gives each its own wobble.
|
|
58
|
+
*/
|
|
59
|
+
export declare function puffOffset(sec: number, age: number, seed: number, wind: number, m: PuffMotion): {
|
|
60
|
+
dx: number;
|
|
61
|
+
dy: number;
|
|
62
|
+
};
|
|
63
|
+
//# sourceMappingURL=lifeMotion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lifeMotion.d.ts","sourceRoot":"","sources":["../../../../src/ambient/life/lifeMotion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAQlD,+BAA+B;AAC/B,MAAM,WAAW,SAAS;IACxB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,4GAA4G;AAC5G,MAAM,WAAW,OAAQ,SAAQ,SAAS;IACxC,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,CAAC,CAAC,EAAE,MAAM,CAAC;CACZ;AAED,0EAA0E;AAC1E,MAAM,WAAW,OAAO;IACtB,2GAA2G;IAC3G,KAAK,EAAE,MAAM,CAAC;IACd,4EAA4E;IAC5E,IAAI,EAAE,MAAM,CAAC;CACd;AAED,qGAAqG;AACrG,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,MAAM,KAAK,CAAC,GAAG,IAAI,CAAC;AAEzG,wEAAwE;AACxE,wBAAgB,SAAS,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,SAAI,GAAG,OAAO,CAEzE;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,OAAO,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,MAAM,EAAE,KAAK,SAAI,GAAG,CAAC,GAAG,IAAI,CAO5H;AAED,+FAA+F;AAC/F,wBAAgB,QAAQ,CAAC,CAAC,SAAS,OAAO,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,EAAE,KAAK,SAAI,GAAG,UAAU,CAAC,CAAC,CAAC,CAEzF;AAED,uHAAuH;AACvH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,SAAM,GAAG,CAAC,GAAG,CAAC,CAG1E;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAI/G;AAED,uHAAuH;AACvH,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAGhD;AAED,gGAAgG;AAChG,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAEnE;AAED,gGAAgG;AAChG,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAGjE;AAED,MAAM,WAAW,UAAU;IACzB,mCAAmC;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,uDAAuD;IACvD,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,UAAU,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAK1H"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { CanvasTexture } from '../core/TextureRegistry.js';
|
|
2
|
+
import type { LdtkProject } from '../tilemap/ldtk.js';
|
|
2
3
|
import { type TileMap, type Tileset } from '../tilemap/tiled.js';
|
|
3
4
|
import { type AtlasFrame } from './textureAtlas.js';
|
|
4
5
|
/** Where loaded images go: the stage's `TextureRegistry` satisfies it. */
|
|
@@ -50,6 +51,13 @@ export interface TilemapAssetOptions {
|
|
|
50
51
|
/** The texture key a tileset's image is loaded under (default: the tileset's name). */
|
|
51
52
|
textureKey?: (tileset: Tileset) => string;
|
|
52
53
|
}
|
|
54
|
+
export interface LdtkAssetOptions extends TilemapAssetOptions {
|
|
55
|
+
/**
|
|
56
|
+
* Which external level files to fetch with the project (by level identifier); default every one. A level left out
|
|
57
|
+
* stays `loaded: false`, to be fetched later and read with `loadLdtkLevel`.
|
|
58
|
+
*/
|
|
59
|
+
levels?: readonly string[];
|
|
60
|
+
}
|
|
53
61
|
export interface LoadProgress {
|
|
54
62
|
done: number;
|
|
55
63
|
total: number;
|
|
@@ -79,6 +87,7 @@ export declare class AssetLoader {
|
|
|
79
87
|
private readonly queue;
|
|
80
88
|
private readonly data;
|
|
81
89
|
private readonly maps;
|
|
90
|
+
private readonly ldtks;
|
|
82
91
|
private readonly atlases;
|
|
83
92
|
/** Decoded audio by key; a key with bytes only waits for a context (`decodeAudio`). */
|
|
84
93
|
private readonly audioBuffers;
|
|
@@ -99,6 +108,14 @@ export declare class AssetLoader {
|
|
|
99
108
|
text(key: string, url: string): this;
|
|
100
109
|
/** A Tiled JSON map, then every tileset image it names (resolved beside the map file). */
|
|
101
110
|
tilemap(key: string, url: string, options?: TilemapAssetOptions): this;
|
|
111
|
+
/**
|
|
112
|
+
* An LDtk project: the `.ldtk` file, the `.ldtkl` file of each level it saves apart (resolved beside the project),
|
|
113
|
+
* then every tileset image (resolved beside the project, as LDtk writes `relPath`). Counts as one asset, plus one
|
|
114
|
+
* per tileset image. Read it back with `ldtkProject(key)`; each level's `map` goes to `TilemapView` as it is.
|
|
115
|
+
*/
|
|
116
|
+
ldtk(key: string, url: string, options?: LdtkAssetOptions): this;
|
|
117
|
+
/** A loaded LDtk project. */
|
|
118
|
+
ldtkProject(key: string): LdtkProject;
|
|
102
119
|
/**
|
|
103
120
|
* A TexturePacker (or Pixi) JSON atlas, hash or array format: its page image, and for a multipack atlas every page
|
|
104
121
|
* named in `meta.related_multi_packs` (each resolved beside the file naming it). The first page is the texture
|
|
@@ -132,8 +149,11 @@ export declare class AssetLoader {
|
|
|
132
149
|
/** A loaded Tiled map. */
|
|
133
150
|
map(key: string): TileMap;
|
|
134
151
|
private add;
|
|
152
|
+
private full;
|
|
135
153
|
private request;
|
|
136
154
|
private blob;
|
|
155
|
+
/** An image file decoded into a canvas; a file that is not an image fails naming its URL. */
|
|
156
|
+
private canvas;
|
|
137
157
|
private bytes;
|
|
138
158
|
private decode;
|
|
139
159
|
}
|