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.
Everything not listed in this reference is internal and may change without notice.
The framework changes some of the game’s methods when it starts, so it can tell your mod when something breaks. This page calls each group of those changes a feature group. Each group has a name that shows up in the log. The page’s own group is obenseuer.moddingframework.breakables, and it is split into four smaller groups: .break (the Broken event), .repair (the Repaired event), .lock (the LockBroken event) and .smash (the Smashed event).
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). That includes the code that handles every event.
- It is safe to call any of it at any time, even on the main menu or while a save is loading. If there is nothing to read yet, you get an empty list,
nullorfalse. - Nothing here throws an error to your code. An id that is unknown, null or empty gives
nullorfalse. A change that cannot be made givesfalse. Break,RepairandBreakLockdo nothing while a save is loading or being written. They returnfalse. Try again later, for example from a timer. (They checkSaveGate.Busy.)- Your event handlers run inside the game’s own call, one at a time. If one handler throws an error, the framework logs it and still runs the other handlers. Do not change scenes or break more objects from inside a handler. Wait until the game has finished its work, for example with a timer. (
Broken,Repaired,LockBrokenandSmashedare raised synchronously from a Harmony postfix on the main thread.) - No event fires while a save is loading. That includes a repair timer that expired while the game was closed. (The events check
SaveController.Loading.)
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.
- Each event depends on its own small feature group.
Brokenneedsobenseuer.moddingframework.breakables.break,Repairedneeds.repair,LockBrokenneeds.lockandSmashedneeds.smash. If one cannot be set up, only that group is turned off,Breakables.IsAvailablebecomesfalse, and the framework writes error lines and a warning to the log. The other events and all the calls keep working:All,Get,IsBroken,Break,Repair,LocksandBreakLock. (The game methods involved areBreakable.Break(break),Breakable.RepairandBreakable.OnLoadingGame(repair),BreakableLock.Break(lock) andSpawnItemOnBreak.Damage(smash). The log line reads “breakable hooks incomplete, IsAvailable is false, the events whose hooks are missing are disabled”.)