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,19 @@
|
||||
using System.Threading;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using QuizPleaseTest.Common.Services;
|
||||
|
||||
namespace QuizPleaseTest.Boot.Flow
|
||||
{
|
||||
public class BootFlowService : Service, IBootFlowService
|
||||
{
|
||||
public override UniTask InitializeAsync(CancellationToken ct)
|
||||
{
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
|
||||
public override UniTask ReleaseAsync(CancellationToken ct)
|
||||
{
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f3333333333333333333333333333333
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f4444444444444444444444444444444
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
using QuizPleaseTest.Common.Services;
|
||||
|
||||
namespace QuizPleaseTest.Boot.Flow
|
||||
{
|
||||
public interface IBootFlowService : IService
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f2222222222222222222222222222222
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user