mirror of
https://github.com/tobspr/shapez.io.git
synced 2026-03-02 03:39:21 +00:00
Implement wire networks, add levers
This commit is contained in:
20
src/js/game/components/lever.js
Normal file
20
src/js/game/components/lever.js
Normal file
@@ -0,0 +1,20 @@
|
||||
import { Component } from "../component";
|
||||
|
||||
export class LeverComponent extends Component {
|
||||
static getId() {
|
||||
return "Lever";
|
||||
}
|
||||
|
||||
duplicateWithoutContents() {
|
||||
return new LeverComponent({ toggled: this.toggled });
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {object} param0
|
||||
* @param {boolean=} param0.toggled
|
||||
*/
|
||||
constructor({ toggled = false }) {
|
||||
super();
|
||||
this.toggled = toggled;
|
||||
}
|
||||
}
|
||||
26
src/js/game/components/logic_gate.js
Normal file
26
src/js/game/components/logic_gate.js
Normal file
@@ -0,0 +1,26 @@
|
||||
import { Component } from "../component";
|
||||
|
||||
/** @enum {string} */
|
||||
export const enumLogicGateType = {
|
||||
and: "and",
|
||||
};
|
||||
|
||||
export class LogicGateComponent extends Component {
|
||||
static getId() {
|
||||
return "LogicGate";
|
||||
}
|
||||
|
||||
duplicateWithoutContents() {
|
||||
return new LogicGateComponent({ type: this.type });
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {object} param0
|
||||
* @param {enumLogicGateType=} param0.type
|
||||
*/
|
||||
constructor({ type = enumLogicGateType.and }) {
|
||||
super();
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,11 @@ export class WireComponent extends Component {
|
||||
constructor({ type = enumWireType.regular }) {
|
||||
super();
|
||||
this.type = type;
|
||||
|
||||
/**
|
||||
* @type {import("../systems/wire").WireNetwork}
|
||||
*/
|
||||
this.linkedNetwork = null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,7 +18,8 @@ export const enumPinSlotType = {
|
||||
* pos: Vector,
|
||||
* type: enumPinSlotType,
|
||||
* direction: enumDirection,
|
||||
* value: BaseItem
|
||||
* value: BaseItem,
|
||||
* linkedNetwork: import("../systems/wire").WireNetwork
|
||||
* }} WirePinSlot */
|
||||
|
||||
export class WiredPinsComponent extends Component {
|
||||
@@ -65,6 +66,7 @@ export class WiredPinsComponent extends Component {
|
||||
type: slotData.type,
|
||||
direction: slotData.direction,
|
||||
value: null,
|
||||
linkedNetwork: null,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user