Skip to content

Commit d45939d

Browse files
2 parents d1f15de + b03cb1c commit d45939d

File tree

19 files changed

+159
-20
lines changed

19 files changed

+159
-20
lines changed

Code/ContextSystem/Contexter.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ List<Context> contexts
7979
}
8080

8181
var currentStatement = statementStack.FirstOrDefault();
82+
string error;
8283
if (context is StatementContext treeExtenderContext and IStatementExtender treeExtenderInfo)
8384
{
8485
if (currentStatement is null)
@@ -99,10 +100,10 @@ List<Context> contexts
99100
extendable.RegisteredSignals[treeExtenderInfo.Extends] = treeExtenderContext.Run;
100101
statementStack.Pop();
101102
statementStack.Push(treeExtenderContext);
102-
return true;
103+
return context.VerifyCurrentState().HasErrored(out error) ? rs + error : true;
103104
}
104105

105-
if (context.VerifyCurrentState().HasErrored(out var error))
106+
if (context.VerifyCurrentState().HasErrored(out error))
106107
return rs + error;
107108

108109
if (currentStatement is not null)

Code/EventSystem/EventHandler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ private static void OnNonArgumentedEvent(string evName)
145145
continue;
146146
}
147147

148-
script.Run();
148+
script.Run(RunContext.Event);
149149
}
150150
}
151151

@@ -179,7 +179,7 @@ private static void OnArgumentedEvent<T>(string evName, T ev) where T : EventArg
179179
}
180180

181181
script.AddVariables(variables);
182-
var isAllowed = script.RunForEvent();
182+
var isAllowed = script.RunForEvent(RunContext.Event);
183183
if (isAllowed.HasValue && ev is ICancellableEvent cancellable1)
184184
cancellable1.IsAllowed = isAllowed.Value;
185185
}

Code/FlagSystem/Flags/CustomCommandFlag.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ public static Result RunAttachedScript(CustomCommand requestingCommand, ScriptEx
222222
script.AddVariable(new LiteralVariable<TextValue>(name, slice.Value));
223223
}
224224

225-
script.Run();
225+
script.Run(RunContext.Command);
226226
return true;
227227
}
228228

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
}

Code/MethodSystem/Methods/IntercomMethods/IntercomInfoMethod.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using PlayerRoles.Voice;
44
using SER.Code.ArgumentSystem.Arguments;
55
using SER.Code.ArgumentSystem.BaseArguments;
6+
using SER.Code.ArgumentSystem.Structures;
67
using SER.Code.Helpers.Exceptions;
78
using SER.Code.MethodSystem.BaseMethods;
89
using SER.Code.ValueSystem;
@@ -17,7 +18,7 @@ public class IntercomInfoMethod : ReturningMethod
1718
public override Argument[] ExpectedArguments { get; } =
1819
[
1920
new OptionsArgument("mode",
20-
"state",
21+
Option.Enum<IntercomState>("state"),
2122
"speaker",
2223
"cooldown",
2324
"speechTimeLeft",
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/MethodSystem/Methods/ScriptMethods/RunFuncMethod.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using SER.Code.Helpers.Extensions;
88
using SER.Code.MethodSystem.BaseMethods;
99
using SER.Code.MethodSystem.MethodDescriptors;
10+
using SER.Code.ScriptSystem;
1011
using SER.Code.ValueSystem;
1112
using SER.Code.VariableSystem.Bases;
1213

@@ -82,6 +83,6 @@ public override void Execute()
8283
scriptToRun.AddVariable(variable);
8384
}
8485

85-
scriptToRun.Run();
86+
scriptToRun.Run(RunContext.Script, Script);
8687
}
8788
}

0 commit comments

Comments
 (0)