UI, lifecycle, and persistence APIs¶
Use these operations from the Unity main thread after assigning and initializing the required scene components. Functional guides explain how to author their configuration.
UI command facade¶
Sital.Tunal.UI.TunalUIRuntimeController centralizes commands for one selected context. Its Ready property only requires initialized Time. Check individual HasCalendar, HasAstronomy, HasPhases or CanPersist properties for the operation you offer.
| Member | Contract |
|---|---|
SetContext(TunalContext) |
Select command context and resolve matching single-context persistence; does not change world registration |
SetTimeMode(TimeMode) |
Coordinates source change and Calendar refresh |
SetDisplayClock(int,int,int = 0) |
Player-facing display clock input; requires editable simulated clock |
SkipDisplayHours(int) |
Uses display-hour mapping; differs from canonical SkipHours(float) |
SetClock(int,int,int = 0) |
Canonical clock input |
SetGregorianDate(int year,int month,int day,bool immediate = false) |
Year-first convenience signature; differs from DateData(day,month,year) |
SetLocation(float latitude,float longitude,float meridian) |
Combined observer change; underlying Astronomy has separate setters |
SetCustomCalendar(CalendarDefinition) / SetGregorianCalendar() |
Change calendar configuration, not just formatting |
UseSingleContextPersistence() / UseWorldPersistence() |
Button-friendly persistence mode commands |
SaveToSlot(string) / LoadFromSlot(string) |
Return PersistenceResult; synchronous save is not browser-commit confirmation |
SaveToSlotConfirmed(string, Action<PersistenceResult>) |
Coroutine; captures backend before yielding and manages IsSaving |
TunalUguiContext.SetController binds command authority; SetPresentationGroup binds visual scope. BeforeLoad is a C# event and NotifyBeforeLoad/NotifyLoaded coordinate views; these do not themselves perform persistence. See UI binding.
Lifecycle composition¶
Use Sital.Tunal.Lifecycle.SystemBasedLifecycle as a component rather than a subclass. The component is sealed.
| Member | Contract |
|---|---|
StartLifecycle() |
Boolean success; requires valid profile/source; BeginLifecycle() is void/event-friendly |
PauseLifecycle() / ResumeLifecycle() |
Hold/resume progression without pausing context time |
ResetLifecycle() / ResetLifecycle(bool restart) |
Reset, with optional restart; no-argument overload restarts |
AdvanceToStage(string) |
Boolean success; deliberate stage change establishes a history barrier |
SetStage(string) |
Void/event-friendly stage command |
CompleteLifecycle() |
Explicit completion |
SetProfile(LifecycleProfile) |
Replace configuration and reset instance state |
Reconcile() |
Reconcile to current source chronology; does not advance the source clock |
CaptureState() / RestoreState(LifecycleStateData) |
Low-level integration; require compatible profile/identity and clock-first ordering |
C# StageChanged supplies a LifecycleStage; Inspector onStageChanged supplies its string ID. ProgressChanged/onProgressChanged supply normalized float progress. LifecycleCompleted, LifecycleReset and StateReconciled are separate C# events. Reconciliation is not historical gameplay-event replay. See history and restoration.
Persistence orchestration¶
All types below are in Sital.Tunal.Persistence; configuration profiles remain in their source namespaces. Check PersistenceResult.success, error, and warnings on every operation.
| Owner/member | Contract |
|---|---|
TunalPersistence.Capture(out Snapshot) |
Capture selected context sections; no file write |
ValidateRestore(Snapshot) |
Preflight; no transaction lock or guarantee against later application failure |
Restore(Snapshot) |
Validate/apply with context ordering and lifecycle suspension |
TrySaveLocal(string slotOverride = null) |
Local JSON write plus pending WebGL synchronization warning where applicable |
SaveLocalConfirmed(Action<PersistenceResult>, string slotOverride = null) |
Coroutine; wait for completion before showing confirmed success |
TryLoadLocal(string slotOverride = null) |
Synchronous local load and restore |
WorldPersistence.ValidateConfiguration() |
Validate explicit registry/identities |
TrySaveWorld(string slotOverride = null) |
Capture registered contexts, stage inactive bank, publish manifest |
SaveWorldConfirmed(Action<PersistenceResult>, string slotOverride = null) |
Coroutine with browser confirmation boundary |
TryLoadWorld(string slotOverride = null) |
Match/preflight contexts, then sequential application; partial changes possible on failure |
StateSerializer.ToJson(Snapshot) / FromJson(string) |
Portable data conversion; parsing invalid input can throw |
Use the complete single-context and world examples rather than independently calling partial restore helpers. Lifecycle registrations and GUID catalogs are prerequisites, not content automatically created by deserialization.