dont require output belts to be aligned with output ports
This commit is contained in:
@@ -92,18 +92,14 @@ void BeltSystem::setSplitterFilters(QPoint tile,
|
||||
// Port interface
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
bool BeltSystem::tryPutItem(Port port, Item item)
|
||||
bool BeltSystem::tryPutItem(QPoint tile, Item item)
|
||||
{
|
||||
const std::map<std::pair<int, int>, BeltTile>::iterator it = m_belts.find(key(port.tile));
|
||||
const std::map<std::pair<int, int>, BeltTile>::iterator it = m_belts.find(key(tile));
|
||||
if (it == m_belts.end())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (it->second.direction != port.direction)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return tryPlaceOnBelt(port.tile, item);
|
||||
return tryPlaceOnBelt(tile, item);
|
||||
}
|
||||
|
||||
std::optional<Item> BeltSystem::tryTakeItem(Port port)
|
||||
|
||||
@@ -56,9 +56,9 @@ public:
|
||||
// port.tile = the belt tile adjacent to the building
|
||||
// port.direction = direction items flow on that tile
|
||||
//
|
||||
// tryPutItem: place item onto port.tile entering from the opposite side.
|
||||
// Returns false if the tile is not a belt, direction mismatches, or tile full.
|
||||
bool tryPutItem(Port port, Item item);
|
||||
// tryPutItem: place item onto tile.
|
||||
// Returns false if the tile is not a belt, or tile full.
|
||||
bool tryPutItem(QPoint tile, Item item);
|
||||
|
||||
// tryTakeItem: remove and return the leading item from port.tile.
|
||||
// Returns nullopt if tile is not a belt, direction mismatches, or tile empty.
|
||||
@@ -119,3 +119,4 @@ private:
|
||||
std::map<std::pair<int, int>, BeltTile> m_belts;
|
||||
std::map<std::pair<int, int>, SplitterTile> m_splitters;
|
||||
};
|
||||
|
||||
|
||||
@@ -726,7 +726,7 @@ void BuildingSystem::tickBeltPush()
|
||||
break;
|
||||
}
|
||||
const Item item = building.outputBuffer.items.front();
|
||||
if (m_belts.tryPutItem(outputPort, item))
|
||||
if (m_belts.tryPutItem(outputPort.tile, item))
|
||||
{
|
||||
building.outputBuffer.items.erase(building.outputBuffer.items.begin());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user