2020-09-24 17:43:50 +02:00
|
|
|
import { formatItemsPerSecond } from "../../core/utils";
|
2020-08-29 09:35:14 +02:00
|
|
|
import { enumDirection, Vector } from "../../core/vector";
|
2020-09-24 17:43:50 +02:00
|
|
|
import { T } from "../../translations";
|
2020-09-19 19:30:04 +02:00
|
|
|
import { FilterComponent } from "../components/filter";
|
2020-08-29 09:35:14 +02:00
|
|
|
import { ItemAcceptorComponent } from "../components/item_acceptor";
|
|
|
|
import { ItemEjectorComponent } from "../components/item_ejector";
|
2020-08-29 10:38:23 +02:00
|
|
|
import { enumPinSlotType, WiredPinsComponent } from "../components/wired_pins";
|
|
|
|
import { Entity } from "../entity";
|
|
|
|
import { MetaBuilding } from "../meta_building";
|
|
|
|
import { GameRoot } from "../root";
|
2020-09-23 09:24:25 +02:00
|
|
|
import { enumHubGoalRewards } from "../tutorial_goals";
|
2020-08-29 09:35:14 +02:00
|
|
|
|
|
|
|
export class MetaFilterBuilding extends MetaBuilding {
|
|
|
|
constructor() {
|
|
|
|
super("filter");
|
|
|
|
}
|
|
|
|
|
|
|
|
getSilhouetteColor() {
|
|
|
|
return "#c45c2e";
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {GameRoot} root
|
|
|
|
*/
|
|
|
|
getIsUnlocked(root) {
|
2020-09-23 09:24:25 +02:00
|
|
|
return root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_wires_filters_and_levers);
|
2020-08-29 09:35:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
getDimensions() {
|
|
|
|
return new Vector(2, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
getShowWiresLayerPreview() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-09-24 17:43:50 +02:00
|
|
|
/**
|
|
|
|
* @param {GameRoot} root
|
|
|
|
* @param {string} variant
|
|
|
|
* @returns {Array<[string, string]>}
|
|
|
|
*/
|
|
|
|
getAdditionalStatistics(root, variant) {
|
|
|
|
const beltSpeed = root.hubGoals.getBeltBaseSpeed();
|
|
|
|
return [[T.ingame.buildingPlacement.infoTexts.speed, formatItemsPerSecond(beltSpeed)]];
|
|
|
|
}
|
|
|
|
|
2020-08-29 09:35:14 +02:00
|
|
|
/**
|
|
|
|
* 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,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
})
|
|
|
|
);
|
|
|
|
|
2020-09-19 19:30:04 +02:00
|
|
|
entity.addComponent(new FilterComponent());
|
2020-08-29 09:35:14 +02:00
|
|
|
}
|
|
|
|
}
|