feat(task-0003): implement boot flow service with menu restart signal and state transitions
- Implement BootFlowService with IStatesController injection and RunFlowAsync logic - Add Splash → Load → Menu loop with cancellation support in boot flow - Create IMenuRestartSignal interface for menu restart coordination - Implement MenuRestartSignal using UniTaskCompletionSource - Update MenuState to wait for restart signal instead of completing immediately - Register MenuRestartSignal as singleton in GameLifetimeScope DI container Выполнена задача TASK-0003 и реализован поток загрузки: - Реализован BootFlowService с внедрением IStatesController и логикой RunFlowAsync - Добавлен цикл Splash → Load → Menu с поддержкой отмены в потоке загрузки - Создан интерфейс IMenuRestartSignal для координации перезапуска меню - Реализован MenuRestartSignal с использованием UniTaskCompletionSource - Обновлён MenuState для ожидания сигнала перезапуска вместо немедленного завершения - Зарегистрирован MenuRestartSignal как синглтон в DI контейнере GameLifetimeScope
This commit is contained in:
@@ -1,5 +1,9 @@
|
|||||||
# TASK-0003: BootFlowService и запуск сценария
|
# TASK-0003: BootFlowService и запуск сценария
|
||||||
|
|
||||||
|
## Статус
|
||||||
|
|
||||||
|
Ready
|
||||||
|
|
||||||
## Цель
|
## Цель
|
||||||
|
|
||||||
Реализовать внешний flow coordinator, который запускает и управляет сценарием загрузки приложения.
|
Реализовать внешний flow coordinator, который запускает и управляет сценарием загрузки приложения.
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ namespace QuizPleaseTest.Boot.Composition
|
|||||||
.As<IBootFlowService>()
|
.As<IBootFlowService>()
|
||||||
.As<IService>();
|
.As<IService>();
|
||||||
|
|
||||||
|
builder.Register<MenuRestartSignal>(Lifetime.Singleton)
|
||||||
|
.As<IMenuRestartSignal>();
|
||||||
|
|
||||||
builder.Register<BootStatesController>(Lifetime.Singleton)
|
builder.Register<BootStatesController>(Lifetime.Singleton)
|
||||||
.As<IStatesController<BootStateCode>>()
|
.As<IStatesController<BootStateCode>>()
|
||||||
.AsSelf();
|
.AsSelf();
|
||||||
|
|||||||
@@ -1,19 +1,42 @@
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using Cysharp.Threading.Tasks;
|
using Cysharp.Threading.Tasks;
|
||||||
|
using QuizPleaseTest.Boot.States;
|
||||||
using QuizPleaseTest.Common.Services;
|
using QuizPleaseTest.Common.Services;
|
||||||
|
using QuizPleaseTest.Common.StateMachine;
|
||||||
|
|
||||||
namespace QuizPleaseTest.Boot.Flow
|
namespace QuizPleaseTest.Boot.Flow
|
||||||
{
|
{
|
||||||
public class BootFlowService : Service, IBootFlowService
|
public class BootFlowService : Service, IBootFlowService
|
||||||
{
|
{
|
||||||
public override UniTask InitializeAsync(CancellationToken ct)
|
private readonly IStatesController<BootStateCode> _statesController;
|
||||||
|
|
||||||
|
public BootFlowService(IStatesController<BootStateCode> statesController)
|
||||||
{
|
{
|
||||||
return UniTask.CompletedTask;
|
_statesController = statesController;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async UniTask InitializeAsync(CancellationToken ct)
|
||||||
|
{
|
||||||
|
await RunFlowAsync(ct);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override UniTask ReleaseAsync(CancellationToken ct)
|
public override UniTask ReleaseAsync(CancellationToken ct)
|
||||||
{
|
{
|
||||||
return UniTask.CompletedTask;
|
return UniTask.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async UniTask RunFlowAsync(CancellationToken ct)
|
||||||
|
{
|
||||||
|
await _statesController.EnterStateAsync(BootStateCode.Splash, ct);
|
||||||
|
await _statesController.EnterStateAsync(BootStateCode.Load, ct);
|
||||||
|
|
||||||
|
while (!ct.IsCancellationRequested)
|
||||||
|
{
|
||||||
|
await _statesController.EnterStateAsync(BootStateCode.Menu, ct);
|
||||||
|
await _statesController.EnterStateAsync(BootStateCode.Load, ct);
|
||||||
|
}
|
||||||
|
|
||||||
|
ct.ThrowIfCancellationRequested();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
using System.Threading;
|
||||||
|
using Cysharp.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace QuizPleaseTest.Boot.Flow
|
||||||
|
{
|
||||||
|
public interface IMenuRestartSignal
|
||||||
|
{
|
||||||
|
UniTask WaitAsync(CancellationToken ct);
|
||||||
|
void RequestRestart();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: a2222222222222222222222222222222
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
using System.Threading;
|
||||||
|
using Cysharp.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace QuizPleaseTest.Boot.Flow
|
||||||
|
{
|
||||||
|
public class MenuRestartSignal : IMenuRestartSignal
|
||||||
|
{
|
||||||
|
private UniTaskCompletionSource _restartCompletionSource;
|
||||||
|
|
||||||
|
public UniTask WaitAsync(CancellationToken ct)
|
||||||
|
{
|
||||||
|
ct.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
|
_restartCompletionSource = new UniTaskCompletionSource();
|
||||||
|
return _restartCompletionSource.Task.AttachExternalCancellation(ct);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RequestRestart()
|
||||||
|
{
|
||||||
|
_restartCompletionSource?.TrySetResult();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: a3333333333333333333333333333333
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using Cysharp.Threading.Tasks;
|
using Cysharp.Threading.Tasks;
|
||||||
|
using QuizPleaseTest.Boot.Flow;
|
||||||
using QuizPleaseTest.Boot.UI;
|
using QuizPleaseTest.Boot.UI;
|
||||||
using QuizPleaseTest.Common.StateMachine;
|
using QuizPleaseTest.Common.StateMachine;
|
||||||
|
|
||||||
@@ -8,16 +9,18 @@ namespace QuizPleaseTest.Boot.States
|
|||||||
public class MenuState : IState
|
public class MenuState : IState
|
||||||
{
|
{
|
||||||
private readonly MenuUIView _view;
|
private readonly MenuUIView _view;
|
||||||
|
private readonly IMenuRestartSignal _restartSignal;
|
||||||
|
|
||||||
public MenuState(MenuUIView view)
|
public MenuState(MenuUIView view, IMenuRestartSignal restartSignal)
|
||||||
{
|
{
|
||||||
_view = view;
|
_view = view;
|
||||||
|
_restartSignal = restartSignal;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UniTask EnterAsync(CancellationToken ct)
|
public async UniTask EnterAsync(CancellationToken ct)
|
||||||
{
|
{
|
||||||
_view.Initialize();
|
_view.Initialize();
|
||||||
return UniTask.CompletedTask;
|
await _restartSignal.WaitAsync(ct);
|
||||||
}
|
}
|
||||||
|
|
||||||
public UniTask ExitAsync(CancellationToken ct)
|
public UniTask ExitAsync(CancellationToken ct)
|
||||||
|
|||||||
Reference in New Issue
Block a user