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.
tobspr_shapez.io/src/js/game/buildings/wire_tunnel.js

88 lines
2.1 KiB

import { Vector } from "../../core/vector";
import { Entity } from "../entity";
4 years ago
import { MetaBuilding, defaultBuildingVariant } from "../meta_building";
import { GameRoot } from "../root";
import { WireTunnelComponent } from "../components/wire_tunnel";
4 years ago
import { generateMatrixRotations } from "../../core/utils";
/** @enum {string} */
export const enumWireTunnelVariants = {
coating: "coating",
};
const wireTunnelOverlayMatrices = {
[defaultBuildingVariant]: generateMatrixRotations([0, 1, 0, 1, 1, 1, 0, 1, 0]),
[enumWireTunnelVariants.coating]: generateMatrixRotations([0, 1, 0, 0, 1, 0, 0, 1, 0]),
};
export class MetaWireTunnelBuilding extends MetaBuilding {
constructor() {
super("wire_tunnel");
}
getSilhouetteColor() {
4 years ago
return "#777a86";
}
/**
* @param {GameRoot} root
*/
getIsUnlocked(root) {
// @todo
return true;
}
4 years ago
/**
*
* @param {number} rotation
* @param {number} rotationVariant
* @param {string} variant
* @param {Entity} entity
*/
getSpecialOverlayRenderMatrix(rotation, rotationVariant, variant, entity) {
return wireTunnelOverlayMatrices[variant][rotation];
}
getIsRotateable(variant) {
return variant !== defaultBuildingVariant;
}
getDimensions() {
return new Vector(1, 1);
}
4 years ago
getAvailableVariants() {
return [defaultBuildingVariant, enumWireTunnelVariants.coating];
}
/** @returns {"wires"} **/
getLayer() {
return "wires";
}
4 years ago
getRotateAutomaticallyWhilePlacing() {
return true;
}
getStayInPlacementMode() {
return true;
}
/**
* Creates the entity at the given location
* @param {Entity} entity
*/
setupEntityComponents(entity) {
4 years ago
entity.addComponent(new WireTunnelComponent({}));
}
/**
* @param {Entity} entity
* @param {number} rotationVariant
* @param {string} variant
*/
updateVariants(entity, rotationVariant, variant) {
entity.components.WireTunnel.multipleDirections = variant === defaultBuildingVariant;
}
}