1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2025-12-15 11:11: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 * What we are currently processing, empty if we don't produce anything rn
* requiredSlot: Item *must* be ejected on this slot * 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 * 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 * 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 // Take items from acceptor
const input = acceptorComp.completedInputs.get(0); 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); acceptorComp.completedInputs.delete(0);
} }
@ -42,11 +42,10 @@ export class FilterSystem extends GameSystemWithFilter {
/** /**
* *
* @param {Entity} entity * @param {Entity} entity
* @param {Object} param0 * @param {BaseItem} item
* @param {BaseItem} param0.item * @param {number} extraProgress
* @param {number} param0.extraProgress
*/ */
tryAcceptItem(entity, { item, extraProgress }) { tryAcceptItem(entity, item, extraProgress) {
const network = entity.components.WiredPins.slots[0].linkedNetwork; const network = entity.components.WiredPins.slots[0].linkedNetwork;
if (!network || !network.hasValue()) { if (!network || !network.hasValue()) {
// Filter is not connected // Filter is not connected

View File

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

View File

@ -300,15 +300,6 @@ export class ItemEjectorSystem extends GameSystemWithFilter {
^ ^ item @ 0.9 ^ ^ item @ 0.9
^ max progress = 0.3 ^ 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. 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 { ColorItem, COLOR_ITEM_SINGLETONS } from "../items/color_item";
import { ShapeItem } from "../items/shape_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 * Whole data for a produced item
* *
@ -85,13 +79,13 @@ export class ItemProcessorSystem extends GameSystemWithFilter {
const ejectorComp = entity.components.ItemEjector; 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 // 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)) { if (this.canProcess(entity)) {
this.startNewCharge(entity); this.startNewCharge(entity);
} }
} }
const currentCharge = processorComp.ongoingCharges[0]; const currentCharge = processorComp.currentCharge;
if (currentCharge) { if (currentCharge) {
// Process next charge // Process next charge
if (currentCharge.remainingTime > 0.0) { if (currentCharge.remainingTime > 0.0) {
@ -111,7 +105,7 @@ export class ItemProcessorSystem extends GameSystemWithFilter {
processorComp.queuedEjects.push(itemsToEject[j]); processorComp.queuedEjects.push(itemsToEject[j]);
} }
processorComp.ongoingCharges.shift(); processorComp.currentCharge = null;
} }
} }
@ -267,10 +261,10 @@ export class ItemProcessorSystem extends GameSystemWithFilter {
const timeToProcess = originalTime - bonusTimeToApply; const timeToProcess = originalTime - bonusTimeToApply;
processorComp.bonusTime -= bonusTimeToApply; processorComp.bonusTime -= bonusTimeToApply;
processorComp.ongoingCharges.push({ processorComp.currentCharge = {
items: outItems, items: outItems,
remainingTime: timeToProcess, remainingTime: timeToProcess,
}); };
acceptorComp.completedInputs.clear(); acceptorComp.completedInputs.clear();
} }