mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-06-13 13:04:03 +00:00
Implement tryTakeItem in Belt
This commit is contained in:
parent
223e0e2615
commit
9ef0e77910
@ -60,6 +60,7 @@ export class MetaBeltBaseBuilding extends MetaBuilding {
|
|||||||
pos: new Vector(0, 0),
|
pos: new Vector(0, 0),
|
||||||
directions: [enumDirection.bottom],
|
directions: [enumDirection.bottom],
|
||||||
layer: this.getLayer(),
|
layer: this.getLayer(),
|
||||||
|
processor: "Belt",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
animated: false,
|
animated: false,
|
||||||
|
@ -4,6 +4,7 @@ import { BeltPath } from "../belt_path";
|
|||||||
import { Component } from "../component";
|
import { Component } from "../component";
|
||||||
import { Entity } from "../entity";
|
import { Entity } from "../entity";
|
||||||
import { enumLayer } from "../root";
|
import { enumLayer } from "../root";
|
||||||
|
import { BaseItem } from "../base_item";
|
||||||
|
|
||||||
export const curvedBeltLength = /* Math.PI / 4 */ 0.78;
|
export const curvedBeltLength = /* Math.PI / 4 */ 0.78;
|
||||||
|
|
||||||
@ -118,4 +119,19 @@ export class BeltComponent extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {BaseItem} item
|
||||||
|
* @param {number} slot
|
||||||
|
*/
|
||||||
|
tryTakeItem(item, slot) {
|
||||||
|
const path = this.assignedPath;
|
||||||
|
assert(path, "belt has no path");
|
||||||
|
if (path.tryAcceptItem(item)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// Belt can have nothing else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -274,17 +274,6 @@ export class ItemEjectorSystem extends GameSystemWithFilter {
|
|||||||
|
|
||||||
const itemLayer = enumItemTypeToLayer[item.getItemType()];
|
const itemLayer = enumItemTypeToLayer[item.getItemType()];
|
||||||
|
|
||||||
const beltComp = receiver.components.Belt;
|
|
||||||
if (beltComp) {
|
|
||||||
const path = beltComp.assignedPath;
|
|
||||||
assert(path, "belt has no path");
|
|
||||||
if (path.tryAcceptItem(item)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
// Belt can have nothing else
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const energyConsumerComp = receiver.components.EnergyConsumer;
|
const energyConsumerComp = receiver.components.EnergyConsumer;
|
||||||
if (energyConsumerComp) {
|
if (energyConsumerComp) {
|
||||||
if (energyConsumerComp.tryAcceptItem(item, slotIndex)) {
|
if (energyConsumerComp.tryAcceptItem(item, slotIndex)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user