mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-06-13 13:04:03 +00:00
Fix multi-tile buildings for shrinking
This commit is contained in:
parent
2027b6ff50
commit
0aa1488372
@ -72,7 +72,7 @@ export class Rectangle {
|
||||
/**
|
||||
* Returns if this rectangle is equal to the other while taking an epsilon into account
|
||||
* @param {Rectangle} other
|
||||
* @param {number} epsilon
|
||||
* @param {number} [epsilon]
|
||||
*/
|
||||
equalsEpsilon(other, epsilon) {
|
||||
return (
|
||||
|
@ -68,9 +68,11 @@ export class PuzzleEditGameMode extends PuzzleGameMode {
|
||||
const newZone = this.createCenteredRectangle(this.zoneWidth + w, this.zoneHeight + h);
|
||||
const entities = this.root.entityMgr.entities;
|
||||
|
||||
// @fixme find a better way to check this
|
||||
for (const entity of entities) {
|
||||
const point = entity.components.StaticMapEntity.origin;
|
||||
if (!newZone.containsPoint(point.x, point.y)) {
|
||||
const staticComp = entity.components.StaticMapEntity;
|
||||
const union = newZone.getUnion(staticComp.getTileSpaceBounds());
|
||||
if (!union.equalsEpsilon(newZone)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -49,17 +49,14 @@ export class ZoneSystem extends GameSystem {
|
||||
transformed.y += tile.y;
|
||||
}
|
||||
|
||||
let withinAnyZone = false;
|
||||
for (const zone of zones) {
|
||||
const intersection = zone.getIntersection(transformed);
|
||||
if (intersection && intersection.w * intersection.h === transformed.w * transformed.h) {
|
||||
withinAnyZone = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!withinAnyZone) {
|
||||
return STOP_PROPAGATION;
|
||||
}
|
||||
return STOP_PROPAGATION;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user