-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathDoorInfoMethod.cs
More file actions
67 lines (60 loc) · 2.36 KB
/
DoorInfoMethod.cs
File metadata and controls
67 lines (60 loc) · 2.36 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
using Interactables.Interobjects.DoorUtils;
using JetBrains.Annotations;
using LabApi.Features.Enums;
using LabApi.Features.Wrappers;
using SER.Code.ArgumentSystem.Arguments;
using SER.Code.ArgumentSystem.BaseArguments;
using SER.Code.ArgumentSystem.Structures;
using SER.Code.Exceptions;
using SER.Code.MethodSystem.BaseMethods.Synchronous;
using SER.Code.MethodSystem.MethodDescriptors;
using SER.Code.ValueSystem;
namespace SER.Code.MethodSystem.Methods.DoorMethods;
[UsedImplicitly]
public class DoorInfoMethod : LiteralValueReturningMethod, IReferenceResolvingMethod
{
public Type ResolvesReference => typeof(Door);
public override TypeOfValue LiteralReturnTypes => new TypesOfValue([
typeof(TextValue),
typeof(BoolValue),
typeof(NumberValue)
]);
public override string Description => IReferenceResolvingMethod.Desc.Get(this);
public override Argument[] ExpectedArguments { get; } =
[
new ReferenceArgument<Door>("door"),
new OptionsArgument("info",
"isOpen",
"isClosed",
"isLocked",
"isUnlocked",
"isGate",
"isCheckpoint",
Option.Enum<DoorName>("name"),
"unityName",
"remainingHealth",
"maxHealth",
Option.Enum<DoorPermissionFlags>("permissions")
)
];
public override void Execute()
{
var door = Args.GetReference<Door>("door");
var info = Args.GetOption("info");
ReturnValue = info switch
{
"name" => new StaticTextValue(door.DoorName.ToString()),
"unityname" => new StaticTextValue(door.Base.name),
"isopen" => new BoolValue(door.IsOpened),
"isclosed" => new BoolValue(!door.IsOpened),
"islocked" => new BoolValue(door.IsLocked),
"isunlocked" => new BoolValue(!door.IsLocked),
"isgate" => new BoolValue(door is Gate),
"ischeckpoint" => new BoolValue(door is CheckpointDoor),
"remaininghealth" => new NumberValue(door is BreakableDoor bDoor ? (decimal)bDoor.Health : -1),
"maxhealth" => new NumberValue(door is BreakableDoor bDoor ? (decimal)bDoor.MaxHealth : -1),
"permissions" => new StaticTextValue(door.Permissions.ToString()),
_ => throw new AndrzejFuckedUpException()
};
}
}