fix(quickbuild): take precondition items when the build starts, give them back on cancel

A quickbuild's HasItem preconditions took their items only when the build
completed and never gave them back. Live took them when the build started
and gave them back when it was cancelled: the FV Stone Warrior pedestal
(LOT 8551, precondition 99: 5 of LOT 6194) took the items at Building 5
times and added them back with the loot source Quickbuild on each of the 3
cancels in the live captures.

Preconditions now report their item costs instead of removing items while
checking. A quickbuild takes them at the start, gives them back on cancel
or a reset during the build, keeps them on completion, and gives them back
when the builder leaves the world mid-build.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Aaron Kimbrell
2026-09-29 12:54:34 -05:00
parent 47814f1f74
commit b8a7ac897d
8 changed files with 180 additions and 34 deletions

View File

@@ -140,8 +140,12 @@ void PetComponent::OnUse(Entity* originator) {
return;
}
if (m_Preconditions.has_value() && !m_Preconditions->Check(originator, true)) {
return;
if (m_Preconditions.has_value()) {
if (!m_Preconditions->Check(originator)) return;
// Taming uses up the items its preconditions ask for
for (const auto& cost : m_Preconditions->GetItemCosts(originator)) {
inventoryComponent->RemoveItem(cost.lot, cost.count, eInventoryType::ALL);
}
}
auto* const movementAIComponent = m_Parent->GetComponent<MovementAIComponent>();