You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
107 lines
2.9 KiB
107 lines
2.9 KiB
import { generateMatrixRotations } from "../../core/utils";
|
|
import { enumDirection, Vector } from "../../core/vector";
|
|
import { ACHIEVEMENTS } from "../../platform/achievement_provider";
|
|
import { ItemAcceptorComponent } from "../components/item_acceptor";
|
|
import { enumItemProcessorTypes, ItemProcessorComponent } from "../components/item_processor";
|
|
import { Entity } from "../entity";
|
|
import { defaultBuildingVariant, MetaBuilding } from "../meta_building";
|
|
import { GameRoot } from "../root";
|
|
import { enumHubGoalRewards } from "../tutorial_goals";
|
|
|
|
const overlayMatrix = generateMatrixRotations([1, 1, 0, 1, 1, 1, 0, 1, 1]);
|
|
|
|
export class MetaTrashBuilding extends MetaBuilding {
|
|
constructor() {
|
|
super("trash");
|
|
}
|
|
|
|
static getAllVariantCombinations() {
|
|
return [
|
|
{
|
|
internalId: 20,
|
|
variant: defaultBuildingVariant,
|
|
},
|
|
];
|
|
}
|
|
|
|
getIsRotateable() {
|
|
return false;
|
|
}
|
|
|
|
getSilhouetteColor() {
|
|
return "#ed1d5d";
|
|
}
|
|
|
|
getDimensions() {
|
|
return new Vector(1, 1);
|
|
}
|
|
|
|
getSpecialOverlayRenderMatrix(rotation) {
|
|
return overlayMatrix[rotation];
|
|
}
|
|
|
|
/**
|
|
* @param {GameRoot} root
|
|
*/
|
|
getIsUnlocked(root) {
|
|
return root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_cutter_and_trash);
|
|
}
|
|
|
|
addAchievementReceiver(entity) {
|
|
if (!entity.root) {
|
|
return;
|
|
}
|
|
|
|
const itemProcessor = entity.components.ItemProcessor;
|
|
const tryTakeItem = itemProcessor.tryTakeItem.bind(itemProcessor);
|
|
|
|
itemProcessor.tryTakeItem = () => {
|
|
const taken = tryTakeItem(...arguments);
|
|
|
|
if (taken) {
|
|
entity.root.signals.achievementCheck.dispatch(ACHIEVEMENTS.trash1000, 1);
|
|
}
|
|
|
|
return taken;
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Creates the entity at the given location
|
|
* @param {Entity} entity
|
|
*/
|
|
setupEntityComponents(entity) {
|
|
entity.addComponent(
|
|
new ItemAcceptorComponent({
|
|
slots: [
|
|
{
|
|
pos: new Vector(0, 0),
|
|
direction: enumDirection.top,
|
|
},
|
|
{
|
|
pos: new Vector(0, 0),
|
|
direction: enumDirection.right,
|
|
},
|
|
{
|
|
pos: new Vector(0, 0),
|
|
direction: enumDirection.bottom,
|
|
},
|
|
{
|
|
pos: new Vector(0, 0),
|
|
direction: enumDirection.left,
|
|
},
|
|
],
|
|
})
|
|
);
|
|
|
|
entity.addComponent(
|
|
new ItemProcessorComponent({
|
|
inputsPerCharge: 1,
|
|
processorType: enumItemProcessorTypes.trash,
|
|
})
|
|
);
|
|
|
|
this.addAchievementReceiver(entity);
|
|
}
|
|
}
|