1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2026-02-12 10:59:23 +00:00

improved stuff

This commit is contained in:
Sense101 2021-06-25 15:19:45 +01:00
parent 6e5b46ea5e
commit e6c54d61bc
5 changed files with 11 additions and 40 deletions

View File

@ -22,14 +22,6 @@ export class MetaBlockBuilding extends MetaBuilding {
return root.gameMode.getIsEditor();
}
/**
* @param {import("../../savegame/savegame_serializer").GameRoot} root
* @returns {boolean}
*/
getIsPuzzleRemovable(root) {
return false;
}
/**
* Creates the entity at the given location
* @param {Entity} entity

View File

@ -26,14 +26,6 @@ export class MetaConstantProducerBuilding extends MetaBuilding {
return root.gameMode.getIsEditor();
}
/**
* @param {import("../../savegame/savegame_serializer").GameRoot} root
* @returns {boolean}
*/
getIsPuzzleRemovable(root) {
return false;
}
/**
* Creates the entity at the given location
* @param {Entity} entity

View File

@ -26,14 +26,6 @@ export class MetaGoalAcceptorBuilding extends MetaBuilding {
return root.gameMode.getIsEditor();
}
/**
* @param {import("../../savegame/savegame_serializer").GameRoot} root
* @returns {boolean}
*/
getIsPuzzleRemovable(root) {
return false;
}
/**
* Creates the entity at the given location
* @param {Entity} entity

View File

@ -1,10 +1,14 @@
/* typehints:start */
/* typehints:end */
import { globalConfig } from "../../../core/config";
import { gMetaBuildingRegistry } from "../../../core/global_registries";
import { createLogger } from "../../../core/logging";
import { Rectangle } from "../../../core/rectangle";
import { makeDiv } from "../../../core/utils";
import { T } from "../../../translations";
import { MetaBlockBuilding } from "../../buildings/block";
import { MetaConstantProducerBuilding } from "../../buildings/constant_producer";
import { MetaGoalAcceptorBuilding } from "../../buildings/goal_acceptor";
import { StaticMapEntityComponent } from "../../components/static_map_entity";
import { PuzzleGameMode } from "../../modes/puzzle";
import { BaseHUDPart } from "../base_hud_part";
@ -58,7 +62,7 @@ export class HUDPuzzleEditorSettings extends BaseHUDPart {
bind(".zoneHeight .plus", () => this.modifyZone(0, 1));
bind("button.trim", this.trim);
bind("button.clearItems", this.clearItems);
bind("button.resetPuzzle", this.resetPuzzle);
bind("button.clearBuildings", this.clearBuildings);
}
}
@ -66,15 +70,15 @@ export class HUDPuzzleEditorSettings extends BaseHUDPart {
this.root.logic.clearAllBeltsAndItems();
}
resetPuzzle() {
clearBuildings() {
for (const entity of this.root.entityMgr.getAllWithComponent(StaticMapEntityComponent)) {
const staticComp = entity.components.StaticMapEntity;
const goalComp = entity.components.GoalAcceptor;
if (!staticComp.getMetaBuilding().getIsPuzzleRemovable(this.root)) {
if (goalComp) {
goalComp.clear();
}
if (
[MetaGoalAcceptorBuilding, MetaConstantProducerBuilding, MetaBlockBuilding]
.map(metaClass => gMetaBuildingRegistry.findByClass(metaClass).id)
.includes(staticComp.getMetaBuilding().id)
) {
continue;
}

View File

@ -115,15 +115,6 @@ export class MetaBuilding {
return true;
}
/**
* Returns whether this building is removable in puzzle mode
* @param {GameRoot} root
* @returns {boolean}
*/
getIsPuzzleRemovable(root) {
return true;
}
/**
* Returns the placement sound
* @returns {string}