1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2026-03-02 03:39:21 +00:00

Fix wires blueprint pasting bug, do not show wire info on unconnected wires

This commit is contained in:
tobspr
2020-08-15 18:14:00 +02:00
parent 070bce7020
commit b1fb0fca7e
5 changed files with 107 additions and 19 deletions

View File

@@ -376,6 +376,23 @@ export class Rectangle {
);
}
/**
* Good for printing stuff
*/
toString() {
return (
"[x:" +
round2Digits(this.x) +
"| y:" +
round2Digits(this.y) +
"| w:" +
round2Digits(this.w) +
"| h:" +
round2Digits(this.h) +
"]"
);
}
/**
* Returns a new recangle in tile space which includes all tiles which are visible in this rect
* @param {boolean=} includeHalfTiles

View File

@@ -0,0 +1,50 @@
import { createLogger } from "./logging";
import { Rectangle } from "./rectangle";
import { globalConfig } from "./config";
const logger = createLogger("stale_areas");
export class StaleAreaDetector {
/**
*
* @param {object} param0
* @param {import("../game/root").GameRoot} param0.root
* @param {string} param0.name The name for reference
* @param {(Rectangle) => void} param0.recomputeMethod Method which recomputes the given area
*/
constructor({ root, name, recomputeMethod }) {
this.root = root;
this.name = name;
this.recomputeMethod = recomputeMethod;
/** @type {Rectangle} */
this.staleArea = null;
}
/**
* Invalidates the given area
* @param {Rectangle} area
*/
invalidate(area) {
// logger.log(this.name, "invalidated", area.toString());
if (this.staleArea) {
this.staleArea = this.staleArea.getUnion(area);
} else {
this.staleArea = area.clone();
}
}
/**
* Updates the stale area
*/
update() {
if (this.staleArea) {
logger.log(this.name, "is recomputing", this.staleArea.toString());
if (G_IS_DEV && globalConfig.debug.renderChanges) {
this.root.hud.parts.changesDebugger.renderChange(this.name, this.staleArea, "#fd145b");
}
this.recomputeMethod(this.staleArea);
this.staleArea = null;
}
}
}