Skip to content

Commit 1ead57a

Browse files
committed
3 new methods
1 parent e877b6c commit 1ead57a

3 files changed

Lines changed: 106 additions & 0 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using JetBrains.Annotations;
2+
using SER.Code.ArgumentSystem.Arguments;
3+
using SER.Code.ArgumentSystem.BaseArguments;
4+
using SER.Code.MethodSystem.BaseMethods.Synchronous;
5+
using SER.Code.ValueSystem;
6+
7+
namespace SER.Code.MethodSystem.Methods.ParsingMethods;
8+
9+
[UsedImplicitly]
10+
public class IsLiteralMethod : ReturningMethod<BoolValue>
11+
{
12+
public override string Description => $"Returns true if given value is a {nameof(LiteralValue)}";
13+
14+
public override Argument[] ExpectedArguments { get; } =
15+
[
16+
new AnyValueArgument("value to check")
17+
];
18+
19+
public override void Execute()
20+
{
21+
ReturnValue = Args.GetAnyValue("value to check") is LiteralValue;
22+
}
23+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using JetBrains.Annotations;
2+
using Respawning;
3+
using Respawning.Waves;
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.RespawnMethods;
9+
10+
[UsedImplicitly]
11+
public class PlayWaveEffectMethod : SynchronousMethod
12+
{
13+
public override string Description => "Plays a Respawn Wave effect (the NTF helicopter/CI van arrival animation)";
14+
15+
public override Argument[] ExpectedArguments { get; } =
16+
[
17+
new OptionsArgument("wave faction",
18+
"ntf",
19+
"ci")
20+
];
21+
public override void Execute()
22+
{
23+
var faction = Args.GetOption("wave faction");
24+
25+
WaveUpdateMessage.ServerSendUpdate(
26+
WaveManager.Waves.First(wave =>
27+
faction == "ntf"
28+
? wave is NtfSpawnWave
29+
: wave is ChaosSpawnWave),
30+
UpdateMessageFlags.Trigger);
31+
}
32+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
using JetBrains.Annotations;
2+
using SER.Code.ArgumentSystem.Arguments;
3+
using SER.Code.ArgumentSystem.BaseArguments;
4+
using SER.Code.Exceptions;
5+
using SER.Code.MethodSystem.BaseMethods.Synchronous;
6+
using SER.Code.MethodSystem.MethodDescriptors;
7+
using SER.Code.TokenSystem;
8+
using SER.Code.TokenSystem.Tokens.VariableTokens;
9+
using SER.Code.ValueSystem;
10+
using SER.Code.VariableSystem;
11+
using SER.Code.VariableSystem.Bases;
12+
13+
namespace SER.Code.MethodSystem.Methods.VariableMethods;
14+
15+
[UsedImplicitly]
16+
public class GetVariableByNameMethod : ReturningMethod, ICanError
17+
{
18+
public override string Description => "Returns the value of a variable with the given name and prefix.";
19+
20+
public string[] ErrorReasons =>
21+
[
22+
"Provided argument is not a syntactically valid variable name.",
23+
"Specified variable doesn't exist"
24+
];
25+
26+
public override Argument[] ExpectedArguments { get; } =
27+
[
28+
new TextArgument("variable name")
29+
];
30+
31+
public override void Execute()
32+
{
33+
var variableName = Args.GetText("variable name");
34+
35+
if (Tokenizer.GetTokenFromString(variableName, Script, null)
36+
.HasErrored(out var error, out var token))
37+
throw new TosoksFuckedUpException(error);
38+
39+
if (token is not VariableToken variableToken)
40+
throw new ScriptRuntimeError(this, ErrorReasons[0]);
41+
42+
ReturnValue =
43+
Script.LocalVariables
44+
.FirstOrDefault(variable => Variable.AreSyntacticallySame(variable, variableToken))?.BaseValue
45+
?? VariableIndex.GlobalVariables
46+
.FirstOrDefault(global => Variable.AreSyntacticallySame(global, variableToken))?.BaseValue
47+
?? throw new ScriptRuntimeError(this, ErrorReasons[1]);
48+
}
49+
50+
public override TypeOfValue Returns { get; } = new UnknownTypeOfValue();
51+
}

0 commit comments

Comments
 (0)