mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-12-15 19:21:49 +00:00
Minor changes for processor consistency
This commit is contained in:
parent
b39d129152
commit
9f7c95aec3
@ -104,6 +104,12 @@ export class ItemProcessorComponent extends Component {
|
|||||||
*/
|
*/
|
||||||
this.currentCharge = null;
|
this.currentCharge = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* How much processing time we have left from the last tick
|
||||||
|
* @type {number}
|
||||||
|
*/
|
||||||
|
this.bonusTime = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {Array<EjectorItemToEject>}
|
* @type {Array<EjectorItemToEject>}
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -163,24 +163,6 @@ export class ItemEjectorSystem extends GameSystemWithFilter {
|
|||||||
if (sourceSlot.progress < maxProgress) {
|
if (sourceSlot.progress < maxProgress) {
|
||||||
// Advance items on the slot
|
// Advance items on the slot
|
||||||
sourceSlot.progress += progressGrowth;
|
sourceSlot.progress += progressGrowth;
|
||||||
|
|
||||||
// limit the progress to stop items being too close
|
|
||||||
if (sourceSlot.cachedTargetEntity && sourceSlot.cachedDestSlot) {
|
|
||||||
const acceptorComp = sourceSlot.cachedTargetEntity.components.ItemAcceptor;
|
|
||||||
let acceptorInput = null;
|
|
||||||
for (let i = 0; i < acceptorComp.inputs.length; i++) {
|
|
||||||
const input = acceptorComp.inputs[i];
|
|
||||||
if (input.slotIndex == sourceSlot.cachedDestSlot.index) {
|
|
||||||
acceptorInput = input;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (acceptorInput) {
|
|
||||||
const maxProgress =
|
|
||||||
0.5 + acceptorInput.animProgress - globalConfig.itemSpacingOnBelts;
|
|
||||||
sourceSlot.progress = Math.min(maxProgress, sourceSlot.progress);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (G_IS_DEV && globalConfig.debug.disableEjectorProcessing) {
|
if (G_IS_DEV && globalConfig.debug.disableEjectorProcessing) {
|
||||||
|
|||||||
@ -18,6 +18,7 @@ import { ShapeItem } from "../items/shape_item";
|
|||||||
*
|
*
|
||||||
* @typedef {{
|
* @typedef {{
|
||||||
* item: BaseItem,
|
* item: BaseItem,
|
||||||
|
* extraProgress?: number,
|
||||||
* preferredSlot?: number,
|
* preferredSlot?: number,
|
||||||
* requiredSlot?: number,
|
* requiredSlot?: number,
|
||||||
* doNotTrack?: boolean
|
* doNotTrack?: boolean
|
||||||
@ -89,22 +90,19 @@ export class ItemProcessorSystem extends GameSystemWithFilter {
|
|||||||
// Process next charge
|
// Process next charge
|
||||||
if (currentCharge.remainingTime > 0.0) {
|
if (currentCharge.remainingTime > 0.0) {
|
||||||
currentCharge.remainingTime -= this.root.dynamicTickrate.deltaSeconds;
|
currentCharge.remainingTime -= this.root.dynamicTickrate.deltaSeconds;
|
||||||
|
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 && processorComp.queuedEjects.length < 1) {
|
if (currentCharge.remainingTime <= 0.0 && processorComp.queuedEjects.length < 1) {
|
||||||
const itemsToEject = currentCharge.items;
|
const itemsToEject = currentCharge.items;
|
||||||
//@SENSETODO not sure this is correct
|
|
||||||
const extraProgress =
|
|
||||||
-currentCharge.remainingTime *
|
|
||||||
globalConfig.beltSpeedItemsPerSecond *
|
|
||||||
globalConfig.itemSpacingOnBelts;
|
|
||||||
|
|
||||||
// Go over all items and try to eject them
|
// Go over all items and try to eject them
|
||||||
for (let j = 0; j < itemsToEject.length; ++j) {
|
for (let j = 0; j < itemsToEject.length; ++j) {
|
||||||
const items = itemsToEject[j];
|
processorComp.queuedEjects.push(itemsToEject[j]);
|
||||||
items.extraProgress = extraProgress;
|
|
||||||
processorComp.queuedEjects.push(items);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
processorComp.currentCharge = null;
|
processorComp.currentCharge = null;
|
||||||
@ -247,10 +245,7 @@ export class ItemProcessorSystem extends GameSystemWithFilter {
|
|||||||
extraProgress = Math.max(extraProgress, input.extraProgress);
|
extraProgress = Math.max(extraProgress, input.extraProgress);
|
||||||
}
|
}
|
||||||
|
|
||||||
//@SENSETODO not sure if this is right
|
/** @type {Array<ProducedItem>} */
|
||||||
const extraTime =
|
|
||||||
extraProgress / (globalConfig.beltSpeedItemsPerSecond * globalConfig.itemSpacingOnBelts);
|
|
||||||
|
|
||||||
const outItems = [];
|
const outItems = [];
|
||||||
|
|
||||||
/** @type {function(ProcessorImplementationPayload) : void} */
|
/** @type {function(ProcessorImplementationPayload) : void} */
|
||||||
@ -269,11 +264,18 @@ export class ItemProcessorSystem extends GameSystemWithFilter {
|
|||||||
if (!outItems[i].doNotTrack) {
|
if (!outItems[i].doNotTrack) {
|
||||||
this.root.signals.itemProduced.dispatch(outItems[i].item);
|
this.root.signals.itemProduced.dispatch(outItems[i].item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// also set extra progress
|
||||||
|
outItems[i].extraProgress = extraProgress;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Queue Charge
|
// Queue Charge
|
||||||
const originalTime = this.root.hubGoals.getProcessingTime(processorComp.type);
|
const originalTime = this.root.hubGoals.getProcessingTime(processorComp.type);
|
||||||
const timeToProcess = originalTime - extraTime;
|
|
||||||
|
const bonusTimeToApply = Math.min(originalTime, processorComp.bonusTime);
|
||||||
|
const timeToProcess = originalTime - bonusTimeToApply;
|
||||||
|
|
||||||
|
processorComp.bonusTime -= bonusTimeToApply;
|
||||||
|
|
||||||
processorComp.currentCharge = {
|
processorComp.currentCharge = {
|
||||||
items: outItems,
|
items: outItems,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user