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(); return root.gameMode.getIsEditor();
} }
/**
* @param {import("../../savegame/savegame_serializer").GameRoot} root
* @returns {boolean}
*/
getIsPuzzleRemovable(root) {
return false;
}
/** /**
* Creates the entity at the given location * Creates the entity at the given location
* @param {Entity} entity * @param {Entity} entity

View File

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

View File

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

View File

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

View File

@ -115,15 +115,6 @@ export class MetaBuilding {
return true; 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 the placement sound
* @returns {string} * @returns {string}