From e3dc236286eaab758ffba5a30cb4e2664ca543f8 Mon Sep 17 00:00:00 2001 From: Sense101 <67970865+Sense101@users.noreply.github.com> Date: Thu, 20 Jan 2022 22:47:11 +0000 Subject: [PATCH] remove cap on startProgress to help fix high speeds - item ejector is still limited to 1 item/tick though --- src/js/game/belt_path.js | 11 +++++++---- src/js/game/components/item_acceptor.js | 3 ++- src/js/game/systems/filter.js | 6 +++--- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/js/game/belt_path.js b/src/js/game/belt_path.js index 23948b9b..4b274092 100644 --- a/src/js/game/belt_path.js +++ b/src/js/game/belt_path.js @@ -134,12 +134,15 @@ export class BeltPath extends BasicSerializableObject { */ tryAcceptItem(item, startProgress = 0) { if (this.spacingToFirstItem >= globalConfig.itemSpacingOnBelts) { - // First, compute how much progress we can make *at max* + // *Never* cap start progress, or if an item moves more than a belt in a tick, it breaks + // instead return false if the start progress is too much const maxProgress = Math.max(0, this.spacingToFirstItem - globalConfig.itemSpacingOnBelts); - const initialProgress = Math.min(maxProgress, startProgress); + if (startProgress > maxProgress) { + return false; + } - this.items.unshift([this.spacingToFirstItem - initialProgress, item]); - this.spacingToFirstItem = initialProgress; + this.items.unshift([this.spacingToFirstItem - startProgress, item]); + this.spacingToFirstItem = startProgress; if (G_IS_DEV && globalConfig.debug.checkBeltPaths) { this.debug_checkIntegrity("accept-item"); diff --git a/src/js/game/components/item_acceptor.js b/src/js/game/components/item_acceptor.js index 0c9189c3..de0e77c3 100644 --- a/src/js/game/components/item_acceptor.js +++ b/src/js/game/components/item_acceptor.js @@ -98,10 +98,11 @@ export class ItemAcceptorComponent extends Component { return false; } + // if the start progress is bigger than 0.5, the remainder should get passed on to the ejector this.inputs.set(slotIndex, { item, direction, - animProgress: Math.min(0.5, startProgress), + animProgress: startProgress, }); return true; } diff --git a/src/js/game/systems/filter.js b/src/js/game/systems/filter.js index 507bf2f8..fcdd8d25 100644 --- a/src/js/game/systems/filter.js +++ b/src/js/game/systems/filter.js @@ -43,9 +43,9 @@ export class FilterSystem extends GameSystemWithFilter { * * @param {Entity} entity * @param {BaseItem} item - * @param {number} extraProgress + * @param {number} startProgress */ - tryAcceptItem(entity, item, extraProgress) { + tryAcceptItem(entity, item, startProgress) { const network = entity.components.WiredPins.slots[0].linkedNetwork; if (!network || !network.hasValue()) { // Filter is not connected @@ -72,7 +72,7 @@ export class FilterSystem extends GameSystemWithFilter { // Actually accept item listToCheck.push({ item, - extraProgress, + extraProgress: startProgress, }); return true; }