Skip to content

Commit 8513b3c

Browse files
Create OverlappingMethod.cs
1 parent fb77727 commit 8513b3c

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using JetBrains.Annotations;
2+
using LabApi.Features.Wrappers;
3+
using SER.Code.ArgumentSystem.Arguments;
4+
using SER.Code.ArgumentSystem.BaseArguments;
5+
using SER.Code.MethodSystem.BaseMethods.Synchronous;
6+
using SER.Code.ValueSystem;
7+
using SER.Code.VariableSystem.Variables;
8+
9+
namespace SER.Code.MethodSystem.Methods.PlayerVariableMethods;
10+
11+
[UsedImplicitly]
12+
public class OverlappingMethod : ReturningMethod<BoolValue>
13+
{
14+
public override string Description => "Checks if all player variables have the same players.";
15+
16+
public override Argument[] ExpectedArguments { get; } =
17+
[
18+
new VariableArgument<PlayerVariable>("player variables")
19+
{
20+
ConsumesRemainingValues = true
21+
}
22+
];
23+
24+
public override void Execute()
25+
{
26+
var variables = Args
27+
.GetRemainingArguments<PlayerVariable, VariableArgument<PlayerVariable>>("player variables");
28+
29+
if (variables.Length <= 1)
30+
{
31+
ReturnValue = true;
32+
return;
33+
};
34+
35+
int startHash = variables[0].Value.GetHashCode();
36+
ReturnValue = new BoolValue(variables.Skip(1).All(v => v.Value.GetHashCode() == startHash));
37+
}
38+
}

0 commit comments

Comments
 (0)