diff --git a/src/js/changelog.js b/src/js/changelog.js index e80806ed..7bd21795 100644 --- a/src/js/changelog.js +++ b/src/js/changelog.js @@ -4,7 +4,7 @@ export const CHANGELOG = [ date: "24.06.2021", entries: [ "Puzzle DLC: Goal acceptors now reset after getting no items for a while (This should prevent being able to 'cheat' puzzles) (by Sense101)", - "Puzzle DLC: Added button to clear all buildings (by Sense101)", + "Puzzle DLC: Added button to clear all buildings / reset the puzzle (by Sense101)", "Puzzle DLC: Allow copy-paste in puzzle mode (by Sense101)", ], }, diff --git a/src/js/game/blueprint.js b/src/js/game/blueprint.js index a2aa7186..795b27c3 100644 --- a/src/js/game/blueprint.js +++ b/src/js/game/blueprint.js @@ -101,10 +101,11 @@ export class Blueprint { const entity = this.entities[i]; const staticComp = entity.components.StaticMapEntity; - if (staticComp.getMetaBuilding().getIsRotateable()) { - staticComp.rotation = (staticComp.rotation + 90) % 360; - staticComp.originalRotation = (staticComp.originalRotation + 90) % 360; - } + // Actually keeping this in as an easter egg to rotate the trash can + // if (staticComp.getMetaBuilding().getIsRotateable()) { + staticComp.rotation = (staticComp.rotation + 90) % 360; + staticComp.originalRotation = (staticComp.originalRotation + 90) % 360; + // } staticComp.origin = staticComp.origin.rotateFastMultipleOf90(90); } @@ -142,6 +143,9 @@ export class Blueprint { * @param {GameRoot} root */ canAfford(root) { + if (root.gameMode.getHasFreeCopyPaste()) { + return true; + } return root.hubGoals.getShapesStoredByKey(root.gameMode.getBlueprintShapeKey()) >= this.getCost(); } diff --git a/src/js/game/components/goal_acceptor.js b/src/js/game/components/goal_acceptor.js index 485f385b..bb13ee61 100644 --- a/src/js/game/components/goal_acceptor.js +++ b/src/js/game/components/goal_acceptor.js @@ -30,20 +30,23 @@ export class GoalAcceptorComponent extends Component { } clear() { - // the last items we delivered - /** @type {{ item: BaseItem; time: number; }} */ + /** + * The last item we delivered + * @type {{ item: BaseItem; time: number; } | null} */ this.lastDelivery = null; + // The amount of items we delivered so far this.currentDeliveredItems = 0; // Used for animations this.displayPercentage = 0; } - // clears items but doesn't instantly reset the progress bar + /** + * Clears items but doesn't instantly reset the progress bar + */ clearItems() { this.lastDelivery = null; - this.currentDeliveredItems = 0; } diff --git a/src/js/game/hud/parts/blueprint_placer.js b/src/js/game/hud/parts/blueprint_placer.js index e006d24a..4b2bafb2 100644 --- a/src/js/game/hud/parts/blueprint_placer.js +++ b/src/js/game/hud/parts/blueprint_placer.js @@ -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} */ @@ -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); } diff --git a/src/js/game/hud/parts/puzzle_editor_settings.js b/src/js/game/hud/parts/puzzle_editor_settings.js index bcd2c85c..11b046bf 100644 --- a/src/js/game/hud/parts/puzzle_editor_settings.js +++ b/src/js/game/hud/parts/puzzle_editor_settings.js @@ -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; } diff --git a/src/js/game/hud/parts/puzzle_play_settings.js b/src/js/game/hud/parts/puzzle_play_settings.js index 88034f72..8ae28166 100644 --- a/src/js/game/hud/parts/puzzle_play_settings.js +++ b/src/js/game/hud/parts/puzzle_play_settings.js @@ -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"], ` - + ` ); @@ -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; } diff --git a/src/js/game/systems/goal_acceptor.js b/src/js/game/systems/goal_acceptor.js index f7ac16a6..40100324 100644 --- a/src/js/game/systems/goal_acceptor.js +++ b/src/js/game/systems/goal_acceptor.js @@ -25,6 +25,7 @@ export class GoalAcceptorSystem extends GameSystemWithFilter { const goalComp = entity.components.GoalAcceptor; if (!goalComp.lastDelivery) { + allAccepted = false; continue; } diff --git a/translations/base-en.yaml b/translations/base-en.yaml index bf5a1890..02d8e948 100644 --- a/translations/base-en.yaml +++ b/translations/base-en.yaml @@ -633,6 +633,7 @@ ingame: trimZone: Trim clearItems: Clear Items clearBuildings: Clear Buildings + resetPuzzle: Reset Puzzle share: Share report: Report