Lifecycle and readiness

Understand realms, dependency-first activation, bounded loading, readiness acknowledgement and deterministic teardown.

ILitherarpAddon

MemberRealmWhen it runs
string AddonId { get; }bothRequired stable identity. It must normalize to the configured id.
string DisplayName { get; }bothHuman-readable name. The default is AddonId.
string Version { get; }bothImplementation version. The default is 1.0.0.
int ProtocolVersion { get; }bothApplication protocol. It must match the manifest. The default is 1.
Task OnHostLoadingAsync(context, cancellationToken)hostBounded async setup before OnHostLoaded. The platform timeout is 15 seconds.
void OnHostLoaded(context)hostRegister authoritative gameplay and host state.
Task OnClientLoadingAsync(context, cancellationToken)clientBounded async presentation setup before OnClientLoaded.
void OnClientLoaded(context)clientRegister panels, phone apps and client handlers.
void OnHostReady(context)hostRuns after the complete host dependency plan is active.
void OnClientReady(context)clientRuns after the complete client dependency plan is active.
void OnHostTick(context)hostRuns every frame while active. Repeated recoverable failures quarantine the tick callback.
void OnClientTick(context)clientRuns every client frame, including a listen host client. It has a separate repeated-failure quarantine.
void OnHostShutdown(context)hostRuns when a host realm that completed its loaded phase is retired.
void OnClientShutdown(context)clientRuns when a client realm that completed its loaded phase is retired. On a listen host this runs before host shutdown.
void OnShutdown(context)bothLegacy combined shutdown. It runs once after realm-specific shutdown when at least one loaded phase completed.
1[LitherarpAddon( "myaddon" )]
2public sealed class MyAddon : ILitherarpAddon
3{
4 public string AddonId => "myaddon";
5 public string DisplayName => "My Addon";
6 public string Version => "1.2.0";
7 public int ProtocolVersion => 2;
8
9 public Task OnHostLoadingAsync( LitherarpAddonContext context, CancellationToken token )
10 => LoadDefinitionsAsync( token );
11
12 public void OnHostLoaded( LitherarpAddonContext context ) { }
13 public Task OnClientLoadingAsync( LitherarpAddonContext context, CancellationToken token )
14 => LoadPresentationAsync( token );
15 public void OnClientLoaded( LitherarpAddonContext context ) { }
16 public void OnHostReady( LitherarpAddonContext context ) { }
17 public void OnClientReady( LitherarpAddonContext context ) { }
18 public void OnHostTick( LitherarpAddonContext context ) { }
19 public void OnClientTick( LitherarpAddonContext context ) { }
20 public void OnHostShutdown( LitherarpAddonContext context ) { }
21 public void OnClientShutdown( LitherarpAddonContext context ) { }
22 public void OnShutdown( LitherarpAddonContext context ) { }
23}

Realms

RealmHostClient
SharedHost loading, loaded, ready and tick.Client loading, loaded and ready.
ServerHost loading, loaded, ready and tick.Not sent as a client code addon.
ClientNo host lifecycle. A listen host can run its client lifecycle.Client loading, loaded and ready.

Activation order

  1. Validate manifest identity, parent package, versions, conflicts, capabilities and package revisions.
  2. Resolve the dependency plan.
  3. Mount packages and discover the one attributed implementation for each id.
  4. Run async loading, then loaded callbacks in dependency order.
  5. After the plan is active, run ready callbacks.
  6. Finish host world bootstrap. WorldReady then becomes observable.
  7. On each client, finish the verified snapshot barrier. ClientWorldReady then becomes observable for that successful snapshot.

Client readiness

The host sends a fingerprint over the exact enabled package revisions and client code plan. A joining client mounts and activates that snapshot, then acknowledges the same fingerprint. Initial pawn creation waits for a successful acknowledgement when required client work exists.

  • A required client package or code failure disconnects the client with a bounded error message.
  • A stale acknowledgement for an older hot snapshot is ignored.
  • Existing players acknowledge a changed hot snapshot too. The client readiness barrier is lowered while that snapshot is reconciled.
  • clientReadinessTimeoutSeconds is clamped from 15 to 300 seconds. Its default is 90.
  • The local listen-host connection is ready immediately.

Teardown

Context-managed registrations are removed in reverse teardown order. Tracked objects and components are destroyed during normal disable. Cancellation sources are canceled and disposed. Services, network messages, storage writes and per-player sections are cleaned up by the context.

Use OnHostShutdown, OnClientShutdown, legacy OnShutdown or OnTeardown for state created outside a context registration. Do not rely on addon assembly static fields being reset by disable.