IStartup
The entry point of the IdleKit framework resides in the IStartup. It is responsible for starting the game, switching to a different IContent (timed event), switching to a different IStage (ascension), and resetting the game. In this article, we will go over the start, switch content, reset, and switch stage game-flow and their various components.
Note
For a general introduction to setting up your first IdleKit scene, including creating your own Startup
implementation, see the First Scene tutorial.
Overview
Below are the primary functions of IStartup:
- StartGame() - called once on startup to initialize the IdleKit and is called again in the process of ResetGame(Boolean).
- SwitchContent(String) - called when the user switches between contents.
- SwitchStage() - called when the user switches between stages.
- ResetGame(Boolean) - called when the user resets the game with the option of resetting all the ISavedData. Once everything is cleaned up, StartGame() is called.
Start Game and Switch Content Flow
Start Game
The game is first started by the StartGame() that performs various steps such as binding the dependencies, initializing the game, and loading the entities. Once the steps are completed, the user then enters the core game loop of the IdleKit and starts playing the game.
Switch Content
At some point, the user would want to move to a different IContent either to play a limited-time event or return to the main game from the limited-time event. When this happens, SwitchContent(String) would be invoked, which clears the current IContent and load into the new IContent.
Reset Game Flow
Reset Game
Resetting the game is carried out by first clearing the current IContent, then cleaning up other non-content specific entities and services, and unbinding the dependencies. After these steps are performed, it invokes the Start Game Flow to restart the game.
Switch Stage Flow
Switch Stage
The switch stage contains only a single step Switch Stage which advances the IStage the user is on. More ILoadPhase for loading IStage specific data or assets can be added to the step.
Steps and Load Phases
As the flow diagrams indicate, each IStartup function can be broken down into various steps that further divide into reusable load phases. In the next section, we will discuss all the steps and the load phases that make them up.
ILoadPhase
LoadPhases are the lowest-level building blocks used in the startup flow that can contain multiple load sequences. An example of an ILoadPhase would be the ILoadContentLoadPhase, which is utilized in StartGame() and SwitchContent(String), to set the IContent the user will be playing and load the entities associated with the IContent.
Step - Bind Dependencies
The step calls Bind() and initializes a number of system-wide load phases, services, and actions, which includes fire-and-forget signals such as regular IActions and ISavedData altering IStateActions. After the bindings are complete, all the services are initialized.
Step - Initialize Game
Initialize User
This ILoadPhase initializes and loads the IUserSavedData, which stores relevant user-related ISavedData.
Load Global Data
This ILoadPhase loads the IStaticData and IEntity that are not related to any IContent (system-wide).
Step - Process Event
Process Event Saved Data
This ILoadPhase deletes all the content specific ISavedData for IEventContent that have been completed.
Step - Load Content
Load Content Data
This ILoadPhase loads the IStaticData that are related to the IContent that we are loading determined in the previous step.
Load Content
This ILoadPhase loads the entities associated with the current IContent, including the IContent itself.
Step - Clear Content
Clear Content
This ILoadPhase is the opposite of the ILoadContentLoadPhase. It removes all entities related to the previous IContent.
Clear Content Data
This ILoadPhase is the opposite of the ILoadContentDataLoadPhase. It unloads all static data related to the IContent that was unloaded in the previous ILoadContentDataLoadPhase.
Step - Cleanup Game
Clear Global Data
This ILoadPhase is the opposite of the ILoadGlobalDataLoadPhase. It unloads all the IStaticData and IEntity that are not related to any IContent.
Step - Unbind Dependencies
This step is the opposite of the Step - Bind Dependency. It cleans up all the services and unbind all the system-wide load phases, services, and actions. After this, the game can then be restarted.
Step - Switch Stage
Advance Stage
This ILoadPhase advance the user from the current IStage to the next.