Table of Contents

Class GameLifecycle

Namespace
S1API.Lifecycle
Assembly
S1API.dll

Provides lifecycle events for game initialization and loading. Subscribe to these events to execute code at specific points in the game's lifecycle.

public static class GameLifecycle
Inheritance
GameLifecycle
Inherited Members

Examples

// Subscribe to PreLoad event to initialize items before game loads
GameLifecycle.OnPreLoad += () => {
    MelonLogger.Msg("Creating custom items...");
    CreateMyCustomItems();
};

Remarks

This API provides a cross-runtime abstraction over ScheduleOne's LoadManager events, eliminating the need for runtime-specific conditional compilation in mods.

Events

OnLoadComplete

Fired when the game has finished loading all data and the player can interact with the world. This is the ideal time to initialize mod systems that depend on game state being fully loaded.

public static event Action OnLoadComplete

Event Type

Action

Examples

// Subscribe to OnLoadComplete to initialize systems after game loads
GameLifecycle.OnLoadComplete += () => {
    MelonLogger.Msg("Game loaded! Initializing mod systems...");
    InitializeMyModSystems();
};

Remarks

Equivalent to LoadManager.onLoadComplete but abstracted for cross-runtime compatibility. Fires after all save data has been loaded and the loading screen is about to close.

OnPreLoad

Fired before the game begins loading saved data. This is the ideal time to register custom items, as they need to exist before save data is loaded.

public static event Action OnPreLoad

Event Type

Action

Remarks

Equivalent to LoadManager.onPreLoad but abstracted for cross-runtime compatibility.

OnPreSceneChange

Fired before the game transitions to a different scene (e.g., Menu to Main, or exiting to Menu). Use this to clean up resources or save mod state before the scene changes.

public static event Action OnPreSceneChange

Event Type

Action

Examples

// Subscribe to OnPreSceneChange to clean up before scene transition
GameLifecycle.OnPreSceneChange += () => {
    MelonLogger.Msg("Scene changing, saving mod data...");
    SaveMyModData();
};

Remarks

Equivalent to LoadManager.onPreSceneChange but abstracted for cross-runtime compatibility. Fires before any cleanup occurs, giving mods a chance to perform their own cleanup.

OnSaveComplete

Fired when the game has finished saving all data. Use this to confirm mod data was saved or perform post-save cleanup.

public static event Action OnSaveComplete

Event Type

Action

Examples

// Subscribe to OnSaveComplete to confirm save completion
GameLifecycle.OnSaveComplete += () => {
    MelonLogger.Msg("Game save complete!");
    ConfirmModDataSaved();
};

Remarks

Equivalent to SaveManager.onSaveComplete but abstracted for cross-runtime compatibility. Only fires on the host/server after all save operations complete.

OnSaveInfoLoaded

Fired when save game information has been loaded and refreshed. This occurs when the save menu is opened or when save data is re-scanned.

public static event Action OnSaveInfoLoaded

Event Type

Action

Examples

// Subscribe to OnSaveInfoLoaded to react to save data updates
GameLifecycle.OnSaveInfoLoaded += () => {
    MelonLogger.Msg("Save info refreshed, updating mod UI...");
    UpdateSaveDisplay();
};

Remarks

Equivalent to LoadManager.onSaveInfoLoaded but abstracted for cross-runtime compatibility. Useful for mods that need to know about available saves or display save information.

OnSaveStart

Fired when the game begins saving data. Use this to prepare mod data for saving or trigger custom save logic.

public static event Action OnSaveStart

Event Type

Action

Examples

// Subscribe to OnSaveStart to prepare data before save
GameLifecycle.OnSaveStart += () => {
    MelonLogger.Msg("Game saving started, preparing mod data...");
    PrepareModDataForSave();
};

Remarks

Equivalent to SaveManager.onSaveStart but abstracted for cross-runtime compatibility. Only fires on the host/server. Clients do not trigger saves.