mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-06-13 13:04:03 +00:00
Add a separate field for whether an ejector slot is buffered
This commit is contained in:
parent
473d91365b
commit
007aeaafd2
@ -12,7 +12,8 @@ import { typeItemSingleton } from "../item_resolver";
|
|||||||
* direction: enumDirection,
|
* direction: enumDirection,
|
||||||
* item: BaseItem,
|
* item: BaseItem,
|
||||||
* progress: number?,
|
* progress: number?,
|
||||||
* nextItem?: BaseItem,
|
* buffered: boolean,
|
||||||
|
* nextItem: BaseItem,
|
||||||
* cachedDestSlot?: import("./item_acceptor").ItemAcceptorLocatedSlot,
|
* cachedDestSlot?: import("./item_acceptor").ItemAcceptorLocatedSlot,
|
||||||
* cachedBeltPath?: BeltPath,
|
* cachedBeltPath?: BeltPath,
|
||||||
* cachedTargetEntity?: Entity
|
* cachedTargetEntity?: Entity
|
||||||
@ -62,7 +63,8 @@ export class ItemEjectorComponent extends Component {
|
|||||||
direction: slot.direction,
|
direction: slot.direction,
|
||||||
item: null,
|
item: null,
|
||||||
progress: 0,
|
progress: 0,
|
||||||
nextItem: slot.buffered ? null : undefined,
|
buffered: slot.buffered,
|
||||||
|
nextItem: null,
|
||||||
cachedDestSlot: null,
|
cachedDestSlot: null,
|
||||||
cachedTargetEntity: null,
|
cachedTargetEntity: null,
|
||||||
});
|
});
|
||||||
@ -99,7 +101,8 @@ export class ItemEjectorComponent extends Component {
|
|||||||
*/
|
*/
|
||||||
canEjectOnSlot(slotIndex) {
|
canEjectOnSlot(slotIndex) {
|
||||||
assert(slotIndex >= 0 && slotIndex < this.slots.length, "Invalid ejector slot: " + slotIndex);
|
assert(slotIndex >= 0 && slotIndex < this.slots.length, "Invalid ejector slot: " + slotIndex);
|
||||||
return !this.slots[slotIndex].item || this.slots[slotIndex].nextItem === null;
|
const slot = this.slots[slotIndex];
|
||||||
|
return !slot.item || (slot.buffered && !slot.nextItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -142,11 +145,11 @@ export class ItemEjectorComponent extends Component {
|
|||||||
takeSlotItem(slotIndex) {
|
takeSlotItem(slotIndex) {
|
||||||
const slot = this.slots[slotIndex];
|
const slot = this.slots[slotIndex];
|
||||||
const item = slot.item;
|
const item = slot.item;
|
||||||
if (slot.nextItem === undefined) {
|
if (slot.buffered) {
|
||||||
slot.item = null;
|
|
||||||
} else {
|
|
||||||
slot.item = slot.nextItem;
|
slot.item = slot.nextItem;
|
||||||
slot.nextItem = null;
|
slot.nextItem = null;
|
||||||
|
} else {
|
||||||
|
slot.item = null;
|
||||||
}
|
}
|
||||||
slot.progress = 0.0;
|
slot.progress = 0.0;
|
||||||
return item;
|
return item;
|
||||||
|
Loading…
Reference in New Issue
Block a user