Files
Infratest/Assets/Code/Infrastructure/App/States/BootstrapState.cs
T
2026-01-27 03:03:52 +03:00

52 lines
1.7 KiB
C#

using Code.Infrastructure.Audio;
using Code.Infrastructure.Generators;
using Code.Infrastructure.SceneLoader;
using Code.Infrastructure.UI;
namespace Code.Infrastructure.App.States
{
[State(typeof(AppStates),typeof(AppStateMachineContext))]
[StateRaisingEvent]
public partial class BootstrapState : IOnGameplaySceneLoadedHandler, IUIPanelLoaded, IReadyToPlayHandle
{
private EventBus.EventBus _eventBus;
public BootstrapState(AppStateMachineContext context, EventBus.EventBus eventBus) : base(context,eventBus)
{
_eventBus = eventBus;
}
public override AppStates myState => AppStates.Bootstrap;
protected override void OnEnterState()
{
_eventBus.Subscribe(this);
Context.UIService.TryLoadPanel(UIPanelType.DebugSceneChooser);
Context.AudioFactory.LoadAudioClips(AudioNames.UISounds);
// Context.SceneLoader.LoadSceneAsync(SceneId.Gameplay, LoadSceneMode.Single).Forget();
}
protected override void OnExitState()
{
Context.AudioFactory.ReleaseAudios(AudioNames.UISounds);
Context.UIService.TryRemovePanel(UIPanelType.DebugSceneChooser);
_eventBus.Unsubscribe(this);
}
public void OnGameplaySceneLoaded()
{
}
public void UILoaded(UIPanelType uiPanelType)
{
if (uiPanelType != UIPanelType.DebugSceneChooser) return;
Context.UIService.OpenPanel(uiPanelType);
}
public void OnReadyToPlay(AudioNames groupName)
{
Context.AudioService.PlayTest();
}
}
}