mirror of
https://github.com/tobspr/shapez.io.git
synced 2026-03-02 03:39:21 +00:00
Add ability to edit constant signals, bump version
This commit is contained in:
@@ -48,6 +48,7 @@ import { HUDBetaOverlay } from "./parts/beta_overlay";
|
||||
import { HUDStandaloneAdvantages } from "./parts/standalone_advantages";
|
||||
import { HUDCatMemes } from "./parts/cat_memes";
|
||||
import { HUDTutorialVideoOffer } from "./parts/tutorial_video_offer";
|
||||
import { HUDConstantSignalEdit } from "./parts/constant_signal_edit";
|
||||
|
||||
export class GameHUD {
|
||||
/**
|
||||
@@ -86,6 +87,7 @@ export class GameHUD {
|
||||
waypoints: new HUDWaypoints(this.root),
|
||||
wireInfo: new HUDWireInfo(this.root),
|
||||
leverToggle: new HUDLeverToggle(this.root),
|
||||
constantSignalEdit: new HUDConstantSignalEdit(this.root),
|
||||
|
||||
// Must always exist
|
||||
pinnedShapes: new HUDPinnedShapes(this.root),
|
||||
|
||||
33
src/js/game/hud/parts/constant_signal_edit.js
Normal file
33
src/js/game/hud/parts/constant_signal_edit.js
Normal file
@@ -0,0 +1,33 @@
|
||||
import { STOP_PROPAGATION } from "../../../core/signal";
|
||||
import { Vector } from "../../../core/vector";
|
||||
import { enumMouseButton } from "../../camera";
|
||||
import { BaseHUDPart } from "../base_hud_part";
|
||||
|
||||
export class HUDConstantSignalEdit extends BaseHUDPart {
|
||||
initialize() {
|
||||
this.root.camera.downPreHandler.add(this.downPreHandler, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Vector} pos
|
||||
* @param {enumMouseButton} button
|
||||
*/
|
||||
downPreHandler(pos, button) {
|
||||
const tile = this.root.camera.screenToWorld(pos).toTileSpace();
|
||||
const contents = this.root.map.getLayerContentXY(tile.x, tile.y, "wires");
|
||||
if (contents) {
|
||||
const constantComp = contents.components.ConstantSignal;
|
||||
if (constantComp) {
|
||||
if (button === enumMouseButton.left) {
|
||||
this.root.systemMgr.systems.constantSignal.editConstantSignal(contents, {
|
||||
deleteOnCancel: false,
|
||||
});
|
||||
return STOP_PROPAGATION;
|
||||
} else if (button === enumMouseButton.right) {
|
||||
this.root.logic.tryDeleteBuilding(contents);
|
||||
return STOP_PROPAGATION;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user