From ec02dcd07adfca3f993958f80a3552a73e346472 Mon Sep 17 00:00:00 2001 From: EmeraldBlock Date: Fri, 4 Jun 2021 20:10:24 -0500 Subject: [PATCH] fix item acceptor rendering from map view --- src/js/game/hud/parts/screenshot_exporter.js | 1 + src/js/game/systems/item_acceptor.js | 30 ++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/src/js/game/hud/parts/screenshot_exporter.js b/src/js/game/hud/parts/screenshot_exporter.js index 139e98ef..96841846 100644 --- a/src/js/game/hud/parts/screenshot_exporter.js +++ b/src/js/game/hud/parts/screenshot_exporter.js @@ -307,6 +307,7 @@ export class HUDScreenshotExporter extends BaseHUDPart { this.root.currentLayer = "regular"; this.root.hud.parts.wiresOverlay.currentAlpha = 0; } + this.root.systemMgr.systems.itemAcceptor.updateForScreenshot(); // Render all relevant chunks this.root.signals.gameFrameStarted.dispatch(); diff --git a/src/js/game/systems/item_acceptor.js b/src/js/game/systems/item_acceptor.js index 780b4abd..ff95e21a 100644 --- a/src/js/game/systems/item_acceptor.js +++ b/src/js/game/systems/item_acceptor.js @@ -56,6 +56,36 @@ export class ItemAcceptorSystem extends GameSystemWithFilter { } } + updateForScreenshot() { + // Compute how much ticks we missed + const numTicks = this.accumulatedTicksWhileInMapOverview; + const progress = + this.root.dynamicTickrate.deltaSeconds * + 2 * + this.root.hubGoals.getBeltBaseSpeed() * + globalConfig.itemSpacingOnBelts * // * 2 because its only a half tile + numTicks; + + // Reset accumulated ticks + this.accumulatedTicksWhileInMapOverview = 0; + + for (let i = 0; i < this.allEntities.length; ++i) { + const entity = this.allEntities[i]; + const aceptorComp = entity.components.ItemAcceptor; + const animations = aceptorComp.itemConsumptionAnimations; + + // Process item consumption animations to avoid items popping from the belts + for (let animIndex = 0; animIndex < animations.length; ++animIndex) { + const anim = animations[animIndex]; + anim.animProgress += progress; + if (anim.animProgress > 1) { + fastArrayDelete(animations, animIndex); + animIndex -= 1; + } + } + } + } + /** * @param {DrawParameters} parameters * @param {MapChunkView} chunk