From 221c8301ee5322c23a8498ca27672baa330f1a49 Mon Sep 17 00:00:00 2001 From: Sense101 <67970865+Sense101@users.noreply.github.com> Date: Thu, 12 Nov 2020 16:53:19 +0000 Subject: [PATCH 01/11] added the new splitter --- translations/base-en.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/translations/base-en.yaml b/translations/base-en.yaml index 62ed2808..85e3b9b0 100644 --- a/translations/base-en.yaml +++ b/translations/base-en.yaml @@ -575,6 +575,9 @@ buildings: splitter-inverse: name: Splitter (compact) description: Splits one conveyor belt into two. + splitter-triple: + name: Splitter (compact) + description: Splits one conveyor belt into three. cutter: default: From 72fff955d77ed818afa46e131e195f12b5e2bfd6 Mon Sep 17 00:00:00 2001 From: Sense101 <67970865+Sense101@users.noreply.github.com> Date: Thu, 12 Nov 2020 19:01:21 +0000 Subject: [PATCH 02/11] Update base-en.yaml --- translations/base-en.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/translations/base-en.yaml b/translations/base-en.yaml index 85e3b9b0..62ed2808 100644 --- a/translations/base-en.yaml +++ b/translations/base-en.yaml @@ -575,9 +575,6 @@ buildings: splitter-inverse: name: Splitter (compact) description: Splits one conveyor belt into two. - splitter-triple: - name: Splitter (compact) - description: Splits one conveyor belt into three. cutter: default: From ea375e92e31147e605f64904053203e7463557fe Mon Sep 17 00:00:00 2001 From: Sense101 <67970865+Sense101@users.noreply.github.com> Date: Thu, 15 Apr 2021 22:12:38 +0100 Subject: [PATCH 03/11] fixed the belt reader --- src/js/game/systems/belt_reader.js | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/js/game/systems/belt_reader.js b/src/js/game/systems/belt_reader.js index fbd00b6c..14518181 100644 --- a/src/js/game/systems/belt_reader.js +++ b/src/js/game/systems/belt_reader.js @@ -24,11 +24,15 @@ export class BeltReaderSystem extends GameSystemWithFilter { } pinsComp.slots[1].value = readerComp.lastItem; - pinsComp.slots[0].value = - (readerComp.lastItemTimes[readerComp.lastItemTimes.length - 1] || 0) > - minimumTimeForThroughput - ? BOOL_TRUE_SINGLETON - : BOOL_FALSE_SINGLETON; + if( (readerComp.lastItemTimes[readerComp.lastItemTimes.length - 1] || 0) > + minimumTimeForThroughput) { + pinsComp.slots[0].value = BOOL_TRUE_SINGLETON; + } else { + pinsComp.slots[0].value = BOOL_FALSE_SINGLETON; + if(entity.components.ItemEjector.canEjectOnSlot(0)) { + readerComp.lastItem = null; + } + } if (now - readerComp.lastThroughputComputation > 0.5) { // Compute throughput @@ -46,10 +50,15 @@ export class BeltReaderSystem extends GameSystemWithFilter { } throughput = 1 / (averageSpacing / averageSpacingNum); + const decimal = throughput - Math.floor(throughput); + if(decimal > 0.8) + { + throughput = Math.round(throughput); + } } readerComp.lastThroughput = Math.min(globalConfig.beltSpeedItemsPerSecond * 23.9, throughput); } } } -} +} \ No newline at end of file From 64546d65543fabf4ec9ef3511c5292293ca5f7d9 Mon Sep 17 00:00:00 2001 From: Sense101 <67970865+Sense101@users.noreply.github.com> Date: Fri, 16 Apr 2021 09:36:13 +0100 Subject: [PATCH 04/11] prettier --- src/js/game/systems/belt_reader.js | 15 ++++++--------- src/js/webworkers/tsconfig.json | 2 +- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/js/game/systems/belt_reader.js b/src/js/game/systems/belt_reader.js index 14518181..5cde34ca 100644 --- a/src/js/game/systems/belt_reader.js +++ b/src/js/game/systems/belt_reader.js @@ -24,12 +24,14 @@ export class BeltReaderSystem extends GameSystemWithFilter { } pinsComp.slots[1].value = readerComp.lastItem; - if( (readerComp.lastItemTimes[readerComp.lastItemTimes.length - 1] || 0) > - minimumTimeForThroughput) { + if ( + (readerComp.lastItemTimes[readerComp.lastItemTimes.length - 1] || 0) > + minimumTimeForThroughput + ) { pinsComp.slots[0].value = BOOL_TRUE_SINGLETON; } else { pinsComp.slots[0].value = BOOL_FALSE_SINGLETON; - if(entity.components.ItemEjector.canEjectOnSlot(0)) { + if (entity.components.ItemEjector.canEjectOnSlot(0)) { readerComp.lastItem = null; } } @@ -50,15 +52,10 @@ export class BeltReaderSystem extends GameSystemWithFilter { } throughput = 1 / (averageSpacing / averageSpacingNum); - const decimal = throughput - Math.floor(throughput); - if(decimal > 0.8) - { - throughput = Math.round(throughput); - } } readerComp.lastThroughput = Math.min(globalConfig.beltSpeedItemsPerSecond * 23.9, throughput); } } } -} \ No newline at end of file +} diff --git a/src/js/webworkers/tsconfig.json b/src/js/webworkers/tsconfig.json index dce06856..3a428cfc 100644 --- a/src/js/webworkers/tsconfig.json +++ b/src/js/webworkers/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "lib": ["ES2018","WebWorker"] + "lib": ["ES2018", "WebWorker"] }, "exclude": [], "extends": "../tsconfig", From 14eaa2d9aace6807f92087f7cdae8b79754b8c86 Mon Sep 17 00:00:00 2001 From: Sense101 <67970865+Sense101@users.noreply.github.com> Date: Fri, 16 Apr 2021 13:06:07 +0100 Subject: [PATCH 05/11] changed belt reader to make it more precise --- src/js/game/components/belt_reader.js | 2 ++ src/js/game/systems/belt_reader.js | 45 ++++++++++++--------------- 2 files changed, 22 insertions(+), 25 deletions(-) diff --git a/src/js/game/components/belt_reader.js b/src/js/game/components/belt_reader.js index d451bab5..4eeb76a9 100644 --- a/src/js/game/components/belt_reader.js +++ b/src/js/game/components/belt_reader.js @@ -40,5 +40,7 @@ export class BeltReaderComponent extends Component { * @type {number} */ this.lastThroughputComputation = 0; + + this.lastRemovedItemTime = 0; } } diff --git a/src/js/game/systems/belt_reader.js b/src/js/game/systems/belt_reader.js index 5cde34ca..9ffb3ca3 100644 --- a/src/js/game/systems/belt_reader.js +++ b/src/js/game/systems/belt_reader.js @@ -16,45 +16,40 @@ export class BeltReaderSystem extends GameSystemWithFilter { const entity = this.allEntities[i]; const readerComp = entity.components.BeltReader; + const lastItemTimes = readerComp.lastItemTimes; const pinsComp = entity.components.WiredPins; // Remove outdated items - while (readerComp.lastItemTimes[0] < minimumTime) { - readerComp.lastItemTimes.shift(); + while (lastItemTimes[0] < minimumTime) { + readerComp.lastRemovedItemTime = lastItemTimes.shift(); } - - pinsComp.slots[1].value = readerComp.lastItem; - if ( - (readerComp.lastItemTimes[readerComp.lastItemTimes.length - 1] || 0) > - minimumTimeForThroughput - ) { - pinsComp.slots[0].value = BOOL_TRUE_SINGLETON; - } else { - pinsComp.slots[0].value = BOOL_FALSE_SINGLETON; - if (entity.components.ItemEjector.canEjectOnSlot(0)) { - readerComp.lastItem = null; - } - } - + if (now - readerComp.lastThroughputComputation > 0.5) { // Compute throughput readerComp.lastThroughputComputation = now; + const oneItem = lastItemTimes.length == 1; let throughput = 0; - if (readerComp.lastItemTimes.length < 2) { - throughput = 0; - } else { - let averageSpacing = 0; - let averageSpacingNum = 0; - for (let i = 0; i < readerComp.lastItemTimes.length - 1; ++i) { - averageSpacing += readerComp.lastItemTimes[i + 1] - readerComp.lastItemTimes[i]; + if (lastItemTimes.length > 0) { + let averageSpacing = oneItem ? lastItemTimes[0] - readerComp.lastRemovedItemTime : 0; + let averageSpacingNum = oneItem ? 1 : 0; + for (let i = 0; i < lastItemTimes.length - 1; ++i) { + averageSpacing += lastItemTimes[i + 1] - lastItemTimes[i]; ++averageSpacingNum; } - throughput = 1 / (averageSpacing / averageSpacingNum); + throughput = 1 / (averageSpacing / averageSpacingNum) + 0.01; } - readerComp.lastThroughput = Math.min(globalConfig.beltSpeedItemsPerSecond * 23.9, throughput); + readerComp.lastThroughput = Math.min(globalConfig.beltSpeedItemsPerSecond, throughput); + } + + if (readerComp.lastThroughput > 0) { + pinsComp.slots[0].value = BOOL_TRUE_SINGLETON; + pinsComp.slots[1].value = readerComp.lastItem; + } else { + pinsComp.slots[0].value = BOOL_FALSE_SINGLETON; + pinsComp.slots[1].value = null; } } } From 5405d34c217c70cf2b0aa4e231d559b26a1398b0 Mon Sep 17 00:00:00 2001 From: Sense101 <67970865+Sense101@users.noreply.github.com> Date: Fri, 16 Apr 2021 13:11:27 +0100 Subject: [PATCH 06/11] comments and prettier added --- src/js/game/components/belt_reader.js | 4 ++++ src/js/game/systems/belt_reader.js | 9 ++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/js/game/components/belt_reader.js b/src/js/game/components/belt_reader.js index 4eeb76a9..a91ae2c4 100644 --- a/src/js/game/components/belt_reader.js +++ b/src/js/game/components/belt_reader.js @@ -41,6 +41,10 @@ export class BeltReaderComponent extends Component { */ this.lastThroughputComputation = 0; + /** + * Stores the entry time of the latest removed item + * @type {number} + */ this.lastRemovedItemTime = 0; } } diff --git a/src/js/game/systems/belt_reader.js b/src/js/game/systems/belt_reader.js index 9ffb3ca3..449defc1 100644 --- a/src/js/game/systems/belt_reader.js +++ b/src/js/game/systems/belt_reader.js @@ -11,7 +11,6 @@ export class BeltReaderSystem extends GameSystemWithFilter { update() { const now = this.root.time.now(); const minimumTime = now - globalConfig.readerAnalyzeIntervalSeconds; - const minimumTimeForThroughput = now - 1; for (let i = 0; i < this.allEntities.length; ++i) { const entity = this.allEntities[i]; @@ -19,16 +18,19 @@ export class BeltReaderSystem extends GameSystemWithFilter { const lastItemTimes = readerComp.lastItemTimes; const pinsComp = entity.components.WiredPins; - // Remove outdated items + // Remove outdated items and set lastRemovedItemTime while (lastItemTimes[0] < minimumTime) { readerComp.lastRemovedItemTime = lastItemTimes.shift(); } - + if (now - readerComp.lastThroughputComputation > 0.5) { // Compute throughput readerComp.lastThroughputComputation = now; + //if only one item is in the list, use the time from the last removed item + //to allow for much lower numbers to be correctly calculated const oneItem = lastItemTimes.length == 1; + let throughput = 0; if (lastItemTimes.length > 0) { let averageSpacing = oneItem ? lastItemTimes[0] - readerComp.lastRemovedItemTime : 0; @@ -44,6 +46,7 @@ export class BeltReaderSystem extends GameSystemWithFilter { readerComp.lastThroughput = Math.min(globalConfig.beltSpeedItemsPerSecond, throughput); } + // Set the pins value - shape output consistent with the boolean output if (readerComp.lastThroughput > 0) { pinsComp.slots[0].value = BOOL_TRUE_SINGLETON; pinsComp.slots[1].value = readerComp.lastItem; From 82c0120014e19faf32e6ff0737f0f73764302ef7 Mon Sep 17 00:00:00 2001 From: Sense101 <67970865+Sense101@users.noreply.github.com> Date: Fri, 16 Apr 2021 13:30:33 +0100 Subject: [PATCH 07/11] fixed shape output clearing if the belt is backed up --- src/js/game/systems/belt_reader.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/js/game/systems/belt_reader.js b/src/js/game/systems/belt_reader.js index 449defc1..8bdfa309 100644 --- a/src/js/game/systems/belt_reader.js +++ b/src/js/game/systems/belt_reader.js @@ -52,7 +52,9 @@ export class BeltReaderSystem extends GameSystemWithFilter { pinsComp.slots[1].value = readerComp.lastItem; } else { pinsComp.slots[0].value = BOOL_FALSE_SINGLETON; - pinsComp.slots[1].value = null; + if(entity.components.ItemProcessor.ongoingCharges.length < 2) { + pinsComp.slots[1].value = null; + } } } } From 6fd4422424d22492d787793d0a5b71c92703ede0 Mon Sep 17 00:00:00 2001 From: Sense101 <67970865+Sense101@users.noreply.github.com> Date: Fri, 16 Apr 2021 13:37:09 +0100 Subject: [PATCH 08/11] fixed linting error --- src/js/game/systems/belt_reader.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/game/systems/belt_reader.js b/src/js/game/systems/belt_reader.js index 8bdfa309..dbdff912 100644 --- a/src/js/game/systems/belt_reader.js +++ b/src/js/game/systems/belt_reader.js @@ -52,7 +52,7 @@ export class BeltReaderSystem extends GameSystemWithFilter { pinsComp.slots[1].value = readerComp.lastItem; } else { pinsComp.slots[0].value = BOOL_FALSE_SINGLETON; - if(entity.components.ItemProcessor.ongoingCharges.length < 2) { + if (entity.components.ItemProcessor.ongoingCharges.length < 2) { pinsComp.slots[1].value = null; } } From 4ba63d10d7dd7ea52e10c7c361b41a970fa7cfc9 Mon Sep 17 00:00:00 2001 From: Sense101 <67970865+Sense101@users.noreply.github.com> Date: Fri, 16 Apr 2021 15:32:21 +0100 Subject: [PATCH 09/11] readers are capped to max current belt speed not 2! --- src/js/game/systems/belt_reader.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/game/systems/belt_reader.js b/src/js/game/systems/belt_reader.js index dbdff912..494d8d5d 100644 --- a/src/js/game/systems/belt_reader.js +++ b/src/js/game/systems/belt_reader.js @@ -43,7 +43,7 @@ export class BeltReaderSystem extends GameSystemWithFilter { throughput = 1 / (averageSpacing / averageSpacingNum) + 0.01; } - readerComp.lastThroughput = Math.min(globalConfig.beltSpeedItemsPerSecond, throughput); + readerComp.lastThroughput = Math.min(globalConfig.beltSpeedItemsPerSecond * this.root.hubGoals.upgradeLevels["belt"], throughput); } // Set the pins value - shape output consistent with the boolean output From c47ea745c5b334dff1c6385808a9dded97cb04b8 Mon Sep 17 00:00:00 2001 From: Sense101 <67970865+Sense101@users.noreply.github.com> Date: Fri, 16 Apr 2021 16:30:58 +0100 Subject: [PATCH 10/11] fixed linting errors (again) --- src/js/game/systems/belt_reader.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/js/game/systems/belt_reader.js b/src/js/game/systems/belt_reader.js index 494d8d5d..2e09d9c1 100644 --- a/src/js/game/systems/belt_reader.js +++ b/src/js/game/systems/belt_reader.js @@ -43,7 +43,10 @@ export class BeltReaderSystem extends GameSystemWithFilter { throughput = 1 / (averageSpacing / averageSpacingNum) + 0.01; } - readerComp.lastThroughput = Math.min(globalConfig.beltSpeedItemsPerSecond * this.root.hubGoals.upgradeLevels["belt"], throughput); + readerComp.lastThroughput = Math.min( + globalConfig.beltSpeedItemsPerSecond * this.root.hubGoals.upgradeLevels.belt, + throughput + ); } // Set the pins value - shape output consistent with the boolean output From 4857d33cbfa1e45f0c68eab84d018ce4fb200c9b Mon Sep 17 00:00:00 2001 From: Sense101 <67970865+Sense101@users.noreply.github.com> Date: Mon, 19 Apr 2021 14:21:58 +0100 Subject: [PATCH 11/11] fixed reader capping to zero, it now actually correctly caps to the max spped of the belt --- src/js/game/systems/belt_reader.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/game/systems/belt_reader.js b/src/js/game/systems/belt_reader.js index 2e09d9c1..3c164d9c 100644 --- a/src/js/game/systems/belt_reader.js +++ b/src/js/game/systems/belt_reader.js @@ -44,7 +44,7 @@ export class BeltReaderSystem extends GameSystemWithFilter { } readerComp.lastThroughput = Math.min( - globalConfig.beltSpeedItemsPerSecond * this.root.hubGoals.upgradeLevels.belt, + globalConfig.beltSpeedItemsPerSecond * this.root.hubGoals.upgradeImprovements.belt, throughput ); }