Handle blob removal in spawn system

This commit is contained in:
Daddy32
2025-12-15 18:04:32 +01:00
parent 466bed56dd
commit 946c73d933
2 changed files with 17 additions and 1 deletions

View File

@@ -529,7 +529,7 @@
clearedByColor[key] = (clearedByColor[key] || 0) + 1;
}
});
removeBlob(id);
spawnSystem.removeBlob(id);
});
// Remove cleared balls from tracking list.
for (let i = balls.length - 1; i >= 0; i -= 1) {

View File

@@ -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 = () => {
spawnCount = 0;
};
@@ -465,6 +480,7 @@
updateBallRadius,
computeBallRadius,
cleanupBall,
removeBlob,
resetSpawnState,
};
};