Lifecycle & Events
FTK2API.State describes the host lifecycle. Native content work belongs in GameDataReady, published for each newly usable game-data generation.
IDisposable ready = mod.Events.Subscribe<GameDataReady>(evt =>
{
mod.Log.Info("Lifecycle", $"Ready generation {evt.Generation}");
});
GameDataUnavailable reports loss of a previously usable generation. Scene or campaign changes alone do not imply a new generation.
Threading
Registration, services, event subscription, callbacks, activation handles, and subscription disposal are main-thread operations. Logging can be called independently. A violation reports MAIN_THREAD_REQUIRED rather than allowing unsafe Unity state access.
FTK2 may load combat assets on worker threads. ModAPI 0.5.9 keeps its internal diagnostic observers passive there; mod authors should still follow each public service's main-thread contract.
Cleanup order
- Release runtime item leases after their native objects leave live containers.
- Deactivate and remove custom items.
- Deactivate and remove custom abilities.
- Remove localization entries.
- Dispose subscriptions and the optional IModSession.
Do not treat every Unity OnDisable or OnDestroy callback as process shutdown.