1
0
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:
Даниїл Григор'єв 2021-04-30 18:11:51 +03:00
parent 2027b6ff50
commit 0aa1488372
No known key found for this signature in database
GPG Key ID: B890DF16341D8C1D
3 changed files with 7 additions and 8 deletions

View File

@ -72,7 +72,7 @@ export class Rectangle {
/** /**
* Returns if this rectangle is equal to the other while taking an epsilon into account * Returns if this rectangle is equal to the other while taking an epsilon into account
* @param {Rectangle} other * @param {Rectangle} other
* @param {number} epsilon * @param {number} [epsilon]
*/ */
equalsEpsilon(other, epsilon) { equalsEpsilon(other, epsilon) {
return ( return (

View File

@ -68,9 +68,11 @@ export class PuzzleEditGameMode extends PuzzleGameMode {
const newZone = this.createCenteredRectangle(this.zoneWidth + w, this.zoneHeight + h); const newZone = this.createCenteredRectangle(this.zoneWidth + w, this.zoneHeight + h);
const entities = this.root.entityMgr.entities; const entities = this.root.entityMgr.entities;
// @fixme find a better way to check this
for (const entity of entities) { for (const entity of entities) {
const point = entity.components.StaticMapEntity.origin; const staticComp = entity.components.StaticMapEntity;
if (!newZone.containsPoint(point.x, point.y)) { const union = newZone.getUnion(staticComp.getTileSpaceBounds());
if (!union.equalsEpsilon(newZone)) {
return; return;
} }
} }

View File

@ -49,18 +49,15 @@ export class ZoneSystem extends GameSystem {
transformed.y += tile.y; transformed.y += tile.y;
} }
let withinAnyZone = false;
for (const zone of zones) { for (const zone of zones) {
const intersection = zone.getIntersection(transformed); const intersection = zone.getIntersection(transformed);
if (intersection && intersection.w * intersection.h === transformed.w * transformed.h) { if (intersection && intersection.w * intersection.h === transformed.w * transformed.h) {
withinAnyZone = true; return;
} }
} }
if (!withinAnyZone) {
return STOP_PROPAGATION; return STOP_PROPAGATION;
} }
}
/** /**
* Draws the zone * Draws the zone