1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2025-12-15 19:21:49 +00:00
This commit is contained in:
Sense101 2022-01-22 21:06:06 +00:00
parent 3bd86aa6d0
commit 93daf53b0f
4 changed files with 13 additions and 24 deletions

View File

@ -34,7 +34,7 @@ export const enumItemProcessorRequirements = {
* }} EjectorItemToEject */ * }} EjectorItemToEject */
/** @typedef {{ /** @typedef {{
* remainingTime: number, * remainingProgress: number,
* items: Array<EjectorItemToEject>, * items: Array<EjectorItemToEject>,
* }} EjectorCharge */ * }} EjectorCharge */
@ -103,12 +103,6 @@ export class ItemProcessorComponent extends Component {
* @type {Array<EjectorCharge>} * @type {Array<EjectorCharge>}
*/ */
this.ongoingCharges = []; this.ongoingCharges = [];
/**
* How much processing time we have left from the last tick
* @type {number}
*/
this.bonusTime = 0;
} }
/** /**

View File

@ -560,7 +560,7 @@ export class HubGoals extends BasicSerializableObject {
); );
const progress = globalConfig.buildingRatios[processorType] - 1; const progress = globalConfig.buildingRatios[processorType] - 1;
return progress / upgrade; return progress + 0.5 / upgrade;
} }
/** /**

View File

@ -327,7 +327,7 @@ export class ItemEjectorSystem extends GameSystemWithFilter {
} }
// Limit the progress to the maximum available space on the next belt (also see #1000) // Limit the progress to the maximum available space on the next belt (also see #1000)
let progress = slot.progress; let progress = Math.min(0.5, slot.progress);
const nextBeltPath = slot.cachedBeltPath; const nextBeltPath = slot.cachedBeltPath;
if (nextBeltPath) { if (nextBeltPath) {
/* /*

View File

@ -76,6 +76,11 @@ export class ItemProcessorSystem extends GameSystemWithFilter {
} }
update() { update() {
const progressGrowth =
this.root.dynamicTickrate.deltaSeconds *
globalConfig.beltSpeedItemsPerSecond *
globalConfig.itemSpacingOnBelts;
for (let i = 0; i < this.allEntities.length; ++i) { for (let i = 0; i < this.allEntities.length; ++i) {
const entity = this.allEntities[i]; const entity = this.allEntities[i];
@ -86,16 +91,12 @@ export class ItemProcessorSystem extends GameSystemWithFilter {
if (currentCharge) { if (currentCharge) {
// Process next charge // Process next charge
if (currentCharge.remainingTime > 0.0) { if (currentCharge.remainingProgress > 0.0) {
currentCharge.remainingTime -= this.root.dynamicTickrate.deltaSeconds; currentCharge.remainingProgress -= progressGrowth;
if (currentCharge.remainingTime < 0.0) {
// Add bonus time, this is the time we spent too much
processorComp.bonusTime += -currentCharge.remainingTime;
}
} }
// Check if it finished // Check if it finished
if (currentCharge.remainingTime <= 0.0) { if (currentCharge.remainingProgress <= 0.0) {
const itemsToEject = currentCharge.items; const itemsToEject = currentCharge.items;
// Go over all items and try to eject them // Go over all items and try to eject them
@ -286,16 +287,10 @@ export class ItemProcessorSystem extends GameSystemWithFilter {
} }
// Queue Charge // Queue Charge
const baseSpeed = this.root.hubGoals.getProcessorBaseSpeed(processorComp.type); const progress = this.root.hubGoals.getProcessingProgress(processorComp.type);
const originalTime = 1 / baseSpeed;
const bonusTimeToApply = Math.min(originalTime, processorComp.bonusTime);
const timeToProcess = originalTime - bonusTimeToApply;
processorComp.bonusTime -= bonusTimeToApply;
processorComp.ongoingCharges.push({ processorComp.ongoingCharges.push({
items: outItems, items: outItems,
remainingTime: timeToProcess, remainingProgress: progress, // + Math.min(extra progress' of inputs)
}); });
processorComp.inputSlots.clear(); processorComp.inputSlots.clear();