From 08a5b9070dd357956f2a14fb38d24805b65bc42b Mon Sep 17 00:00:00 2001 From: tobspr Date: Mon, 10 Aug 2020 20:09:04 +0200 Subject: [PATCH] Simplify hub component --- src/js/game/components/hub.js | 23 ----------------------- src/js/game/systems/hub.js | 16 +--------------- src/js/game/systems/item_processor.js | 2 +- 3 files changed, 2 insertions(+), 39 deletions(-) diff --git a/src/js/game/components/hub.js b/src/js/game/components/hub.js index f9c13dc3..e038cf3e 100644 --- a/src/js/game/components/hub.js +++ b/src/js/game/components/hub.js @@ -6,27 +6,4 @@ export class HubComponent extends Component { static getId() { return "Hub"; } - - static getSchema() { - return { - definitionsToAnalyze: types.array(types.knownType(ShapeDefinition)), - }; - } - - constructor() { - super(); - - /** - * Shape definitions in queue to be analyzed and counted towards the goal - * @type {Array} - */ - this.definitionsToAnalyze = []; - } - - /** - * @param {ShapeDefinition} definition - */ - queueShapeDefinition(definition) { - this.definitionsToAnalyze.push(definition); - } } diff --git a/src/js/game/systems/hub.js b/src/js/game/systems/hub.js index f1d4ee28..5050b16a 100644 --- a/src/js/game/systems/hub.js +++ b/src/js/game/systems/hub.js @@ -17,21 +17,7 @@ export class HubSystem extends GameSystemWithFilter { this.forEachMatchingEntityOnScreen(parameters, this.drawEntity.bind(this)); } - update() { - for (let i = 0; i < this.allEntities.length; ++i) { - const entity = this.allEntities[i]; - - const hubComponent = entity.components.Hub; - - const queue = hubComponent.definitionsToAnalyze; - for (let k = 0; k < queue.length; ++k) { - const definition = queue[k]; - this.root.hubGoals.handleDefinitionDelivered(definition); - } - - hubComponent.definitionsToAnalyze = []; - } - } + update() {} /** * @param {DrawParameters} parameters diff --git a/src/js/game/systems/item_processor.js b/src/js/game/systems/item_processor.js index 5bebfed7..582ea8fe 100644 --- a/src/js/game/systems/item_processor.js +++ b/src/js/game/systems/item_processor.js @@ -348,7 +348,7 @@ export class ItemProcessorSystem extends GameSystemWithFilter { for (let i = 0; i < items.length; ++i) { const shapeItem = /** @type {ShapeItem} */ (items[i].item); - hubComponent.queueShapeDefinition(shapeItem.definition); + this.root.hubGoals.handleDefinitionDelivered(shapeItem.definition); } break;