fix: napalm flows whenever there is free space
This commit is contained in:
1 parent
95565f996d
commit
f11c6f888e
1 file changed
+19
-2
+19
-2
@@ -887,7 +887,7 @@ export function spawnNapalm(x, y, totalParticles, source) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function tryEmitParticle(x, y, source) {
|
function tryEmitParticle(x, y, source) {
|
||||||
const p = {x, y, dir: 0, hasDir: false, alive: true, source, emitX: x, emitY: y};
|
const p = {x, y, dir: 0, hasDir: false, alive: true, source, emitX: x, emitY: y, settleTime: 0};
|
||||||
|
|
||||||
const below = isTerrain(terrain, p.x, p.y + 1);
|
const below = isTerrain(terrain, p.x, p.y + 1);
|
||||||
if (!below) return p;
|
if (!below) return p;
|
||||||
@@ -1071,6 +1071,7 @@ function trySpill(p, dir) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function updateParticle(p) {
|
function updateParticle(p) {
|
||||||
|
const prevX = p.x, prevY = p.y;
|
||||||
const below = isTerrain(terrain, p.x, p.y + 1) || isTank(p.x, p.y + 1);
|
const below = isTerrain(terrain, p.x, p.y + 1) || isTank(p.x, p.y + 1);
|
||||||
const napalmBelow = hasNapalmAt(p.x, p.y + 1, p);
|
const napalmBelow = hasNapalmAt(p.x, p.y + 1, p);
|
||||||
|
|
||||||
@@ -1154,7 +1155,7 @@ function updateParticle(p) {
|
|||||||
if (tryFlow(p, p.dir) || trySpill(p, p.dir)) return;
|
if (tryFlow(p, p.dir) || trySpill(p, p.dir)) return;
|
||||||
|
|
||||||
const otherDir = p.dir === -1 ? 1 : -1;
|
const otherDir = p.dir === -1 ? 1 : -1;
|
||||||
if (tryFlow(p, otherDir)) {
|
if (tryFlow(p, otherDir) || trySpill(p, otherDir)) {
|
||||||
p.dir = otherDir;
|
p.dir = otherDir;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1162,6 +1163,22 @@ function updateParticle(p) {
|
|||||||
if (p.x === p.emitX && p.y === p.emitY) {
|
if (p.x === p.emitX && p.y === p.emitY) {
|
||||||
pushNapalmColumn(p.x, p.y - 1);
|
pushNapalmColumn(p.x, p.y - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Settle time: spread fire to adjacent terrain if stationary >= 1s
|
||||||
|
if (p.x !== prevX || p.y !== prevY) {
|
||||||
|
p.settleTime = 0;
|
||||||
|
} else {
|
||||||
|
p.settleTime += dt;
|
||||||
|
}
|
||||||
|
if (p.settleTime >= 1) {
|
||||||
|
[p.x - 1, p.x + 1].forEach(nx => {
|
||||||
|
if (isTerrain(terrain, nx, p.y) && !hasFireAt(nx, p.y)) {
|
||||||
|
createFire(nx, p.y, p.source);
|
||||||
|
p.alive = false;
|
||||||
|
reservedPositions.delete(p.x + ',' + p.y);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function applyFireDamage(dt) {
|
function applyFireDamage(dt) {
|
||||||
|
|||||||
Reference in new issue
Block a user