fix bug where items get already consumed right after being placed on a belt
This commit is contained in:
@@ -119,19 +119,13 @@ std::optional<Item> BeltSystem::tryTakeItem(Port port)
|
||||
}
|
||||
|
||||
BeltTile& bt = it->second;
|
||||
if (bt.front)
|
||||
if (bt.front && bt.front->progress >= 1.0)
|
||||
{
|
||||
const Item taken = bt.front->item;
|
||||
bt.front = bt.back;
|
||||
bt.back = std::nullopt;
|
||||
return taken;
|
||||
}
|
||||
if (bt.back)
|
||||
{
|
||||
const Item taken = bt.back->item;
|
||||
bt.back = std::nullopt;
|
||||
return taken;
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
@@ -149,14 +143,10 @@ std::optional<ItemType> BeltSystem::peekItem(Port port) const
|
||||
}
|
||||
|
||||
const BeltTile& bt = it->second;
|
||||
if (bt.front)
|
||||
if (bt.front && bt.front->progress >= 1.0)
|
||||
{
|
||||
return bt.front->item.type;
|
||||
}
|
||||
if (bt.back)
|
||||
{
|
||||
return bt.back->item.type;
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user