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:
@@ -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
|
||||
|
||||
50
src/js/core/stale_area_detector.js
Normal file
50
src/js/core/stale_area_detector.js
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user