Skip to content

Commit b03cb1c

Browse files
committed
peanut observers method and variable
1 parent 850e5b9 commit b03cb1c

File tree

6 files changed

+63
-1
lines changed

6 files changed

+63
-1
lines changed

Code/Helpers/Extensions/PlayerExtensions.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using LabApi.Features.Wrappers;
2+
using PlayerRoles.PlayableScps.Scp173;
23
using UnityEngine;
34

45
namespace SER.Code.Helpers.Extensions;
@@ -9,4 +10,17 @@ public static Vector3 RelativeRoomPosition(this Player player)
910
{
1011
return player.Room == null ? new(0,0,0) : player.Room.Transform.InverseTransformPoint(player.Position) - new Vector3(0, player.Scale.y + 0.01f, 0);
1112
}
13+
14+
extension(Scp173Role peanut)
15+
{
16+
public Scp173ObserversTracker ObserversTracker =>
17+
!peanut.SubroutineModule.TryGetSubroutine(out Scp173ObserversTracker observersTracker)
18+
? throw new Exception("I fucking hate Northwood so much.")
19+
: observersTracker;
20+
21+
public Player[] ObservingPlayers => peanut.ObserversTracker.Observers
22+
.Select(Player.Get)
23+
.RemoveNulls()
24+
.ToArray();
25+
}
1226
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
using Exiled.Events.Handlers;
2+
using JetBrains.Annotations;
3+
using PlayerRoles.PlayableScps.Scp173;
4+
using SER.Code.ArgumentSystem.Arguments;
5+
using SER.Code.ArgumentSystem.BaseArguments;
6+
using SER.Code.ContextSystem.Structures;
7+
using SER.Code.Helpers.Exceptions;
8+
using SER.Code.Helpers.Extensions;
9+
using SER.Code.MethodSystem.BaseMethods;
10+
using SER.Code.MethodSystem.MethodDescriptors;
11+
using SER.Code.ValueSystem;
12+
using Player = LabApi.Features.Wrappers.Player;
13+
14+
namespace SER.Code.MethodSystem.Methods.ScpMethods;
15+
16+
[UsedImplicitly]
17+
public class Get173ObserversMethod : ReturningMethod<PlayerValue>, ICanError
18+
{
19+
public override string Description => "Returns the people that are looking at the specified SCP-173";
20+
21+
public string[] ErrorReasons =>
22+
[
23+
"The specified player isn't SCP-173."
24+
];
25+
26+
public override Argument[] ExpectedArguments { get; } =
27+
[
28+
new PlayerArgument("peanut")
29+
];
30+
31+
public override void Execute()
32+
{
33+
var pnut = Args.GetPlayer("peanut");
34+
35+
if (pnut.RoleBase is not Scp173Role pnutRole)
36+
throw new ScriptRuntimeError(this, ErrorReasons[0]);
37+
38+
ReturnValue = new PlayerValue(pnutRole.ObservingPlayers);
39+
}
40+
}

Code/MethodSystem/Methods/Scp079Methods/Set079AccessTierMethod.cs renamed to Code/MethodSystem/Methods/ScpMethods/Set079AccessTierMethod.cs

File renamed without changes.

Code/MethodSystem/Methods/Scp079Methods/Set079AuxPowerMethod.cs renamed to Code/MethodSystem/Methods/ScpMethods/Set079AuxPowerMethod.cs

File renamed without changes.

Code/MethodSystem/Methods/Scp079Methods/Set079ExpMethod.cs renamed to Code/MethodSystem/Methods/ScpMethods/Set079ExpMethod.cs

File renamed without changes.

Code/VariableSystem/VariableIndex.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using LabApi.Features.Wrappers;
22
using MapGeneration;
33
using PlayerRoles;
4+
using PlayerRoles.PlayableScps.Scp173;
45
using SER.Code.Helpers.Extensions;
56
using SER.Code.VariableSystem.Bases;
67
using SER.Code.VariableSystem.Variables;
@@ -20,7 +21,14 @@ public static void Initialize()
2021
new("all", Player.ReadyList.ToList, "Other"),
2122
new("alivePlayers", () => Player.ReadyList.Where(plr => plr.IsAlive).ToList(), "Other"),
2223
new("npcPlayers", () => Player.ReadyList.Where(plr => plr.IsNpc).ToList(), "Other"),
23-
new("empty", () => [], "Other")
24+
new("empty", () => [], "Other"),
25+
new("scp173Observers", () => Player.ReadyList
26+
.Select(plr => plr.RoleBase is Scp173Role peanut ? peanut.ObservingPlayers : null)
27+
.RemoveNulls()
28+
.Flatten()
29+
.ToList(),
30+
"SCP Specific")
31+
2432
];
2533

2634
allApiVariables.AddRange(

0 commit comments

Comments
 (0)