41 lines
915 B
C#
41 lines
915 B
C#
![]() |
using Godot;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Text;
|
||
|
|
||
|
namespace Rokojori
|
||
|
{
|
||
|
[GlobalClass,Tool]
|
||
|
public partial class AudioManager:Node
|
||
|
{
|
||
|
[Export]
|
||
|
public float bufferCutLength = 0.021f;
|
||
|
|
||
|
Dictionary<SelectorFlag,float> _lastPlayTime = new Dictionary<SelectorFlag, float>();
|
||
|
|
||
|
public float GetLastPlayed( SelectorFlag selectorFlag )
|
||
|
{
|
||
|
if ( ! _lastPlayTime.ContainsKey( selectorFlag ) )
|
||
|
{
|
||
|
return -1;
|
||
|
}
|
||
|
|
||
|
return _lastPlayTime[ selectorFlag ];
|
||
|
}
|
||
|
|
||
|
public void RecordSoundPlaying( SelectorFlag selectorFlag )
|
||
|
{
|
||
|
_lastPlayTime[ selectorFlag ] = TimeLine.osTime;
|
||
|
}
|
||
|
|
||
|
public bool CanPlay( SelectorFlag selectorFlag, float blockDuration )
|
||
|
{
|
||
|
if ( ! _lastPlayTime.ContainsKey( selectorFlag ) )
|
||
|
{
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
return ( TimeLine.osTime - _lastPlayTime[ selectorFlag ] ) > blockDuration;
|
||
|
|
||
|
}
|
||
|
}
|
||
|
}
|