2020-05-09 14:45:23 +00:00
|
|
|
import { globalConfig } from "../../core/config";
|
|
|
|
import { enumDirection, Vector } from "../../core/vector";
|
|
|
|
import { ItemAcceptorComponent } from "../components/item_acceptor";
|
|
|
|
import { ItemEjectorComponent } from "../components/item_ejector";
|
|
|
|
import { enumItemProcessorTypes, ItemProcessorComponent } from "../components/item_processor";
|
|
|
|
import { Entity } from "../entity";
|
2020-05-16 20:45:40 +00:00
|
|
|
import { MetaBuilding, defaultBuildingVariant } from "../meta_building";
|
2020-05-09 14:45:23 +00:00
|
|
|
import { GameRoot } from "../root";
|
|
|
|
import { enumHubGoalRewards } from "../tutorial_goals";
|
|
|
|
|
2020-05-16 20:45:40 +00:00
|
|
|
/** @enum {string} */
|
|
|
|
export const enumSplitterVariants = { compact: "compact" };
|
|
|
|
|
2020-05-09 14:45:23 +00:00
|
|
|
export class MetaSplitterBuilding extends MetaBuilding {
|
|
|
|
constructor() {
|
|
|
|
super("splitter");
|
|
|
|
}
|
|
|
|
|
2020-05-16 20:45:40 +00:00
|
|
|
getDimensions(variant) {
|
|
|
|
switch (variant) {
|
|
|
|
case defaultBuildingVariant:
|
|
|
|
return new Vector(2, 1);
|
|
|
|
case enumSplitterVariants.compact:
|
|
|
|
return new Vector(1, 1);
|
|
|
|
default:
|
|
|
|
assertAlways(false, "Unknown splitter variant: " + variant);
|
|
|
|
}
|
2020-05-09 14:45:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
getSilhouetteColor() {
|
|
|
|
return "#444";
|
|
|
|
}
|
|
|
|
|
2020-05-16 20:45:40 +00:00
|
|
|
getAvailableVariants(root) {
|
|
|
|
return [defaultBuildingVariant, enumSplitterVariants.compact];
|
|
|
|
}
|
|
|
|
|
2020-05-09 14:45:23 +00:00
|
|
|
/**
|
|
|
|
* @param {GameRoot} root
|
|
|
|
*/
|
|
|
|
getIsUnlocked(root) {
|
|
|
|
return root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_splitter);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates the entity at the given location
|
|
|
|
* @param {Entity} entity
|
|
|
|
*/
|
|
|
|
setupEntityComponents(entity) {
|
|
|
|
entity.addComponent(
|
|
|
|
new ItemAcceptorComponent({
|
|
|
|
slots: [
|
|
|
|
{
|
|
|
|
pos: new Vector(0, 0),
|
|
|
|
directions: [enumDirection.bottom],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
pos: new Vector(1, 0),
|
|
|
|
directions: [enumDirection.bottom],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
})
|
|
|
|
);
|
|
|
|
|
|
|
|
entity.addComponent(
|
|
|
|
new ItemProcessorComponent({
|
|
|
|
inputsPerCharge: 1,
|
|
|
|
processorType: enumItemProcessorTypes.splitter,
|
|
|
|
})
|
|
|
|
);
|
|
|
|
|
|
|
|
entity.addComponent(
|
|
|
|
new ItemEjectorComponent({
|
|
|
|
slots: [
|
|
|
|
{ pos: new Vector(0, 0), direction: enumDirection.top },
|
|
|
|
{ pos: new Vector(1, 0), direction: enumDirection.top },
|
|
|
|
],
|
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
2020-05-16 20:45:40 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param {Entity} entity
|
2020-05-16 21:48:56 +00:00
|
|
|
* @param {number} rotationVariant
|
2020-05-16 20:45:40 +00:00
|
|
|
* @param {string} variant
|
|
|
|
*/
|
2020-05-16 21:48:56 +00:00
|
|
|
updateVariants(entity, rotationVariant, variant) {
|
2020-05-16 20:45:40 +00:00
|
|
|
switch (variant) {
|
|
|
|
case defaultBuildingVariant: {
|
|
|
|
entity.components.ItemAcceptor.setSlots([
|
|
|
|
{
|
|
|
|
pos: new Vector(0, 0),
|
|
|
|
directions: [enumDirection.bottom],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
pos: new Vector(1, 0),
|
|
|
|
directions: [enumDirection.bottom],
|
|
|
|
},
|
|
|
|
]);
|
|
|
|
|
|
|
|
entity.components.ItemEjector.setSlots([
|
|
|
|
{ pos: new Vector(0, 0), direction: enumDirection.top },
|
|
|
|
{ pos: new Vector(1, 0), direction: enumDirection.top },
|
|
|
|
]);
|
|
|
|
|
2020-05-17 08:07:20 +00:00
|
|
|
entity.components.ItemAcceptor.beltUnderlays = [
|
2020-05-16 20:45:40 +00:00
|
|
|
{ pos: new Vector(0, 0), direction: enumDirection.top },
|
|
|
|
{ pos: new Vector(1, 0), direction: enumDirection.top },
|
|
|
|
];
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case enumSplitterVariants.compact: {
|
|
|
|
entity.components.ItemAcceptor.setSlots([
|
|
|
|
{
|
|
|
|
pos: new Vector(0, 0),
|
|
|
|
directions: [enumDirection.bottom],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
pos: new Vector(0, 0),
|
|
|
|
directions: [enumDirection.right],
|
|
|
|
},
|
|
|
|
]);
|
|
|
|
|
|
|
|
entity.components.ItemEjector.setSlots([
|
|
|
|
{ pos: new Vector(0, 0), direction: enumDirection.top },
|
|
|
|
]);
|
|
|
|
|
2020-05-17 08:07:20 +00:00
|
|
|
entity.components.ItemAcceptor.beltUnderlays = [
|
2020-05-16 20:45:40 +00:00
|
|
|
{ pos: new Vector(0, 0), direction: enumDirection.top },
|
|
|
|
];
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
assertAlways(false, "Unknown painter variant: " + variant);
|
|
|
|
}
|
|
|
|
}
|
2020-05-09 14:45:23 +00:00
|
|
|
}
|