mirror of
https://github.com/tobspr/shapez.io.git
synced 2024-10-27 20:34:29 +00:00
Minor PR adjustments
This commit is contained in:
parent
d24a4a848e
commit
7b18d54cbe
@ -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)",
|
||||
],
|
||||
},
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ export class GoalAcceptorSystem extends GameSystemWithFilter {
|
||||
const goalComp = entity.components.GoalAcceptor;
|
||||
|
||||
if (!goalComp.lastDelivery) {
|
||||
allAccepted = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -633,6 +633,7 @@ ingame:
|
||||
trimZone: Trim
|
||||
clearItems: Clear Items
|
||||
clearBuildings: Clear Buildings
|
||||
resetPuzzle: Reset Puzzle
|
||||
share: Share
|
||||
report: Report
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user