Skip to content

Commit 1943091

Browse files
Create GetWaveTimerMethod.cs
1 parent 79a347a commit 1943091

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using JetBrains.Annotations;
2+
using LabApi.Features.Wrappers;
3+
using SER.Code.ArgumentSystem.Arguments;
4+
using SER.Code.ArgumentSystem.BaseArguments;
5+
using SER.Code.Helpers.Exceptions;
6+
using SER.Code.MethodSystem.BaseMethods.Synchronous;
7+
using SER.Code.MethodSystem.Structures;
8+
using SER.Code.ValueSystem;
9+
10+
namespace SER.Code.MethodSystem.Methods.RespawnMethods;
11+
12+
[UsedImplicitly]
13+
public class GetWaveTimerMethod : ReferenceReturningMethod<Result<DurationValue>>
14+
{
15+
public override string Description => "Returns the duration of a given spawn wave.";
16+
17+
public override Argument[] ExpectedArguments { get; } =
18+
[
19+
new OptionsArgument("wave type",
20+
"primaryMtfWave",
21+
"miniMtfWave",
22+
"primaryChaosWave",
23+
"miniChaosWave"
24+
)
25+
];
26+
27+
28+
public override void Execute()
29+
{
30+
float duration = Args.GetOption("wave type") switch
31+
{
32+
"primarymtfwave" => RespawnWaves.PrimaryMtfWave?.TimeLeft ?? -1,
33+
"minimtfwave" => RespawnWaves.MiniMtfWave?.TimeLeft ?? -1,
34+
"primarychaoswave" => RespawnWaves.PrimaryChaosWave?.TimeLeft ?? -1,
35+
"minichaoswave" => RespawnWaves.MiniChaosWave?.TimeLeft ?? -1,
36+
_ => throw new AndrzejFuckedUpException()
37+
};
38+
39+
ReturnValue = new Result<DurationValue>(
40+
duration >= 0
41+
? TimeSpan.FromSeconds(duration)
42+
: null
43+
);
44+
}
45+
}

0 commit comments

Comments
 (0)