using Darkmatter.Core;
using Darkmatter.Domain;
using Darkmatter.Presentation;
using UnityEngine;
using VContainer;
using VContainer.Unity;

namespace Darkmatter.App
{
    public class GameLifetimeScope : LifetimeScope
    {
        [SerializeField] private PlatformPool platformPool;
        [SerializeField] private LeaderBoardDataPool leaderBoardDataPool;
        [SerializeField] private PlayerSplashPool playerSplashPool;
        [SerializeField] private PlatformManager manager;
        [SerializeField] private InputReaderSO inputReader;
        [SerializeField] private GameSessionSO gameSession;
        [SerializeField] private Player player;
        [SerializeField] private AudioController audioController;

        //UI References
        [SerializeField] private GameScreenView gameScreenView;
        [SerializeField] private StartScreenView startScreenView;
        [SerializeField] private DeathScreenView deathScreenView;
        [SerializeField] private PauseScreenView pauseScreenView;
        [SerializeField] private LeaderBoardView leaderBoardView;
        protected override void Configure(IContainerBuilder builder)
        {
            builder.RegisterComponent(platformPool).As<IPool<Platform>>();
            builder.RegisterComponent(leaderBoardDataPool).As<IPool<LeaderBoardData>>();
            builder.RegisterComponent(playerSplashPool).As<IPool<Splash>>();
            builder.RegisterComponent(manager).As<IPlatformManager>();
            builder.RegisterInstance(inputReader).As<IInputReader>();
            builder.Register<ScoreService>(Lifetime.Singleton).As<IScoreService>();
            builder.RegisterInstance<GameSessionSO>(gameSession).As<IGameSession>();
            builder.RegisterComponent(player).As<IPlayer>();
            builder.RegisterComponent(audioController).As<IAudioController>().AsSelf();


            builder.RegisterEntryPoint<StartScreenController>(Lifetime.Singleton).WithParameter(startScreenView);
            builder.Register<GameScreenController>(Lifetime.Singleton).WithParameter(gameScreenView).As<IGameScreenController>();
            builder.Register<PauseScreenController>(Lifetime.Singleton).WithParameter(pauseScreenView).As<IPauseScreenController>();
            builder.Register<DeathScreenController>(Lifetime.Singleton).WithParameter(deathScreenView).As<IDeathScreenController>();
            builder.Register<LeaderBoardController>(Lifetime.Singleton).WithParameter(leaderBoardView).As<ILeaderBoardController>();


        }
    }
}
