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

Refactor filters to make them not stall if one output is blocked

This commit is contained in:
tobspr
2020-09-19 19:30:04 +02:00
parent 518d9b9f6f
commit 26cd38b68c
16 changed files with 471 additions and 365 deletions

View File

@@ -0,0 +1,55 @@
import { types } from "../../savegame/serialization";
import { BaseItem } from "../base_item";
import { Component } from "../component";
import { typeItemSingleton } from "../item_resolver";
/**
* @typedef {{
* item: BaseItem,
* progress: number
* }} PendingFilterItem
*/
export class FilterComponent extends Component {
static getId() {
return "Filter";
}
duplicateWithoutContents() {
return new FilterComponent();
}
static getSchema() {
return {
pendingItemsToLeaveThrough: types.array(
types.structured({
item: typeItemSingleton,
progress: types.ufloat,
})
),
pendingItemsToReject: types.array(
types.structured({
item: typeItemSingleton,
progress: types.ufloat,
})
),
};
}
constructor() {
super();
/**
* Items in queue to leave through
* @type {Array<PendingFilterItem>}
*/
this.pendingItemsToLeaveThrough = [];
/**
* Items in queue to reject
* @type {Array<PendingFilterItem>}
*/
this.pendingItemsToReject = [];
}
}

View File

@@ -24,7 +24,6 @@ export const enumItemProcessorTypes = {
/** @enum {string} */
export const enumItemProcessorRequirements = {
painterQuad: "painterQuad",
filter: "filter",
};
/** @typedef {{