ApplicationConstants
Namespace: SaffronLibrary.Prime.Systems.Application
Static class of shared application constants.
public static class ApplicationConstants
{
public const float PausedGameSpeed = 0f;
}| Member | Description |
|---|---|
PausedGameSpeed | Time scale value that stops game time. Intended for use with Time.timeScale. |
ApplicationCoordinator
Namespace: SaffronLibrary.Prime.Systems.Application
Abstract MonoBehaviour that implements IInitializable and IAsyncInitializable. It is the application's entry point and lifecycle manager. Attach a concrete subclass to a root GameObject in the startup scene.
public abstract class ApplicationCoordinator : MonoBehaviour, IInitializable, IAsyncInitializablePublic static fields
public static ApplicationCoordinator Instance;Global singleton instance. A TODO in the source notes the intent to remove this singleton.
Protected fields (for subclasses)
protected ApplicationLogicManager logicManager;
protected IApplicationLifecycleHandler lifecycleHandler;
protected IApplicationLifecycleAdapter lifecycleAdapter;| Field | Description |
|---|---|
logicManager | Owns focus-loss timing. Created in Init. |
lifecycleHandler | The project's lifecycle handler. Set by InitializeLifecycle. |
lifecycleAdapter | The project's lifecycle adapter. Set by InitializeLifecycle. |
Methods
protected void Awake()Enforces the singleton. The first instance is stored in Instance, marked DontDestroyOnLoad, and registered with InitializationRegistry as both IInitializable and IAsyncInitializable. Duplicates are destroyed.
public virtual void Init()Creates logicManager as a new ApplicationLogicManager. Called during the sync initialization phase.
public async Task InitAsync()Subscribes InitializeApplication to SaffronLibrarySignals.SystemsReady using SignalBus.WhenRaised, then awaits InitializeVolumeState.
public virtual void InitializeApplication()Calls RegisterPlatformModules, RunPlatformModules, InitializeStartupPresentation, and the lifecycle setup. Runs when SystemsReady is raised.
public void SetLifecycleHandler(IApplicationLifecycleHandler handler)Assigns lifecycleHandler.
public void SetLifecycleAdapter(IApplicationLifecycleAdapter adapter)Assigns lifecycleAdapter.
public void ProcessQuery(IQuery query)Routes a query by verb and subject. For QueryVerb.Get with subject ApplicationSubjects.Focus, it sets CoreParamKeys.Duration on the query result to the focus-loss duration. Other combinations are ignored.
Protected abstract hooks
protected abstract void InitializeStartupPresentation();
protected abstract Task InitializeVolumeState();
protected abstract void RegisterPlatformModules();
protected abstract void RunPlatformModules();
protected abstract IApplicationLifecycleHandler CreateLifecycleHandler();
protected abstract IApplicationLifecycleAdapter CreateLifecycleAdapter();| Hook | Description |
|---|---|
InitializeStartupPresentation | Project-specific startup presentation. |
InitializeVolumeState | Project-specific volume restoration, awaited during InitAsync. |
RegisterPlatformModules | Registers platform-specific modules. |
RunPlatformModules | Runs registered platform modules. |
CreateLifecycleHandler | Creates the project's lifecycle handler. |
CreateLifecycleAdapter | Creates the project's lifecycle adapter. |
ApplicationFlowController
Namespace: SaffronLibrary.Prime.Systems.Application
Flow controller for Domain.Application. Derives from FlowController.
public class ApplicationFlowController : FlowControllerprotected override Domain Domain => Domain.Application;Property. Identifies the domain this controller owns.
public override void Init()Calls base.Init() to register the command handler, then registers OnQuery with the QueryBus for Domain.Application.
protected void OnQuery(IQuery query)Forwards the query to ApplicationCoordinator.Instance.ProcessQuery.
protected override void HandleCommand(ICommand cmd)Empty. No commands are routed through Domain.Application.
ApplicationFlowService
Namespace: SaffronLibrary.Prime.Systems.Application
public static partial class ApplicationFlowServicepublic static void ResetLocalData(Action onReload)Calls PlayerPrefs.DeleteAll(), then invokes onReload if it is not null. The source remarks describe this as an irreversible reset of all local data.
ApplicationInterfaces
Namespace: SaffronLibrary.Prime.Systems.Application.Interfaces
public interface IApplicationLifecycleHandler
{
void OnFocusChanged(bool hasFocus);
}| Member | Description |
|---|---|
OnFocusChanged(bool hasFocus) | Called when application focus changes. |
public interface IApplicationLifecycleAdapter
{
void Initialize(IApplicationLifecycleHandler handler);
float GetRealtimeSinceStartup();
}| Member | Description |
|---|---|
Initialize(IApplicationLifecycleHandler handler) | Assigns the handler that receives forwarded events. |
GetRealtimeSinceStartup() | Returns the engine's running time in seconds since startup. |
ApplicationKeyNames
Namespace: SaffronLibrary.Prime.Systems.Application
public static class ApplicationKeyNames
{
public const string HasFocus = Base + ".hasfocus";
public const string Subject = Base + ".subject";
}| Member | Description |
|---|---|
HasFocus | Name for the focus state key. Resolves to core.application.hasfocus. |
Subject | Name for the subject key. Resolves to core.application.subject. |
The private Base constant is core.application.
ApplicationParamKeys
Namespace: SaffronLibrary.Prime.Systems.Application
public static class ApplicationParamKeys
{
public static readonly ParamKey<bool> HasFocus;
public static readonly ParamKey<ApplicationSubjects> ApplicationSubject;
}| Member | Description |
|---|---|
HasFocus | ParamKey<bool> for whether the application has OS-level focus. |
ApplicationSubject | ParamKey<ApplicationSubjects> for the subject a message is about. |
ApplicationEventFactory
Namespace: SaffronLibrary.Prime.Systems.Application
public static class ApplicationEventFactorypublic static void OnFocusChanged(bool hasFocus)Raises an Event on Domain.Application with verb ApplicationEventVerb.Changed, subject ApplicationSubjects.Focus, and the HasFocus param set to hasFocus.
public static void OnApplicationQuit()Raises an Event on Domain.Application with verb ApplicationEventVerb.Quit and subject ApplicationSubjects.Application.
ApplicationEventVerb
Namespace: SaffronLibrary.Prime.Systems.Application
public enum ApplicationEventVerb
{
Changed = 0,
Quit = 1,
}| Value | Description |
|---|---|
Changed | An application state changed, such as focus. |
Quit | The application is quitting. |
ApplicationLifecycleHandler
Namespace: SaffronLibrary.Prime.Systems.Application
Abstract base for lifecycle handlers. Implements IApplicationLifecycleHandler.
public abstract class ApplicationLifecycleHandler : IApplicationLifecycleHandlerpublic void OnFocusChanged(bool hasFocus)Not overridable. Calls ApplicationEventFactory.OnFocusChanged(hasFocus), then ProcessFocusChanged(hasFocus).
protected abstract void ProcessFocusChanged(bool hasFocus)Project-specific reaction to a focus change.
UnityLifecycleAdapter
Namespace: SaffronLibrary.Prime.Systems.Application
MonoBehaviour that implements IApplicationLifecycleAdapter.
public class UnityLifecycleAdapter : MonoBehaviour, IApplicationLifecycleAdapterpublic void Initialize(IApplicationLifecycleHandler handler)Stores the handler that receives forwarded events.
public float GetRealtimeSinceStartup()Returns Time.realtimeSinceStartup.
The adapter also has two private Unity callbacks, OnApplicationFocus(bool hasFocus) and OnApplicationQuit(). The first forwards focus changes to the handler if one is set. The second calls ApplicationEventFactory.OnApplicationQuit().
ApplicationLogicManager
Namespace: SaffronLibrary.Prime.Systems.Application
Plain C# class that tracks focus-loss timing.
public class ApplicationLogicManagerpublic void SetFocusLossTime(float timeSinceStartup)Stores the given time as the last focus-loss time.
public float GetFocusLossDuration(float timeSinceStartup)Returns timeSinceStartup minus the stored focus-loss time. If SetFocusLossTime has never been called, the stored time is 0, so the result is the time since startup.
ApplicationQueryFactory
Namespace: SaffronLibrary.Prime.Systems.Application
public static class ApplicationQueryFactorypublic static float GetFocusLossDuration()Creates a Query for Domain.Application with verb QueryVerb.Get and subject ApplicationSubjects.Focus, then returns the CoreParamKeys.Duration result through BusUtility.AskAndGet. Throws if the result is missing.
ServiceLocator
Namespace: SaffronLibrary.Prime.Systems.Application
public static class ServiceLocatorpublic static void Initialize(BusRegistry registry)Stores the BusRegistry. Intended to be called once during bootstrap.
public static BusRegistry GetBusRegistry()Returns the stored BusRegistry, or null if Initialize has not been called.
ApplicationSubjects
Namespace: SaffronLibrary.Prime.Systems.Application
public enum ApplicationSubjects
{
Focus = 0,
Application = 1,
}| Value | Description |
|---|---|
Focus | Subject for focus-related events and queries. |
Application | Subject for application-level events, such as quitting. |