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
* @param {Rectangle} other
* @param {number} epsilon
* @param {number} [epsilon]
*/
equalsEpsilon(other, epsilon) {
return (

View File

@ -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;
}
}

View File

@ -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;
}
/**