Rename belt_base -> belt, minor refactorings

pull/670/head
tobspr 4 years ago
parent 0377c6d58f
commit 16902bed8d

@ -1,52 +1,230 @@
import { Loader } from "../../core/loader";
import { enumDirection } from "../../core/vector";
import { SOUNDS } from "../../platform/sound";
import { arrayBeltVariantToRotation, MetaBeltBaseBuilding } from "./belt_base";
export class MetaBeltBuilding extends MetaBeltBaseBuilding {
constructor() {
super("belt");
}
getSilhouetteColor() {
return "#777";
}
getPlacementSound() {
return SOUNDS.placeBelt;
}
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");
}
}
}
}
import { Loader } from "../../core/loader";
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 {}
export class MetaBeltBuilding extends MetaBuilding {
constructor() {
super("belt");
}
getSilhouetteColor() {
return "#777";
}
getPlacementSound() {
return SOUNDS.placeBelt;
}
getHasDirectionLockAvailable() {
return true;
}
getStayInPlacementMode() {
return true;
}
getRotateAutomaticallyWhilePlacing() {
return true;
}
getSprite() {
return null;
}
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,
};
}
}

@ -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,
};
}
}

@ -1,21 +1,21 @@
import { MetaBeltBaseBuilding } from "../../buildings/belt_base";
import { MetaBeltBuilding } from "../../buildings/belt";
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 { MetaMixerBuilding } from "../../buildings/mixer";
import { MetaPainterBuilding } from "../../buildings/painter";
import { MetaReaderBuilding } from "../../buildings/reader";
import { MetaRotaterBuilding } from "../../buildings/rotater";
import { MetaSplitterBuilding } from "../../buildings/splitter";
import { MetaStackerBuilding } from "../../buildings/stacker";
import { MetaTrashBuilding } from "../../buildings/trash";
import { MetaUndergroundBeltBuilding } from "../../buildings/underground_belt";
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 = [
MetaBeltBaseBuilding,
MetaBeltBuilding,
MetaSplitterBuilding,
MetaUndergroundBeltBuilding,
MetaMinerBuilding,

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

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

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

File diff suppressed because it is too large Load Diff

@ -133,7 +133,7 @@ export class MainMenuState extends GameState {
!this.app.platformWrapper.getHasUnlimitedSavegames()
) {
this.app.analytics.trackUiClick("importgame_slot_limit_show");
this.dialogs.showWarning(T.dialogs.oneSavegameLimit.title, T.dialogs.oneSavegameLimit.desc);
this.showSavegameSlotLimit();
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() {
this.moveToState("SettingsState");
}
@ -540,7 +555,7 @@ export class MainMenuState extends GameState {
!this.app.platformWrapper.getHasUnlimitedSavegames()
) {
this.app.analytics.trackUiClick("startgame_slot_limit_show");
this.dialogs.showWarning(T.dialogs.oneSavegameLimit.title, T.dialogs.oneSavegameLimit.desc);
this.showSavegameSlotLimit();
return;
}

Loading…
Cancel
Save