mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-06-07 10:03:59 +00:00
Minor puzzle control refactoring
This commit is contained in:
parent
285dd3840d
commit
db355da09e
@ -1,5 +1,3 @@
|
|||||||
/* typehints:start */
|
|
||||||
/* typehints:end */
|
|
||||||
import { globalConfig } from "../../../core/config";
|
import { globalConfig } from "../../../core/config";
|
||||||
import { gMetaBuildingRegistry } from "../../../core/global_registries";
|
import { gMetaBuildingRegistry } from "../../../core/global_registries";
|
||||||
import { createLogger } from "../../../core/logging";
|
import { createLogger } from "../../../core/logging";
|
||||||
@ -50,7 +48,7 @@ export class HUDPuzzleEditorSettings extends BaseHUDPart {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="buildingsButton">
|
<div class="buildingsButton">
|
||||||
<button class="styledButton clearBuildings">${T.ingame.puzzleEditorSettings.clearBuildings}</button>
|
<button class="styledButton resetPuzzle">${T.ingame.puzzleEditorSettings.resetPuzzle}</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>`
|
</div>`
|
||||||
@ -62,7 +60,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.clearBuildings", this.clearBuildings);
|
bind("button.resetPuzzle", this.resetPuzzle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,9 +68,14 @@ export class HUDPuzzleEditorSettings extends BaseHUDPart {
|
|||||||
this.root.logic.clearAllBeltsAndItems();
|
this.root.logic.clearAllBeltsAndItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
clearBuildings() {
|
resetPuzzle() {
|
||||||
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 (goalComp) {
|
||||||
|
goalComp.clear();
|
||||||
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
[MetaGoalAcceptorBuilding, MetaConstantProducerBuilding, MetaBlockBuilding]
|
[MetaGoalAcceptorBuilding, MetaConstantProducerBuilding, MetaBlockBuilding]
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
import { gMetaBuildingRegistry } from "../../../core/global_registries";
|
|
||||||
import { createLogger } from "../../../core/logging";
|
import { createLogger } from "../../../core/logging";
|
||||||
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 { BaseHUDPart } from "../base_hud_part";
|
import { BaseHUDPart } from "../base_hud_part";
|
||||||
|
|
||||||
@ -23,13 +19,13 @@ export class HUDPuzzlePlaySettings extends BaseHUDPart {
|
|||||||
["section"],
|
["section"],
|
||||||
`
|
`
|
||||||
<button class="styledButton clearItems">${T.ingame.puzzleEditorSettings.clearItems}</button>
|
<button class="styledButton clearItems">${T.ingame.puzzleEditorSettings.clearItems}</button>
|
||||||
<button class="styledButton clearBuildings">${T.ingame.puzzleEditorSettings.resetPuzzle}</button>
|
<button class="styledButton resetPuzzle">${T.ingame.puzzleEditorSettings.resetPuzzle}</button>
|
||||||
|
|
||||||
`
|
`
|
||||||
);
|
);
|
||||||
|
|
||||||
bind("button.clearItems", this.clearItems);
|
bind("button.clearItems", this.clearItems);
|
||||||
bind("button.clearBuildings", this.clearBuildings);
|
bind("button.resetPuzzle", this.resetPuzzle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,20 +33,19 @@ export class HUDPuzzlePlaySettings extends BaseHUDPart {
|
|||||||
this.root.logic.clearAllBeltsAndItems();
|
this.root.logic.clearAllBeltsAndItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
clearBuildings() {
|
resetPuzzle() {
|
||||||
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 (
|
if (goalComp) {
|
||||||
[MetaGoalAcceptorBuilding, MetaConstantProducerBuilding, MetaBlockBuilding]
|
goalComp.clear();
|
||||||
.map(metaClass => gMetaBuildingRegistry.findByClass(metaClass).id)
|
|
||||||
.includes(staticComp.getMetaBuilding().id)
|
|
||||||
) {
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.root.map.removeStaticEntity(entity);
|
if (staticComp.getMetaBuilding().getIsRemovable(this.root)) {
|
||||||
this.root.entityMgr.destroyEntity(entity);
|
this.root.map.removeStaticEntity(entity);
|
||||||
|
this.root.entityMgr.destroyEntity(entity);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.root.entityMgr.processDestroyList();
|
this.root.entityMgr.processDestroyList();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user