Skip to content

Lifecycle Events

Use lifecycle events when a mod needs game timing but does not need to own a Harmony patch.

var subscription = RitsuLibFramework.SubscribeLifecycle<GameReadyEvent>(evt =>
{
Logger.Info($"Game ready: {evt.Game.Name}");
});

Dispose the returned subscription when the handler is temporary.

RitsuLibFramework.SubscribeLifecycle<CombatStartingEvent>((evt, sub) =>
{
PrepareForCombat(evt.RunState);
sub.Dispose();
});

Replayable events are delivered immediately to late subscribers by default. Pass replayCurrentState: false when you only want future events.

TimingEvents
Framework bootFrameworkInitializingEvent, FrameworkInitializedEvent
Model setupContentRegistrationClosedEvent, ModelRegistryInitializedEvent, ModelIdsInitializedEvent, ModelPreloadingCompletedEvent
Game nodeGameTreeEnteredEvent, GameReadyEvent
Profiles and savesProfileIdInitializedEvent, ProfileSwitchingEvent, ProfileSwitchedEvent, RunSavingEvent, RunSavedEvent, ProgressSavingEvent, ProgressSavedEvent, ProfileDeletingEvent, ProfileDeletedEvent
Run flowRunStartedEvent, RunLoadedEvent, RunEndedEvent, RoomEnteringEvent, RoomEnteredEvent, RoomExitedEvent, ActEnteringEvent, ActEnteredEvent
CombatCombatStartingEvent, CombatEndedEvent, CombatVictoryEvent, SideTurnStartingEvent, SideTurnStartedEvent, CardPlayingEvent, CardPlayedEvent
CardsCardMovedBetweenPilesEvent, CardDrawnEvent, CardDiscardedEvent, CardExhaustedEvent, BeforeFlushEvent, CardsFlushedEvent
Rewards and inventoryGoldGainedEvent, GoldLostEvent, PotionProcuredEvent, PotionDiscardedEvent, RelicObtainedEvent, RelicRemovedEvent, RewardTakenEvent
UnlocksEpochObtainedEvent, EpochRevealedEvent, UnlockIncrementedEvent

CardRetainedEvent is obsolete on newer host APIs. Use CardsFlushedEvent when you need retained and flushed cards together.

For game API differences that affect event availability, check Diagnostics and compatibility.