Skip to content
12 changes: 12 additions & 0 deletions Code/Exceptions/RetroReulFuckedUpException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace SER.Code.Exceptions;

public class RetroReulFuckedUpException : DeveloperFuckedUpException
{
public RetroReulFuckedUpException() : base("retroreul")
{
}

public RetroReulFuckedUpException(string msg) : base("retroreul", msg)
{
}
}
23 changes: 23 additions & 0 deletions Code/MethodSystem/Methods/AudioMethods/SpeakerExistsMethod.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using JetBrains.Annotations;
using SER.Code.ArgumentSystem.Arguments;
using SER.Code.ArgumentSystem.BaseArguments;
using SER.Code.MethodSystem.BaseMethods.Synchronous;
using SER.Code.ValueSystem;

namespace SER.Code.MethodSystem.Methods.AudioMethods;

[UsedImplicitly]
public class SpeakerExistsMethod : ReturningMethod<BoolValue>
{
public override string Description => "Returns true or false indicating if a speaker with the provided name exists.";

public override Argument[] ExpectedArguments { get; } =
[
new TextArgument("speaker name")
];

public override void Execute()
{
ReturnValue = AudioPlayer.TryGet(Args.GetText("speaker name"), out _);
}
}
4 changes: 4 additions & 0 deletions Code/MethodSystem/Methods/DoorMethods/DoorInfoMethod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public class DoorInfoMethod : LiteralValueReturningMethod, IReferenceResolvingMe
"isClosed",
"isLocked",
"isUnlocked",
"isGate",
"isCheckpoint",
Option.Enum<DoorName>("name"),
"unityName",
"remainingHealth",
Expand All @@ -54,6 +56,8 @@ public override void Execute()
"isclosed" => new BoolValue(!door.IsOpened),
"islocked" => new BoolValue(door.IsLocked),
"isunlocked" => new BoolValue(!door.IsLocked),
"isgate" => new BoolValue(door is Gate),
"ischeckpoint" => new BoolValue(door is CheckpointDoor),
"remaininghealth" => new NumberValue(door is BreakableDoor bDoor ? (decimal)bDoor.Health : -1),
"maxhealth" => new NumberValue(door is BreakableDoor bDoor ? (decimal)bDoor.MaxHealth : -1),
"permissions" => new StaticTextValue(door.Permissions.ToString()),
Expand Down
45 changes: 45 additions & 0 deletions Code/MethodSystem/Methods/DoorMethods/PryGateMethod.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using JetBrains.Annotations;
using LabApi.Features.Wrappers;
using MapGeneration.Distributors;
using SER.Code.ArgumentSystem.Arguments;
using SER.Code.ArgumentSystem.BaseArguments;
using SER.Code.MethodSystem.BaseMethods.Synchronous;

namespace SER.Code.MethodSystem.Methods.DoorMethods;

[UsedImplicitly]
public class PryGateMethod : SynchronousMethod
{
public override string Description => "Pries a gate.";

public override Argument[] ExpectedArguments =>
[
new DoorArgument("gate"),
new BoolArgument("should play effects")
{
DefaultValue = new(false, "does not play button effects"),
Description = "Whether to play gate button effects when pried."
}
];

public override void Execute()
{
var door = Args.GetDoor("gate");
var playEffects = Args.GetBool("should play effects");

if (door is not Gate gate) return;

if (gate.IsOpened || gate.ExactState != 0f || gate.Base.IsBeingPried) return;

if (playEffects)
{
gate.PlayPermissionDeniedAnimation();
gate.PlayLockBypassDeniedSound();
}

// Spawn pickups in case a player goes through the gate. This should not duplicate pickups if the gate gets opened properly later.
SpawnablesDistributorBase.ServerSpawnForAllDoor(gate.Base);

gate.Pry();
}
}
39 changes: 39 additions & 0 deletions Code/MethodSystem/Methods/EffectMethods/ClearEffectMethod.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using Exiled.API.Enums;
using Exiled.API.Features;
using JetBrains.Annotations;
using SER.Code.ArgumentSystem.Arguments;
using SER.Code.ArgumentSystem.BaseArguments;
using SER.Code.Helpers;
using SER.Code.MethodSystem.BaseMethods.Synchronous;
using SER.Code.MethodSystem.MethodDescriptors;
using SER.Code.MethodSystem.Structures;

namespace SER.Code.MethodSystem.Methods.EffectMethods;

[UsedImplicitly]
public class ClearEffectMethod : SynchronousMethod, IDependOnFramework
{
public override string Description => "Removes the provided status effect from players.";

public override Argument[] ExpectedArguments =>
[
new PlayersArgument("players"),
new EnumArgument<EffectType>("effect type")
{ DefaultValue = new (null, "Removes all status effects") },
];

public override void Execute()
{
var players = Args.GetPlayers("players");
var effectType = Args.GetNullableEnum<EffectType>("effect type");

if (effectType.HasValue)
foreach (var plr in players)
Player.Get(plr).DisableEffect(effectType.Value);
else
foreach (var plr in players)
Player.Get(plr).DisableAllEffects();
}

public FrameworkBridge.Type DependsOn => FrameworkBridge.Type.Exiled;
}
50 changes: 50 additions & 0 deletions Code/MethodSystem/Methods/EffectMethods/EffectInfoMethod.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using CustomPlayerEffects;
using JetBrains.Annotations;
using SER.Code.ArgumentSystem.Arguments;
using SER.Code.ArgumentSystem.BaseArguments;
using SER.Code.Exceptions;
using SER.Code.MethodSystem.BaseMethods.Synchronous;
using SER.Code.MethodSystem.MethodDescriptors;
using SER.Code.ValueSystem;

namespace SER.Code.MethodSystem.Methods.EffectMethods;

[UsedImplicitly]
public class EffectInfoMethod : LiteralValueReturningMethod, IReferenceResolvingMethod
{
public override string Description => IReferenceResolvingMethod.Desc.Get(this);

public override Argument[] ExpectedArguments =>
[
new ReferenceArgument<StatusEffectBase>("effect"),
new OptionsArgument("info", options:
[
new("name"),
new("duration"),
new("intensity"),
new("classification"),
new("timeLeft")
])
];
public override void Execute()
{
var effect = Args.GetReference<StatusEffectBase>("effect");
ReturnValue = Args.GetOption("info") switch
{
"name" => new StaticTextValue(effect.name),
"duration" => new DurationValue(TimeSpan.FromSeconds(effect.Duration)),
"intensity" => new NumberValue(effect.Intensity),
"classification" => new StaticTextValue(effect.Classification.ToString()),
"timeleft" => new DurationValue(TimeSpan.FromSeconds(effect.TimeLeft)),
_ => throw new RetroReulFuckedUpException()
};
}

public override TypeOfValue LiteralReturnTypes => new TypesOfValue([
typeof(TextValue),
typeof(NumberValue),
typeof(DurationValue)
]);

public Type ResolvesReference => typeof(StatusEffectBase);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
using SER.Code.MethodSystem.BaseMethods.Synchronous;
using SER.Code.MethodSystem.Structures;

namespace SER.Code.MethodSystem.Methods.PlayerMethods;
namespace SER.Code.MethodSystem.Methods.EffectMethods;

[UsedImplicitly]
public class GiveEffectMethod : SynchronousMethod, IDependOnFramework
{
public FrameworkBridge.Type DependsOn => FrameworkBridge.Type.Exiled;

public override string Description => "Adds a provided effect to a player.";

public override Argument[] ExpectedArguments =>
Expand All @@ -40,9 +40,11 @@ public override void Execute()
var effectType = Args.GetEnum<EffectType>("effect type");
var duration = (float)Args.GetDuration("duration").TotalSeconds;
var intensity = (byte)Args.GetInt("intensity");

players.ForEach(plr
=> Player.Get(plr).EnableEffect(effectType, intensity, duration)
);
var addDurationIfActive = Args.GetBool("add duration if active");

foreach (var plr in players)
{
Player.Get(plr).EnableEffect(effectType, intensity, duration, addDurationIfActive);
}
}
}
39 changes: 39 additions & 0 deletions Code/MethodSystem/Methods/EffectMethods/HasEffectMethod.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using Exiled.API.Enums;
using Exiled.API.Features;
using JetBrains.Annotations;
using SER.Code.ArgumentSystem.Arguments;
using SER.Code.ArgumentSystem.BaseArguments;
using SER.Code.Helpers;
using SER.Code.MethodSystem.BaseMethods.Synchronous;
using SER.Code.MethodSystem.Structures;
using SER.Code.ValueSystem;

namespace SER.Code.MethodSystem.Methods.EffectMethods;

[UsedImplicitly]
public class HasEffectMethod : LiteralValueReturningMethod, IDependOnFramework
{
public override TypeOfValue LiteralReturnTypes => new SingleTypeOfValue(typeof(BoolValue));

public override string Description => "Returns true or false indicating if the player has the provided effect.";

public override Argument[] ExpectedArguments =>
[
new PlayerArgument("player"),
new EnumArgument<EffectType>("effect type")
];

public override void Execute()
{
var player = Args.GetPlayer("player");
var effectType = Args.GetEnum<EffectType>("effect type");

if (!Player.Get(player).TryGetEffect(effectType, out var effect))
ReturnValue = new BoolValue(false);

// this feels kinda stupid, but you never know...
ReturnValue = new BoolValue(effect.IsEnabled);
}

public FrameworkBridge.Type DependsOn => FrameworkBridge.Type.Exiled;
}
53 changes: 53 additions & 0 deletions Code/MethodSystem/Methods/ElevatorMethods/ElevatorInfoMethod.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using JetBrains.Annotations;
using LabApi.Features.Wrappers;
using SER.Code.ArgumentSystem.Arguments;
using SER.Code.ArgumentSystem.BaseArguments;
using SER.Code.Exceptions;
using SER.Code.MethodSystem.BaseMethods.Synchronous;
using SER.Code.MethodSystem.MethodDescriptors;
using SER.Code.ValueSystem;

namespace SER.Code.MethodSystem.Methods.ElevatorMethods;

[UsedImplicitly]
public class ElevatorInfoMethod : LiteralValueReturningMethod, IReferenceResolvingMethod
{
public override string Description => IReferenceResolvingMethod.Desc.Get(this);
public override Argument[] ExpectedArguments =>
[
new ReferenceArgument<Elevator>("elevator"),
new OptionsArgument("info", options:
[
new("name"),
new("group"),
new("isReady"),
new("isGoingUp"),
new("currentSequence"),
new("allDoorsLockedReason"),
new("anyDoorLockedReason"),
new("isAdminLocked")
])
];
public override void Execute()
{
var elevator = Args.GetReference<Elevator>("elevator");
ReturnValue = Args.GetOption("info") switch
{
"name" => new StaticTextValue(elevator.Base.name),
"group" => new StaticTextValue(elevator.Group.ToString()),
"isready" => new BoolValue(elevator.IsReady),
"isgoingup" => new BoolValue(elevator.GoingUp),
"currentsequence" => new StaticTextValue(elevator.CurrentSequence.ToString()),
"alldoorslockedreason" => new StaticTextValue(elevator.AllDoorsLockedReason.ToString()),
"anydoorlockedreason" => new StaticTextValue(elevator.AnyDoorLockedReason.ToString()),
"isadminlocked" => new BoolValue(elevator.DynamicAdminLock),
_ => throw new RetroReulFuckedUpException()
};
}

public override TypeOfValue LiteralReturnTypes => new TypesOfValue([
typeof(TextValue),
typeof(BoolValue)
]);
public Type ResolvesReference => typeof(Elevator);
}
29 changes: 29 additions & 0 deletions Code/MethodSystem/Methods/ElevatorMethods/SetElevatorTextMethod.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using JetBrains.Annotations;
using LabApi.Features.Wrappers;
using SER.Code.ArgumentSystem.Arguments;
using SER.Code.ArgumentSystem.BaseArguments;
using SER.Code.MethodSystem.BaseMethods.Synchronous;
using SER.Code.MethodSystem.MethodDescriptors;

namespace SER.Code.MethodSystem.Methods.ElevatorMethods;

[UsedImplicitly]
public class SetElevatorTextMethod : SynchronousMethod, IAdditionalDescription
{
public override string Description => "Changes the text on the elevator panels between LCZ and HCZ.";

public override Argument[] ExpectedArguments =>
[
new TextArgument("text")
{
DefaultValue = new(string.Empty, "Resets the text to it's original value."),
}
];

public override void Execute()
{
Decontamination.ElevatorsText = Args.GetText("text");
}

public string AdditionalDescription => "An empty text value will reset the elevator panel text to it's original value.";
}
27 changes: 27 additions & 0 deletions Code/MethodSystem/Methods/HealthMethods/RegenerateMethod.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using JetBrains.Annotations;
using SER.Code.ArgumentSystem.Arguments;
using SER.Code.ArgumentSystem.BaseArguments;
using SER.Code.MethodSystem.BaseMethods.Synchronous;

namespace SER.Code.MethodSystem.Methods.HealthMethods;

[UsedImplicitly]
public class RegenerateMethod : SynchronousMethod
{
public override string Description => "Adds health regeneration to players.";

public override Argument[] ExpectedArguments =>
[
new PlayersArgument("players"),
new FloatArgument("regeneration rate"),
new FloatArgument("regeneration duration")
];

public override void Execute()
{
var players = Args.GetPlayers("players");
var regenerationRate = Args.GetFloat("regeneration rate");
var regenerationDuration = Args.GetFloat("regeneration duration");
players.ForEach(plr => plr.AddRegeneration(regenerationRate, regenerationDuration));
}
}
Loading