1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2024-10-27 20:34:29 +00:00

Rename belt_base -> belt, minor refactorings

This commit is contained in:
tobspr 2020-09-18 12:55:46 +02:00
parent 0377c6d58f
commit 16902bed8d
8 changed files with 907 additions and 904 deletions

View File

@ -1,52 +1,230 @@
import { Loader } from "../../core/loader"; import { Loader } from "../../core/loader";
import { enumDirection } from "../../core/vector"; import { formatItemsPerSecond, generateMatrixRotations } from "../../core/utils";
import { SOUNDS } from "../../platform/sound"; import { enumAngleToDirection, enumDirection, Vector } from "../../core/vector";
import { arrayBeltVariantToRotation, MetaBeltBaseBuilding } from "./belt_base"; import { SOUNDS } from "../../platform/sound";
import { T } from "../../translations";
export class MetaBeltBuilding extends MetaBeltBaseBuilding { import { BeltComponent } from "../components/belt";
constructor() { import { Entity } from "../entity";
super("belt"); import { MetaBuilding } from "../meta_building";
} import { GameRoot } from "../root";
getSilhouetteColor() { export const arrayBeltVariantToRotation = [enumDirection.top, enumDirection.left, enumDirection.right];
return "#777";
} export const beltOverlayMatrices = {
[enumDirection.top]: generateMatrixRotations([0, 1, 0, 0, 1, 0, 0, 1, 0]),
getPlacementSound() { [enumDirection.left]: generateMatrixRotations([0, 0, 0, 1, 1, 0, 0, 1, 0]),
return SOUNDS.placeBelt; [enumDirection.right]: generateMatrixRotations([0, 0, 0, 0, 1, 1, 0, 1, 0]),
} };
getPreviewSprite(rotationVariant) { export class MetaBeltBaseBuilding extends MetaBuilding {}
switch (arrayBeltVariantToRotation[rotationVariant]) {
case enumDirection.top: { export class MetaBeltBuilding extends MetaBuilding {
return Loader.getSprite("sprites/buildings/belt_top.png"); constructor() {
} super("belt");
case enumDirection.left: { }
return Loader.getSprite("sprites/buildings/belt_left.png");
} getSilhouetteColor() {
case enumDirection.right: { return "#777";
return Loader.getSprite("sprites/buildings/belt_right.png"); }
}
default: { getPlacementSound() {
assertAlways(false, "Invalid belt rotation variant"); return SOUNDS.placeBelt;
} }
}
} getHasDirectionLockAvailable() {
return true;
getBlueprintSprite(rotationVariant) { }
switch (arrayBeltVariantToRotation[rotationVariant]) { getStayInPlacementMode() {
case enumDirection.top: { return true;
return Loader.getSprite("sprites/blueprints/belt_top.png"); }
}
case enumDirection.left: { getRotateAutomaticallyWhilePlacing() {
return Loader.getSprite("sprites/blueprints/belt_left.png"); return true;
} }
case enumDirection.right: {
return Loader.getSprite("sprites/blueprints/belt_right.png"); getSprite() {
} return null;
default: { }
assertAlways(false, "Invalid belt rotation variant");
} getIsReplaceable() {
} return true;
} }
}
/**
* @param {GameRoot} root
* @param {string} variant
* @returns {Array<[string, string]>}
*/
getAdditionalStatistics(root, variant) {
const beltSpeed = root.hubGoals.getBeltBaseSpeed();
return [[T.ingame.buildingPlacement.infoTexts.speed, formatItemsPerSecond(beltSpeed)]];
}
getPreviewSprite(rotationVariant) {
switch (arrayBeltVariantToRotation[rotationVariant]) {
case enumDirection.top: {
return Loader.getSprite("sprites/buildings/belt_top.png");
}
case enumDirection.left: {
return Loader.getSprite("sprites/buildings/belt_left.png");
}
case enumDirection.right: {
return Loader.getSprite("sprites/buildings/belt_right.png");
}
default: {
assertAlways(false, "Invalid belt rotation variant");
}
}
}
getBlueprintSprite(rotationVariant) {
switch (arrayBeltVariantToRotation[rotationVariant]) {
case enumDirection.top: {
return Loader.getSprite("sprites/blueprints/belt_top.png");
}
case enumDirection.left: {
return Loader.getSprite("sprites/blueprints/belt_left.png");
}
case enumDirection.right: {
return Loader.getSprite("sprites/blueprints/belt_right.png");
}
default: {
assertAlways(false, "Invalid belt rotation variant");
}
}
}
/**
*
* @param {number} rotation
* @param {number} rotationVariant
* @param {string} variant
* @param {Entity} entity
*/
getSpecialOverlayRenderMatrix(rotation, rotationVariant, variant, entity) {
return beltOverlayMatrices[entity.components.Belt.direction][rotation];
}
/**
* Creates the entity at the given location
* @param {Entity} entity
*/
setupEntityComponents(entity) {
entity.addComponent(
new BeltComponent({
direction: enumDirection.top, // updated later
})
);
}
/**
*
* @param {Entity} entity
* @param {number} rotationVariant
*/
updateVariants(entity, rotationVariant) {
entity.components.Belt.direction = arrayBeltVariantToRotation[rotationVariant];
}
/**
* Should compute the optimal rotation variant on the given tile
* @param {object} param0
* @param {GameRoot} param0.root
* @param {Vector} param0.tile
* @param {number} param0.rotation
* @param {string} param0.variant
* @param {Layer} param0.layer
* @return {{ rotation: number, rotationVariant: number, connectedEntities?: Array<Entity> }}
*/
computeOptimalDirectionAndRotationVariantAtTile({ root, tile, rotation, variant, layer }) {
const topDirection = enumAngleToDirection[rotation];
const rightDirection = enumAngleToDirection[(rotation + 90) % 360];
const bottomDirection = enumAngleToDirection[(rotation + 180) % 360];
const leftDirection = enumAngleToDirection[(rotation + 270) % 360];
const { ejectors, acceptors } = root.logic.getEjectorsAndAcceptorsAtTile(tile);
let hasBottomEjector = false;
let hasRightEjector = false;
let hasLeftEjector = false;
let hasTopAcceptor = false;
let hasLeftAcceptor = false;
let hasRightAcceptor = false;
// Check all ejectors
for (let i = 0; i < ejectors.length; ++i) {
const ejector = ejectors[i];
if (ejector.toDirection === topDirection) {
hasBottomEjector = true;
} else if (ejector.toDirection === leftDirection) {
hasRightEjector = true;
} else if (ejector.toDirection === rightDirection) {
hasLeftEjector = true;
}
}
// Check all acceptors
for (let i = 0; i < acceptors.length; ++i) {
const acceptor = acceptors[i];
if (acceptor.fromDirection === bottomDirection) {
hasTopAcceptor = true;
} else if (acceptor.fromDirection === rightDirection) {
hasLeftAcceptor = true;
} else if (acceptor.fromDirection === leftDirection) {
hasRightAcceptor = true;
}
}
// Soo .. if there is any ejector below us we always prioritize
// this ejector
if (!hasBottomEjector) {
// When something ejects to us from the left and nothing from the right,
// do a curve from the left to the top
if (hasRightEjector && !hasLeftEjector) {
return {
rotation: (rotation + 270) % 360,
rotationVariant: 2,
};
}
// When something ejects to us from the right and nothing from the left,
// do a curve from the right to the top
if (hasLeftEjector && !hasRightEjector) {
return {
rotation: (rotation + 90) % 360,
rotationVariant: 1,
};
}
}
// When there is a top acceptor, ignore sides
// NOTICE: This makes the belt prefer side turns *way* too much!
if (!hasTopAcceptor) {
// When there is an acceptor to the right but no acceptor to the left,
// do a turn to the right
if (hasRightAcceptor && !hasLeftAcceptor) {
return {
rotation,
rotationVariant: 2,
};
}
// When there is an acceptor to the left but no acceptor to the right,
// do a turn to the left
if (hasLeftAcceptor && !hasRightAcceptor) {
return {
rotation,
rotationVariant: 1,
};
}
}
return {
rotation,
rotationVariant: 0,
};
}
}

View File

@ -1,186 +0,0 @@
import { formatItemsPerSecond, generateMatrixRotations } from "../../core/utils";
import { enumAngleToDirection, enumDirection, Vector } from "../../core/vector";
import { SOUNDS } from "../../platform/sound";
import { T } from "../../translations";
import { BeltComponent } from "../components/belt";
import { Entity } from "../entity";
import { MetaBuilding } from "../meta_building";
import { GameRoot } from "../root";
export const arrayBeltVariantToRotation = [enumDirection.top, enumDirection.left, enumDirection.right];
export const beltOverlayMatrices = {
[enumDirection.top]: generateMatrixRotations([0, 1, 0, 0, 1, 0, 0, 1, 0]),
[enumDirection.left]: generateMatrixRotations([0, 0, 0, 1, 1, 0, 0, 1, 0]),
[enumDirection.right]: generateMatrixRotations([0, 0, 0, 0, 1, 1, 0, 1, 0]),
};
export class MetaBeltBaseBuilding extends MetaBuilding {
getHasDirectionLockAvailable() {
return true;
}
/**
* @param {GameRoot} root
* @param {string} variant
* @returns {Array<[string, string]>}
*/
getAdditionalStatistics(root, variant) {
const beltSpeed = root.hubGoals.getBeltBaseSpeed();
return [[T.ingame.buildingPlacement.infoTexts.speed, formatItemsPerSecond(beltSpeed)]];
}
getStayInPlacementMode() {
return true;
}
getRotateAutomaticallyWhilePlacing() {
return true;
}
getPlacementSound() {
return SOUNDS.placeBelt;
}
getSprite() {
return null;
}
getIsReplaceable() {
return true;
}
/**
*
* @param {number} rotation
* @param {number} rotationVariant
* @param {string} variant
* @param {Entity} entity
*/
getSpecialOverlayRenderMatrix(rotation, rotationVariant, variant, entity) {
return beltOverlayMatrices[entity.components.Belt.direction][rotation];
}
/**
* Creates the entity at the given location
* @param {Entity} entity
*/
setupEntityComponents(entity) {
entity.addComponent(
new BeltComponent({
direction: enumDirection.top, // updated later
})
);
}
/**
*
* @param {Entity} entity
* @param {number} rotationVariant
*/
updateVariants(entity, rotationVariant) {
entity.components.Belt.direction = arrayBeltVariantToRotation[rotationVariant];
}
/**
* Should compute the optimal rotation variant on the given tile
* @param {object} param0
* @param {GameRoot} param0.root
* @param {Vector} param0.tile
* @param {number} param0.rotation
* @param {string} param0.variant
* @param {Layer} param0.layer
* @return {{ rotation: number, rotationVariant: number, connectedEntities?: Array<Entity> }}
*/
computeOptimalDirectionAndRotationVariantAtTile({ root, tile, rotation, variant, layer }) {
const topDirection = enumAngleToDirection[rotation];
const rightDirection = enumAngleToDirection[(rotation + 90) % 360];
const bottomDirection = enumAngleToDirection[(rotation + 180) % 360];
const leftDirection = enumAngleToDirection[(rotation + 270) % 360];
const { ejectors, acceptors } = root.logic.getEjectorsAndAcceptorsAtTile(tile);
let hasBottomEjector = false;
let hasRightEjector = false;
let hasLeftEjector = false;
let hasTopAcceptor = false;
let hasLeftAcceptor = false;
let hasRightAcceptor = false;
// Check all ejectors
for (let i = 0; i < ejectors.length; ++i) {
const ejector = ejectors[i];
if (ejector.toDirection === topDirection) {
hasBottomEjector = true;
} else if (ejector.toDirection === leftDirection) {
hasRightEjector = true;
} else if (ejector.toDirection === rightDirection) {
hasLeftEjector = true;
}
}
// Check all acceptors
for (let i = 0; i < acceptors.length; ++i) {
const acceptor = acceptors[i];
if (acceptor.fromDirection === bottomDirection) {
hasTopAcceptor = true;
} else if (acceptor.fromDirection === rightDirection) {
hasLeftAcceptor = true;
} else if (acceptor.fromDirection === leftDirection) {
hasRightAcceptor = true;
}
}
// Soo .. if there is any ejector below us we always prioritize
// this ejector
if (!hasBottomEjector) {
// When something ejects to us from the left and nothing from the right,
// do a curve from the left to the top
if (hasRightEjector && !hasLeftEjector) {
return {
rotation: (rotation + 270) % 360,
rotationVariant: 2,
};
}
// When something ejects to us from the right and nothing from the left,
// do a curve from the right to the top
if (hasLeftEjector && !hasRightEjector) {
return {
rotation: (rotation + 90) % 360,
rotationVariant: 1,
};
}
}
// When there is a top acceptor, ignore sides
// NOTICE: This makes the belt prefer side turns *way* too much!
if (!hasTopAcceptor) {
// When there is an acceptor to the right but no acceptor to the left,
// do a turn to the right
if (hasRightAcceptor && !hasLeftAcceptor) {
return {
rotation,
rotationVariant: 2,
};
}
// When there is an acceptor to the left but no acceptor to the right,
// do a turn to the left
if (hasLeftAcceptor && !hasRightAcceptor) {
return {
rotation,
rotationVariant: 1,
};
}
}
return {
rotation,
rotationVariant: 0,
};
}
}

View File

@ -1,21 +1,21 @@
import { MetaBeltBaseBuilding } from "../../buildings/belt_base"; import { MetaBeltBuilding } from "../../buildings/belt";
import { MetaCutterBuilding } from "../../buildings/cutter"; import { MetaCutterBuilding } from "../../buildings/cutter";
import { MetaDisplayBuilding } from "../../buildings/display";
import { MetaFilterBuilding } from "../../buildings/filter";
import { MetaLeverBuilding } from "../../buildings/lever";
import { MetaMinerBuilding } from "../../buildings/miner"; import { MetaMinerBuilding } from "../../buildings/miner";
import { MetaMixerBuilding } from "../../buildings/mixer"; import { MetaMixerBuilding } from "../../buildings/mixer";
import { MetaPainterBuilding } from "../../buildings/painter"; import { MetaPainterBuilding } from "../../buildings/painter";
import { MetaReaderBuilding } from "../../buildings/reader";
import { MetaRotaterBuilding } from "../../buildings/rotater"; import { MetaRotaterBuilding } from "../../buildings/rotater";
import { MetaSplitterBuilding } from "../../buildings/splitter"; import { MetaSplitterBuilding } from "../../buildings/splitter";
import { MetaStackerBuilding } from "../../buildings/stacker"; import { MetaStackerBuilding } from "../../buildings/stacker";
import { MetaTrashBuilding } from "../../buildings/trash"; import { MetaTrashBuilding } from "../../buildings/trash";
import { MetaUndergroundBeltBuilding } from "../../buildings/underground_belt"; import { MetaUndergroundBeltBuilding } from "../../buildings/underground_belt";
import { HUDBaseToolbar } from "./base_toolbar"; import { HUDBaseToolbar } from "./base_toolbar";
import { MetaLeverBuilding } from "../../buildings/lever";
import { MetaFilterBuilding } from "../../buildings/filter";
import { MetaDisplayBuilding } from "../../buildings/display";
import { MetaReaderBuilding } from "../../buildings/reader";
const supportedBuildings = [ const supportedBuildings = [
MetaBeltBaseBuilding, MetaBeltBuilding,
MetaSplitterBuilding, MetaSplitterBuilding,
MetaUndergroundBeltBuilding, MetaUndergroundBeltBuilding,
MetaMinerBuilding, MetaMinerBuilding,

View File

@ -67,7 +67,7 @@ export class HUDMinerHighlight extends BaseHUDPart {
const maxThroughput = this.root.hubGoals.getBeltBaseSpeed(); const maxThroughput = this.root.hubGoals.getBeltBaseSpeed();
const screenPos = this.root.camera.screenToWorld(mousePos); const tooltipLocation = this.root.camera.screenToWorld(mousePos);
const scale = (1 / this.root.camera.zoomLevel) * this.root.app.getEffectiveUiScale(); const scale = (1 / this.root.camera.zoomLevel) * this.root.app.getEffectiveUiScale();
@ -76,8 +76,8 @@ export class HUDMinerHighlight extends BaseHUDPart {
// Background // Background
parameters.context.fillStyle = THEME.map.connectedMiners.background; parameters.context.fillStyle = THEME.map.connectedMiners.background;
parameters.context.beginRoundedRect( parameters.context.beginRoundedRect(
screenPos.x + 5 * scale, tooltipLocation.x + 5 * scale,
screenPos.y - 3 * scale, tooltipLocation.y - 3 * scale,
(isCapped ? 100 : 65) * scale, (isCapped ? 100 : 65) * scale,
(isCapped ? 45 : 30) * scale, (isCapped ? 45 : 30) * scale,
2 2
@ -89,8 +89,8 @@ export class HUDMinerHighlight extends BaseHUDPart {
parameters.context.font = "bold " + scale * 10 + "px GameFont"; parameters.context.font = "bold " + scale * 10 + "px GameFont";
parameters.context.fillText( parameters.context.fillText(
formatItemsPerSecond(throughput), formatItemsPerSecond(throughput),
screenPos.x + 10 * scale, tooltipLocation.x + 10 * scale,
screenPos.y + 10 * scale tooltipLocation.y + 10 * scale
); );
// Amount of miners // Amount of miners
@ -100,8 +100,8 @@ export class HUDMinerHighlight extends BaseHUDPart {
connectedEntities.length === 1 connectedEntities.length === 1
? T.ingame.connectedMiners.one_miner ? T.ingame.connectedMiners.one_miner
: T.ingame.connectedMiners.n_miners.replace("<amount>", String(connectedEntities.length)), : T.ingame.connectedMiners.n_miners.replace("<amount>", String(connectedEntities.length)),
screenPos.x + 10 * scale, tooltipLocation.x + 10 * scale,
screenPos.y + 22 * scale tooltipLocation.y + 22 * scale
); );
parameters.context.globalAlpha = 1; parameters.context.globalAlpha = 1;
@ -113,8 +113,8 @@ export class HUDMinerHighlight extends BaseHUDPart {
"<max_throughput>", "<max_throughput>",
formatItemsPerSecond(maxThroughput) formatItemsPerSecond(maxThroughput)
), ),
screenPos.x + 10 * scale, tooltipLocation.x + 10 * scale,
screenPos.y + 34 * scale tooltipLocation.y + 34 * scale
); );
} }
} }

View File

@ -1,125 +1,122 @@
import { GameRoot } from "../root"; import { GameRoot } from "../root";
import { globalConfig } from "../../core/config"; import { globalConfig } from "../../core/config";
import { Vector, mixVector } from "../../core/vector"; import { Vector, mixVector } from "../../core/vector";
import { lerp } from "../../core/utils"; import { lerp } from "../../core/utils";
/* dev:start */ /* dev:start */
import trailerPoints from "./trailer_points"; import trailerPoints from "./trailer_points";
import { gMetaBuildingRegistry } from "../../core/global_registries";
import { MetaBeltBaseBuilding } from "../buildings/belt_base"; const tickrate = 1 / 165;
import { MinerComponent } from "../components/miner";
export class TrailerMaker {
const tickrate = 1 / 165; /**
*
export class TrailerMaker { * @param {GameRoot} root
/** */
* constructor(root) {
* @param {GameRoot} root this.root = root;
*/
constructor(root) { this.markers = [];
this.root = root; this.playbackMarkers = null;
this.currentPlaybackOrigin = new Vector();
this.markers = []; this.currentPlaybackZoom = 3;
this.playbackMarkers = null;
this.currentPlaybackOrigin = new Vector(); window.addEventListener("keydown", ev => {
this.currentPlaybackZoom = 3; if (ev.key === "j") {
console.log("Record");
window.addEventListener("keydown", ev => { this.markers.push({
if (ev.key === "j") { pos: this.root.camera.center.copy(),
console.log("Record"); zoom: this.root.camera.zoomLevel,
this.markers.push({ time: 1,
pos: this.root.camera.center.copy(), wait: 0,
zoom: this.root.camera.zoomLevel, });
time: 1, } else if (ev.key === "k") {
wait: 0, console.log("Export");
}); const json = JSON.stringify(this.markers);
} else if (ev.key === "k") { const handle = window.open("about:blank");
console.log("Export"); handle.document.write(json);
const json = JSON.stringify(this.markers); } else if (ev.key === "u") {
const handle = window.open("about:blank"); if (this.playbackMarkers && this.playbackMarkers.length > 0) {
handle.document.write(json); this.playbackMarkers = [];
} else if (ev.key === "u") { return;
if (this.playbackMarkers && this.playbackMarkers.length > 0) { }
this.playbackMarkers = []; console.log("Playback");
return; this.playbackMarkers = trailerPoints.map(p => Object.assign({}, p));
} this.playbackMarkers.unshift(this.playbackMarkers[0]);
console.log("Playback"); this.currentPlaybackOrigin = Vector.fromSerializedObject(this.playbackMarkers[0].pos);
this.playbackMarkers = trailerPoints.map(p => Object.assign({}, p));
this.playbackMarkers.unshift(this.playbackMarkers[0]); this.currentPlaybackZoom = this.playbackMarkers[0].zoom;
this.currentPlaybackOrigin = Vector.fromSerializedObject(this.playbackMarkers[0].pos); this.root.camera.center = this.currentPlaybackOrigin.copy();
this.root.camera.zoomLevel = this.currentPlaybackZoom;
this.currentPlaybackZoom = this.playbackMarkers[0].zoom; console.log("STart at", this.currentPlaybackOrigin);
this.root.camera.center = this.currentPlaybackOrigin.copy();
this.root.camera.zoomLevel = this.currentPlaybackZoom; // this.root.entityMgr.getAllWithComponent(MinerComponent).forEach(miner => {
console.log("STart at", this.currentPlaybackOrigin); // miner.components.Miner.itemChainBuffer = [];
// miner.components.Miner.lastMiningTime = this.root.time.now() + 5;
// this.root.entityMgr.getAllWithComponent(MinerComponent).forEach(miner => { // miner.components.ItemEjector.slots.forEach(slot => (slot.item = null));
// miner.components.Miner.itemChainBuffer = []; // });
// miner.components.Miner.lastMiningTime = this.root.time.now() + 5;
// miner.components.ItemEjector.slots.forEach(slot => (slot.item = null)); // this.root.logic.tryPlaceBuilding({
// }); // origin: new Vector(-428, -15),
// building: gMetaBuildingRegistry.findByClass(MetaBeltBaseBuilding),
// this.root.logic.tryPlaceBuilding({ // originalRotation: 0,
// origin: new Vector(-428, -15), // rotation: 0,
// building: gMetaBuildingRegistry.findByClass(MetaBeltBaseBuilding), // variant: "default",
// originalRotation: 0, // rotationVariant: 0,
// rotation: 0, // });
// variant: "default",
// rotationVariant: 0, // this.root.logic.tryPlaceBuilding({
// }); // origin: new Vector(-427, -15),
// building: gMetaBuildingRegistry.findByClass(MetaBeltBaseBuilding),
// this.root.logic.tryPlaceBuilding({ // originalRotation: 0,
// origin: new Vector(-427, -15), // rotation: 0,
// building: gMetaBuildingRegistry.findByClass(MetaBeltBaseBuilding), // variant: "default",
// originalRotation: 0, // rotationVariant: 0,
// rotation: 0, // });
// variant: "default", }
// rotationVariant: 0, });
// }); }
}
}); update() {
} if (this.playbackMarkers && this.playbackMarkers.length > 0) {
const nextMarker = this.playbackMarkers[0];
update() {
if (this.playbackMarkers && this.playbackMarkers.length > 0) { if (!nextMarker.startTime) {
const nextMarker = this.playbackMarkers[0]; console.log("Starting to approach", nextMarker.pos);
nextMarker.startTime = performance.now() / 1000.0;
if (!nextMarker.startTime) { }
console.log("Starting to approach", nextMarker.pos);
nextMarker.startTime = performance.now() / 1000.0; const speed =
} globalConfig.tileSize *
globalConfig.beltSpeedItemsPerSecond *
const speed = globalConfig.itemSpacingOnBelts;
globalConfig.tileSize * // let time =
globalConfig.beltSpeedItemsPerSecond * // this.currentPlaybackOrigin.distance(Vector.fromSerializedObject(nextMarker.pos)) / speed;
globalConfig.itemSpacingOnBelts; const time = nextMarker.time;
// let time =
// this.currentPlaybackOrigin.distance(Vector.fromSerializedObject(nextMarker.pos)) / speed; const progress = (performance.now() / 1000.0 - nextMarker.startTime) / time;
const time = nextMarker.time;
if (progress > 1.0) {
const progress = (performance.now() / 1000.0 - nextMarker.startTime) / time; if (nextMarker.wait > 0) {
nextMarker.wait -= tickrate;
if (progress > 1.0) { } else {
if (nextMarker.wait > 0) { console.log("Approached");
nextMarker.wait -= tickrate; this.currentPlaybackOrigin = this.root.camera.center.copy();
} else { this.currentPlaybackZoom = this.root.camera.zoomLevel;
console.log("Approached"); this.playbackMarkers.shift();
this.currentPlaybackOrigin = this.root.camera.center.copy(); }
this.currentPlaybackZoom = this.root.camera.zoomLevel; return;
this.playbackMarkers.shift(); }
}
return; const targetPos = Vector.fromSerializedObject(nextMarker.pos);
} const targetZoom = nextMarker.zoom;
const targetPos = Vector.fromSerializedObject(nextMarker.pos); const pos = mixVector(this.currentPlaybackOrigin, targetPos, progress);
const targetZoom = nextMarker.zoom; const zoom = lerp(this.currentPlaybackZoom, targetZoom, progress);
this.root.camera.zoomLevel = zoom;
const pos = mixVector(this.currentPlaybackOrigin, targetPos, progress); this.root.camera.center = pos;
const zoom = lerp(this.currentPlaybackZoom, targetZoom, progress); }
this.root.camera.zoomLevel = zoom; }
this.root.camera.center = pos; }
}
} /* dev:end */
}
/* dev:end */

View File

@ -1,7 +1,6 @@
import { gMetaBuildingRegistry } from "../core/global_registries"; import { gMetaBuildingRegistry } from "../core/global_registries";
import { createLogger } from "../core/logging"; import { createLogger } from "../core/logging";
import { MetaBeltBuilding } from "./buildings/belt"; import { MetaBeltBuilding } from "./buildings/belt";
import { MetaBeltBaseBuilding } from "./buildings/belt_base";
import { enumCutterVariants, MetaCutterBuilding } from "./buildings/cutter"; import { enumCutterVariants, MetaCutterBuilding } from "./buildings/cutter";
import { MetaHubBuilding } from "./buildings/hub"; import { MetaHubBuilding } from "./buildings/hub";
import { enumMinerVariants, MetaMinerBuilding } from "./buildings/miner"; import { enumMinerVariants, MetaMinerBuilding } from "./buildings/miner";
@ -49,9 +48,9 @@ export function initMetaBuildingRegistry() {
gMetaBuildingRegistry.register(MetaReaderBuilding); gMetaBuildingRegistry.register(MetaReaderBuilding);
// Belt // Belt
registerBuildingVariant(1, MetaBeltBaseBuilding, defaultBuildingVariant, 0); registerBuildingVariant(1, MetaBeltBuilding, defaultBuildingVariant, 0);
registerBuildingVariant(2, MetaBeltBaseBuilding, defaultBuildingVariant, 1); registerBuildingVariant(2, MetaBeltBuilding, defaultBuildingVariant, 1);
registerBuildingVariant(3, MetaBeltBaseBuilding, defaultBuildingVariant, 2); registerBuildingVariant(3, MetaBeltBuilding, defaultBuildingVariant, 2);
// Splitter // Splitter
registerBuildingVariant(4, MetaSplitterBuilding); registerBuildingVariant(4, MetaSplitterBuilding);

File diff suppressed because it is too large Load Diff

View File

@ -133,7 +133,7 @@ export class MainMenuState extends GameState {
!this.app.platformWrapper.getHasUnlimitedSavegames() !this.app.platformWrapper.getHasUnlimitedSavegames()
) { ) {
this.app.analytics.trackUiClick("importgame_slot_limit_show"); this.app.analytics.trackUiClick("importgame_slot_limit_show");
this.dialogs.showWarning(T.dialogs.oneSavegameLimit.title, T.dialogs.oneSavegameLimit.desc); this.showSavegameSlotLimit();
return; return;
} }
@ -522,6 +522,21 @@ export class MainMenuState extends GameState {
}); });
} }
/**
* Shows a hint that the slot limit has been reached
*/
showSavegameSlotLimit() {
const { getStandalone } = this.dialogs.showWarning(
T.dialogs.oneSavegameLimit.title,
T.dialogs.oneSavegameLimit.desc,
["cancel:bad", "getStandalone:good"]
);
getStandalone.add(() => {
this.app.analytics.trackUiClick("visit_steampage_from_slot_limit");
this.app.platformWrapper.openExternalLink(THIRDPARTY_URLS.standaloneStorePage);
});
}
onSettingsButtonClicked() { onSettingsButtonClicked() {
this.moveToState("SettingsState"); this.moveToState("SettingsState");
} }
@ -540,7 +555,7 @@ export class MainMenuState extends GameState {
!this.app.platformWrapper.getHasUnlimitedSavegames() !this.app.platformWrapper.getHasUnlimitedSavegames()
) { ) {
this.app.analytics.trackUiClick("startgame_slot_limit_show"); this.app.analytics.trackUiClick("startgame_slot_limit_show");
this.dialogs.showWarning(T.dialogs.oneSavegameLimit.title, T.dialogs.oneSavegameLimit.desc); this.showSavegameSlotLimit();
return; return;
} }