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

Add item filter

This commit is contained in:
tobspr
2020-08-13 20:30:43 +02:00
parent 984bea1921
commit f44563fc05
26 changed files with 1149 additions and 885 deletions

View File

@@ -283,6 +283,16 @@ export class ItemEjectorSystem extends GameSystemWithFilter {
const itemProcessorComp = receiver.components.ItemProcessor;
if (itemProcessorComp) {
// @todo HACK
// Check if there are pins, and if so if they are connected
const pinsComp = receiver.components.WiredPins;
if (pinsComp && pinsComp.slots.length === 1) {
const network = pinsComp.slots[0].linkedNetwork;
if (!network || !network.currentValue) {
return false;
}
}
// Its an item processor ..
if (itemProcessorComp.tryTakeItem(item, slotIndex)) {
return true;

View File

@@ -1,9 +1,10 @@
import { globalConfig } from "../../core/config";
import { BaseItem, enumItemType } from "../base_item";
import { BaseItem } from "../base_item";
import { enumColorMixingResults } from "../colors";
import { enumItemProcessorTypes, ItemProcessorComponent } from "../components/item_processor";
import { Entity } from "../entity";
import { GameSystemWithFilter } from "../game_system_with_filter";
import { BOOL_TRUE_SINGLETON } from "../items/boolean_item";
import { ColorItem } from "../items/color_item";
import { ShapeItem } from "../items/shape_item";
@@ -329,6 +330,38 @@ export class ItemProcessorSystem extends GameSystemWithFilter {
break;
}
// FILTER
case enumItemProcessorTypes.filter: {
// TODO
trackProduction = false;
const item = itemsBySlot[0].item;
const network = entity.components.WiredPins.slots[0].linkedNetwork;
if (!network || !network.currentValue) {
outItems.push({
item,
requiredSlot: 1,
});
break;
}
const value = network.currentValue;
if (value.equals(BOOL_TRUE_SINGLETON) || value.equals(item)) {
outItems.push({
item,
requiredSlot: 0,
});
} else {
outItems.push({
item,
requiredSlot: 1,
});
}
break;
}
// HUB
case enumItemProcessorTypes.hub: {