re-cover copy-settings through single-building blueprints
This commit is contained in:
@@ -30,9 +30,27 @@ bool bodyCellsWithinWorldBounds(const FactoryState& state, const GameConfig& con
|
||||
bool isPlacementValid(const FactoryState& state, const GameConfig& config,
|
||||
BuildingType type, QPoint anchor, Rotation rotation);
|
||||
|
||||
// An existing building or site whose footprint a ghost exactly covers.
|
||||
struct CoincidingBuilding
|
||||
{
|
||||
BuildingId id;
|
||||
Rotation rotation;
|
||||
};
|
||||
|
||||
// The building or site whose footprint a ghost of the given type/anchor/rotation
|
||||
// exactly covers: same type, same body cells, a single owner. Operational buildings
|
||||
// and construction sites alike. Rotation is not part of the test -- the target's own
|
||||
// facing is reported so each caller can apply its own rule to it.
|
||||
std::optional<CoincidingBuilding> findCoincidingSameTypeBuilding(const FactoryState& state,
|
||||
const GameConfig& config,
|
||||
BuildingType type,
|
||||
QPoint anchor,
|
||||
Rotation rot);
|
||||
|
||||
// The building or site that a ghost of the given type/anchor/rotation would
|
||||
// rotate in place rather than replace: same type, same body cells, one owner
|
||||
// (REQ-BLD-ROTATE-IN-PLACE). Tunnels never qualify.
|
||||
// (REQ-BLD-ROTATE-IN-PLACE). Tunnels never qualify. Builder mode only; blueprint
|
||||
// placement mode never rotates anything -- see resolveBlueprintGhost.
|
||||
std::optional<BuildingId> findRotateInPlaceTarget(const FactoryState& state,
|
||||
const GameConfig& config,
|
||||
BuildingType type, QPoint anchor,
|
||||
@@ -46,6 +64,36 @@ std::optional<BuildingId> findRotateInPlaceTarget(const FactoryState& state,
|
||||
bool canPlaceBuilding(const FactoryState& state, const GameConfig& config,
|
||||
BuildingType type, QPoint anchor, Rotation rotation);
|
||||
|
||||
// What one ghost of a blueprint would do at its resolved tile.
|
||||
enum class BlueprintGhostAction
|
||||
{
|
||||
PlaceNew, // free, valid cells: a new construction site, charged for
|
||||
CompatibleOverlap, // the same building is already there: left untouched, free
|
||||
// (REQ-UI-BLUEPRINT-OVERLAP)
|
||||
Transfer, // hand this blueprint's settings to the building already there,
|
||||
// free (REQ-UI-BLUEPRINT-TRANSFER)
|
||||
Invalid // terrain, bounds, or an overlap that is neither of the above
|
||||
};
|
||||
|
||||
struct BlueprintGhostResolved
|
||||
{
|
||||
BlueprintGhostAction action;
|
||||
std::optional<BuildingId> targetId; // set for CompatibleOverlap and Transfer
|
||||
};
|
||||
|
||||
// Classifies one ghost of a blueprint against the current factory state
|
||||
// (REQ-UI-BLUEPRINT-OVERLAP, REQ-UI-BLUEPRINT-TRANSFER). `blueprintHoldsOneBuilding` is
|
||||
// the blueprint's stored size, counted before locked types are dropped, so the gesture
|
||||
// does not change behavior as the player unlocks things.
|
||||
//
|
||||
// Shared by the ghost coloring and the click path so a preview cannot disagree with what
|
||||
// the click then does -- the same reason resolveBeltDragPath is shared.
|
||||
BlueprintGhostResolved resolveBlueprintGhost(const FactoryState& state,
|
||||
const GameConfig& config,
|
||||
BuildingType type, QPoint anchor,
|
||||
Rotation rotation,
|
||||
bool blueprintHoldsOneBuilding);
|
||||
|
||||
// What a belt drag would do to one tile of its path (REQ-BLD-BELT-DRAG).
|
||||
enum class BeltTileAction
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user