Skip to content

Commit 8d972a2

Browse files
committed
new IsPlayingAudio method
1 parent 8809352 commit 8d972a2

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using JetBrains.Annotations;
2+
using SER.Code.ArgumentSystem.Arguments;
3+
using SER.Code.ArgumentSystem.BaseArguments;
4+
using SER.Code.Exceptions;
5+
using SER.Code.MethodSystem.BaseMethods.Synchronous;
6+
using SER.Code.MethodSystem.MethodDescriptors;
7+
using SER.Code.ValueSystem;
8+
9+
namespace SER.Code.MethodSystem.Methods.AudioMethods;
10+
11+
[UsedImplicitly]
12+
public class IsPlayingAudioMethod : ReturningMethod<BoolValue>, ICanError
13+
{
14+
public override string Description => "Checks if the audio player is playing anything.";
15+
16+
public string[] ErrorReasons =>
17+
[
18+
"Speaker doesn't exist."
19+
];
20+
21+
public override Argument[] ExpectedArguments { get; } =
22+
[
23+
new TextArgument("speaker name")
24+
];
25+
26+
public override void Execute()
27+
{
28+
var speakerName = Args.GetText("speaker name");
29+
if (!AudioPlayer.TryGet(speakerName, out var speaker))
30+
throw new ScriptRuntimeError(this, $"Speaker '{speakerName}' doesn't exist.");
31+
32+
ReturnValue = !speaker.ClipsById.IsEmpty();
33+
}
34+
35+
}

0 commit comments

Comments
 (0)