mirror of
https://github.com/tobspr/shapez.io.git
synced 2026-03-02 03:39:21 +00:00
Minor PR adjustments
This commit is contained in:
@@ -27,8 +27,6 @@ export class HUDBlueprintPlacer extends BaseHUDPart {
|
||||
}
|
||||
|
||||
initialize() {
|
||||
this.isCopyPasteFree = this.root.gameMode.getHasFreeCopyPaste();
|
||||
|
||||
this.root.hud.signals.buildingsSelectedForCopy.add(this.createBlueprintFromBuildings, this);
|
||||
|
||||
/** @type {TypedTrackedState<Blueprint?>} */
|
||||
@@ -52,6 +50,10 @@ export class HUDBlueprintPlacer extends BaseHUDPart {
|
||||
this.trackedCanAfford = new TrackedState(this.onCanAffordChanged, this);
|
||||
}
|
||||
|
||||
getHasFreeCopyPaste() {
|
||||
return this.root.gameMode.getHasFreeCopyPaste();
|
||||
}
|
||||
|
||||
abortPlacement() {
|
||||
if (this.currentBlueprint.get()) {
|
||||
this.currentBlueprint.set(null);
|
||||
@@ -84,7 +86,9 @@ export class HUDBlueprintPlacer extends BaseHUDPart {
|
||||
|
||||
update() {
|
||||
const currentBlueprint = this.currentBlueprint.get();
|
||||
this.domAttach.update(!this.isCopyPasteFree && currentBlueprint && currentBlueprint.getCost() > 0);
|
||||
this.domAttach.update(
|
||||
!this.getHasFreeCopyPaste() && currentBlueprint && currentBlueprint.getCost() > 0
|
||||
);
|
||||
this.trackedCanAfford.set(currentBlueprint && currentBlueprint.canAfford(this.root));
|
||||
}
|
||||
|
||||
@@ -116,7 +120,7 @@ export class HUDBlueprintPlacer extends BaseHUDPart {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.isCopyPasteFree && !blueprint.canAfford(this.root)) {
|
||||
if (!this.getHasFreeCopyPaste() && !blueprint.canAfford(this.root)) {
|
||||
this.root.soundProxy.playUiError();
|
||||
return;
|
||||
}
|
||||
@@ -124,7 +128,7 @@ export class HUDBlueprintPlacer extends BaseHUDPart {
|
||||
const worldPos = this.root.camera.screenToWorld(pos);
|
||||
const tile = worldPos.toTileSpace();
|
||||
if (blueprint.tryPlace(this.root, tile)) {
|
||||
if (!this.isCopyPasteFree) {
|
||||
if (!this.getHasFreeCopyPaste()) {
|
||||
const cost = blueprint.getCost();
|
||||
this.root.hubGoals.takeShapeByKey(this.root.gameMode.getBlueprintShapeKey(), cost);
|
||||
}
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
/* typehints:start */
|
||||
import { PuzzleGameMode } from "../../modes/puzzle";
|
||||
/* 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 { StaticMapEntityComponent } from "../../components/static_map_entity";
|
||||
import { BaseHUDPart } from "../base_hud_part";
|
||||
import { gMetaBuildingRegistry } from "../../../core/global_registries";
|
||||
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";
|
||||
|
||||
const logger = createLogger("puzzle-editor");
|
||||
|
||||
@@ -72,13 +73,11 @@ export class HUDPuzzleEditorSettings extends BaseHUDPart {
|
||||
clearBuildings() {
|
||||
for (const entity of this.root.entityMgr.getAllWithComponent(StaticMapEntityComponent)) {
|
||||
const staticComp = entity.components.StaticMapEntity;
|
||||
const signalComp = entity.components.ConstantSignal;
|
||||
const goalComp = entity.components.GoalAcceptor;
|
||||
|
||||
if (
|
||||
signalComp ||
|
||||
goalComp ||
|
||||
staticComp.getMetaBuilding().id === gMetaBuildingRegistry.findByClass(MetaBlockBuilding).id
|
||||
[MetaGoalAcceptorBuilding, MetaConstantProducerBuilding, MetaBlockBuilding]
|
||||
.map(metaClass => gMetaBuildingRegistry.findByClass(metaClass).id)
|
||||
.includes(staticComp.getMetaBuilding().id)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ import { createLogger } from "../../../core/logging";
|
||||
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 { BaseHUDPart } from "../base_hud_part";
|
||||
|
||||
@@ -21,7 +23,7 @@ export class HUDPuzzlePlaySettings extends BaseHUDPart {
|
||||
["section"],
|
||||
`
|
||||
<button class="styledButton clearItems">${T.ingame.puzzleEditorSettings.clearItems}</button>
|
||||
<button class="styledButton clearBuildings">${T.ingame.puzzleEditorSettings.clearBuildings}</button>
|
||||
<button class="styledButton clearBuildings">${T.ingame.puzzleEditorSettings.resetPuzzle}</button>
|
||||
|
||||
`
|
||||
);
|
||||
@@ -38,13 +40,11 @@ export class HUDPuzzlePlaySettings extends BaseHUDPart {
|
||||
clearBuildings() {
|
||||
for (const entity of this.root.entityMgr.getAllWithComponent(StaticMapEntityComponent)) {
|
||||
const staticComp = entity.components.StaticMapEntity;
|
||||
const signalComp = entity.components.ConstantSignal;
|
||||
const goalComp = entity.components.GoalAcceptor;
|
||||
|
||||
if (
|
||||
signalComp ||
|
||||
goalComp ||
|
||||
staticComp.getMetaBuilding().id === gMetaBuildingRegistry.findByClass(MetaBlockBuilding).id
|
||||
[MetaGoalAcceptorBuilding, MetaConstantProducerBuilding, MetaBlockBuilding]
|
||||
.map(metaClass => gMetaBuildingRegistry.findByClass(metaClass).id)
|
||||
.includes(staticComp.getMetaBuilding().id)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user