using System.Collections; using System.Collections.Generic; using UnityEngine; using Zenject; using Sirenix.OdinInspector; namespace KairoEngine.Core.ModuleSystem { [HideMonoScript, AddComponentMenu("KairoEngine/Game Installer"), RequireComponent(typeof(SceneContext))] public class GameInstaller : MonoInstaller { public GameConfig gameConfig; public override void InstallBindings() { //Container.Bind().FromInstance("Hello World!"); //Container.Bind().AsSingle().NonLazy(); //Container.Bind().To().AsSingle(); for (int i = 0; i < gameConfig.modules.Count; i++) { if(gameConfig.modules[i].enableModule) gameConfig.modules[i].module.Load(this.transform); } } public override void Start() { for (int i = 0; i < gameConfig.configOptions.list.Count; i++) { gameConfig.configOptions.list[i].LoadValue(gameConfig.configOptions.debug); } } void OnDestroy() { int c = 0; for (int i = 0; i < gameConfig.modules.Count; i++) { if(gameConfig.modules[i].enableModule) { gameConfig.modules[i].module.Destroy(); c += 1; } } Debug.Log($"Unloaded {c} module{(c > 1 || c == 0 ? 's' : ' ')}"); } } }