Simplify hub component

This commit is contained in:
tobspr 2020-08-10 20:09:04 +02:00
parent b3fffe340d
commit 08a5b9070d
3 changed files with 2 additions and 39 deletions

View File

@ -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<ShapeDefinition>}
*/
this.definitionsToAnalyze = [];
}
/**
* @param {ShapeDefinition} definition
*/
queueShapeDefinition(definition) {
this.definitionsToAnalyze.push(definition);
}
}

View File

@ -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

View File

@ -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;