1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2025-12-16 03:31:52 +00:00

Undo unnecesary renaming

This commit is contained in:
Sense101 2022-01-23 17:04:05 +00:00
parent fb0a66f5ca
commit 5a310629c0
9 changed files with 18 additions and 26 deletions

View File

@ -87,7 +87,7 @@ export const globalConfig = {
puzzleMaxBoundsSize: 20, puzzleMaxBoundsSize: 20,
puzzleValidationDurationSeconds: 30, puzzleValidationDurationSeconds: 30,
buildingAmountsToBelt: { buildingRatios: {
cutter: 4, cutter: 4,
cutterQuad: 4, cutterQuad: 4,
painter: 6, painter: 6,

View File

@ -134,15 +134,12 @@ export class BeltPath extends BasicSerializableObject {
*/ */
tryAcceptItem(item, startProgress = 0) { tryAcceptItem(item, startProgress = 0) {
if (this.spacingToFirstItem >= globalConfig.itemSpacingOnBelts) { if (this.spacingToFirstItem >= globalConfig.itemSpacingOnBelts) {
// *Never* cap start progress, or if an item moves more than a belt in a tick, it breaks // First, compute how much progress we can make *at max*
// instead return false if the start progress is too much
const maxProgress = Math.max(0, this.spacingToFirstItem - globalConfig.itemSpacingOnBelts); const maxProgress = Math.max(0, this.spacingToFirstItem - globalConfig.itemSpacingOnBelts);
if (startProgress > maxProgress) { const initialProgress = Math.min(maxProgress, startProgress);
return false;
}
this.items.unshift([this.spacingToFirstItem - startProgress, item]); this.items.unshift([this.spacingToFirstItem - initialProgress, item]);
this.spacingToFirstItem = startProgress; this.spacingToFirstItem = initialProgress;
if (G_IS_DEV && globalConfig.debug.checkBeltPaths) { if (G_IS_DEV && globalConfig.debug.checkBeltPaths) {
this.debug_checkIntegrity("accept-item"); this.debug_checkIntegrity("accept-item");
@ -273,11 +270,6 @@ export class BeltPath extends BasicSerializableObject {
const matchingDirection = enumInvertedDirections[ejectingDirection]; const matchingDirection = enumInvertedDirections[ejectingDirection];
return function (item, startProgress = 0.0) { return function (item, startProgress = 0.0) {
// storage has to have its own duplicated logic, as it's the ONLY building which the acceptor can't filter for it
const storageComp = targetEntity.components.Storage;
if (storageComp && !storageComp.canAcceptItem(item)) {
return false;
}
if (targetAcceptorComp.tryAcceptItem(matchingSlotIndex, matchingDirection, item, startProgress)) { if (targetAcceptorComp.tryAcceptItem(matchingSlotIndex, matchingDirection, item, startProgress)) {
return true; return true;
} }

View File

@ -104,7 +104,7 @@ export class MetaBalancerBuilding extends MetaBuilding {
speedMultiplier = 1; speedMultiplier = 1;
} }
const speed = root.hubGoals.getProcessingSpeed(enumItemProcessorTypes.balancer) * speedMultiplier; const speed = root.hubGoals.getProcessorBaseSpeed(enumItemProcessorTypes.balancer) * speedMultiplier;
return [[T.ingame.buildingPlacement.infoTexts.speed, formatItemsPerSecond(speed)]]; return [[T.ingame.buildingPlacement.infoTexts.speed, formatItemsPerSecond(speed)]];
} }

View File

@ -54,7 +54,7 @@ export class MetaCutterBuilding extends MetaBuilding {
if (root.gameMode.throughputDoesNotMatter()) { if (root.gameMode.throughputDoesNotMatter()) {
return []; return [];
} }
const speed = root.hubGoals.getProcessingSpeed( const speed = root.hubGoals.getProcessorBaseSpeed(
variant === enumCutterVariants.quad variant === enumCutterVariants.quad
? enumItemProcessorTypes.cutterQuad ? enumItemProcessorTypes.cutterQuad
: enumItemProcessorTypes.cutter : enumItemProcessorTypes.cutter

View File

@ -47,7 +47,7 @@ export class MetaMixerBuilding extends MetaBuilding {
if (root.gameMode.throughputDoesNotMatter()) { if (root.gameMode.throughputDoesNotMatter()) {
return []; return [];
} }
const speed = root.hubGoals.getProcessingSpeed(enumItemProcessorTypes.mixer); const speed = root.hubGoals.getProcessorBaseSpeed(enumItemProcessorTypes.mixer);
return [[T.ingame.buildingPlacement.infoTexts.speed, formatItemsPerSecond(speed)]]; return [[T.ingame.buildingPlacement.infoTexts.speed, formatItemsPerSecond(speed)]];
} }

View File

@ -73,15 +73,15 @@ export class MetaPainterBuilding extends MetaBuilding {
switch (variant) { switch (variant) {
case defaultBuildingVariant: case defaultBuildingVariant:
case enumPainterVariants.mirrored: { case enumPainterVariants.mirrored: {
const speed = root.hubGoals.getProcessingSpeed(enumItemProcessorTypes.painter); const speed = root.hubGoals.getProcessorBaseSpeed(enumItemProcessorTypes.painter);
return [[T.ingame.buildingPlacement.infoTexts.speed, formatItemsPerSecond(speed)]]; return [[T.ingame.buildingPlacement.infoTexts.speed, formatItemsPerSecond(speed)]];
} }
case enumPainterVariants.double: { case enumPainterVariants.double: {
const speed = root.hubGoals.getProcessingSpeed(enumItemProcessorTypes.painterDouble); const speed = root.hubGoals.getProcessorBaseSpeed(enumItemProcessorTypes.painterDouble);
return [[T.ingame.buildingPlacement.infoTexts.speed, formatItemsPerSecond(speed, true)]]; return [[T.ingame.buildingPlacement.infoTexts.speed, formatItemsPerSecond(speed, true)]];
} }
case enumPainterVariants.quad: { case enumPainterVariants.quad: {
const speed = root.hubGoals.getProcessingSpeed(enumItemProcessorTypes.painterQuad); const speed = root.hubGoals.getProcessorBaseSpeed(enumItemProcessorTypes.painterQuad);
return [[T.ingame.buildingPlacement.infoTexts.speed, formatItemsPerSecond(speed)]]; return [[T.ingame.buildingPlacement.infoTexts.speed, formatItemsPerSecond(speed)]];
} }
} }

View File

@ -70,15 +70,15 @@ export class MetaRotaterBuilding extends MetaBuilding {
} }
switch (variant) { switch (variant) {
case defaultBuildingVariant: { case defaultBuildingVariant: {
const speed = root.hubGoals.getProcessingSpeed(enumItemProcessorTypes.rotater); const speed = root.hubGoals.getProcessorBaseSpeed(enumItemProcessorTypes.rotater);
return [[T.ingame.buildingPlacement.infoTexts.speed, formatItemsPerSecond(speed)]]; return [[T.ingame.buildingPlacement.infoTexts.speed, formatItemsPerSecond(speed)]];
} }
case enumRotaterVariants.ccw: { case enumRotaterVariants.ccw: {
const speed = root.hubGoals.getProcessingSpeed(enumItemProcessorTypes.rotaterCCW); const speed = root.hubGoals.getProcessorBaseSpeed(enumItemProcessorTypes.rotaterCCW);
return [[T.ingame.buildingPlacement.infoTexts.speed, formatItemsPerSecond(speed)]]; return [[T.ingame.buildingPlacement.infoTexts.speed, formatItemsPerSecond(speed)]];
} }
case enumRotaterVariants.rotate180: { case enumRotaterVariants.rotate180: {
const speed = root.hubGoals.getProcessingSpeed(enumItemProcessorTypes.rotater180); const speed = root.hubGoals.getProcessorBaseSpeed(enumItemProcessorTypes.rotater180);
return [[T.ingame.buildingPlacement.infoTexts.speed, formatItemsPerSecond(speed)]]; return [[T.ingame.buildingPlacement.infoTexts.speed, formatItemsPerSecond(speed)]];
} }
} }

View File

@ -40,7 +40,7 @@ export class MetaStackerBuilding extends MetaBuilding {
if (root.gameMode.throughputDoesNotMatter()) { if (root.gameMode.throughputDoesNotMatter()) {
return []; return [];
} }
const speed = root.hubGoals.getProcessingSpeed(enumItemProcessorTypes.stacker); const speed = root.hubGoals.getProcessorBaseSpeed(enumItemProcessorTypes.stacker);
return [[T.ingame.buildingPlacement.infoTexts.speed, formatItemsPerSecond(speed)]]; return [[T.ingame.buildingPlacement.infoTexts.speed, formatItemsPerSecond(speed)]];
} }

View File

@ -555,13 +555,13 @@ export class HubGoals extends BasicSerializableObject {
*/ */
getProcessorTimeWithUpgrades(upgrade, processorType) { getProcessorTimeWithUpgrades(upgrade, processorType) {
assert( assert(
globalConfig.buildingAmountsToBelt[processorType], globalConfig.buildingRatios[processorType],
"Processor type has no speed set in globalConfig.buildingSpeeds: " + processorType "Processor type has no speed set in globalConfig.buildingSpeeds: " + processorType
); );
// super complicated maths here, but it works // super complicated maths here, but it works
const processorTime = const processorTime =
globalConfig.buildingAmountsToBelt[processorType] / globalConfig.beltSpeedItemsPerSecond; globalConfig.buildingRatios[processorType] / globalConfig.beltSpeedItemsPerSecond;
return processorTime / upgrade; return processorTime / upgrade;
} }
/** /**
@ -569,7 +569,7 @@ export class HubGoals extends BasicSerializableObject {
* @param {enumItemProcessorTypes} processorType * @param {enumItemProcessorTypes} processorType
* @returns {number} process time in seconds * @returns {number} process time in seconds
*/ */
getProcessingSpeed(processorType) { getProcessorBaseSpeed(processorType) {
const time = this.getProcessingTime(processorType); const time = this.getProcessingTime(processorType);
if (!time) { if (!time) {
return this.getBeltBaseSpeed(); return this.getBeltBaseSpeed();