-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathElevatorInfoMethod.cs
More file actions
53 lines (50 loc) · 2.09 KB
/
ElevatorInfoMethod.cs
File metadata and controls
53 lines (50 loc) · 2.09 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
51
52
53
using JetBrains.Annotations;
using LabApi.Features.Wrappers;
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.ElevatorMethods;
[UsedImplicitly]
public class ElevatorInfoMethod : LiteralValueReturningMethod, IReferenceResolvingMethod
{
public override string Description => IReferenceResolvingMethod.Desc.Get(this);
public override Argument[] ExpectedArguments =>
[
new ReferenceArgument<Elevator>("elevator"),
new OptionsArgument("info", options:
[
new("name"),
new("group"),
new("isReady"),
new("isGoingUp"),
new("currentSequence"),
new("allDoorsLockedReason"),
new("anyDoorLockedReason"),
new("isAdminLocked")
])
];
public override void Execute()
{
var elevator = Args.GetReference<Elevator>("elevator");
ReturnValue = Args.GetOption("info") switch
{
"name" => new StaticTextValue(elevator.Base.name),
"group" => new StaticTextValue(elevator.Group.ToString()),
"isready" => new BoolValue(elevator.IsReady),
"isgoingup" => new BoolValue(elevator.GoingUp),
"currentsequence" => new StaticTextValue(elevator.CurrentSequence.ToString()),
"alldoorslockedreason" => new StaticTextValue(elevator.AllDoorsLockedReason.ToString()),
"anydoorlockedreason" => new StaticTextValue(elevator.AnyDoorLockedReason.ToString()),
"isadminlocked" => new BoolValue(elevator.DynamicAdminLock),
_ => throw new RetroReulFuckedUpException()
};
}
public override TypeOfValue LiteralReturnTypes => new TypesOfValue([
typeof(TextValue),
typeof(BoolValue)
]);
public Type ResolvesReference => typeof(Elevator);
}