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:
parent
0377c6d58f
commit
16902bed8d
@ -1,9 +1,24 @@
|
|||||||
import { Loader } from "../../core/loader";
|
import { Loader } from "../../core/loader";
|
||||||
import { enumDirection } from "../../core/vector";
|
import { formatItemsPerSecond, generateMatrixRotations } from "../../core/utils";
|
||||||
|
import { enumAngleToDirection, enumDirection, Vector } from "../../core/vector";
|
||||||
import { SOUNDS } from "../../platform/sound";
|
import { SOUNDS } from "../../platform/sound";
|
||||||
import { arrayBeltVariantToRotation, MetaBeltBaseBuilding } from "./belt_base";
|
import { T } from "../../translations";
|
||||||
|
import { BeltComponent } from "../components/belt";
|
||||||
|
import { Entity } from "../entity";
|
||||||
|
import { MetaBuilding } from "../meta_building";
|
||||||
|
import { GameRoot } from "../root";
|
||||||
|
|
||||||
export class MetaBeltBuilding extends MetaBeltBaseBuilding {
|
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() {
|
constructor() {
|
||||||
super("belt");
|
super("belt");
|
||||||
}
|
}
|
||||||
@ -16,6 +31,35 @@ export class MetaBeltBuilding extends MetaBeltBaseBuilding {
|
|||||||
return SOUNDS.placeBelt;
|
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) {
|
getPreviewSprite(rotationVariant) {
|
||||||
switch (arrayBeltVariantToRotation[rotationVariant]) {
|
switch (arrayBeltVariantToRotation[rotationVariant]) {
|
||||||
case enumDirection.top: {
|
case enumDirection.top: {
|
||||||
@ -49,4 +93,138 @@ export class MetaBeltBuilding extends MetaBeltBaseBuilding {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @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 { 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,
|
||||||
|
@ -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
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,9 +5,6 @@ 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";
|
|
||||||
import { MinerComponent } from "../components/miner";
|
|
||||||
|
|
||||||
const tickrate = 1 / 165;
|
const tickrate = 1 / 165;
|
||||||
|
|
||||||
|
@ -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);
|
||||||
|
@ -7,13 +7,13 @@ import { AtlasSprite } from "../../core/sprites";
|
|||||||
import { fastArrayDeleteValue } from "../../core/utils";
|
import { fastArrayDeleteValue } from "../../core/utils";
|
||||||
import { enumDirection, enumDirectionToVector, enumInvertedDirections, Vector } from "../../core/vector";
|
import { enumDirection, enumDirectionToVector, enumInvertedDirections, Vector } from "../../core/vector";
|
||||||
import { BeltPath } from "../belt_path";
|
import { BeltPath } from "../belt_path";
|
||||||
import { arrayBeltVariantToRotation, MetaBeltBaseBuilding } from "../buildings/belt_base";
|
|
||||||
import { BeltComponent } from "../components/belt";
|
import { BeltComponent } from "../components/belt";
|
||||||
import { Entity } from "../entity";
|
import { Entity } from "../entity";
|
||||||
import { GameSystemWithFilter } from "../game_system_with_filter";
|
import { GameSystemWithFilter } from "../game_system_with_filter";
|
||||||
import { MapChunkView } from "../map_chunk_view";
|
import { MapChunkView } from "../map_chunk_view";
|
||||||
import { defaultBuildingVariant } from "../meta_building";
|
import { defaultBuildingVariant } from "../meta_building";
|
||||||
import { getCodeFromBuildingData } from "../building_codes";
|
import { getCodeFromBuildingData } from "../building_codes";
|
||||||
|
import { arrayBeltVariantToRotation, MetaBeltBuilding } from "../buildings/belt";
|
||||||
|
|
||||||
export const BELT_ANIM_COUNT = 14;
|
export const BELT_ANIM_COUNT = 14;
|
||||||
|
|
||||||
@ -123,7 +123,7 @@ export class BeltSystem extends GameSystemWithFilter {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const metaBelt = gMetaBuildingRegistry.findByClass(MetaBeltBaseBuilding);
|
const metaBelt = gMetaBuildingRegistry.findByClass(MetaBeltBuilding);
|
||||||
// Compute affected area
|
// Compute affected area
|
||||||
const originalRect = staticComp.getTileSpaceBounds();
|
const originalRect = staticComp.getTileSpaceBounds();
|
||||||
const affectedArea = originalRect.expandedInAllDirections(1);
|
const affectedArea = originalRect.expandedInAllDirections(1);
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user