Add item filter
BIN
res/ui/building_icons/filter.png
Normal file
After Width: | Height: | Size: 5.9 KiB |
Before Width: | Height: | Size: 70 KiB After Width: | Height: | Size: 70 KiB |
Before Width: | Height: | Size: 1.1 MiB After Width: | Height: | Size: 1.2 MiB |
Before Width: | Height: | Size: 217 KiB After Width: | Height: | Size: 223 KiB |
Before Width: | Height: | Size: 532 KiB After Width: | Height: | Size: 538 KiB |
Before Width: | Height: | Size: 997 KiB After Width: | Height: | Size: 1.0 MiB |
BIN
res_raw/sprites/blueprints/filter.png
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
res_raw/sprites/blueprints/logic_gate-or.png
Normal file
After Width: | Height: | Size: 9.5 KiB |
BIN
res_raw/sprites/buildings/filter.png
Normal file
After Width: | Height: | Size: 11 KiB |
@ -1,5 +1,5 @@
|
|||||||
$buildings: belt, cutter, miner, mixer, painter, rotater, splitter, stacker, trash, underground_belt, wire,
|
$buildings: belt, cutter, miner, mixer, painter, rotater, splitter, stacker, trash, underground_belt, wire,
|
||||||
constant_signal, logic_gate, lever;
|
constant_signal, logic_gate, lever, filter;
|
||||||
|
|
||||||
@each $building in $buildings {
|
@each $building in $buildings {
|
||||||
[data-icon="building_icons/#{$building}.png"] {
|
[data-icon="building_icons/#{$building}.png"] {
|
||||||
|
@ -70,6 +70,7 @@ export const globalConfig = {
|
|||||||
mixer: 1 / 5,
|
mixer: 1 / 5,
|
||||||
stacker: 1 / 6,
|
stacker: 1 / 6,
|
||||||
advancedProcessor: 1 / 3,
|
advancedProcessor: 1 / 3,
|
||||||
|
filter: 1,
|
||||||
},
|
},
|
||||||
|
|
||||||
// Zooming
|
// Zooming
|
||||||
|
@ -1182,7 +1182,7 @@ export class BeltPath extends BasicSerializableObject {
|
|||||||
const beltLength = beltComp.getEffectiveLengthTiles();
|
const beltLength = beltComp.getEffectiveLengthTiles();
|
||||||
|
|
||||||
// Check if the current items are on the belt
|
// Check if the current items are on the belt
|
||||||
while (trackPos + beltLength >= currentItemPos - 1e-51) {
|
while (trackPos + beltLength >= currentItemPos - 1e-5) {
|
||||||
// Its on the belt, render it now
|
// Its on the belt, render it now
|
||||||
const staticComp = entity.components.StaticMapEntity;
|
const staticComp = entity.components.StaticMapEntity;
|
||||||
assert(
|
assert(
|
||||||
|
82
src/js/game/buildings/filter.js
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
import { enumDirection, Vector } from "../../core/vector";
|
||||||
|
import { enumPinSlotType, WiredPinsComponent } from "../components/wired_pins";
|
||||||
|
import { Entity } from "../entity";
|
||||||
|
import { MetaBuilding } from "../meta_building";
|
||||||
|
import { GameRoot } from "../root";
|
||||||
|
import { LeverComponent } from "../components/lever";
|
||||||
|
import { ItemAcceptorComponent } from "../components/item_acceptor";
|
||||||
|
import { ItemEjectorComponent } from "../components/item_ejector";
|
||||||
|
import { ItemProcessorComponent, enumItemProcessorTypes } from "../components/item_processor";
|
||||||
|
|
||||||
|
export class MetaFilterBuilding extends MetaBuilding {
|
||||||
|
constructor() {
|
||||||
|
super("filter");
|
||||||
|
}
|
||||||
|
|
||||||
|
getSilhouetteColor() {
|
||||||
|
return "#c45c2e";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {GameRoot} root
|
||||||
|
*/
|
||||||
|
getIsUnlocked(root) {
|
||||||
|
// @todo
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
getDimensions() {
|
||||||
|
return new Vector(2, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates the entity at the given location
|
||||||
|
* @param {Entity} entity
|
||||||
|
*/
|
||||||
|
setupEntityComponents(entity) {
|
||||||
|
entity.addComponent(
|
||||||
|
new WiredPinsComponent({
|
||||||
|
slots: [
|
||||||
|
{
|
||||||
|
pos: new Vector(0, 0),
|
||||||
|
direction: enumDirection.left,
|
||||||
|
type: enumPinSlotType.logicalAcceptor,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
entity.addComponent(
|
||||||
|
new ItemAcceptorComponent({
|
||||||
|
slots: [
|
||||||
|
{
|
||||||
|
pos: new Vector(0, 0),
|
||||||
|
directions: [enumDirection.bottom],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
entity.addComponent(
|
||||||
|
new ItemEjectorComponent({
|
||||||
|
slots: [
|
||||||
|
{
|
||||||
|
pos: new Vector(0, 0),
|
||||||
|
direction: enumDirection.top,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
pos: new Vector(1, 0),
|
||||||
|
direction: enumDirection.right,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
entity.addComponent(
|
||||||
|
new ItemProcessorComponent({
|
||||||
|
processorType: enumItemProcessorTypes.filter,
|
||||||
|
inputsPerCharge: 1,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -19,6 +19,7 @@ export const enumItemProcessorTypes = {
|
|||||||
painterDouble: "painterDouble",
|
painterDouble: "painterDouble",
|
||||||
painterQuad: "painterQuad",
|
painterQuad: "painterQuad",
|
||||||
hub: "hub",
|
hub: "hub",
|
||||||
|
filter: "filter",
|
||||||
};
|
};
|
||||||
|
|
||||||
export class ItemProcessorComponent extends Component {
|
export class ItemProcessorComponent extends Component {
|
||||||
|
@ -404,6 +404,8 @@ export class HubGoals extends BasicSerializableObject {
|
|||||||
return 1e30;
|
return 1e30;
|
||||||
case enumItemProcessorTypes.splitter:
|
case enumItemProcessorTypes.splitter:
|
||||||
return globalConfig.beltSpeedItemsPerSecond * this.upgradeImprovements.belt * 2;
|
return globalConfig.beltSpeedItemsPerSecond * this.upgradeImprovements.belt * 2;
|
||||||
|
case enumItemProcessorTypes.filter:
|
||||||
|
return globalConfig.beltSpeedItemsPerSecond * this.upgradeImprovements.belt;
|
||||||
|
|
||||||
case enumItemProcessorTypes.mixer:
|
case enumItemProcessorTypes.mixer:
|
||||||
case enumItemProcessorTypes.painter:
|
case enumItemProcessorTypes.painter:
|
||||||
|
@ -11,6 +11,7 @@ import { MetaUndergroundBeltBuilding } from "../../buildings/underground_belt";
|
|||||||
import { enumLayer } from "../../root";
|
import { enumLayer } from "../../root";
|
||||||
import { HUDBaseToolbar } from "./base_toolbar";
|
import { HUDBaseToolbar } from "./base_toolbar";
|
||||||
import { MetaLeverBuilding } from "../../buildings/lever";
|
import { MetaLeverBuilding } from "../../buildings/lever";
|
||||||
|
import { MetaFilterBuilding } from "../../buildings/filter";
|
||||||
|
|
||||||
const supportedBuildings = [
|
const supportedBuildings = [
|
||||||
MetaBeltBaseBuilding,
|
MetaBeltBaseBuilding,
|
||||||
@ -24,6 +25,7 @@ const supportedBuildings = [
|
|||||||
MetaPainterBuilding,
|
MetaPainterBuilding,
|
||||||
MetaTrashBuilding,
|
MetaTrashBuilding,
|
||||||
MetaLeverBuilding,
|
MetaLeverBuilding,
|
||||||
|
MetaFilterBuilding,
|
||||||
];
|
];
|
||||||
|
|
||||||
export class HUDBuildingsToolbar extends HUDBaseToolbar {
|
export class HUDBuildingsToolbar extends HUDBaseToolbar {
|
||||||
|
@ -59,6 +59,7 @@ export const KEYMAPPINGS = {
|
|||||||
constant_signal: { keyCode: key("2") },
|
constant_signal: { keyCode: key("2") },
|
||||||
logic_gate: { keyCode: key("3") },
|
logic_gate: { keyCode: key("3") },
|
||||||
lever: { keyCode: key("4") },
|
lever: { keyCode: key("4") },
|
||||||
|
filter: { keyCode: key("5") },
|
||||||
},
|
},
|
||||||
|
|
||||||
placement: {
|
placement: {
|
||||||
|
@ -18,6 +18,7 @@ import { defaultBuildingVariant } from "./meta_building";
|
|||||||
import { MetaConstantSignalBuilding } from "./buildings/constant_signal";
|
import { MetaConstantSignalBuilding } from "./buildings/constant_signal";
|
||||||
import { MetaLogicGateBuilding, enumLogicGateVariants } from "./buildings/logic_gate";
|
import { MetaLogicGateBuilding, enumLogicGateVariants } from "./buildings/logic_gate";
|
||||||
import { MetaLeverBuilding } from "./buildings/lever";
|
import { MetaLeverBuilding } from "./buildings/lever";
|
||||||
|
import { MetaFilterBuilding } from "./buildings/filter";
|
||||||
|
|
||||||
const logger = createLogger("building_registry");
|
const logger = createLogger("building_registry");
|
||||||
|
|
||||||
@ -37,6 +38,7 @@ export function initMetaBuildingRegistry() {
|
|||||||
gMetaBuildingRegistry.register(MetaConstantSignalBuilding);
|
gMetaBuildingRegistry.register(MetaConstantSignalBuilding);
|
||||||
gMetaBuildingRegistry.register(MetaLogicGateBuilding);
|
gMetaBuildingRegistry.register(MetaLogicGateBuilding);
|
||||||
gMetaBuildingRegistry.register(MetaLeverBuilding);
|
gMetaBuildingRegistry.register(MetaLeverBuilding);
|
||||||
|
gMetaBuildingRegistry.register(MetaFilterBuilding);
|
||||||
|
|
||||||
// Belt
|
// Belt
|
||||||
registerBuildingVariant(1, MetaBeltBaseBuilding, defaultBuildingVariant, 0);
|
registerBuildingVariant(1, MetaBeltBaseBuilding, defaultBuildingVariant, 0);
|
||||||
@ -104,6 +106,9 @@ export function initMetaBuildingRegistry() {
|
|||||||
// Lever
|
// Lever
|
||||||
registerBuildingVariant(33, MetaLeverBuilding);
|
registerBuildingVariant(33, MetaLeverBuilding);
|
||||||
|
|
||||||
|
// Filter
|
||||||
|
registerBuildingVariant(37, MetaFilterBuilding);
|
||||||
|
|
||||||
// Propagate instances
|
// Propagate instances
|
||||||
for (const key in gBuildingVariants) {
|
for (const key in gBuildingVariants) {
|
||||||
gBuildingVariants[key].metaInstance = gMetaBuildingRegistry.findByClass(
|
gBuildingVariants[key].metaInstance = gMetaBuildingRegistry.findByClass(
|
||||||
|
@ -283,6 +283,16 @@ export class ItemEjectorSystem extends GameSystemWithFilter {
|
|||||||
|
|
||||||
const itemProcessorComp = receiver.components.ItemProcessor;
|
const itemProcessorComp = receiver.components.ItemProcessor;
|
||||||
if (itemProcessorComp) {
|
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 ..
|
// Its an item processor ..
|
||||||
if (itemProcessorComp.tryTakeItem(item, slotIndex)) {
|
if (itemProcessorComp.tryTakeItem(item, slotIndex)) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
import { globalConfig } from "../../core/config";
|
import { globalConfig } from "../../core/config";
|
||||||
import { BaseItem, enumItemType } from "../base_item";
|
import { BaseItem } from "../base_item";
|
||||||
import { enumColorMixingResults } from "../colors";
|
import { enumColorMixingResults } from "../colors";
|
||||||
import { enumItemProcessorTypes, ItemProcessorComponent } from "../components/item_processor";
|
import { enumItemProcessorTypes, ItemProcessorComponent } from "../components/item_processor";
|
||||||
import { Entity } from "../entity";
|
import { Entity } from "../entity";
|
||||||
import { GameSystemWithFilter } from "../game_system_with_filter";
|
import { GameSystemWithFilter } from "../game_system_with_filter";
|
||||||
|
import { BOOL_TRUE_SINGLETON } from "../items/boolean_item";
|
||||||
import { ColorItem } from "../items/color_item";
|
import { ColorItem } from "../items/color_item";
|
||||||
import { ShapeItem } from "../items/shape_item";
|
import { ShapeItem } from "../items/shape_item";
|
||||||
|
|
||||||
@ -329,6 +330,38 @@ export class ItemProcessorSystem extends GameSystemWithFilter {
|
|||||||
break;
|
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
|
// HUB
|
||||||
|
|
||||||
case enumItemProcessorTypes.hub: {
|
case enumItemProcessorTypes.hub: {
|
||||||
|
@ -574,6 +574,12 @@ buildings:
|
|||||||
name: OR
|
name: OR
|
||||||
description: Emits a truthy signal if one of the inputs is truthy.
|
description: Emits a truthy signal if one of the inputs is truthy.
|
||||||
|
|
||||||
|
filter:
|
||||||
|
default:
|
||||||
|
name: &filter Filter
|
||||||
|
# TEMP
|
||||||
|
description: Only leaves through items who match exactly the provided shape / color. If you put in a boolean 1, it leaves everything through, if you put in a 0 it will leave nothing through.
|
||||||
|
|
||||||
storyRewards:
|
storyRewards:
|
||||||
# Those are the rewards gained from completing the store
|
# Those are the rewards gained from completing the store
|
||||||
reward_cutter_and_trash:
|
reward_cutter_and_trash:
|
||||||
@ -845,6 +851,7 @@ keybindings:
|
|||||||
constant_signal: *constant_signal
|
constant_signal: *constant_signal
|
||||||
logic_gate: *logic_gate
|
logic_gate: *logic_gate
|
||||||
lever: *lever
|
lever: *lever
|
||||||
|
filter: *filter
|
||||||
# ---
|
# ---
|
||||||
|
|
||||||
pipette: Pipette
|
pipette: Pipette
|
||||||
|