parent
4b088980f3
commit
82aaf7f037
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue