mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-06-13 13:04:03 +00:00
Remove items array since it's no longer used. (working)
This commit is contained in:
parent
605dcd208c
commit
be51f282d5
@ -81,7 +81,7 @@ export class ItemProcessorComponent extends Component {
|
|||||||
this.processingRequirement = processingRequirement;
|
this.processingRequirement = processingRequirement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Our current inputs
|
* Our current inputs. Mapping of slot number to item.
|
||||||
* @type {Map<number, BaseItem>}
|
* @type {Map<number, BaseItem>}
|
||||||
*/
|
*/
|
||||||
this.inputSlotsMap = new Map();
|
this.inputSlotsMap = new Map();
|
||||||
@ -95,12 +95,6 @@ export class ItemProcessorComponent extends Component {
|
|||||||
// sure the outputs always match
|
// sure the outputs always match
|
||||||
this.nextOutputSlot = 0;
|
this.nextOutputSlot = 0;
|
||||||
|
|
||||||
/**
|
|
||||||
* Our current inputs
|
|
||||||
* @type {Array<{ item: BaseItem, sourceSlot: number }>}
|
|
||||||
*/
|
|
||||||
this.inputSlots = [];
|
|
||||||
|
|
||||||
this.inputSlotsMap.clear();
|
this.inputSlotsMap.clear();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -126,20 +120,12 @@ export class ItemProcessorComponent extends Component {
|
|||||||
tryTakeItem(item, sourceSlot) {
|
tryTakeItem(item, sourceSlot) {
|
||||||
if (specialCaseProcessorTypes.contains(this.type)) {
|
if (specialCaseProcessorTypes.contains(this.type)) {
|
||||||
// Hub has special logic .. not really nice but efficient.
|
// Hub has special logic .. not really nice but efficient.
|
||||||
this.inputSlots.push({ item, sourceSlot });
|
|
||||||
this.inputSlotsMap.set(sourceSlot, item);
|
this.inputSlotsMap.set(sourceSlot, item);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check that we only take one item per slot
|
if (this.inputSlotsMap.has(sourceSlot)) return false;
|
||||||
for (let i = 0; i < this.inputSlots.length; ++i) {
|
|
||||||
const slot = this.inputSlots[i];
|
|
||||||
if (slot.sourceSlot === sourceSlot) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.inputSlots.push({ item, sourceSlot });
|
|
||||||
this.inputSlotsMap.set(sourceSlot, item);
|
this.inputSlotsMap.set(sourceSlot, item);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -253,14 +253,8 @@ export class ItemProcessorSystem extends GameSystemWithFilter {
|
|||||||
const processorComp = entity.components.ItemProcessor;
|
const processorComp = entity.components.ItemProcessor;
|
||||||
|
|
||||||
// First, take items
|
// First, take items
|
||||||
processorComp.inputSlots = [];
|
|
||||||
|
|
||||||
/** @type {Map<number, BaseItem>} */
|
/** @type {Map<number, BaseItem>} */
|
||||||
const itemsBySlotMap = new Map();
|
const itemsBySlotMap = processorComp.inputSlotsMap;
|
||||||
for (let [key, value] of processorComp.inputSlotsMap.entries()) {
|
|
||||||
itemsBySlotMap.set(key, value);
|
|
||||||
}
|
|
||||||
processorComp.inputSlotsMap.clear();
|
|
||||||
|
|
||||||
/** @type {Array<ProducedItem>} */
|
/** @type {Array<ProducedItem>} */
|
||||||
const outItems = [];
|
const outItems = [];
|
||||||
@ -276,6 +270,8 @@ export class ItemProcessorSystem extends GameSystemWithFilter {
|
|||||||
outItems,
|
outItems,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
processorComp.inputSlotsMap.clear();
|
||||||
|
|
||||||
// Track produced items
|
// Track produced items
|
||||||
for (let i = 0; i < outItems.length; ++i) {
|
for (let i = 0; i < outItems.length; ++i) {
|
||||||
if (!outItems[i].doNotTrack) {
|
if (!outItems[i].doNotTrack) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user