1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2026-03-02 03:39:21 +00:00

Restructure buildings

This commit is contained in:
tobspr
2020-09-24 12:53:40 +02:00
parent 0202387739
commit c54ec9fd2a
99 changed files with 2374 additions and 2449 deletions

View File

@@ -12,7 +12,7 @@ export const enumLogicGateType = {
rotater: "rotater",
unstacker: "unstacker",
cutter: "cutter",
shapecompare: "shapecompare",
compare: "compare",
stacker: "stacker",
painter: "painter",
};

View File

@@ -63,6 +63,14 @@ export class StaticMapEntityComponent extends Component {
return getBuildingDataFromCode(this.code).metaInstance;
}
/**
* Returns the buildings variant
* @returns {string}
*/
getVariant() {
return getBuildingDataFromCode(this.code).variant;
}
/**
* Copy the current state to another component
* @param {Component} otherComponent

View File

@@ -2,12 +2,19 @@ import { Component } from "../component";
/** @enum {string} */
export const enumWireType = {
regular: "regular",
forward: "forward",
turn: "turn",
split: "split",
cross: "cross",
};
/** @enum {string} */
export const enumWireVariant = {
first: "first",
second: "second",
third: "third",
};
export class WireComponent extends Component {
static getId() {
return "Wire";
@@ -16,54 +23,21 @@ export class WireComponent extends Component {
/**
* @param {object} param0
* @param {enumWireType=} param0.type
* @param {enumWireVariant=} param0.variant
*/
constructor({ type = enumWireType.regular }) {
constructor({ type = enumWireType.forward, variant = enumWireVariant.first }) {
super();
this.type = type;
/**
* The variant of the wire, different variants do not connect
* @type {enumWireVariant}
*/
this.variant = variant;
/**
* @type {import("../systems/wire").WireNetwork}
*/
this.linkedNetwork = null;
}
/**
* Returns the local connections
* @returns {import("../../core/utils").DirectionalObject}
*/
getLocalConnections() {
return {
top: true,
right: false,
bottom: true,
left: false,
};
// 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);
// }
}
}

View File

@@ -5,13 +5,8 @@ export class WireTunnelComponent extends Component {
return "WireTunnel";
}
/**
* @param {object} param0
* @param {boolean=} param0.multipleDirections
*/
constructor({ multipleDirections = true }) {
constructor() {
super();
this.multipleDirections = multipleDirections;
/**
* Linked network, only if its not multiple directions