Details
Target: Obenseuer 0.5.08 (buildid 25969064), Unity 6000.0.77f1 Mono, BepInEx 6 Unity.Mono (be.788, the tested build) or BepInEx 5 (5.4.23 or later). Namespace: ObenseuerCore. Source: src/Api/Inventory.cs, src/Api/InventoryPatches.cs, src/Api/InventoryStack.cs, src/Api/Containers.cs and src/Api/ContainersPatches.cs.
Everything not listed in this reference is internal and may change without notice. Item ids are the game’s whole-number item ids.
The framework changes some of the game’s methods when it starts, so it can tell your mod when items are added or removed and when a container opens or closes. This page calls each group of these changes a feature group. This page uses two: obenseuer.moddingframework.inventory (the ItemAdded and ItemRemoved events) and obenseuer.moddingframework.containers (the Opened and Closed events). These are the names you will see in the log.
When you can call it
- Call everything from your mod’s normal code (
OnLoad, event handlers,Update), not from a background thread you started. The game only runs safely on the main thread (see the glossary). - It is safe to call any of it at any time. With no save loaded, or on the main menu, reads give
0,falseor an empty list.
What to check for and what comes back
PlayerInventory.IsAvailabletells you whetherItemAddedandItemRemovedwork. It isfalsewhen the framework could not set up those events, or when the feature group was turned off. Reads and writes are not affected.- Writes return
bool. A count of0or less passed toHas,Give,Takeor any of theContainerswrites throws anArgumentException, and nothing else throws.
If something fails to set up
The framework changes some of the game’s methods when it starts. If a game update breaks one of them, the framework turns off the feature group that depends on it, and writes error lines and a warning to the group’s log file in BepInEx\logs. The rest of the framework keeps working.
- If any of the four changes for the inventory events fails, the whole inventory feature group turns off.
ItemAddedandItemRemovedstop,PlayerInventory.IsAvailablebecomesfalse, and the framework writes error lines and a warning to the log. Reads and writes keep working. (The changes are a postfix onSlotController.AddItemAndReturnRemainingand a postfix onSlotController.TakeItem(Item, int, int, object[]), which raise the events; and prefix and finalizer pairs onSlotController.TakeItem(ItemData)andSlotController.DropItem, which count the drags in the inventory screens so the events stay quiet while the player moves items there.) - If any of the three container changes fails, the containers feature group turns off.
OpenedandClosedstop, error lines and a warning go to the log, and the rest ofContainerskeeps working. (The changes are postfixes onStorage.EnterExternally(bool),Storage.ExitExternally()andStorage.OnDisable(). The log line reads “container hooks incomplete, Opened and Closed events are disabled”.)