Now Audio Playing

This commit is contained in:
ThomasCharester committed 2026-01-27 03:03:52 +03:00
1 parent b7527d8d68
commit 513d6d0bc5
62 files changed
+1168 -119

No files matched your search

@@ -1,3 +1,4 @@
using Code.Infrastructure.Audio;
using Code.Infrastructure.Camera;
using Code.Infrastructure.UI;
using Reflex.Attributes;
@@ -16,6 +17,8 @@ namespace Code.Infrastructure.App
[Inject] public SceneLoader.SceneLoader SceneLoader { get; set; }
[Inject] public CameraStateMachine Camera { get; set; }
[Inject] public IUIService UIService { get; set; }
[Inject] public IAudioFactory AudioFactory { get; set; }
[Inject] public IAudioService AudioService { get; set; }
}
[Generators.StateMachine(typeof(AppStateMachineContext),typeof(AppStates))]
@@ -1,4 +1,5 @@
using System;
using Code.Infrastructure.Audio;
using Code.Infrastructure.Camera;
using Code.Infrastructure.Configs;
using Code.Infrastructure.Input;
@@ -21,7 +22,9 @@ namespace Code.Infrastructure.App
IUIInitializedHandle,
IUIPanelLoaded,
IVolumesInitializedHandle,
IVolumeLoaded
IVolumeLoaded,
IAudioSourcePoolInitializedHandle,
IAudioConfigsLoadedHandle
{
public void InstallBindings(ContainerBuilder containerBuilder)
{
@@ -51,6 +54,13 @@ namespace Code.Infrastructure.App
containerBuilder.RegisterType(typeof(VolumeFactory), new[] { typeof(IVolumeFactory) }, Lifetime.Singleton,
Resolution.Eager);
containerBuilder.RegisterType(typeof(AudioFactory), new[] { typeof(IAudioFactory) }, Lifetime.Singleton,
Resolution.Eager);
containerBuilder.RegisterType(typeof(AudioSourcePool), new[] { typeof(IAudioSourcePool) }, Lifetime.Singleton,
Resolution.Eager);
containerBuilder.RegisterType(typeof(AudioService), new[] { typeof(IAudioService) }, Lifetime.Singleton,
Resolution.Eager);
// UIFactory
// Logo
// Scene configs
@@ -58,7 +68,9 @@ namespace Code.Infrastructure.App
// Camera
// Volume Factory
// Loading volume
_initialLoading = new Loading(7, () => EssentialLoadEnded(_thatRightContainer));
// Audio Factory
// Audio Pool
_initialLoading = new Loading(9, () => EssentialLoadEnded(_thatRightContainer));
_ui2CamLoading = new Loading(2,
() =>
{
@@ -156,5 +168,15 @@ namespace Code.Infrastructure.App
break;
}
}
public void AudioSourcePoolInitialized()
{
_initialLoading.DoProgress();
}
public void AudioConfigsLoaded()
{
_initialLoading.DoProgress();
}
}
}
@@ -1,16 +1,13 @@
using Code.Infrastructure.Camera;
using Code.Infrastructure.Audio;
using Code.Infrastructure.Generators;
using Code.Infrastructure.SceneLoader;
using Code.Infrastructure.UI;
using Cysharp.Threading.Tasks;
using UnityEngine;
using UnityEngine.SceneManagement;
namespace Code.Infrastructure.App.States
{
[State(typeof(AppStates),typeof(AppStateMachineContext))]
[StateRaisingEvent]
public partial class BootstrapState : IOnGameplaySceneLoadedHandler, IUIPanelLoaded
public partial class BootstrapState : IOnGameplaySceneLoadedHandler, IUIPanelLoaded, IReadyToPlayHandle
{
private EventBus.EventBus _eventBus;
public BootstrapState(AppStateMachineContext context, EventBus.EventBus eventBus) : base(context,eventBus)
@@ -24,11 +21,13 @@ namespace Code.Infrastructure.App.States
_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);
}
@@ -44,5 +43,10 @@ namespace Code.Infrastructure.App.States
Context.UIService.OpenPanel(uiPanelType);
}
public void OnReadyToPlay(AudioNames groupName)
{
Context.AudioService.PlayTest();
}
}
}