1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2024-10-27 20:34:29 +00:00
tobspr_shapez.io/src/js/game/buildings/hub.js

143 lines
4.6 KiB
JavaScript
Raw Normal View History

2020-05-09 14:45:23 +00:00
import { enumDirection, Vector } from "../../core/vector";
import { enumItemType } from "../base_item";
import { HubComponent } from "../components/hub";
import { ItemAcceptorComponent } from "../components/item_acceptor";
import { enumItemProcessorTypes, ItemProcessorComponent } from "../components/item_processor";
2020-05-09 14:45:23 +00:00
import { Entity } from "../entity";
import { MetaBuilding } from "../meta_building";
2020-08-10 13:02:49 +00:00
import { WiredPinsComponent, enumPinSlotType } from "../components/wired_pins";
2020-05-09 14:45:23 +00:00
export class MetaHubBuilding extends MetaBuilding {
constructor() {
super("hub");
}
getDimensions() {
return new Vector(4, 4);
}
getSilhouetteColor() {
return "#eb5555";
}
isRotateable() {
return false;
}
2020-05-27 12:30:59 +00:00
getBlueprintSprite() {
return null;
}
getSprite() {
// We render it ourself
return null;
}
getIsRemovable() {
return false;
}
2020-05-09 14:45:23 +00:00
/**
* Creates the entity at the given location
* @param {Entity} entity
*/
setupEntityComponents(entity) {
entity.addComponent(new HubComponent());
entity.addComponent(
new ItemProcessorComponent({
inputsPerCharge: 1,
processorType: enumItemProcessorTypes.hub,
})
);
2020-05-17 08:07:20 +00:00
2020-08-10 13:02:49 +00:00
entity.addComponent(
new WiredPinsComponent({
slots: [
{
pos: new Vector(0, 0),
type: enumPinSlotType.logicalEjector,
direction: enumDirection.top,
},
],
})
);
2020-05-09 14:45:23 +00:00
entity.addComponent(
new ItemAcceptorComponent({
slots: [
{
pos: new Vector(0, 0),
directions: [enumDirection.top, enumDirection.left],
filter: enumItemType.shape,
2020-05-09 14:45:23 +00:00
},
{
pos: new Vector(1, 0),
directions: [enumDirection.top],
filter: enumItemType.shape,
2020-05-09 14:45:23 +00:00
},
{
pos: new Vector(2, 0),
directions: [enumDirection.top],
filter: enumItemType.shape,
2020-05-09 14:45:23 +00:00
},
{
pos: new Vector(3, 0),
directions: [enumDirection.top, enumDirection.right],
filter: enumItemType.shape,
2020-05-09 14:45:23 +00:00
},
{
pos: new Vector(0, 3),
directions: [enumDirection.bottom, enumDirection.left],
filter: enumItemType.shape,
2020-05-09 14:45:23 +00:00
},
{
pos: new Vector(1, 3),
directions: [enumDirection.bottom],
filter: enumItemType.shape,
2020-05-09 14:45:23 +00:00
},
{
pos: new Vector(2, 3),
directions: [enumDirection.bottom],
filter: enumItemType.shape,
2020-05-09 14:45:23 +00:00
},
{
pos: new Vector(3, 3),
directions: [enumDirection.bottom, enumDirection.right],
filter: enumItemType.shape,
2020-05-09 14:45:23 +00:00
},
{
pos: new Vector(0, 1),
directions: [enumDirection.left],
filter: enumItemType.shape,
2020-05-09 14:45:23 +00:00
},
{
pos: new Vector(0, 2),
directions: [enumDirection.left],
filter: enumItemType.shape,
2020-05-09 14:45:23 +00:00
},
{
pos: new Vector(0, 3),
directions: [enumDirection.left],
filter: enumItemType.shape,
2020-05-09 14:45:23 +00:00
},
{
pos: new Vector(3, 1),
directions: [enumDirection.right],
filter: enumItemType.shape,
2020-05-09 14:45:23 +00:00
},
{
pos: new Vector(3, 2),
directions: [enumDirection.right],
filter: enumItemType.shape,
2020-05-09 14:45:23 +00:00
},
{
pos: new Vector(3, 3),
directions: [enumDirection.right],
filter: enumItemType.shape,
2020-05-09 14:45:23 +00:00
},
],
})
);
}
}