Stateless-by-convention recipe transaction service over real Item Vault inventories. A craft follows exactly one atomic path: validate recipe → validate requested quantity → resolve exact total inputs and outputs (per requested quantity) → verify every item identity resolves in the Item Vault database → preflight input availability → preflight output capacity AFTER planned consumption (dry run on a transient clone using Item Vault's own transaction semantics) → begin one atomic InventoryTransaction → consume inputs → insert net outputs → commit → return a typed CraftingResult On ANY failure: no inputs remain partially consumed, no outputs remain partially inserted, no items are duplicated, the result carries a stable reason, and authoritative Item Vault state is unchanged. [method can_craft] is a pure/read-only query: it never mutates metrics, logs, or inventory state. Safe for UI previews, tooltips, and AI scoring. Logging routes through Item Vault's [ItemVaultLogger]; install a structured-event sink via [method set_log_sink] to receive one [CraftingLog] per craft attempt and outcome. Counter metrics are always tracked on [member metrics].
Source: addons/item_vault/crafting/services/crafting_service.gd
Syntax
class CraftingService extends RefCountedMembers
| Name | Kind | Summary |
|---|---|---|
operation_counter | Property | Monotonic craft operation counter. Persisted via [CraftingSave] so operation identity continues across sessions without duplication. |
metrics | Property | |
MAX_TRACKED_REQUESTS | Field | |
set_log_sink | Method | |
clear_log_sink | Method | |
set_metrics | Method | |
reset_metrics | Method | |
set_operation_counter | Method | |
clear_request_tracking | Method | |
can_craft | Method | |
craft | Method | |
craft_request | Method | |
required | Property | |
produced | Property | |
required_total | Property | |
available | Property | |
want | Property |