mirror of
https://github.com/tobspr/shapez.io.git
synced 2026-03-02 03:39:21 +00:00
Improve wire auto-connect
This commit is contained in:
@@ -4,9 +4,8 @@ import { Rectangle } from "../../core/rectangle";
|
||||
import { AtlasSprite } from "../../core/sprites";
|
||||
import { enumDirection, Vector } from "../../core/vector";
|
||||
import { types } from "../../savegame/serialization";
|
||||
import { Component } from "../component";
|
||||
import { getBuildingDataFromCode } from "../building_codes";
|
||||
import { MetaBuilding } from "../meta_building";
|
||||
import { Component } from "../component";
|
||||
|
||||
export class StaticMapEntityComponent extends Component {
|
||||
static getId() {
|
||||
@@ -58,7 +57,7 @@ export class StaticMapEntityComponent extends Component {
|
||||
|
||||
/**
|
||||
* Returns the meta building
|
||||
* @returns {MetaBuilding}
|
||||
* @returns {import("../meta_building").MetaBuilding}
|
||||
*/
|
||||
getMetaBuilding() {
|
||||
return getBuildingDataFromCode(this.code).metaInstance;
|
||||
|
||||
@@ -5,6 +5,7 @@ export const enumWireType = {
|
||||
regular: "regular",
|
||||
turn: "turn",
|
||||
split: "split",
|
||||
cross: "cross",
|
||||
};
|
||||
|
||||
export class WireComponent extends Component {
|
||||
@@ -30,31 +31,38 @@ export class WireComponent extends Component {
|
||||
* @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,
|
||||
};
|
||||
return {
|
||||
top: true,
|
||||
right: false,
|
||||
bottom: true,
|
||||
left: false,
|
||||
};
|
||||
|
||||
default:
|
||||
assertAlways(false, "Invalid wire type: " + this.type);
|
||||
}
|
||||
// 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);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { enumDirection, Vector } from "../../core/vector";
|
||||
import { BaseItem } from "../base_item";
|
||||
import { Component } from "../component";
|
||||
import { Vector, enumDirection } from "../../core/vector";
|
||||
import { types } from "../../savegame/serialization";
|
||||
|
||||
/** @enum {string} */
|
||||
export const enumPinSlotType = {
|
||||
@@ -17,7 +17,8 @@ export const enumPinSlotType = {
|
||||
/** @typedef {{
|
||||
* pos: Vector,
|
||||
* type: enumPinSlotType,
|
||||
* direction: enumDirection
|
||||
* direction: enumDirection,
|
||||
* value: BaseItem
|
||||
* }} WirePinSlot */
|
||||
|
||||
export class WiredPinsComponent extends Component {
|
||||
@@ -63,6 +64,7 @@ export class WiredPinsComponent extends Component {
|
||||
pos: slotData.pos,
|
||||
type: slotData.type,
|
||||
direction: slotData.direction,
|
||||
value: null,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user