mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-06-13 13:04:03 +00:00
Implement tryTakeItem in EnergyConsumer
This commit is contained in:
parent
9ef0e77910
commit
7b60cc9420
@ -103,6 +103,7 @@ export class MetaAdvancedProcessorBuilding extends MetaBuilding {
|
||||
directions: [enumDirection.top],
|
||||
filter: enumItemType.positiveEnergy,
|
||||
layer: enumLayer.wires,
|
||||
processor: "EnergyConsumer",
|
||||
},
|
||||
],
|
||||
})
|
||||
|
@ -59,6 +59,21 @@ export class EnergyConsumerComponent extends Component {
|
||||
this.piledOutput = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {BaseItem} item
|
||||
* @param {number} slot
|
||||
*/
|
||||
tryTakeItem(item, slot) {
|
||||
if (this.tryAcceptItem(item, slot)) {
|
||||
// All good
|
||||
return true;
|
||||
}
|
||||
|
||||
// Energy consumer can have more components
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to accept a given item
|
||||
* @param {BaseItem} item
|
||||
|
@ -267,23 +267,6 @@ export class ItemEjectorSystem extends GameSystemWithFilter {
|
||||
}
|
||||
}
|
||||
|
||||
// Try figuring out how what to do with the item
|
||||
// TODO: Kinda hacky. How to solve this properly? Don't want to go through inheritance hell.
|
||||
// Also its just a few cases (hope it stays like this .. :x).
|
||||
const slotIndex = slot.index;
|
||||
|
||||
const itemLayer = enumItemTypeToLayer[item.getItemType()];
|
||||
|
||||
const energyConsumerComp = receiver.components.EnergyConsumer;
|
||||
if (energyConsumerComp) {
|
||||
if (energyConsumerComp.tryAcceptItem(item, slotIndex)) {
|
||||
// All good
|
||||
return true;
|
||||
}
|
||||
|
||||
// Energy consumer can have more components
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user