mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-06-13 13:04:03 +00:00
Disallow shrinking zone if there are buildings
This commit is contained in:
parent
640d1065f0
commit
2027b6ff50
@ -142,7 +142,7 @@ export class GameMode extends BasicSerializableObject {
|
|||||||
* @param {number} w
|
* @param {number} w
|
||||||
* @param {number} h
|
* @param {number} h
|
||||||
*/
|
*/
|
||||||
expandZone(w = 0, h = 0) {
|
adjustZone(w = 0, h = 0) {
|
||||||
abstract;
|
abstract;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ export class HUDModeSettings extends BaseHUDPart {
|
|||||||
}
|
}
|
||||||
|
|
||||||
modifyZone(width, height) {
|
modifyZone(width, height) {
|
||||||
this.root.gameMode.expandZone(width, height);
|
this.root.gameMode.adjustZone(width, height);
|
||||||
this.updateZoneValues();
|
this.updateZoneValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,16 +55,28 @@ export class PuzzleEditGameMode extends PuzzleGameMode {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
expandZone(w = 0, h = 0) {
|
adjustZone(w = 0, h = 0) {
|
||||||
if (this.zoneWidth + w > 0) {
|
// @todo notify user when zone cannot be shrunk
|
||||||
this.zoneWidth += w;
|
if (this.zoneWidth + w <= 0) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.zoneHeight + h > 0) {
|
if (this.zoneHeight + h <= 0) {
|
||||||
this.zoneHeight += h;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.zone = this.createCenteredRectangle(this.zoneWidth, this.zoneHeight);
|
const newZone = this.createCenteredRectangle(this.zoneWidth + w, this.zoneHeight + h);
|
||||||
|
const entities = this.root.entityMgr.entities;
|
||||||
|
|
||||||
|
for (const entity of entities) {
|
||||||
|
const point = entity.components.StaticMapEntity.origin;
|
||||||
|
if (!newZone.containsPoint(point.x, point.y)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.zoneWidth = newZone.w;
|
||||||
|
this.zoneHeight = newZone.h;
|
||||||
}
|
}
|
||||||
|
|
||||||
getIsEditor() {
|
getIsEditor() {
|
||||||
|
Loading…
Reference in New Issue
Block a user