Header menu logo BaboonAPI

GameInitializationEvent Module

Game initialization event

Using the listener interface and the GameInitializationEvent.attempt method, you can perform fallible setup tasks that will be safely reported to the user if they go wrong.

Example

member this.Awake() =
    GameInitializationEvent.EVENT.Register this

interface GameInitializationEvent.Listener with
    member this.Initialize() =
        GameInitializationEvent.attempt this.Info (fun () ->
            // fallible logic goes here.
        )

Types

Type Description

Listener

Initialization event listener

Functions and values

Function or value Description

EVENT

Full Usage: EVENT

Returns: Event<Listener>

Event bus

Returns: Event<Listener>

Register info applier

Full Usage: Register info applier

Parameters:
    info : PluginInfo - Metadata used when displaying errors
    applier : Action - Wrapped function

Helper function to quickly register a fallible initialization callback from C#

This function lets you easily set up an initialization callback in C# without having to convert to F# functions manually. An exception thrown in here will safely stop the game loading, and the error will be displayed to the user.

info : PluginInfo

Metadata used when displaying errors

applier : Action

Wrapped function

attempt info applier

Full Usage: attempt info applier

Parameters:
    info : PluginInfo - Metadata used when displaying errors
    applier : unit -> unit - Wrapped function

Returns: Result<unit, LoadError>

Wraps your initialization logic and catches any thrown exceptions.

An exception thrown in here will safely stop the game loading, and the error will be displayed to the user.

info : PluginInfo

Metadata used when displaying errors

applier : unit -> unit

Wrapped function

Returns: Result<unit, LoadError>

Type something to start searching.