新增 FlowScope Git 包雏形
This commit is contained in:
25
Packages/com.flowscope.gamecore/Runtime/Audio/AudioHandle.cs
Normal file
25
Packages/com.flowscope.gamecore/Runtime/Audio/AudioHandle.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
|
||||
namespace FlowScope.Audio
|
||||
{
|
||||
public sealed class AudioHandle : IAudioHandle
|
||||
{
|
||||
private readonly Func<bool> _isPlaying;
|
||||
private readonly Action<float> _stop;
|
||||
|
||||
internal AudioHandle(Func<bool> isPlaying, Action<float> stop)
|
||||
{
|
||||
_isPlaying = isPlaying ?? throw new ArgumentNullException(nameof(isPlaying));
|
||||
_stop = stop ?? throw new ArgumentNullException(nameof(stop));
|
||||
}
|
||||
|
||||
public bool IsPlaying => _isPlaying();
|
||||
|
||||
public void Stop(float fadeOut = 0f)
|
||||
{
|
||||
_stop(fadeOut);
|
||||
}
|
||||
|
||||
internal static AudioHandle Stopped { get; } = new AudioHandle(() => false, _ => { });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user