This commit is contained in:
Mausham
2026-05-29 10:37:07 +05:45
parent 3914adaa84
commit a51a73efdd
3 changed files with 1327 additions and 19 deletions

View File

@@ -23,6 +23,7 @@ public class ColorbookFlowController : IAsyncStartable, IDisposable
private readonly IEventBus _bus;
private IDisposable _selectedSub;
private IDisposable _returnToMainMenuSubscription;
public ColorbookFlowController(
IDrawingCatalogController drawingCatalog,
@@ -40,12 +41,27 @@ public class ColorbookFlowController : IAsyncStartable, IDisposable
public async UniTask StartAsync(CancellationToken cancellation = new CancellationToken())
{
_returnToMainMenuSubscription = _eventBus.Subscribe<ReturnToMainMenuSignal>(OnReturnToMainMenu);
_returnToMainMenuSubscription = _bus.Subscribe<ReturnToMainMenuSignal>(OnReturnToMainMenu);
_loadingScreen.SetProgress(1f);
await _drawingCatalog.InitializeAsync(cancellation);
_selectedSub = _bus.Subscribe<DrawingSelectedSignal>(OnDrawingSelected);
_loadingScreen.Hide();
}
private void OnReturnToMainMenu(ReturnToMainMenuSignal signal)
{
LoadMainMenuSceneAsync().Forget(UnityEngine.Debug.LogException);
}
private async UniTask LoadMainMenuSceneAsync(CancellationToken ct = default)
{
_loadingScreen.Show();
var progress = new Progress<float>(p => _loadingScreen.SetProgress(p * 0.5f));
await _scenes.LoadSceneAsync(nameof(GameScene.MainMenu), progress, ct);
var mappedProgress = new Progress<float>(p => _loadingScreen.SetProgress(0.5f + p * 0.25f));
await _scenes.UnloadSceneAsync(nameof(GameScene.Colorbook), mappedProgress, ct);
}
private void OnDrawingSelected(DrawingSelectedSignal signal)
{
@@ -61,5 +77,6 @@ public class ColorbookFlowController : IAsyncStartable, IDisposable
public void Dispose()
{
_selectedSub?.Dispose();
_returnToMainMenuSubscription?.Dispose();
}
}