mirror of
https://github.com/tobspr/shapez.io.git
synced 2026-02-20 23:09:22 +00:00
cleaned up code and fixed icons not always showing
This commit is contained in:
parent
2442d6d655
commit
bf8f9e989e
@ -34,13 +34,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
&.import {
|
&.import {
|
||||||
/* @load-async */
|
background: uiResource("icons/upload.png") center center / D(15px) no-repeat !important;
|
||||||
background: uiResource("icons/upload.png") center center / D(15px) no-repeat;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&.export {
|
&.export {
|
||||||
/* @load-async */
|
background: uiResource("icons/download.png") center center / D(15px) no-repeat !important;
|
||||||
background: uiResource("icons/download.png") center center / D(15px) no-repeat;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import { makeDiv } from "../../../core/utils";
|
|||||||
import { T } from "../../../translations";
|
import { T } from "../../../translations";
|
||||||
import { MetaBlockBuilding } from "../../buildings/block";
|
import { MetaBlockBuilding } from "../../buildings/block";
|
||||||
import { MetaConstantProducerBuilding } from "../../buildings/constant_producer";
|
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 { Entity } from "../../entity";
|
import { Entity } from "../../entity";
|
||||||
import { PuzzleGameMode } from "../../modes/puzzle";
|
import { PuzzleGameMode } from "../../modes/puzzle";
|
||||||
@ -94,47 +95,41 @@ export class HUDPuzzleEditorSettings extends BaseHUDPart {
|
|||||||
}, 140);
|
}, 140);
|
||||||
|
|
||||||
if (this.testMode) {
|
if (this.testMode) {
|
||||||
|
const newSolution = [];
|
||||||
for (const entity of this.root.entityMgr.getAllWithComponent(StaticMapEntityComponent)) {
|
for (const entity of this.root.entityMgr.getAllWithComponent(StaticMapEntityComponent)) {
|
||||||
this.storedSolution.push(entity.clone());
|
if (this.isExcludedEntity(entity)) {
|
||||||
|
|
||||||
const metaBuilding = entity.components.StaticMapEntity.getMetaBuilding();
|
|
||||||
const goalComp = entity.components.GoalAcceptor;
|
|
||||||
if (goalComp) {
|
|
||||||
goalComp.clear();
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
newSolution.push(entity.clone());
|
||||||
[MetaConstantProducerBuilding, MetaBlockBuilding]
|
|
||||||
.map(metaClass => gMetaBuildingRegistry.findByClass(metaClass).id)
|
|
||||||
.includes(metaBuilding.id)
|
|
||||||
) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.root.map.removeStaticEntity(entity);
|
this.root.map.removeStaticEntity(entity);
|
||||||
this.root.entityMgr.destroyEntity(entity);
|
this.root.entityMgr.destroyEntity(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.root.entityMgr.processDestroyList();
|
this.root.entityMgr.processDestroyList();
|
||||||
} else if (this.storedSolution.length > 0) {
|
this.storedSolution = newSolution;
|
||||||
|
} else if (this.storedSolution.length) {
|
||||||
this.root.logic.performBulkOperation(() => {
|
this.root.logic.performBulkOperation(() => {
|
||||||
this.root.logic.performImmutableOperation(() => {
|
for (const entity of this.root.entityMgr.getAllWithComponent(StaticMapEntityComponent)) {
|
||||||
for (const entity of this.root.entityMgr.getAllWithComponent(StaticMapEntityComponent)) {
|
if (this.isExcludedEntity(entity)) continue;
|
||||||
this.root.map.removeStaticEntity(entity);
|
|
||||||
this.root.entityMgr.destroyEntity(entity);
|
|
||||||
}
|
|
||||||
this.root.entityMgr.processDestroyList();
|
|
||||||
|
|
||||||
for (const entity of this.storedSolution) {
|
this.root.map.removeStaticEntity(entity);
|
||||||
const placedEntity = this.root.logic.tryPlaceEntity(entity);
|
this.root.entityMgr.destroyEntity(entity);
|
||||||
|
}
|
||||||
|
this.root.entityMgr.processDestroyList();
|
||||||
|
|
||||||
for (const key in entity.components) {
|
for (let i = 0; i < this.storedSolution.length; ++i) {
|
||||||
/** @type {import("../../../core/global_registries").Component} */ (entity
|
const entity = this.storedSolution[i];
|
||||||
.components[key]).copyAdditionalStateTo(placedEntity.components[key]);
|
const placedEntity = this.root.logic.tryPlaceEntity(entity);
|
||||||
}
|
|
||||||
|
for (const key in entity.components) {
|
||||||
|
/** @type {import("../../../core/global_registries").Component} */ (entity.components[
|
||||||
|
key
|
||||||
|
]).copyAdditionalStateTo(placedEntity.components[key]);
|
||||||
}
|
}
|
||||||
this.storedSolution = [];
|
}
|
||||||
});
|
this.storedSolution = [];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -279,4 +274,17 @@ export class HUDPuzzleEditorSettings extends BaseHUDPart {
|
|||||||
getIsTestMode() {
|
getIsTestMode() {
|
||||||
return this.testMode;
|
return this.testMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isExcludedEntity(entity) {
|
||||||
|
const metaBuilding = entity.components.StaticMapEntity.getMetaBuilding();
|
||||||
|
|
||||||
|
if (
|
||||||
|
[MetaConstantProducerBuilding, MetaBlockBuilding, MetaGoalAcceptorBuilding]
|
||||||
|
.map(metaClass => gMetaBuildingRegistry.findByClass(metaClass).id)
|
||||||
|
.includes(metaBuilding.id)
|
||||||
|
) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user