Crafting — Inventory Adapters¶
This folder contains Crafting adapters that integrate with the RevFramework Inventory system.
Adapters here implement: - ICraftingInventoryAdapter - optionally ICraftingInventoryReservationAdapter
They translate Crafting inventory requests into calls to the scene inventory service and item database.
Inventory crafting adapter¶
InventoryCraftingAdapter¶
- Compiled when
REV_INVENTORY_PRESENTis defined. - Forwards inventory operations to
SceneInventoryService. - Uses an adapter-owned, opaque container handle.
- Crafting code never accesses inventory internals directly.
Supported operations: - container resolution - item counting - space checks (non-reserving) - exact add / consume mutations
All operations are defensive: - missing services - invalid handles - invalid identifiers
Result in safe failure (false / 0), not exceptions.
Reservation / escrow support¶
Reservations work. This adapter implements ICraftingInventoryReservationAdapter for real:
TryReserveInputsconsumes the required inputs, summing quantities for repeated item ids so a recipe listing the same input twice is charged for both rows.- If any line cannot be taken, every line already taken is given back before the call returns. A partial consumption is the one outcome a reservation must never leave behind.
TryReserveOutputsreserves the space the outputs will need.- Each reservation is committed or rolled back inside one synchronous call.
This section used to say the opposite
It stated that the Inventory system exposes no reservation primitives, that input and output reservations "always fail safely", and that "no atomic or escrow crafting is provided". None of that is true, and it hid a working headline feature from anyone reading the docs to find out whether it existed.
The real boundary is duration, not capability: escrow crafting refuses any craft whose adjusted duration is above zero, so a reservation is taken, committed and released within one call on Unity's single thread. Reservations that outlive a call would need persisting across save/restore, which is a separate feature and is named as such.
Event deferral¶
DeferEvents always returns a non-null disposable.
This adapter does not batch or defer inventory events. The returned scope is a no-op.