Skip to content

Lifecycle persistence

Lifecycle progression is per instance. Saving the clock or the shared Lifecycle Profile alone does not save which crop reached which stage.

Register scene instances

  1. Configure and validate each lifecycle's profile and context first.
  2. On its owning TunalPersistence, enable the Lifecycles save section.
  3. Populate Lifecycle Instances with actual scene components. Use Find Lifecycles in This Context for owned hierarchy objects or Find Lifecycles Assigned to This Context for explicitly bound objects elsewhere.
  4. Check each instance's stable local ID and ownership. Remove missing/duplicate references.
  5. Use Add Lifecycle Profiles to Catalog or rebuild the assigned catalog so all selected lifecycle profile references resolve.
  6. Capture/restore in Play Mode and verify the final lifecycle and presenter state, not just the clock readout.

The registry belongs to each TunalPersistence, not an obsolete separate LifecycleRegistry component. Reusable prefab assets should not hold references to scene-authored instances. World registration also rejects a lifecycle registered by more than one participating context.

What validation checks

Bindings require nonempty distinct IDs, distinct valid scene components, matching explicit/effective context ownership, valid profiles, and catalog coverage when saving lifecycles. Saved records must resolve against the scene bindings and profile/stage identities expected by that instance. Missing profile or object IDs are not an instruction to spawn a replacement scene object automatically.

Enabling lifecycle saving with no registrations yields a warning. Inspect the result and decide whether an empty collection is intentional. A legacy snapshot without lifecycle records leaves scene lifecycle state unchanged, with compatibility warnings where applicable.

Restoration responsibilities

The context serializer validates lifecycle records before application, suspends progression while restoring, restores chronological configuration/clock and dependent state, then restores registered lifecycles. It releases suspension in a finally block. The presenter consumes the reconciled final state instead of needing a replay of every historical stage event.

Captured state includes stage ID/progress, pause/start/completion, external multiplier, chronology cursor, bounded history, and offline metadata. Opt-in offline progression applies only in the supported absolute-time mode and uses saved constant-rate information; it is not a server-authoritative simulation of time spent offline.

Low-level CaptureState/RestoreState are useful for a carefully designed custom orchestration, but they do not replace ownership/profile validation or correct clock-first ordering. Prefer the context/world APIs for the supplied scene workflow.

Related: catalogs, restore limitations, lifecycle presentation.