make selection box sub-tile aware
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include <QPoint>
|
||||
#include <QRectF>
|
||||
|
||||
#include "BeltSystem.h"
|
||||
#include "Building.h"
|
||||
@@ -135,6 +136,26 @@ TEST_CASE("BuildingSystem: place miner occupies expected body tiles", "[building
|
||||
REQUIRE_FALSE(isTileOccupied(f.state, QPoint(1, 1)));
|
||||
}
|
||||
|
||||
TEST_CASE("buildingsInBox covers a body cell the box only reaches into", "[building]")
|
||||
{
|
||||
PlacementFixture f;
|
||||
|
||||
const BuildingId id = f.bs.place(f.state, BuildingType::Miner, QPoint(0, 0),
|
||||
Rotation::East, 0).value();
|
||||
|
||||
// Body at (0,0),(1,0),(0,1). The box is unsnapped and lies wholly within cell
|
||||
// (1,0) without filling it, which is enough: a building is covered when the box
|
||||
// overlaps any of its body cells (REQ-UI-MULTI-SELECT, Coverage).
|
||||
const std::vector<BuildingId> grazed =
|
||||
buildingsInBox(f.state, QRectF(1.6, 0.4, 0.2, 0.2));
|
||||
REQUIRE(grazed.size() == 1);
|
||||
REQUIRE(grazed.front() == id);
|
||||
|
||||
// (1,1) is the output-port tile, not a body cell, so a box inside it covers
|
||||
// nothing even though it is surrounded by the miner's cells.
|
||||
REQUIRE(buildingsInBox(f.state, QRectF(1.2, 1.2, 0.5, 0.5)).empty());
|
||||
}
|
||||
|
||||
// -- World-bounds rejection (REQ-BLD-PLACE-VALID) ---------------------------
|
||||
|
||||
TEST_CASE("BuildingSystem: place rejects a building above the world (y < 0)", "[building]")
|
||||
|
||||
Reference in New Issue
Block a user