mirror of
https://github.com/tobspr/shapez.io.git
synced 2026-03-02 03:39:21 +00:00
Properly process belt dependencies and fix items not travelling linear on belts
This commit is contained in:
@@ -60,7 +60,7 @@ export class BeltComponent extends Component {
|
||||
/**
|
||||
* Returns if the belt can currently accept an item from the given direction
|
||||
*/
|
||||
canAcceptNewItem() {
|
||||
canAcceptNewItem(leftoverProgress = 0.0) {
|
||||
const firstItem = this.sortedItems[0];
|
||||
if (!firstItem) {
|
||||
return true;
|
||||
@@ -73,8 +73,19 @@ export class BeltComponent extends Component {
|
||||
* Pushes a new item to the belt
|
||||
* @param {BaseItem} item
|
||||
*/
|
||||
takeNewItem(item) {
|
||||
this.sortedItems.unshift([0, item]);
|
||||
takeNewItem(item, leftoverProgress = 0.0) {
|
||||
if (G_IS_DEV) {
|
||||
assert(
|
||||
this.sortedItems.length === 0 ||
|
||||
leftoverProgress <= this.sortedItems[0][0] - globalConfig.itemSpacingOnBelts + 0.001,
|
||||
"Invalid leftover: " +
|
||||
leftoverProgress +
|
||||
" items are " +
|
||||
this.sortedItems.map(item => item[0])
|
||||
);
|
||||
assert(leftoverProgress < 1.0, "Invalid leftover: " + leftoverProgress);
|
||||
}
|
||||
this.sortedItems.unshift([leftoverProgress, item]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user