1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2025-12-13 02:01:51 +00:00

most of the requested changes

This commit is contained in:
Sense101 2022-01-20 21:50:11 +00:00
parent c86416cf79
commit 36f125e6d7
5 changed files with 14 additions and 28 deletions

View File

@ -99,9 +99,9 @@ export class ItemProcessorComponent extends Component {
* What we are currently processing, empty if we don't produce anything rn
* requiredSlot: Item *must* be ejected on this slot
* preferredSlot: Item *can* be ejected on this slot, but others are fine too if the one is not usable
* @type {Array<EjectorCharge>}
* @type {EjectorCharge|null}
*/
this.ongoingCharges = [];
this.currentCharge = null;
/**
* How much processing time we have left from the last tick

View File

@ -20,7 +20,7 @@ export class FilterSystem extends GameSystemWithFilter {
// Take items from acceptor
const input = acceptorComp.completedInputs.get(0);
if (input && this.tryAcceptItem(entity, input)) {
if (input && this.tryAcceptItem(entity, input.item, input.extraProgress)) {
acceptorComp.completedInputs.delete(0);
}
@ -42,11 +42,10 @@ export class FilterSystem extends GameSystemWithFilter {
/**
*
* @param {Entity} entity
* @param {Object} param0
* @param {BaseItem} param0.item
* @param {number} param0.extraProgress
* @param {BaseItem} item
* @param {number} extraProgress
*/
tryAcceptItem(entity, { item, extraProgress }) {
tryAcceptItem(entity, item, extraProgress) {
const network = entity.components.WiredPins.slots[0].linkedNetwork;
if (!network || !network.hasValue()) {
// Filter is not connected

View File

@ -26,7 +26,9 @@ export class ItemAcceptorSystem extends GameSystemWithFilter {
inputs.forEach((values, index) => {
values.animProgress += progressGrowth;
if (values.animProgress < maxProgress) return;
if (values.animProgress < maxProgress) {
return;
}
inputs.delete(index);
acceptorComp.completedInputs.set(index, {

View File

@ -300,15 +300,6 @@ export class ItemEjectorSystem extends GameSystemWithFilter {
^ ^ item @ 0.9
^ max progress = 0.3
Because now our range actually only goes to the end of the building, and not towards the center of the building, we need to multiply
all values by 2: <--------- except max progress is now 0.5 rather than 1, so this isn't needed anymore
Building Belt
| X | X |
| 0.........1.........2 |
^ ^ item @ 1.8
^ max progress = 0.6
And that's it! If you summarize the calculations from above into a formula, you get the one below.
*/

View File

@ -13,12 +13,6 @@ import { isTruthyItem } from "../items/boolean_item";
import { ColorItem, COLOR_ITEM_SINGLETONS } from "../items/color_item";
import { ShapeItem } from "../items/shape_item";
/**
* We need to allow queuing charges, otherwise the throughput will stalls
*/
//@SENSETODO not sure if this needs to be two anymore
const MAX_QUEUED_CHARGES = 1;
/**
* Whole data for a produced item
*
@ -85,13 +79,13 @@ export class ItemProcessorSystem extends GameSystemWithFilter {
const ejectorComp = entity.components.ItemEjector;
// Check if we have an empty queue and can start a new charge - do this first so we don't waste a tick
if (processorComp.ongoingCharges.length < MAX_QUEUED_CHARGES) {
if (!processorComp.currentCharge) {
if (this.canProcess(entity)) {
this.startNewCharge(entity);
}
}
const currentCharge = processorComp.ongoingCharges[0];
const currentCharge = processorComp.currentCharge;
if (currentCharge) {
// Process next charge
if (currentCharge.remainingTime > 0.0) {
@ -111,7 +105,7 @@ export class ItemProcessorSystem extends GameSystemWithFilter {
processorComp.queuedEjects.push(itemsToEject[j]);
}
processorComp.ongoingCharges.shift();
processorComp.currentCharge = null;
}
}
@ -267,10 +261,10 @@ export class ItemProcessorSystem extends GameSystemWithFilter {
const timeToProcess = originalTime - bonusTimeToApply;
processorComp.bonusTime -= bonusTimeToApply;
processorComp.ongoingCharges.push({
processorComp.currentCharge = {
items: outItems,
remainingTime: timeToProcess,
});
};
acceptorComp.completedInputs.clear();
}