feat: add bootstrap architecture and common utilities for Unity project
- Add GameLifetimeScope for dependency injection with Zenject - Implement boot flow service with entry point and interfaces - Create boot state machine (Splash, Menu, Load states) - Add UI views for boot screens - Add common services base class and interface - Implement generic state machine controller - Add base UI view components and ViewModel interface - Update SampleScene.unity - Add BootSettings asset Добавлена архитектура bootstrap и общие утилиты для Unity проекта: - Добавлен GameLifetimeScope для внедрения зависимостей (Zenject) - Реализован сервис потока загрузки с точкой входа и интерфейсами - Создана машина состояний загрузки (Splash, Menu, Load состояния) - Добавлены UI представления для экранов загрузки - Добавлены базовые классы сервисов и интерфейс IService - Реализован контроллер машины состояний - Добавлены базовые компоненты UI вида и интерфейс ViewModel - Обновлена сцена SampleScene.unity - Добавлен ассет BootSettings
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using VContainer.Unity;
|
||||
|
||||
namespace QuizPleaseTest.Boot.Flow
|
||||
{
|
||||
public class BootstrapEntryPoint : IStartable, IDisposable
|
||||
{
|
||||
private readonly IBootFlowService _bootFlowService;
|
||||
private CancellationTokenSource _lifetimeCts;
|
||||
|
||||
public BootstrapEntryPoint(IBootFlowService bootFlowService)
|
||||
{
|
||||
_bootFlowService = bootFlowService;
|
||||
}
|
||||
|
||||
public void Start()
|
||||
{
|
||||
_lifetimeCts = new CancellationTokenSource();
|
||||
RunAsync(_lifetimeCts.Token).Forget();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (_lifetimeCts == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_lifetimeCts.Cancel();
|
||||
_bootFlowService.ReleaseAsync(CancellationToken.None).Forget();
|
||||
_lifetimeCts.Dispose();
|
||||
_lifetimeCts = null;
|
||||
}
|
||||
|
||||
private async UniTask RunAsync(CancellationToken ct)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _bootFlowService.InitializeAsync(ct);
|
||||
}
|
||||
catch (OperationCanceledException) when (ct.IsCancellationRequested)
|
||||
{
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Debug.LogException(exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user