Handle blob removal in spawn system
This commit is contained in:
@@ -529,7 +529,7 @@
|
|||||||
clearedByColor[key] = (clearedByColor[key] || 0) + 1;
|
clearedByColor[key] = (clearedByColor[key] || 0) + 1;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
removeBlob(id);
|
spawnSystem.removeBlob(id);
|
||||||
});
|
});
|
||||||
// Remove cleared balls from tracking list.
|
// Remove cleared balls from tracking list.
|
||||||
for (let i = balls.length - 1; i >= 0; i -= 1) {
|
for (let i = balls.length - 1; i >= 0; i -= 1) {
|
||||||
|
|||||||
16
src/spawn.js
16
src/spawn.js
@@ -452,6 +452,21 @@
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const removeBlob = (blobId) => {
|
||||||
|
if (!blobId) return;
|
||||||
|
const constraints = blobConstraints.get(blobId) || [];
|
||||||
|
constraints.forEach((c) => World.remove(world, c));
|
||||||
|
blobConstraints.delete(blobId);
|
||||||
|
for (let i = balls.length - 1; i >= 0; i -= 1) {
|
||||||
|
const ball = balls[i];
|
||||||
|
if (ball.plugin?.blobId === blobId) {
|
||||||
|
cleanupBall(ball);
|
||||||
|
World.remove(world, ball);
|
||||||
|
balls.splice(i, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const resetSpawnState = () => {
|
const resetSpawnState = () => {
|
||||||
spawnCount = 0;
|
spawnCount = 0;
|
||||||
};
|
};
|
||||||
@@ -465,6 +480,7 @@
|
|||||||
updateBallRadius,
|
updateBallRadius,
|
||||||
computeBallRadius,
|
computeBallRadius,
|
||||||
cleanupBall,
|
cleanupBall,
|
||||||
|
removeBlob,
|
||||||
resetSpawnState,
|
resetSpawnState,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user