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. Logs go toBepInEx\logs\obenseuer.moddingframework.shopstock.log. - Everything not listed in this reference is internal and may change without notice. Items marked experimental may change too.
- The framework changes some of the game’s methods when it starts, so it can add your stock when a shop loads. These changes are grouped as a feature group. This page’s feature group is
obenseuer.moddingframework.shopstock, the name you will see in the log. One more change is shared with the loot pools feature, whose feature group isobenseuer.moddingframework.loot: see below.
When you can call it
- Call everything from your mod’s normal code, not from a background thread you started. The game and Unity only run safely on the main thread (see the glossary).
- The calls that change something return
falsewhile a save is loading or being written. The stock added when a shop loads, and the vending entries, are added inside the game’s own load and spawn code, so a save does not block them. (Writes are refused whileSaveData.Busyis true.)
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 to the group’s log file in
BepInEx\logs. The rest of the framework keeps working. - If any change in this feature group cannot be made, the whole group turns off and
ShopStock.IsAvailablebecomesfalse. The other three calls then returnfalse. (The changes are onVendingMachine.Start,VendingMachine.OnLoadingGame,VendingMachine.Buy,VendingMachine.RefillStockandStorage.OnLoadingGame, plus a lookup ofStorage.AddItemToStorageSlot. A failed change turns off only the feature group that registered it.) - After a restock, the trader’s top-up comes from the loot pools feature. That part runs inside a change made by the loot pools feature group. If it is off, a trader is still topped up when a save loads, and when you call
AddTraderStockfor a shop that is already loaded, but not after the shop restocks. Vending entries andPlacedo not depend on it. (The restock top-up is an addition to theStorage.SpawnItemspostfix that the loot pools patches register underobenseuer.moddingframework.loot.)