-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathEffectInfoMethod.cs
More file actions
50 lines (45 loc) · 1.72 KB
/
EffectInfoMethod.cs
File metadata and controls
50 lines (45 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using CustomPlayerEffects;
using JetBrains.Annotations;
using SER.Code.ArgumentSystem.Arguments;
using SER.Code.ArgumentSystem.BaseArguments;
using SER.Code.Exceptions;
using SER.Code.MethodSystem.BaseMethods.Synchronous;
using SER.Code.MethodSystem.MethodDescriptors;
using SER.Code.ValueSystem;
namespace SER.Code.MethodSystem.Methods.EffectMethods;
[UsedImplicitly]
public class EffectInfoMethod : LiteralValueReturningMethod, IReferenceResolvingMethod
{
public override string Description => IReferenceResolvingMethod.Desc.Get(this);
public override Argument[] ExpectedArguments =>
[
new ReferenceArgument<StatusEffectBase>("effect"),
new OptionsArgument("info", options:
[
new("name"),
new("duration"),
new("intensity"),
new("classification"),
new("timeLeft")
])
];
public override void Execute()
{
var effect = Args.GetReference<StatusEffectBase>("effect");
ReturnValue = Args.GetOption("info") switch
{
"name" => new StaticTextValue(effect.name),
"duration" => new DurationValue(TimeSpan.FromSeconds(effect.Duration)),
"intensity" => new NumberValue(effect.Intensity),
"classification" => new StaticTextValue(effect.Classification.ToString()),
"timeleft" => new DurationValue(TimeSpan.FromSeconds(effect.TimeLeft)),
_ => throw new RetroReulFuckedUpException()
};
}
public override TypeOfValue LiteralReturnTypes => new TypesOfValue([
typeof(TextValue),
typeof(NumberValue),
typeof(DurationValue)
]);
public Type ResolvesReference => typeof(StatusEffectBase);
}