1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2025-06-13 13:04:03 +00:00

Fixed the interval of ItemProcessor not to depend on the speed of ItemEjector

This commit is contained in:
isaisstillalive 2020-07-10 11:53:07 +09:00
parent 2ccf39f1bf
commit 0c67da5a16
2 changed files with 19 additions and 18 deletions

View File

@ -185,7 +185,7 @@ export class ItemEjectorSystem extends GameSystemWithFilter {
}
// Precompute effective belt speed
let progressGrowth = 2 * this.root.dynamicTickrate.deltaSeconds;
let progressGrowth = this.root.dynamicTickrate.deltaSeconds;
if (G_IS_DEV && globalConfig.debug.instantBelts) {
progressGrowth = 1;

View File

@ -29,9 +29,26 @@ export class ItemProcessorSystem extends GameSystemWithFilter {
processorComp.secondsUntilEject = 0;
}
// Check if we have any finished items we can eject
if (
processorComp.secondsUntilEject === 0 && // it was processed in time
processorComp.itemsToEject.length === 0 // Check if we have an empty queue and can start a new charge
) {
if (processorComp.inputSlots.length >= processorComp.inputsPerCharge) {
const energyConsumerComp = entity.components.EnergyConsumer;
if (energyConsumerComp) {
// Check if we have enough energy
if (energyConsumerComp.tryStartNextCharge()) {
this.startNewCharge(entity);
}
} else {
// No further checks required
this.startNewCharge(entity);
}
}
}
// Check if we have any finished items we can eject
if (
processorComp.itemsToEject.length > 0 // we have some items left to eject
) {
for (let itemIndex = 0; itemIndex < processorComp.itemsToEject.length; ++itemIndex) {
@ -66,22 +83,6 @@ export class ItemProcessorSystem extends GameSystemWithFilter {
}
}
}
// Check if we have an empty queue and can start a new charge
if (processorComp.itemsToEject.length === 0) {
if (processorComp.inputSlots.length >= processorComp.inputsPerCharge) {
const energyConsumerComp = entity.components.EnergyConsumer;
if (energyConsumerComp) {
// Check if we have enough energy
if (energyConsumerComp.tryStartNextCharge()) {
this.startNewCharge(entity);
}
} else {
// No further checks required
this.startNewCharge(entity);
}
}
}
}
}