mirror of
https://github.com/tobspr/shapez.io.git
synced 2026-03-02 03:39:21 +00:00
Add basic logic gate and improve wires in general
This commit is contained in:
@@ -38,13 +38,14 @@ export class HUDWiresOverlay extends BaseHUDPart {
|
||||
* Generates the background pattern for the wires overlay
|
||||
*/
|
||||
generateTilePattern() {
|
||||
const overlayTile = Loader.getSprite("sprites/misc/wires_overlay_tile.png");
|
||||
const overlayTile = Loader.getSprite("sprites/wires/overlay_tile.png");
|
||||
const dims = globalConfig.tileSize * wiresBackgroundDpi;
|
||||
const [canvas, context] = makeOffscreenBuffer(dims, dims, {
|
||||
smooth: false,
|
||||
reusable: false,
|
||||
label: "wires-tile-pattern",
|
||||
});
|
||||
context.clearRect(0, 0, dims, dims);
|
||||
overlayTile.draw(context, 0, 0, dims, dims);
|
||||
this.tilePatternCanvas = canvas;
|
||||
}
|
||||
@@ -73,10 +74,14 @@ export class HUDWiresOverlay extends BaseHUDPart {
|
||||
|
||||
const bounds = parameters.visibleRect;
|
||||
|
||||
const scaleFactor = 1 / wiresBackgroundDpi;
|
||||
|
||||
parameters.context.globalAlpha = this.currentAlpha;
|
||||
parameters.context.globalCompositeOperation = "darken";
|
||||
|
||||
const scaleFactor = 1 / wiresBackgroundDpi;
|
||||
parameters.context.globalCompositeOperation = "overlay";
|
||||
parameters.context.fillStyle = "rgba(50, 200, 150, 1)";
|
||||
parameters.context.fillRect(bounds.x, bounds.y, bounds.w, bounds.h);
|
||||
parameters.context.globalCompositeOperation = "source-over";
|
||||
|
||||
parameters.context.scale(scaleFactor, scaleFactor);
|
||||
parameters.context.fillStyle = this.cachedPatternBackground;
|
||||
parameters.context.fillRect(
|
||||
@@ -86,7 +91,7 @@ export class HUDWiresOverlay extends BaseHUDPart {
|
||||
bounds.h / scaleFactor
|
||||
);
|
||||
parameters.context.scale(1 / scaleFactor, 1 / scaleFactor);
|
||||
parameters.context.globalCompositeOperation = "source-over";
|
||||
|
||||
parameters.context.globalAlpha = 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,9 @@ import { enumLayer } from "../../root";
|
||||
import { HUDBaseToolbar } from "./base_toolbar";
|
||||
import { MetaWireBuilding } from "../../buildings/wire";
|
||||
import { MetaConstantSignalBuilding } from "../../buildings/constant_signal";
|
||||
import { MetaLogicGateBuilding } from "../../buildings/logic_gate";
|
||||
|
||||
const supportedBuildings = [MetaWireBuilding, MetaConstantSignalBuilding];
|
||||
const supportedBuildings = [MetaWireBuilding, MetaConstantSignalBuilding, MetaLogicGateBuilding];
|
||||
|
||||
export class HUDWiresToolbar extends HUDBaseToolbar {
|
||||
constructor(root) {
|
||||
|
||||
Reference in New Issue
Block a user