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:
55
src/js/game/components/filter.js
Normal file
55
src/js/game/components/filter.js
Normal 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 = [];
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,6 @@ export const enumItemProcessorTypes = {
|
||||
/** @enum {string} */
|
||||
export const enumItemProcessorRequirements = {
|
||||
painterQuad: "painterQuad",
|
||||
filter: "filter",
|
||||
};
|
||||
|
||||
/** @typedef {{
|
||||
|
||||
Reference in New Issue
Block a user