Skip to content

Commit 39a599a

Browse files
Merge pull request #19 from RetroReul/retro-dev
# New Methods ## Player methods - `Stamina` - Control the stamina of players. (Can add, remove and set stamina. Also comes with stamina regen delay parameter) - `Jump` - Make players jump (with modifiable jump strength). - `ShowHitMarker` - Shows a hit marker to players. ## Effect methods - `HasEffect` [EXILED only] - Returns true or false indicating if the player has the provided effect. - `ClearEffect` [EXILED only] - Removes the provided status effect from players. ## Elevator methods - `SetElevatorText` - Changes the text on the elevator panels between LCZ and HCZ. ## Other methods - `SpeakerExists` [Audio method] - Returns true or false indicating if a speaker with the provided name exists. - `PryGate` [Door method] - Pries a gate. (Like 096 does. Comes with optional parameter to play effects on door button) - `ForceEquip` [Item method] - Forces players to equip a provided item. (Like the Remote Admin command) - `CreateRagdoll` [Map method] - Spawns a ragdoll. - `ScriptExists` [Script method] - Returns true or false indicating if a script with the provided name exists. - `ContainsText` [Text method] - Returns true or false indicating if the provided text contains a provided value. # Method Changes - `GiveEffect` - Moved to `Effect` methods category. # New Player Properties - `IsSpeaking` - `IsSpectatable` - `IsJumping` - `IsGrounded` - `Stamina` - Returns the player's remaining stamina. - `MovementState` - `RoleColor` - Returns the hex value of the player's role color. - `LifeId` - `UnitId` - `Unit` - Returns the player's unit (e.g FOXTROT-03) if player is NTF or Facility Guard, otherwise returns an empty text value.
2 parents 758517f + d2b67e0 commit 39a599a

20 files changed

Lines changed: 603 additions & 5 deletions

File tree

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
using JetBrains.Annotations;
2+
using LabApi.Features.Enums;
3+
using LabApi.Features.Wrappers;
4+
using SER.Code.ArgumentSystem.BaseArguments;
5+
using SER.Code.Extensions;
6+
using SER.Code.Helpers.ResultSystem;
7+
using SER.Code.TokenSystem.Tokens;
8+
using SER.Code.TokenSystem.Tokens.Interfaces;
9+
using SER.Code.ValueSystem;
10+
11+
namespace SER.Code.ArgumentSystem.Arguments;
12+
13+
public class GateArgument(string name) : EnumHandlingArgument(name)
14+
{
15+
public override string InputDescription => $"{nameof(DoorName)} enum (that is a gate) or reference to {nameof(Gate)}";
16+
17+
[UsedImplicitly]
18+
public DynamicTryGet<Gate> GetConvertSolution(BaseToken token)
19+
{
20+
return ResolveEnums<Gate>(
21+
token,
22+
new()
23+
{
24+
[typeof(DoorName)] = doorName =>
25+
{
26+
var door = Gate.List.Where(gate => gate.DoorName == (DoorName)doorName).GetRandomValue();
27+
if (door is null)
28+
{
29+
return $"Gate with name '{doorName}' does not exist.";
30+
}
31+
32+
return door;
33+
}
34+
},
35+
() =>
36+
{
37+
Result rs = $"Value '{token.RawRep}' cannot be interpreted as {InputDescription}.";
38+
39+
if (token is not IValueToken val || !val.CapableOf<ReferenceValue>(out var func))
40+
{
41+
return rs;
42+
}
43+
44+
return new(() =>
45+
{
46+
if (func().HasErrored(out var error, out var refVal))
47+
{
48+
return error;
49+
}
50+
51+
if (ReferenceArgument<Gate>.TryParse(refVal).WasSuccessful(out var gate))
52+
{
53+
return gate;
54+
}
55+
56+
return rs;
57+
});
58+
}
59+
);
60+
}
61+
}

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 Gate GetGate(string argName)
164+
{
165+
return GetValue<Gate, GateArgument>(argName);
166+
}
167+
163168
public TimeSpan? GetNullableDuration(string argName)
164169
{
165170
return GetValueNullableStruct<TimeSpan, DurationArgument>(argName);

Code/ContextSystem/Contexts/Control/ReturnKeyword.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@
44
using SER.Code.ContextSystem.Structures;
55
using SER.Code.Exceptions;
66
using SER.Code.Helpers.ResultSystem;
7-
using SER.Code.TokenSystem.Structures;
87
using SER.Code.TokenSystem.Tokens;
9-
using SER.Code.TokenSystem.Tokens.Interfaces;
10-
using SER.Code.ValueSystem;
118

129
namespace SER.Code.ContextSystem.Contexts.Control;
1310

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
namespace SER.Code.Exceptions;
2+
3+
public class RetroReulFuckedUpException : DeveloperFuckedUpException
4+
{
5+
public RetroReulFuckedUpException() : base("retroreul")
6+
{
7+
}
8+
9+
public RetroReulFuckedUpException(string msg) : base("retroreul", msg)
10+
{
11+
}
12+
}
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.AudioMethods;
8+
9+
[UsedImplicitly]
10+
public class SpeakerExistsMethod : ReturningMethod<BoolValue>
11+
{
12+
public override string Description => "Returns true or false indicating if a speaker with the provided name exists.";
13+
14+
public override Argument[] ExpectedArguments { get; } =
15+
[
16+
new TextArgument("speaker name")
17+
];
18+
19+
public override void Execute()
20+
{
21+
ReturnValue = AudioPlayer.TryGet(Args.GetText("speaker name"), out _);
22+
}
23+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using JetBrains.Annotations;
2+
using MapGeneration.Distributors;
3+
using SER.Code.ArgumentSystem.Arguments;
4+
using SER.Code.ArgumentSystem.BaseArguments;
5+
using SER.Code.MethodSystem.BaseMethods.Synchronous;
6+
7+
namespace SER.Code.MethodSystem.Methods.DoorMethods;
8+
9+
[UsedImplicitly]
10+
public class PryGateMethod : SynchronousMethod
11+
{
12+
public override string Description => "Pries a gate.";
13+
14+
public override Argument[] ExpectedArguments =>
15+
[
16+
new GateArgument("gate"),
17+
new BoolArgument("should play effects")
18+
{
19+
DefaultValue = new(false, "does not play button effects"),
20+
Description = "Whether to play gate button effects when pried."
21+
}
22+
];
23+
24+
public override void Execute()
25+
{
26+
var gate = Args.GetGate("gate");
27+
var playEffects = Args.GetBool("should play effects");
28+
29+
if (gate.IsOpened || gate.ExactState != 0f || gate.Base.IsBeingPried) return;
30+
31+
if (playEffects)
32+
{
33+
gate.PlayPermissionDeniedAnimation();
34+
gate.PlayLockBypassDeniedSound();
35+
}
36+
37+
// Spawn pickups in case a player goes through the gate. This should not duplicate pickups if the gate gets opened properly later.
38+
SpawnablesDistributorBase.ServerSpawnForAllDoor(gate.Base);
39+
40+
gate.Pry();
41+
}
42+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using Exiled.API.Enums;
2+
using Exiled.API.Features;
3+
using JetBrains.Annotations;
4+
using SER.Code.ArgumentSystem.Arguments;
5+
using SER.Code.ArgumentSystem.BaseArguments;
6+
using SER.Code.Helpers;
7+
using SER.Code.MethodSystem.BaseMethods.Synchronous;
8+
using SER.Code.MethodSystem.Structures;
9+
10+
namespace SER.Code.MethodSystem.Methods.EffectMethods;
11+
12+
[UsedImplicitly]
13+
public class ClearEffectMethod : SynchronousMethod, IDependOnFramework
14+
{
15+
public override string Description => "Removes the provided status effect from players.";
16+
17+
public override Argument[] ExpectedArguments =>
18+
[
19+
new PlayersArgument("players"),
20+
new EnumArgument<EffectType>("effect type")
21+
{ DefaultValue = new (null, "Removes all status effects") },
22+
];
23+
24+
public override void Execute()
25+
{
26+
var players = Args.GetPlayers("players");
27+
var effectType = Args.GetNullableEnum<EffectType>("effect type");
28+
29+
if (effectType.HasValue)
30+
foreach (var plr in players)
31+
Player.Get(plr).DisableEffect(effectType.Value);
32+
else
33+
foreach (var plr in players)
34+
Player.Get(plr).DisableAllEffects();
35+
}
36+
37+
public FrameworkBridge.Type DependsOn => FrameworkBridge.Type.Exiled;
38+
}

Code/MethodSystem/Methods/PlayerMethods/GiveEffectMethod.cs renamed to Code/MethodSystem/Methods/EffectMethods/GiveEffectMethod.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
using SER.Code.MethodSystem.BaseMethods.Synchronous;
88
using SER.Code.MethodSystem.Structures;
99

10-
namespace SER.Code.MethodSystem.Methods.PlayerMethods;
10+
namespace SER.Code.MethodSystem.Methods.EffectMethods;
1111

1212
[UsedImplicitly]
1313
public class GiveEffectMethod : SynchronousMethod, IDependOnFramework
1414
{
1515
public FrameworkBridge.Type DependsOn => FrameworkBridge.Type.Exiled;
16-
16+
1717
public override string Description => "Adds a provided effect to a player.";
1818

1919
public override Argument[] ExpectedArguments =>
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using Exiled.API.Enums;
2+
using Exiled.API.Features;
3+
using JetBrains.Annotations;
4+
using SER.Code.ArgumentSystem.Arguments;
5+
using SER.Code.ArgumentSystem.BaseArguments;
6+
using SER.Code.Helpers;
7+
using SER.Code.MethodSystem.BaseMethods.Synchronous;
8+
using SER.Code.MethodSystem.Structures;
9+
using SER.Code.ValueSystem;
10+
11+
namespace SER.Code.MethodSystem.Methods.EffectMethods;
12+
13+
[UsedImplicitly]
14+
public class HasEffectMethod : LiteralValueReturningMethod, IDependOnFramework
15+
{
16+
public override TypeOfValue LiteralReturnTypes => new SingleTypeOfValue(typeof(BoolValue));
17+
18+
public override string Description => "Returns true or false indicating if the player has the provided effect.";
19+
20+
public override Argument[] ExpectedArguments =>
21+
[
22+
new PlayerArgument("player"),
23+
new EnumArgument<EffectType>("effect type")
24+
];
25+
26+
public override void Execute()
27+
{
28+
var player = Args.GetPlayer("player");
29+
var effectType = Args.GetEnum<EffectType>("effect type");
30+
31+
if (!Player.Get(player).TryGetEffect(effectType, out var effect))
32+
ReturnValue = new BoolValue(false);
33+
34+
// this feels kinda stupid, but you never know...
35+
ReturnValue = new BoolValue(effect.IsEnabled);
36+
}
37+
38+
public FrameworkBridge.Type DependsOn => FrameworkBridge.Type.Exiled;
39+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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.MethodSystem.MethodDescriptors;
7+
8+
namespace SER.Code.MethodSystem.Methods.ElevatorMethods;
9+
10+
[UsedImplicitly]
11+
public class SetElevatorTextMethod : SynchronousMethod, IAdditionalDescription
12+
{
13+
public override string Description => "Changes the text on the elevator panels between LCZ and HCZ.";
14+
15+
public override Argument[] ExpectedArguments =>
16+
[
17+
new TextArgument("text")
18+
{
19+
DefaultValue = new(string.Empty, "Resets the text to it's original value."),
20+
}
21+
];
22+
23+
public override void Execute()
24+
{
25+
Decontamination.ElevatorsText = Args.GetText("text");
26+
}
27+
28+
public string AdditionalDescription => "An empty text value will reset the elevator panel text to it's original value.";
29+
}

0 commit comments

Comments
 (0)