Skip to content

Lifecycle progression

A lifecycle tracks an instance through authored stages: a crop grows, an object ages, or a staged process completes. Unlike a reactive response that recomputes from the current condition, lifecycle progression has chronological state and explicit history policies.

LifecycleProfile is shared configuration. SystemBasedLifecycle owns mutable per-instance progress. SystemBasedLifecyclePresenter optionally maps that state to visible models. You can integrate gameplay without using the crop demo art or a presenter.

Create an instance

  1. Create Assets > Create > Sital > Tunal > Lifecycle Profile.
  2. Add stages with unique stable IDs and display names. Use positive durations for ordinary stages; mark an intentional terminal stage where appropriate.
  3. Add Tunal > System Based > System Based Lifecycle to an enabled scene object and assign Profile.
  4. Assign Context explicitly if outside its hierarchy, including objects in switchable scene-content roots.
  5. Choose Start Automatically (default on), Initially Paused, external progression multiplier, backward-time policy, and offline policy.
  6. Enter Play Mode and inspect current stage/progress before adding presentation or persistence.

The source context needs initialized, enabled Time. Stage durations are elapsed canonical simulated seconds, or real UTC seconds for system-clock modes. 86400 is one canonical day; changing display hours does not change that duration.

Author stage behavior

An optional initial stage ID selects the start; empty uses the first entry. Empty Next Stage ID selects the next list entry, with no following entry completing the lifecycle. Explicit IDs can choose another stage. Entering a terminal stage completes immediately. A non-automatic stage stops at 100% until gameplay explicitly advances it.

Effective progression combines profile base rate, instance external multiplier, seasonal multiplier if enabled, and stage rate. A zero rate holds progression. Resolve profile validation errors, missing IDs, invalid durations, or transition configurations rather than assuming a failed Start means a rendering problem.

Seasonal progression matches season names case-insensitively, unlike reactive season selection's stable-ID keys. Shared names across tracks use the same rate. Missing-season policy can pause or use a neutral multiplier; unlisted names use the configured unmatched multiplier. Large skipped intervals are not a reconstruction of unobserved historical seasonal changes: rates are sampled/recorded by this implementation.

Control and observe

StartLifecycle() returns success; BeginLifecycle() is an event-friendly wrapper. Use PauseLifecycle, ResumeLifecycle, ResetLifecycle, AdvanceToStage(id)/SetStage(id), and CompleteLifecycle for deliberate gameplay operations. SetProfile changes configuration and resets instance state; do not use a shared profile as the progress store.

onStageChanged supplies stable stage ID, including initial start; onProgressChanged supplies normalized stage progress. Completion/reset have separate events. C# events expose stage/progress/completion/reset and StateReconciled for adapters. Do not treat these notifications as transactions that automatically undo gameplay effects on rewind.

Continue with history and time policies, visual presentation, and persistence registration.