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/components/wire.js

61 lines
1.4 KiB
JavaScript
Raw Normal View History

2020-08-11 16:40:09 +00:00
import { Component } from "../component";
/** @enum {string} */
export const enumWireType = {
regular: "regular",
turn: "turn",
split: "split",
};
export class WireComponent extends Component {
static getId() {
return "Wire";
}
duplicateWithoutContents() {
return new WireComponent({ type: this.type });
}
/**
* @param {object} param0
2020-08-11 18:02:59 +00:00
* @param {enumWireType=} param0.type
2020-08-11 16:40:09 +00:00
*/
constructor({ type = enumWireType.regular }) {
super();
this.type = type;
}
2020-08-11 18:02:59 +00:00
/**
* Returns the local connections
* @returns {import("../../core/utils").DirectionalObject}
*/
getLocalConnections() {
switch (this.type) {
case enumWireType.regular:
return {
top: true,
right: false,
bottom: true,
left: false,
};
case enumWireType.turn:
return {
top: false,
right: true,
bottom: true,
left: false,
};
case enumWireType.split:
return {
top: false,
right: true,
bottom: true,
left: true,
};
default:
assertAlways(false, "Invalid wire type: " + this.type);
}
}
2020-08-11 16:40:09 +00:00
}