1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2026-03-02 03:39:21 +00:00

Improve item ejector system

This commit is contained in:
tobspr
2020-09-18 18:32:53 +02:00
parent c0c624135b
commit 746f4935ad
2 changed files with 47 additions and 92 deletions

View File

@@ -40,9 +40,9 @@ export class StaleAreaDetector {
* Makes this detector recompute the area of an entity whenever
* it changes in any way
* @param {Array<typeof Component>} components
* @param {number} tilesAround
* @param {number} tilesAround How many tiles arround to expand the area
*/
recomputeOnComponentsChanged(components, tilesAround = 1) {
recomputeOnComponentsChanged(components, tilesAround) {
const componentIds = components.map(component => component.getId());
/**
@@ -50,6 +50,10 @@ export class StaleAreaDetector {
* @param {Entity} entity
*/
const checker = entity => {
if (!this.root.gameInitialized) {
return;
}
// Check for all components
for (let i = 0; i < componentIds.length; ++i) {
if (entity.components[componentIds[i]]) {