1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- 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<string>().FromInstance("Hello World!");
- //Container.Bind<GlobalManager>().AsSingle().NonLazy();
- //Container.Bind<ICursorRules>().To<SneakyCursorRules>().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' : ' ')}");
- }
- }
- }
|