InitializeApplicationState
The InitializeApplicationState class is an entry-point state in the game flow that handles early bootstrapping for both client and server instances. It performs service initialization (Unity, Firebase, Vivox), splash UI loading, dependency injection, and transitions into the first functional menu state once all setup completes.
๐งฉ Overviewโ
public class InitializeApplicationState : GameBaseState, IInjectorReceivable
Implements the base game state flow and is injectable via dependency injection.
โ๏ธ Initialization Flowโ
EnterState()โ
Begins the initialization process:
- For servers: runs
InitializeServer()(minimal/no-op). - For clients: starts splash UI and
InitializeClient()process. - Starts
PrewarmUI()to asynchronously warm up the next state's UI components.
๐ฅ Client Setup Logicโ
InitializeClient()โ
Bootstraps Unity services, auth, and analytics:
- Starts fill animation for splash progress bar.
- Ensures internet connectivity.
- Initializes Unity Services with environment and Vivox credentials.
- Authenticates anonymously if not already signed in.
- Starts Unity Analytics collection.
- Starts AppsFlyer (or shows tracking consent for iOS).
- Initializes orchestrator and user profile via
GetGameOrchestrator(). - Flags initialization complete and transitions to the next state.
๐งช Server Setupโ
InitializeServer()โ
Currently minimal; immediately transitions to next state.
๐จ Splash UI Handlingโ
splashLoadingScreen: GameObject shown during initialization.splashLoadingFill: MPUIKIT image with animated fill progress.fillProgressRoutine: Coroutine that updates fill amount visually.
Fill amount is incrementally updated to simulate progress:
IEnumerator FillProgress()
๐ State Transition Logicโ
ContinueToNextState()โ
Checks that both initializationComplete and injectionsComplete are true, then requests the next state using:
await _manager.RequestState(NextState);
๐งฌ Injection & Orchestrationโ
InjectionCompleted()โ
Called when all required dependencies are injected. Sets injectionsComplete = true, bumps splash fill, and reinvokes orchestrator initialization.
โ Can Exitโ
Only when both initialization and injection are complete:
public override bool CanExitState() => initializationComplete && injectionsComplete;
๐ง Summaryโ
InitializeApplicationState is the gateway into the m00m runtime. It ensures that all platform services are ready, UI is staged, and orchestration is aligned before allowing the player to progress. This design guarantees robust first-time setup across both client and server builds.