Skip to content

Commit a6b9e15

Browse files
add SetInteractableProperties method
1 parent 8ab785c commit a6b9e15

2 files changed

Lines changed: 47 additions & 0 deletions

File tree

Code/ArgumentSystem/ProvidedArguments.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,11 @@ public Door GetDoor(string argName)
160160
return GetValue<Door, DoorArgument>(argName);
161161
}
162162

163+
public TimeSpan? GetNullableDuration(string argName)
164+
{
165+
return GetValueNullableStruct<TimeSpan, DurationArgument>(argName);
166+
}
167+
163168
public TimeSpan GetDuration(string argName)
164169
{
165170
return GetValue<TimeSpan, DurationArgument>(argName);
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using AdminToys;
2+
using JetBrains.Annotations;
3+
using LabApi.Features.Wrappers;
4+
using SER.Code.ArgumentSystem.Arguments;
5+
using SER.Code.ArgumentSystem.BaseArguments;
6+
using SER.Code.MethodSystem.BaseMethods.Synchronous;
7+
8+
namespace SER.Code.MethodSystem.Methods.AdminToyPropertyMethods;
9+
10+
[UsedImplicitly]
11+
public class SetInteractablePropertiesMethod : SynchronousMethod
12+
{
13+
public override string Description => "Sets properties of an Interactable Toy.";
14+
15+
public override Argument[] ExpectedArguments { get; } =
16+
[
17+
new ReferenceArgument<InteractableToy>("toy"),
18+
new EnumArgument<InvisibleInteractableToy.ColliderShape>("shape")
19+
{
20+
DefaultValue = new(null, "not changing")
21+
},
22+
new DurationArgument("interaction duration")
23+
{
24+
DefaultValue = new(null, "not changing")
25+
},
26+
new BoolArgument("is locked")
27+
{
28+
DefaultValue = new(null, "not changing")
29+
}
30+
];
31+
32+
public override void Execute()
33+
{
34+
var toy = Args.GetReference<InteractableToy>("toy");
35+
if (Args.GetNullableEnum<InvisibleInteractableToy.ColliderShape>("shape") is { } shape)
36+
toy.Shape = shape;
37+
if (Args.GetNullableDuration("interaction duration") is { } duration)
38+
toy.InteractionDuration = (float)duration.TotalSeconds;
39+
if (Args.GetNullableBool("is locked") is { } locked)
40+
toy.IsLocked = locked;
41+
}
42+
}

0 commit comments

Comments
 (0)