mirror of
https://github.com/tobspr/shapez.io.git
synced 2024-10-27 20:34:29 +00:00
Add back copy/paste in puzzle mode. (#1230)
* added the new splitter * Update base-en.yaml * added the new splitter Update changelog and update translation regarding 20 upgrade tiers, closes #907 * Update base-en.yaml * Added back copy/paste in puzzle mode * fixed rotating non-rotatable buildings as blueprints and made blocker non-rotatable
This commit is contained in:
parent
1c23549b39
commit
f7cc313ff4
@ -101,8 +101,11 @@ export class Blueprint {
|
|||||||
const entity = this.entities[i];
|
const entity = this.entities[i];
|
||||||
const staticComp = entity.components.StaticMapEntity;
|
const staticComp = entity.components.StaticMapEntity;
|
||||||
|
|
||||||
staticComp.rotation = (staticComp.rotation + 90) % 360;
|
if (staticComp.getMetaBuilding().getIsRotateable()) {
|
||||||
staticComp.originalRotation = (staticComp.originalRotation + 90) % 360;
|
staticComp.rotation = (staticComp.rotation + 90) % 360;
|
||||||
|
staticComp.originalRotation = (staticComp.originalRotation + 90) % 360;
|
||||||
|
}
|
||||||
|
|
||||||
staticComp.origin = staticComp.origin.rotateFastMultipleOf90(90);
|
staticComp.origin = staticComp.origin.rotateFastMultipleOf90(90);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -166,8 +166,8 @@ export class GameMode extends BasicSerializableObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @returns {boolean} */
|
/** @returns {boolean} */
|
||||||
getSupportsCopyPaste() {
|
getHasFreeCopyPaste() {
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @returns {boolean} */
|
/** @returns {boolean} */
|
||||||
|
@ -27,6 +27,8 @@ export class HUDBlueprintPlacer extends BaseHUDPart {
|
|||||||
}
|
}
|
||||||
|
|
||||||
initialize() {
|
initialize() {
|
||||||
|
this.isCopyPasteFree = this.root.gameMode.getHasFreeCopyPaste();
|
||||||
|
|
||||||
this.root.hud.signals.buildingsSelectedForCopy.add(this.createBlueprintFromBuildings, this);
|
this.root.hud.signals.buildingsSelectedForCopy.add(this.createBlueprintFromBuildings, this);
|
||||||
|
|
||||||
/** @type {TypedTrackedState<Blueprint?>} */
|
/** @type {TypedTrackedState<Blueprint?>} */
|
||||||
@ -82,7 +84,7 @@ export class HUDBlueprintPlacer extends BaseHUDPart {
|
|||||||
|
|
||||||
update() {
|
update() {
|
||||||
const currentBlueprint = this.currentBlueprint.get();
|
const currentBlueprint = this.currentBlueprint.get();
|
||||||
this.domAttach.update(currentBlueprint && currentBlueprint.getCost() > 0);
|
this.domAttach.update(!this.isCopyPasteFree && currentBlueprint && currentBlueprint.getCost() > 0);
|
||||||
this.trackedCanAfford.set(currentBlueprint && currentBlueprint.canAfford(this.root));
|
this.trackedCanAfford.set(currentBlueprint && currentBlueprint.canAfford(this.root));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,7 +116,7 @@ export class HUDBlueprintPlacer extends BaseHUDPart {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!blueprint.canAfford(this.root)) {
|
if (!this.isCopyPasteFree && !blueprint.canAfford(this.root)) {
|
||||||
this.root.soundProxy.playUiError();
|
this.root.soundProxy.playUiError();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -122,8 +124,10 @@ export class HUDBlueprintPlacer extends BaseHUDPart {
|
|||||||
const worldPos = this.root.camera.screenToWorld(pos);
|
const worldPos = this.root.camera.screenToWorld(pos);
|
||||||
const tile = worldPos.toTileSpace();
|
const tile = worldPos.toTileSpace();
|
||||||
if (blueprint.tryPlace(this.root, tile)) {
|
if (blueprint.tryPlace(this.root, tile)) {
|
||||||
const cost = blueprint.getCost();
|
if (!this.isCopyPasteFree) {
|
||||||
this.root.hubGoals.takeShapeByKey(this.root.gameMode.getBlueprintShapeKey(), cost);
|
const cost = blueprint.getCost();
|
||||||
|
this.root.hubGoals.takeShapeByKey(this.root.gameMode.getBlueprintShapeKey(), cost);
|
||||||
|
}
|
||||||
this.root.soundProxy.playUi(SOUNDS.placeBuilding);
|
this.root.soundProxy.playUi(SOUNDS.placeBuilding);
|
||||||
}
|
}
|
||||||
return STOP_PROPAGATION;
|
return STOP_PROPAGATION;
|
||||||
@ -131,7 +135,7 @@ export class HUDBlueprintPlacer extends BaseHUDPart {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mose move handler
|
* Mouse move handler
|
||||||
*/
|
*/
|
||||||
onMouseMove() {
|
onMouseMove() {
|
||||||
// Prevent movement while blueprint is selected
|
// Prevent movement while blueprint is selected
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { globalConfig } from "../../../core/config";
|
import { globalConfig } from "../../../core/config";
|
||||||
import { DrawParameters } from "../../../core/draw_parameters";
|
import { DrawParameters } from "../../../core/draw_parameters";
|
||||||
|
import { gMetaBuildingRegistry } from "../../../core/global_registries";
|
||||||
import { createLogger } from "../../../core/logging";
|
import { createLogger } from "../../../core/logging";
|
||||||
import { STOP_PROPAGATION } from "../../../core/signal";
|
import { STOP_PROPAGATION } from "../../../core/signal";
|
||||||
import { formatBigNumberFull } from "../../../core/utils";
|
import { formatBigNumberFull } from "../../../core/utils";
|
||||||
@ -7,6 +8,8 @@ import { Vector } from "../../../core/vector";
|
|||||||
import { ACHIEVEMENTS } from "../../../platform/achievement_provider";
|
import { ACHIEVEMENTS } from "../../../platform/achievement_provider";
|
||||||
import { T } from "../../../translations";
|
import { T } from "../../../translations";
|
||||||
import { Blueprint } from "../../blueprint";
|
import { Blueprint } from "../../blueprint";
|
||||||
|
import { MetaBlockBuilding } from "../../buildings/block";
|
||||||
|
import { MetaConstantProducerBuilding } from "../../buildings/constant_producer";
|
||||||
import { enumMouseButton } from "../../camera";
|
import { enumMouseButton } from "../../camera";
|
||||||
import { Component } from "../../component";
|
import { Component } from "../../component";
|
||||||
import { Entity } from "../../entity";
|
import { Entity } from "../../entity";
|
||||||
@ -260,7 +263,14 @@ export class HUDMassSelector extends BaseHUDPart {
|
|||||||
for (let x = realTileStart.x; x <= realTileEnd.x; ++x) {
|
for (let x = realTileStart.x; x <= realTileEnd.x; ++x) {
|
||||||
for (let y = realTileStart.y; y <= realTileEnd.y; ++y) {
|
for (let y = realTileStart.y; y <= realTileEnd.y; ++y) {
|
||||||
const contents = this.root.map.getLayerContentXY(x, y, this.root.currentLayer);
|
const contents = this.root.map.getLayerContentXY(x, y, this.root.currentLayer);
|
||||||
|
|
||||||
if (contents && this.root.logic.canDeleteBuilding(contents)) {
|
if (contents && this.root.logic.canDeleteBuilding(contents)) {
|
||||||
|
const staticComp = contents.components.StaticMapEntity;
|
||||||
|
|
||||||
|
if (!staticComp.getMetaBuilding().getIsRemovable(this.root)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
this.selectedUids.add(contents.uid);
|
this.selectedUids.add(contents.uid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -320,6 +330,11 @@ export class HUDMassSelector extends BaseHUDPart {
|
|||||||
renderedUids.add(uid);
|
renderedUids.add(uid);
|
||||||
|
|
||||||
const staticComp = contents.components.StaticMapEntity;
|
const staticComp = contents.components.StaticMapEntity;
|
||||||
|
|
||||||
|
if (!staticComp.getMetaBuilding().getIsRemovable(this.root)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
const bounds = staticComp.getTileSpaceBounds();
|
const bounds = staticComp.getTileSpaceBounds();
|
||||||
parameters.context.beginRoundedRect(
|
parameters.context.beginRoundedRect(
|
||||||
bounds.x * globalConfig.tileSize + boundsBorder,
|
bounds.x * globalConfig.tileSize + boundsBorder,
|
||||||
|
@ -158,10 +158,9 @@ export class MetaBuilding {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether this building is rotateable
|
* Returns whether this building is rotateable
|
||||||
* @param {string} variant
|
|
||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
getIsRotateable(variant) {
|
getIsRotateable() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,7 +242,7 @@ export class MetaBuilding {
|
|||||||
* @return {{ rotation: number, rotationVariant: number, connectedEntities?: Array<Entity> }}
|
* @return {{ rotation: number, rotationVariant: number, connectedEntities?: Array<Entity> }}
|
||||||
*/
|
*/
|
||||||
computeOptimalDirectionAndRotationVariantAtTile({ root, tile, rotation, variant, layer }) {
|
computeOptimalDirectionAndRotationVariantAtTile({ root, tile, rotation, variant, layer }) {
|
||||||
if (!this.getIsRotateable(variant)) {
|
if (!this.getIsRotateable()) {
|
||||||
return {
|
return {
|
||||||
rotation: 0,
|
rotation: 0,
|
||||||
rotationVariant: 0,
|
rotationVariant: 0,
|
||||||
|
@ -7,6 +7,8 @@ import { types } from "../../savegame/serialization";
|
|||||||
import { enumGameModeTypes, GameMode } from "../game_mode";
|
import { enumGameModeTypes, GameMode } from "../game_mode";
|
||||||
import { HUDPuzzleBackToMenu } from "../hud/parts/puzzle_back_to_menu";
|
import { HUDPuzzleBackToMenu } from "../hud/parts/puzzle_back_to_menu";
|
||||||
import { HUDPuzzleDLCLogo } from "../hud/parts/puzzle_dlc_logo";
|
import { HUDPuzzleDLCLogo } from "../hud/parts/puzzle_dlc_logo";
|
||||||
|
import { HUDBlueprintPlacer } from "../hud/parts/blueprint_placer";
|
||||||
|
import { HUDMassSelector } from "../hud/parts/mass_selector";
|
||||||
|
|
||||||
export class PuzzleGameMode extends GameMode {
|
export class PuzzleGameMode extends GameMode {
|
||||||
static getType() {
|
static getType() {
|
||||||
@ -30,6 +32,8 @@ export class PuzzleGameMode extends GameMode {
|
|||||||
this.additionalHudParts = {
|
this.additionalHudParts = {
|
||||||
puzzleBackToMenu: HUDPuzzleBackToMenu,
|
puzzleBackToMenu: HUDPuzzleBackToMenu,
|
||||||
puzzleDlcLogo: HUDPuzzleDLCLogo,
|
puzzleDlcLogo: HUDPuzzleDLCLogo,
|
||||||
|
blueprintPlacer: HUDBlueprintPlacer,
|
||||||
|
massSelector: HUDMassSelector,
|
||||||
};
|
};
|
||||||
|
|
||||||
this.zoneWidth = data.zoneWidth || 8;
|
this.zoneWidth = data.zoneWidth || 8;
|
||||||
@ -79,8 +83,8 @@ export class PuzzleGameMode extends GameMode {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
getSupportsCopyPaste() {
|
getHasFreeCopyPaste() {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
throughputDoesNotMatter() {
|
throughputDoesNotMatter() {
|
||||||
|
Loading…
Reference in New Issue
Block a user