1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2025-06-13 13:04:03 +00:00
tobspr_shapez.io/src/js/game/buildings/constant_signal.js

64 lines
1.7 KiB
JavaScript
Raw Normal View History

2020-08-29 19:45:32 +00:00
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 { ConstantSignalComponent } from "../components/constant_signal";
2020-09-24 10:53:40 +00:00
import { generateMatrixRotations } from "../../core/utils";
import { enumHubGoalRewards } from "../tutorial_goals";
2020-09-24 10:53:40 +00:00
const overlayMatrix = generateMatrixRotations([0, 1, 0, 1, 1, 1, 1, 1, 1]);
2020-08-29 19:45:32 +00:00
export class MetaConstantSignalBuilding extends MetaBuilding {
constructor() {
super("constant_signal");
}
getSilhouetteColor() {
2020-09-24 10:53:40 +00:00
return "#2b84fd";
2020-08-29 19:45:32 +00:00
}
/**
* @param {GameRoot} root
*/
getIsUnlocked(root) {
return root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_constant_signal);
2020-08-29 19:45:32 +00:00
}
/** @returns {"wires"} **/
getLayer() {
return "wires";
}
getDimensions() {
return new Vector(1, 1);
}
getRenderPins() {
return false;
}
2020-09-24 10:53:40 +00:00
getSpecialOverlayRenderMatrix(rotation) {
return overlayMatrix[rotation];
}
2020-08-29 19:45:32 +00: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.top,
type: enumPinSlotType.logicalEjector,
},
],
})
);
entity.addComponent(new ConstantSignalComponent({}));
}
}