The ApplicationSystem is the Core infrastructure layer that connects engine-level application events (focus changes, quitting, startup) to the SaffronLibrary bus messaging system. It also provides a single application coordinator that runs startup, platform module registration, and focus-loss queries.
Within SaffronLibrary, this system is the bridge between Unity's application lifecycle callbacks and the rest of the framework. It publishes application events on Domain.Application, answers application queries routed through the QueryBus, and sequences project startup through the initialization system.
Key responsibilities:
- Startup coordination:
ApplicationCoordinatoris aMonoBehaviourthat registers itself withInitializationRegistry, prepares a logic manager during the sync phase, and runs platform module registration, startup presentation, and lifecycle setup onceSystemsReadyis raised. - Lifecycle bridging:
UnityLifecycleAdapterforwards Unity's focus and quit callbacks into the framework, whileApplicationLifecycleHandlerguarantees that a standard focus-changed event is raised before a project-specific reaction runs. - Application queries and focus timing:
ApplicationLogicManagertracks the time of the last focus loss, andApplicationQueryFactoryandApplicationFlowControllerexpose that duration to other systems through the query bus.
Who should use this:
- Project developers who need to subclass
ApplicationCoordinator,ApplicationLifecycleHandler, or implementIApplicationLifecycleAdapterfor a specific game or app. - Systems that need to react to focus or quit events, or ask how long the application has been out of focus.
Dependencies are used here only to show how this system connects: it relies on the initialization system (InitializationRegistry, InitializationManager), the bus system (BusRegistry, QueryBus, SignalBus, BusUtility), the query and param contracts (Query, Params, ParamKey), and the Domain and core key definitions in the Contracts system.