From de0b305276eea26e296bf9f46f318deb326fed50 Mon Sep 17 00:00:00 2001 From: tobspr Date: Sat, 27 Jun 2020 16:40:51 +0200 Subject: [PATCH] Minor fixes to the throughput --- src/js/core/config.js | 2 +- src/js/game/belt_path.js | 19 +++++++++++++++++-- src/js/game/components/item_processor.js | 11 ++++++++--- src/js/game/hud/parts/statistics_handle.js | 15 ++++++++++----- 4 files changed, 36 insertions(+), 11 deletions(-) diff --git a/src/js/core/config.js b/src/js/core/config.js index 0018b746..96a2b40b 100644 --- a/src/js/core/config.js +++ b/src/js/core/config.js @@ -38,7 +38,7 @@ export const globalConfig = { // Production analytics statisticsGraphDpi: 2.5, statisticsGraphSlices: 100, - analyticsSliceDurationSeconds: 10, + analyticsSliceDurationSeconds: G_IS_DEV ? 1 : 10, minimumTickRate: 25, maximumTickRate: 500, diff --git a/src/js/game/belt_path.js b/src/js/game/belt_path.js index ca786a97..e6d25185 100644 --- a/src/js/game/belt_path.js +++ b/src/js/game/belt_path.js @@ -126,8 +126,23 @@ export class BeltPath extends BasicSerializableObject { */ tryAcceptItem(item) { if (this.spacingToFirstItem >= globalConfig.itemSpacingOnBelts) { - this.items.unshift([this.spacingToFirstItem, item]); - this.spacingToFirstItem = 0; + // So, since we already need one tick to accept this item we will add this directly. + const beltProgressPerTick = + this.root.hubGoals.getBeltBaseSpeed() * + this.root.dynamicTickrate.deltaSeconds * + globalConfig.itemSpacingOnBelts; + + // First, compute how much progress we can make *at max* + const maxProgress = Math.max(0, this.spacingToFirstItem - globalConfig.itemSpacingOnBelts); + const initialProgress = Math.min(maxProgress, beltProgressPerTick); + + this.items.unshift([this.spacingToFirstItem - initialProgress, item]); + this.spacingToFirstItem = initialProgress; + + if (G_IS_DEV && globalConfig.debug.checkBeltPaths) { + this.debug_checkIntegrity("accept-item"); + } + return true; } return false; diff --git a/src/js/game/components/item_processor.js b/src/js/game/components/item_processor.js index eab51ae2..7b81ab16 100644 --- a/src/js/game/components/item_processor.js +++ b/src/js/game/components/item_processor.js @@ -1,8 +1,7 @@ +import { gItemRegistry } from "../../core/global_registries"; +import { types } from "../../savegame/serialization"; import { BaseItem } from "../base_item"; import { Component } from "../component"; -import { enumDirection, Vector } from "../../core/vector"; -import { types } from "../../savegame/serialization"; -import { gItemRegistry } from "../../core/global_registries"; /** @enum {string} */ export const enumItemProcessorTypes = { @@ -102,6 +101,12 @@ export class ItemProcessorComponent extends Component { * @param {number} sourceSlot */ tryTakeItem(item, sourceSlot) { + if (this.type === enumItemProcessorTypes.hub || this.type === enumItemProcessorTypes.trash) { + // Hub has special logic .. not really nice but efficient. + this.inputSlots.push({ item, sourceSlot }); + return true; + } + // Check that we only take one item per slot for (let i = 0; i < this.inputSlots.length; ++i) { const slot = this.inputSlots[i]; diff --git a/src/js/game/hud/parts/statistics_handle.js b/src/js/game/hud/parts/statistics_handle.js index d3612d92..d5c60d3b 100644 --- a/src/js/game/hud/parts/statistics_handle.js +++ b/src/js/game/hud/parts/statistics_handle.js @@ -1,10 +1,10 @@ +import { makeOffscreenBuffer } from "../../../core/buffer_utils"; +import { globalConfig } from "../../../core/config"; +import { clamp, formatBigNumber, round2Digits } from "../../../core/utils"; +import { T } from "../../../translations"; +import { enumAnalyticsDataSource } from "../../production_analytics"; import { GameRoot } from "../../root"; import { ShapeDefinition } from "../../shape_definition"; -import { enumAnalyticsDataSource } from "../../production_analytics"; -import { formatBigNumber, clamp } from "../../../core/utils"; -import { globalConfig } from "../../../core/config"; -import { makeOffscreenBuffer } from "../../../core/buffer_utils"; -import { T } from "../../../translations"; /** @enum {string} */ export const enumDisplayMode = { @@ -91,6 +91,11 @@ export class HUDShapeStatisticsHandle { "", formatBigNumber(rate) ); + + if (G_IS_DEV && globalConfig.debug.detailedStatistics) { + this.counter.innerText = "" + round2Digits(rate / 60) + " /s"; + } + break; } }