Installers

Description

Installersarrow-up-right are used to register dependencies in the Zenject container.

Within this module:

  • services, managers, and configuration objects are registered

  • object lifetimes are defined (Singleton / Transient / Cached)

  • interfaces are bound to their concrete implementations

The project organizes installers by functional domains, which allows:

  • easy replacement of implementations

  • reuse of independent modules

  • isolation of dependencies between systems

When adding new systems, it is recommended to create a separate installer.

Implementation path: KrolStudio/SwipeGunner/Scripts/Runtime/Installers


Built-in Installer Implementations

Each installer acts as a Dependency Injection configuration entry point and binds a state machine, its states, and all key game services into the Zenject container:

1. GameInstaller

GameInstaller registers all core game dependencies in the DI container.

It binds:

  • the main game state machine and its states

  • the state factory

  • core services (scene loading, logging, save system, wallet, etc.)

  • device services such as vibration

All dependencies are registered as singleton objects to ensure consistent access and correct dependency injection throughout the project.

The GameInstaller component is attached to the ProjectContext prefab and registered in the ProjectContextarrow-up-right component. This ensures that the Zenject environment is aware of the installer.

The ProjectContext prefab is located at Assets/KrolStudio/SwipeGunner/Resources.


2. GameplayInstaller

GameplayInstaller is responsible for configuring all gameplay-related dependencies.

It registers:

  • the gameplay state machine and its states

  • the player state machine

  • factories

  • window and UI systems

  • pooling and upgrade systems

  • pause, audio, and camera managers

In addition, it binds key scene objects to the DI container, including:

  • UI Root and HUD

  • Main Camera

  • AudioManager

  • CameraSwitcher

  • Player prefab

This ensures correct initialization and interaction of all gameplay components as singleton objects.

The GameplayInstaller component is attached to the GameplayInstaller and registered in the SceneContextarrow-up-right component. This ensures that the Zenject environment is aware of the installer.


3. ConfigsInstaller

ConfigsInstaller is a Zenject ScriptableObjectInstaller used to register all game configuration data.

It binds core ScriptableObject configurations into the DI container, including:

  • gameplay and window assets

  • level data

  • player parameters

  • enemy, weapon, projectile, and rocket settings

  • tutorial, reward, and upgrade configurations

This provides centralized access to immutable game settings from any system without creating hard dependencies on specific assets.

The ConfigInstaller component is registered in the ProjectContextarrow-up-right component. This ensures that the Zenject environment is aware of the installer.

The ProjectContext prefab is located at Assets/KrolStudio/SwipeGunner/Resources.


4. PlayerInstaller

PlayerInstaller configures dependencies related to player logic.

It registers:

  • player state machine states (Idle, Run, Finish, Dead)

  • the state factory

  • the input service (designed for mobile controls)

  • key player gameplay components via interfaces (shooting, turret rotation, trajectory rendering)

This setup ensures modularity and flexible dependency injection of player-related systems as singleton objects.

The PlayerInstaller component is attached to the PlayerContext prefab and registered in the GameObjectContextarrow-up-right component. This ensures that the Zenject environment is aware of the installer.

The PlayerContext prefab is located at Assets/KrolStudio/SwipeGunner/StaticAssets/Units/Player


5. TentacleInstaller

TentacleInstaller configures all dependencies related to the Tentacle entity logic.

It registers:

  • the tentacle state machine and its states (Idle, Attack, Dead)

  • the state factory

  • core tentacle components

The installer binds the context interface to the root Tentacle component and connects auxiliary trigger-check logic, ensuring proper dependency injection and isolated tentacle behavior.

The TentacleInstaller component is attached to the TentacleContext prefab and registered in the GameObjectContextarrow-up-right component. This ensures that the Zenject environment is aware of the installer.

The TentacleContext prefab is located at Assets/KrolStudio/SwipeGunner/StaticAssets/Units/Tentacle


6. EnemyInstaller

EnemyInstaller configures dependencies related to enemy logic.

It registers:

  • the enemy state machine and its full set of states (Idle, Inactive, Hit, Chase, Attack, Wander, Dead)

  • the state factory

  • core enemy components

The installer binds the context interface to the root Enemy component and connects auxiliary logic responsible for detecting transitions into the chase state, ensuring a modular and isolated enemy behavior architecture.

The EnemyInstaller component is attached to the EnemyStickmanContext prefab and registered in the GameObjectContextarrow-up-right component. This ensures that the Zenject environment is aware of the installer.

The EnemyStickmanContext prefab is located at Assets/KrolStudio/SwipeGunner/StaticAssets/Units/Stickman


How to Add a New Installer

To create a new installer:

  1. Define a new class

  2. Inherit from the base MonoInstaller class

  3. Override the InstallBindings method

  1. Register all required services, managers, and configurations, and define their lifetimes (Singleton / Transient / Cached).

Example

  1. To enable Zenject to use the new installer, register it in one of the following contexts: ProjectContext, SceneContext, GameObjectContext.

circle-info

Detailed information about each context can be found here documentationarrow-up-right.

Last updated