mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-12-16 19:51:50 +00:00
Merge branch 'modloader' of github.com:tobspr/shapez.io into modloader
This commit is contained in:
commit
8327f170f9
@ -109,6 +109,11 @@ export class ItemProcessorComponent extends Component {
|
|||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
this.bonusTime = 0;
|
this.bonusTime = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {Array<EjectorItemToEject>}
|
||||||
|
*/
|
||||||
|
this.queuedEjects = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -94,13 +94,28 @@ export class ItemProcessorSystem extends GameSystemWithFilter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if it finished
|
// Check if it finished and we don't already have queued ejects
|
||||||
if (currentCharge.remainingTime <= 0.0) {
|
if (currentCharge.remainingTime <= 0.0 && !processorComp.queuedEjects.length) {
|
||||||
const itemsToEject = currentCharge.items;
|
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) {
|
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");
|
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)) {
|
if (!ejectorComp.tryEject(slot, item)) {
|
||||||
assert(false, "Failed to eject");
|
assert(false, "Failed to eject");
|
||||||
} else {
|
} else {
|
||||||
itemsToEject.splice(j, 1);
|
processorComp.queuedEjects.splice(j, 1);
|
||||||
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