Skip to content

Commit 49936b0

Browse files
fix type checking, modify collection methods etc.
1 parent a239762 commit 49936b0

File tree

18 files changed

+120
-107
lines changed

18 files changed

+120
-107
lines changed

ArgumentSystem/Arguments/CollectionVariableArgument.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using SER.Helpers.ResultSystem;
44
using SER.TokenSystem.Tokens;
55
using SER.TokenSystem.Tokens.VariableTokens;
6-
using SER.VariableSystem.Bases;
76
using SER.VariableSystem.Variables;
87

98
namespace SER.ArgumentSystem.Arguments;

MethodSystem/Methods/CollectionVariableMethods/CollectionInsertMethod.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22
using SER.ArgumentSystem.BaseArguments;
33
using SER.MethodSystem.BaseMethods;
44
using SER.MethodSystem.MethodDescriptors;
5+
using SER.ValueSystem;
56
using SER.VariableSystem.Variables;
67

78
namespace SER.MethodSystem.Methods.CollectionVariableMethods;
9+
810
public class CollectionInsertMethod : SynchronousMethod, IAdditionalDescription
911
{
10-
public override string? Description => "Adds the value to the collection variable";
12+
public override string Description => "Adds a value to a collection variable";
1113

1214
public string AdditionalDescription =>
1315
"If value is a CollectionValue, it will nest the collection inside the collection variable. " +
@@ -22,6 +24,12 @@ public class CollectionInsertMethod : SynchronousMethod, IAdditionalDescription
2224
public override void Execute()
2325
{
2426
var collVar = Args.GetCollectionVariable("collection variable");
25-
Script.AddVariable(new CollectionVariable(collVar.Name, collVar.Value.Insert(Args.GetAnyValue("value"))));
27+
28+
Script.AddVariable(
29+
new CollectionVariable(
30+
collVar.Name,
31+
CollectionValue.Insert(collVar, Args.GetAnyValue("value"))
32+
)
33+
);
2634
}
2735
}

MethodSystem/Methods/CollectionVariableMethods/CollectionRemoveAtMethod.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
using SER.ArgumentSystem.Arguments;
22
using SER.ArgumentSystem.BaseArguments;
33
using SER.MethodSystem.BaseMethods;
4+
using SER.ValueSystem;
45
using SER.VariableSystem.Variables;
56

67
namespace SER.MethodSystem.Methods.CollectionVariableMethods;
8+
79
public class CollectionRemoveAtMethod : SynchronousMethod
810
{
9-
public override string? Description => "Removes the value at the provided index from the collection variable";
11+
public override string Description => "Removes a value at the provided index from a collection variable";
1012

1113
public override Argument[] ExpectedArguments { get; } =
1214
[
@@ -22,6 +24,11 @@ public override void Execute()
2224
var collVar = Args.GetCollectionVariable("collection variable");
2325
var index = Args.GetInt("index");
2426

25-
Script.AddVariable(new CollectionVariable(collVar.Name, collVar.Value.RemoveAt(index)));
27+
Script.AddVariable(
28+
new CollectionVariable(
29+
collVar.Name,
30+
CollectionValue.RemoveAt(collVar, index)
31+
)
32+
);
2633
}
2734
}
Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
using SER.ArgumentSystem.Arguments;
22
using SER.ArgumentSystem.BaseArguments;
33
using SER.MethodSystem.BaseMethods;
4+
using SER.ValueSystem;
45
using SER.VariableSystem.Variables;
56

67
namespace SER.MethodSystem.Methods.CollectionVariableMethods;
8+
79
public class CollectionRemoveMethod : SynchronousMethod
810
{
9-
public override string? Description => "Removes the value from the collection variable";
11+
public override string Description => "Removes a matching value from a collection variable";
1012

1113
public override Argument[] ExpectedArguments { get; } =
1214
[
1315
new CollectionVariableArgument("collection variable"),
14-
new AnyValueArgument("value"),
16+
new AnyValueArgument("value to remove"),
1517
new IntArgument("amount of matches to remove", -1)
1618
{
1719
Description = "Will delete every match if -1.",
@@ -21,10 +23,15 @@ public class CollectionRemoveMethod : SynchronousMethod
2123

2224
public override void Execute()
2325
{
24-
var collVar = Args.GetCollectionVariable("collection variable");
25-
var i = Args.GetInt("amount of matches to remove");
26-
var expectedVal = Args.GetAnyValue("value");
27-
28-
Script.AddVariable(new CollectionVariable(collVar.Name, collVar.Value.Remove(expectedVal, i)));
26+
var collectionVar = Args.GetCollectionVariable("collection variable");
27+
var amountToRemove = Args.GetInt("amount of matches to remove");
28+
var value = Args.GetAnyValue("value to remove");
29+
30+
Script.AddVariable(
31+
new CollectionVariable(
32+
collectionVar.Name,
33+
CollectionValue.Remove(collectionVar.Value, value, amountToRemove)
34+
)
35+
);
2936
}
3037
}
Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,16 @@
1-
using SER.ArgumentSystem.Arguments;
2-
using SER.ArgumentSystem.BaseArguments;
1+
using SER.ArgumentSystem.BaseArguments;
32
using SER.MethodSystem.BaseMethods;
43
using SER.ValueSystem;
5-
using SER.Helpers.Exceptions;
64

75
namespace SER.MethodSystem.Methods.CollectionVariableMethods;
86
public class EmptyCollectionMethod : ReturningMethod<CollectionValue>
97
{
10-
public override string? Description => "Returns an empty collection.";
8+
public override string Description => "Returns an empty collection.";
119

12-
public override Argument[] ExpectedArguments { get; } =
13-
[
14-
new OptionsArgument("collection type",
15-
"bool",
16-
"collection",
17-
"duration",
18-
"number",
19-
"player",
20-
"reference",
21-
"text")
22-
];
10+
public override Argument[] ExpectedArguments { get; } = [];
2311

2412
public override void Execute()
2513
{
26-
ReturnValue = Args.GetOption("collection type") switch
27-
{
28-
"bool" => new CollectionValue<BoolValue>([]),
29-
"collection" => new CollectionValue<CollectionValue>([]),
30-
"duration" => new CollectionValue<DurationValue>([]),
31-
"number" => new CollectionValue<NumberValue>([]),
32-
"player" => new CollectionValue<PlayerValue>([]),
33-
"reference" => new CollectionValue<ReferenceValue>([]),
34-
"text" => new CollectionValue<TextValue>([]),
35-
_ => throw new TosoksFuckedUpException("out of range")
36-
};
14+
ReturnValue = new CollectionValue(Array.Empty<Value>());
3715
}
3816
}

MethodSystem/Methods/CollectionVariableMethods/JoinCollectionsMethod.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
namespace SER.MethodSystem.Methods.CollectionVariableMethods;
77
public class JoinCollectionsMethod : ReturningMethod<CollectionValue>
88
{
9-
public override string? Description => "Returns a collection that has the combined values of all the given collections";
9+
public override string Description => "Returns a collection that has the combined values of all the given collections";
1010

1111
public override Argument[] ExpectedArguments { get; } =
1212
[

MethodSystem/Methods/CollectionVariableMethods/SubtractCollectionsMethod.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
namespace SER.MethodSystem.Methods.CollectionVariableMethods;
77
public class SubtractCollectionsMethod : ReturningMethod<CollectionValue>
88
{
9-
public override string? Description => "Returns a collection that has the values of the first collection without the values of the latter";
9+
public override string Description => "Returns a collection that has the values of the first collection without the values of the latter";
1010

1111
public override Argument[] ExpectedArguments { get; } =
1212
[

MethodSystem/Methods/IntercomMethods/SetIntercomTextMethod.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace SER.MethodSystem.Methods.IntercomMethods;
88

99
public class SetIntercomTextMethod : SynchronousMethod, IAdditionalDescription
1010
{
11-
public override string? Description => "Sets the text on the Intercom.";
11+
public override string Description => "Sets the text on the Intercom.";
1212

1313
public string AdditionalDescription => "Resets the intercom text if given text is empty.";
1414

MethodSystem/Methods/TeleportMethods/TPRelativeMethod.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using SER.ArgumentSystem.Arguments;
22
using SER.ArgumentSystem.BaseArguments;
3-
using SER.Helpers.Extensions;
43
using SER.MethodSystem.BaseMethods;
54
using UnityEngine;
65

SER.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
<HintPath>$(SL_DEV_REFERENCES)\CommandSystem.Core.dll</HintPath>
4747
<Private>true</Private>
4848
</Reference>
49+
<Reference Include="Microsoft.CSharp" />
4950
<Reference Include="Mirror">
5051
<HintPath>$(SL_DEV_REFERENCES)\Mirror.dll</HintPath>
5152
</Reference>

0 commit comments

Comments
 (0)