mirror of
https://github.com/tobspr/shapez.io.git
synced 2024-10-27 20:34:29 +00:00
Simplify hub component
This commit is contained in:
parent
b3fffe340d
commit
08a5b9070d
@ -6,27 +6,4 @@ export class HubComponent extends Component {
|
|||||||
static getId() {
|
static getId() {
|
||||||
return "Hub";
|
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -17,21 +17,7 @@ export class HubSystem extends GameSystemWithFilter {
|
|||||||
this.forEachMatchingEntityOnScreen(parameters, this.drawEntity.bind(this));
|
this.forEachMatchingEntityOnScreen(parameters, this.drawEntity.bind(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
update() {
|
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 = [];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {DrawParameters} parameters
|
* @param {DrawParameters} parameters
|
||||||
|
@ -348,7 +348,7 @@ export class ItemProcessorSystem extends GameSystemWithFilter {
|
|||||||
|
|
||||||
for (let i = 0; i < items.length; ++i) {
|
for (let i = 0; i < items.length; ++i) {
|
||||||
const shapeItem = /** @type {ShapeItem} */ (items[i].item);
|
const shapeItem = /** @type {ShapeItem} */ (items[i].item);
|
||||||
hubComponent.queueShapeDefinition(shapeItem.definition);
|
this.root.hubGoals.handleDefinitionDelivered(shapeItem.definition);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user