implement building system
This commit is contained in:
@@ -135,6 +135,31 @@ std::optional<Item> BeltSystem::tryTakeItem(Port port)
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::optional<ItemType> BeltSystem::peekItem(Port port) const
|
||||
{
|
||||
const std::map<std::pair<int, int>, BeltTile>::const_iterator it =
|
||||
m_belts.find(key(port.tile));
|
||||
if (it == m_belts.end())
|
||||
{
|
||||
return std::nullopt;
|
||||
}
|
||||
if (it->second.direction != port.direction)
|
||||
{
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
const BeltTile& bt = it->second;
|
||||
if (bt.front)
|
||||
{
|
||||
return bt.front->item.type;
|
||||
}
|
||||
if (bt.back)
|
||||
{
|
||||
return bt.back->item.type;
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Maintenance
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user