@adatechnology/game-terrain 0.9.11 → 0.9.12
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 +2 -0
- package/dist/index.global.js +26 -2
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +26 -2
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -541,6 +541,8 @@ interface Terrain {
|
|
|
541
541
|
/** Changes whenever a crack is added or grows, so a renderer redraws only then. */
|
|
542
542
|
readonly cracksVersion: number;
|
|
543
543
|
debris(): readonly TerrainDebris[];
|
|
544
|
+
/** Changes whenever a debris piece is thrown, moves or leaves, so a renderer rewrites the pieces only then (a pile at rest costs nothing per frame). */
|
|
545
|
+
readonly debrisVersion: number;
|
|
544
546
|
/** Cells on fire now, as world points. */
|
|
545
547
|
burningPoints(): readonly (readonly [number, number])[];
|
|
546
548
|
/** Goes up when the marks change. */
|
package/dist/index.global.js
CHANGED
|
@@ -545,6 +545,7 @@ var GameTerrain = (() => {
|
|
|
545
545
|
function createDebrisStore(max) {
|
|
546
546
|
const list = [];
|
|
547
547
|
let serial = 0;
|
|
548
|
+
let version = 0;
|
|
548
549
|
function makeRoom() {
|
|
549
550
|
if (list.length < max()) return;
|
|
550
551
|
let at = 0;
|
|
@@ -565,7 +566,11 @@ var GameTerrain = (() => {
|
|
|
565
566
|
}
|
|
566
567
|
return {
|
|
567
568
|
list,
|
|
569
|
+
get version() {
|
|
570
|
+
return version;
|
|
571
|
+
},
|
|
568
572
|
throwPiece(spec) {
|
|
573
|
+
version++;
|
|
569
574
|
makeRoom();
|
|
570
575
|
list.push({ ...spec, id: ++serial, born: serial, atRest: false, bounces: 0 });
|
|
571
576
|
},
|
|
@@ -575,9 +580,13 @@ var GameTerrain = (() => {
|
|
|
575
580
|
if (piece.atRest) {
|
|
576
581
|
const under = world.heightAt(piece.position[0], piece.position[2]) + piece.radius * 0.6;
|
|
577
582
|
if (piece.position[1] > under + REST_GAP) piece.atRest = false;
|
|
578
|
-
else if (piece.position[1] < under - REST_GAP)
|
|
583
|
+
else if (piece.position[1] < under - REST_GAP) {
|
|
584
|
+
piece.position[1] = under;
|
|
585
|
+
version++;
|
|
586
|
+
}
|
|
579
587
|
if (piece.atRest) continue;
|
|
580
588
|
}
|
|
589
|
+
version++;
|
|
581
590
|
const { position, velocity } = piece;
|
|
582
591
|
velocity[1] -= world.gravity * dt;
|
|
583
592
|
position[0] += velocity[0] * dt;
|
|
@@ -599,6 +608,7 @@ var GameTerrain = (() => {
|
|
|
599
608
|
}
|
|
600
609
|
},
|
|
601
610
|
clear() {
|
|
611
|
+
version++;
|
|
602
612
|
list.length = 0;
|
|
603
613
|
serial = 0;
|
|
604
614
|
}
|
|
@@ -1804,8 +1814,19 @@ var GameTerrain = (() => {
|
|
|
1804
1814
|
if (scorch[index] >= 1) return;
|
|
1805
1815
|
burning.set(key, FIRE_SECONDS);
|
|
1806
1816
|
}
|
|
1817
|
+
const fireKeys = [];
|
|
1818
|
+
const fireLeft = [];
|
|
1819
|
+
const keepFireCell = (remaining, key) => {
|
|
1820
|
+
fireKeys.push(key);
|
|
1821
|
+
fireLeft.push(remaining);
|
|
1822
|
+
};
|
|
1807
1823
|
function updateFire(dt) {
|
|
1808
|
-
|
|
1824
|
+
fireKeys.length = 0;
|
|
1825
|
+
fireLeft.length = 0;
|
|
1826
|
+
burning.forEach(keepFireCell);
|
|
1827
|
+
for (let cell = 0; cell < fireKeys.length; cell++) {
|
|
1828
|
+
const key = fireKeys[cell];
|
|
1829
|
+
const remaining = fireLeft[cell];
|
|
1809
1830
|
const cellRow = Math.floor(key / 65536);
|
|
1810
1831
|
const cellColumn = key - cellRow * 65536;
|
|
1811
1832
|
const x = x0 + (cellColumn + 0.5) * FIRE_CELL;
|
|
@@ -2071,6 +2092,9 @@ var GameTerrain = (() => {
|
|
|
2071
2092
|
return cracks.version;
|
|
2072
2093
|
},
|
|
2073
2094
|
debris: () => debrisStore.list,
|
|
2095
|
+
get debrisVersion() {
|
|
2096
|
+
return debrisStore.version;
|
|
2097
|
+
},
|
|
2074
2098
|
burningPoints: () => [...burning.keys()].map((key) => {
|
|
2075
2099
|
const cellRow = Math.floor(key / 65536);
|
|
2076
2100
|
const cellColumn = key - cellRow * 65536;
|