mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-12-15 19:21:49 +00:00
Fix double painter bug
This commit is contained in:
parent
0540a010a6
commit
569c319e98
@ -109,6 +109,11 @@ export class ItemProcessorComponent extends Component {
|
||||
* @type {number}
|
||||
*/
|
||||
this.bonusTime = 0;
|
||||
|
||||
/**
|
||||
* @type {Array<EjectorItemToEject>}
|
||||
*/
|
||||
this.queuedEjects = [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -94,13 +94,28 @@ export class ItemProcessorSystem extends GameSystemWithFilter {
|
||||
}
|
||||
}
|
||||
|
||||
// Check if it finished
|
||||
if (currentCharge.remainingTime <= 0.0) {
|
||||
// Check if it finished and we don't already have queued ejects
|
||||
if (currentCharge.remainingTime <= 0.0 && !processorComp.queuedEjects.length) {
|
||||
const itemsToEject = currentCharge.items;
|
||||
|
||||
// Go over all items and try to eject them
|
||||
// Go over all items and add them to the queue
|
||||
for (let j = 0; j < itemsToEject.length; ++j) {
|
||||
const { item, requiredSlot, preferredSlot } = itemsToEject[j];
|
||||
processorComp.queuedEjects.push(itemsToEject[j]);
|
||||
}
|
||||
|
||||
processorComp.ongoingCharges.shift();
|
||||
}
|
||||
}
|
||||
|
||||
// Check if we have an empty queue and can start a new charge
|
||||
if (processorComp.ongoingCharges.length < MAX_QUEUED_CHARGES) {
|
||||
if (this.canProcess(entity)) {
|
||||
this.startNewCharge(entity);
|
||||
}
|
||||
}
|
||||
|
||||
for (let j = 0; j < processorComp.queuedEjects.length; ++j) {
|
||||
const { item, requiredSlot, preferredSlot } = processorComp.queuedEjects[j];
|
||||
|
||||
assert(ejectorComp, "To eject items, the building needs to have an ejector");
|
||||
|
||||
@ -127,25 +142,11 @@ export class ItemProcessorSystem extends GameSystemWithFilter {
|
||||
if (!ejectorComp.tryEject(slot, item)) {
|
||||
assert(false, "Failed to eject");
|
||||
} else {
|
||||
itemsToEject.splice(j, 1);
|
||||
processorComp.queuedEjects.splice(j, 1);
|
||||
j -= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If the charge was entirely emptied to the outputs, start the next charge
|
||||
if (itemsToEject.length === 0) {
|
||||
processorComp.ongoingCharges.shift();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check if we have an empty queue and can start a new charge
|
||||
if (processorComp.ongoingCharges.length < MAX_QUEUED_CHARGES) {
|
||||
if (this.canProcess(entity)) {
|
||||
this.startNewCharge(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user