rekey the temporary blueprint to C, add V to re-place it
This commit is contained in:
@@ -116,22 +116,48 @@ void BlueprintLibrary::handleEvent(std::shared_ptr<const SelectionChangedEvent>
|
||||
|
||||
void BlueprintLibrary::handleEvent(std::shared_ptr<const BlueprintModeExitedEvent> /*event*/)
|
||||
{
|
||||
// Only the saved-blueprint index is cleared. A temporary blueprint deliberately
|
||||
// survives its placement mode so V can re-enter it (REQ-UI-BLUEPRINT-TEMP).
|
||||
m_activeIndex = std::nullopt;
|
||||
}
|
||||
|
||||
void BlueprintLibrary::handleEvent(
|
||||
std::shared_ptr<const TemporaryBlueprintRequestedEvent> /*event*/)
|
||||
std::shared_ptr<const TemporaryBlueprintCaptureRequestedEvent> /*event*/)
|
||||
{
|
||||
// Temporary blueprint (REQ-UI-BLUEPRINT-TEMP): build from the current selection and
|
||||
// enter placement mode without adding it to the list or persisting it. If nothing
|
||||
// player-placeable is selected, do nothing.
|
||||
// C (REQ-UI-BLUEPRINT-TEMP): capture the current selection and enter placement mode
|
||||
// for it, without naming it, listing it, or persisting it. If nothing player-placeable
|
||||
// is selected, do nothing at all -- in particular, keep the previous temporary
|
||||
// blueprint, which V can still place.
|
||||
Blueprint blueprint = createBlueprintFromSelection();
|
||||
if (blueprint.buildings.empty()) { return; }
|
||||
|
||||
m_temporaryBlueprint = std::move(blueprint);
|
||||
// No saved blueprint is active while a temporary one is being placed.
|
||||
m_activeIndex = std::nullopt;
|
||||
EventManager::getInstance()->sendEventImmediately(
|
||||
std::make_shared<BlueprintPlacementRequestedEvent>(std::move(blueprint)));
|
||||
std::make_shared<BlueprintPlacementRequestedEvent>(*m_temporaryBlueprint));
|
||||
}
|
||||
|
||||
void BlueprintLibrary::handleEvent(
|
||||
std::shared_ptr<const TemporaryBlueprintPlaceRequestedEvent> /*event*/)
|
||||
{
|
||||
// V (REQ-UI-BLUEPRINT-TEMP): re-enter placement mode for the temporary blueprint,
|
||||
// capturing nothing. With none captured, nothing happens -- no mode is entered and
|
||||
// whichever mode is active is left alone. Affordability is not checked here, matching
|
||||
// C; cost is enforced at placement (REQ-UI-BLUEPRINT-PLACE). The blueprint is copied,
|
||||
// not moved: it stays available for the next V.
|
||||
if (!m_temporaryBlueprint.has_value()) { return; }
|
||||
|
||||
m_activeIndex = std::nullopt;
|
||||
EventManager::getInstance()->sendEventImmediately(
|
||||
std::make_shared<BlueprintPlacementRequestedEvent>(*m_temporaryBlueprint));
|
||||
}
|
||||
|
||||
void BlueprintLibrary::handleEvent(std::shared_ptr<const GameResetEvent> /*event*/)
|
||||
{
|
||||
// A restart begins a new run, and the temporary blueprint belongs to the old one
|
||||
// (REQ-UI-BLUEPRINT-TEMP). The saved blueprints are not run state and stay.
|
||||
m_temporaryBlueprint = std::nullopt;
|
||||
}
|
||||
|
||||
Blueprint BlueprintLibrary::createBlueprintFromSelection() const
|
||||
|
||||
Reference in New Issue
Block a user