Second commit
This commit is contained in:
commit
36840f3ad4
999 files changed
+61364
No files matched your search
@@ -0,0 +1,165 @@
|
||||
using Code.Infrastructure.App;
|
||||
using Code.Infrastructure.Audio;
|
||||
using Code.Infrastructure.Camera;
|
||||
using Code.Infrastructure.Configs;
|
||||
using Code.Infrastructure.Input;
|
||||
using Code.Infrastructure.Loadings;
|
||||
using Code.Infrastructure.Particles;
|
||||
using Code.Infrastructure.SceneLoader;
|
||||
using Code.Infrastructure.UI;
|
||||
using Code.Infrastructure.Volume;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using Reflex.Core;
|
||||
using Reflex.Enums;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering.Universal;
|
||||
using Resolution = Reflex.Enums.Resolution;
|
||||
|
||||
namespace Code.Game
|
||||
{
|
||||
public class PapaInstaller : MonoBehaviour, IInstaller
|
||||
{
|
||||
private Loading _ui2CamLoading;
|
||||
private Container _thatRightContainer;
|
||||
private Canvas _canvas;
|
||||
|
||||
public void InstallBindings(ContainerBuilder containerBuilder)
|
||||
{
|
||||
Debug.Log("Bindings installation");
|
||||
|
||||
Cursor.lockState = CursorLockMode.Locked;
|
||||
|
||||
_canvas = FindAnyObjectByType<Canvas>();
|
||||
|
||||
InitLoadings();
|
||||
|
||||
containerBuilder.OnContainerBuilt += Bootstrap;
|
||||
|
||||
containerBuilder.RegisterType(typeof(ConfigLocator), new[] { typeof(IConfigLocator) }, Lifetime.Singleton,
|
||||
Resolution.Eager);
|
||||
containerBuilder.RegisterType(typeof(CustomCustomSceneManager),
|
||||
new[] { typeof(ISceneLoader), typeof(ICustomSceneManagerInitializer), typeof(ISceneContainerManager) },
|
||||
Lifetime.Singleton, Resolution.Eager);
|
||||
containerBuilder.RegisterType(typeof(InputService),
|
||||
new[] { typeof(IInputService), typeof(IInputServiceInitializer) }, Lifetime.Singleton,
|
||||
Resolution.Eager);
|
||||
|
||||
containerBuilder.RegisterType(typeof(AppStateMachine), Lifetime.Singleton, Resolution.Lazy);
|
||||
containerBuilder.RegisterType(typeof(AppStateMachineContext), Lifetime.Singleton, Resolution.Lazy);
|
||||
|
||||
containerBuilder.RegisterType(typeof(CameraFactory), new[] { typeof(ICameraFactory) }, Lifetime.Singleton,
|
||||
Resolution.Lazy);
|
||||
containerBuilder.RegisterType(typeof(CameraStateMachine), Lifetime.Singleton, Resolution.Lazy);
|
||||
containerBuilder.RegisterType(typeof(CameraStateMachineContext), Lifetime.Singleton, Resolution.Lazy);
|
||||
|
||||
containerBuilder.RegisterType(typeof(UIFactory),
|
||||
new[] { typeof(IUIFactory), typeof(IUIFactoryInitializer) }, Lifetime.Singleton,
|
||||
Resolution.Eager);
|
||||
|
||||
containerBuilder.RegisterType(typeof(VolumeService), new[] { typeof(IVolumeService) }, Lifetime.Singleton,
|
||||
Resolution.Lazy);
|
||||
containerBuilder.RegisterType(typeof(VolumeFactory),
|
||||
new[] { typeof(IVolumeFactory), typeof(IVolumeFactoryInitializer) }, Lifetime.Singleton,
|
||||
Resolution.Eager);
|
||||
|
||||
containerBuilder.RegisterType(typeof(AudioFactory),
|
||||
new[] { typeof(IAudioFactory), typeof(IAudioFactoryInitializer) }, Lifetime.Singleton,
|
||||
Resolution.Eager);
|
||||
containerBuilder.RegisterType(typeof(AudioSourcePool),
|
||||
new[] { typeof(IAudioSourcePool), typeof(IAudioSourcePoolInitializer) },
|
||||
Lifetime.Singleton,
|
||||
Resolution.Eager);
|
||||
containerBuilder.RegisterType(typeof(AudioService),
|
||||
new[] { typeof(IAudioService), typeof(IAudioServiceInitializer) }, Lifetime.Singleton,
|
||||
Resolution.Eager);
|
||||
|
||||
containerBuilder.RegisterType(typeof(ParticlePoolManager),
|
||||
new[] { typeof(IParticlePoolManagerForFabric), typeof(IParticlePoolManagerForService) },
|
||||
Lifetime.Singleton,
|
||||
Resolution.Eager);
|
||||
containerBuilder.RegisterType(typeof(ParticleLoader),
|
||||
new[] { typeof(IParticleLoader), typeof(IParticleLoaderInitializer) },
|
||||
Lifetime.Singleton,
|
||||
Resolution.Eager);
|
||||
containerBuilder.RegisterType(typeof(ParticleService), new[] { typeof(IParticleService) },
|
||||
Lifetime.Singleton,
|
||||
Resolution.Eager);
|
||||
}
|
||||
|
||||
|
||||
private void InitLoadings()
|
||||
{
|
||||
_ui2CamLoading = new Loading(2,
|
||||
() =>
|
||||
{
|
||||
var camera = _thatRightContainer
|
||||
.Resolve<CameraStateMachineContext>().cameraLoadedData.Camera;
|
||||
|
||||
var uiFactory = _thatRightContainer.Resolve<IUIFactoryInitializer>();
|
||||
uiFactory.SetCanvasCamera(camera);
|
||||
});
|
||||
}
|
||||
|
||||
private void Bootstrap(Container container)
|
||||
{
|
||||
_thatRightContainer = container;
|
||||
|
||||
// UIFactory +
|
||||
// Scene configs +
|
||||
// Input service +
|
||||
// Camera +
|
||||
// Volume Factory +
|
||||
// Particle Loader +
|
||||
// Audio Factory +
|
||||
// Audio Pool +
|
||||
// Audio Service +
|
||||
new Loading(0, () => EssentialLoadEnded(_thatRightContainer))
|
||||
.AttachProcess(container.Resolve<ICustomSceneManagerInitializer>().LoadConfigs)
|
||||
.AttachProcess(container.Resolve<IInputServiceInitializer>().LoadConfigs)
|
||||
.AttachProcess(InitializeCamera)
|
||||
.AttachProcess(InitializeUIFactory)
|
||||
.AttachProcess(container.Resolve<IVolumeFactoryInitializer>().LoadConfigs)
|
||||
.AttachProcess(container.Resolve<IParticleLoaderInitializer>().LoadConfigs)
|
||||
.AttachProcess(container.Resolve<IAudioSourcePoolInitializer>().LoadConfigs)
|
||||
.AttachProcess(container.Resolve<IAudioFactoryInitializer>().LoadConfigs)
|
||||
.AttachProcess(container.Resolve<IAudioServiceInitializer>().LoadMixerAsset);
|
||||
}
|
||||
|
||||
private void EssentialLoadEnded(Container container)
|
||||
{
|
||||
var appStateMachine = container.Resolve<AppStateMachine>();
|
||||
|
||||
container.Resolve<AppStateMachineContext>().StateMachine = appStateMachine;
|
||||
|
||||
appStateMachine.SwitchState(AppStates.Testing).Forget();
|
||||
}
|
||||
|
||||
private async UniTask InitializeCamera()
|
||||
{
|
||||
var cameraFactory = _thatRightContainer.Resolve<ICameraFactory>();
|
||||
|
||||
var cameraLoadedData = await cameraFactory.CreateCameraStateMachine();
|
||||
|
||||
_thatRightContainer.Resolve<CameraStateMachineContext>().cameraLoadedData = cameraLoadedData;
|
||||
var cameraStateMachine = _thatRightContainer.Resolve<CameraStateMachine>();
|
||||
await cameraStateMachine.SwitchState(CameraMode.None);
|
||||
|
||||
cameraFactory.CreateCameraStateMachineRunner(cameraStateMachine);
|
||||
|
||||
cameraLoadedData.Camera.GetUniversalAdditionalCameraData().renderPostProcessing = true;
|
||||
|
||||
_ui2CamLoading.DoProgress();
|
||||
}
|
||||
|
||||
private async UniTask InitializeUIFactory()
|
||||
{
|
||||
var uiFactoryInitializer = _thatRightContainer.Resolve<IUIFactoryInitializer>();
|
||||
|
||||
await uiFactoryInitializer.LoadConfigs();
|
||||
|
||||
uiFactoryInitializer.SetCanvas(_canvas);
|
||||
|
||||
_ui2CamLoading.DoProgress();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user