Skip to content

Commit f22586a

Browse files
Create SetDoorPermissionMethod.cs
1 parent 1b70921 commit f22586a

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System;
2+
using System.Linq;
3+
using Interactables.Interobjects.DoorUtils;
4+
using SER.ArgumentSystem.Arguments;
5+
using SER.ArgumentSystem.BaseArguments;
6+
using SER.MethodSystem.BaseMethods;
7+
8+
namespace SER.MethodSystem.Methods.DoorMethods;
9+
10+
public class SetDoorPermissionMethod : SynchronousMethod
11+
{
12+
public override string Description => "Sets door permissions.";
13+
14+
public override Argument[] ExpectedArguments { get; } =
15+
[
16+
new DoorsArgument("doors"),
17+
new EnumArgument<DoorPermissionFlags>("permissions")
18+
{
19+
ConsumesRemainingValues = true,
20+
}
21+
];
22+
23+
public override void Execute()
24+
{
25+
var doors = Args.GetDoors("doors");
26+
var permissions = Args
27+
.GetRemainingArguments<object, EnumArgument<DoorPermissionFlags>>("permissions")
28+
.Cast<DoorPermissionFlags>()
29+
.ToArray();
30+
31+
doors.ForEach(door =>
32+
{
33+
door.Permissions = permissions.Aggregate((a, b) => a | b);
34+
});
35+
}
36+
}

0 commit comments

Comments
 (0)