fix: demolish did not return blocks
This commit is contained in:
@@ -447,6 +447,11 @@ EntityId Simulation::tryPlaceBuilding(BuildingType type, QPoint anchor, Rotation
|
|||||||
return m_buildingSystem->place(type, anchor, rotation, m_currentTick);
|
return m_buildingSystem->place(type, anchor, rotation, m_currentTick);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Simulation::demolish(EntityId id)
|
||||||
|
{
|
||||||
|
m_buildingBlocksStock += m_buildingSystem->demolish(id);
|
||||||
|
}
|
||||||
|
|
||||||
BuildingSystem& Simulation::buildings()
|
BuildingSystem& Simulation::buildings()
|
||||||
{
|
{
|
||||||
return *m_buildingSystem;
|
return *m_buildingSystem;
|
||||||
|
|||||||
@@ -55,6 +55,9 @@ public:
|
|||||||
// Returns the new entity id, or kInvalidEntityId if blocks are insufficient.
|
// Returns the new entity id, or kInvalidEntityId if blocks are insufficient.
|
||||||
EntityId tryPlaceBuilding(BuildingType type, QPoint anchor, Rotation rotation);
|
EntityId tryPlaceBuilding(BuildingType type, QPoint anchor, Rotation rotation);
|
||||||
|
|
||||||
|
// Demolishes the building with the given id and refunds building blocks.
|
||||||
|
void demolish(EntityId id);
|
||||||
|
|
||||||
BuildingSystem& buildings();
|
BuildingSystem& buildings();
|
||||||
const BuildingSystem& buildings() const;
|
const BuildingSystem& buildings() const;
|
||||||
BeltSystem& belts();
|
BeltSystem& belts();
|
||||||
|
|||||||
@@ -958,7 +958,7 @@ void GameWorldView::mousePressEvent(QMouseEvent* event)
|
|||||||
|| b->type == BuildingType::PlayerDefenceStation);
|
|| b->type == BuildingType::PlayerDefenceStation);
|
||||||
if (!protected_)
|
if (!protected_)
|
||||||
{
|
{
|
||||||
m_sim->buildings().demolish(hovered);
|
m_sim->demolish(hovered);
|
||||||
m_demolishHoverId = kInvalidEntityId;
|
m_demolishHoverId = kInvalidEntityId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user