From e6a30a9c60b3d054dd07ef358ca24ef97ca308f7 Mon Sep 17 00:00:00 2001
From: Undid-Iridium <24619207+Undid-Iridium@users.noreply.github.com>
Date: Fri, 30 May 2025 23:54:59 -0400
Subject: [PATCH 1/5] Escaping change
---
.../EventArgs/Player/EscapingEventArgs.cs | 6 +++++
.../Events/Player/EscapingAndEscaped.cs | 26 ++++++++++++++++---
2 files changed, 29 insertions(+), 3 deletions(-)
diff --git a/EXILED/Exiled.Events/EventArgs/Player/EscapingEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Player/EscapingEventArgs.cs
index 4a4fa0dcba..184776cd0b 100644
--- a/EXILED/Exiled.Events/EventArgs/Player/EscapingEventArgs.cs
+++ b/EXILED/Exiled.Events/EventArgs/Player/EscapingEventArgs.cs
@@ -40,8 +40,14 @@ public EscapingEventArgs(ReferenceHub referenceHub, RoleTypeId newRole, EscapeSc
NewRole = newRole;
EscapeScenario = escapeScenario;
IsAllowed = escapeScenario is not EscapeScenario.None and not EscapeScenario.CustomEscape;
+ Defer = false;
}
+ ///
+ /// Gets or sets a value indicating whether to defer to PluginAPI answer or only use Exiled answer. True (Plugin API call is allowed (Ignores IsAllowed)), False (Instant return, doesn't call Plugin API).
+ ///
+ public bool Defer { get; set; }
+
///
/// Gets the player who's escaping.
///
diff --git a/EXILED/Exiled.Events/Patches/Events/Player/EscapingAndEscaped.cs b/EXILED/Exiled.Events/Patches/Events/Player/EscapingAndEscaped.cs
index 72bade7906..3c6f508249 100644
--- a/EXILED/Exiled.Events/Patches/Events/Player/EscapingAndEscaped.cs
+++ b/EXILED/Exiled.Events/Patches/Events/Player/EscapingAndEscaped.cs
@@ -11,6 +11,7 @@ namespace Exiled.Events.Patches.Events.Player
#pragma warning disable IDE0060
using System.Collections.Generic;
+ using System.Reflection;
using System.Reflection.Emit;
using API.Enums;
@@ -19,7 +20,12 @@ namespace Exiled.Events.Patches.Events.Player
using EventArgs.Player;
using Exiled.API.Features.Roles;
using Exiled.Events.Attributes;
+
+ using global::Scp914;
+
using HarmonyLib;
+
+ using PlayerRoles;
using PlayerRoles.FirstPersonControl;
using static HarmonyLib.AccessTools;
@@ -37,13 +43,20 @@ private static IEnumerable Transpiler(IEnumerable newInstructions = ListPool.Pool.Get(instructions);
Label returnLabel = generator.DefineLabel();
+ Label continuePluginApiCode = generator.DefineLabel();
LocalBuilder ev = generator.DeclareLocal(typeof(EscapingEventArgs));
LocalBuilder role = generator.DeclareLocal(typeof(Role));
+ ConstructorInfo plugin_api_constructor = typeof(LabApi.Events.Arguments.PlayerEvents.PlayerEscapingEventArgs)
+ .GetConstructor(new[]
+ {
+ typeof(ReferenceHub),
+ typeof(RoleTypeId),
+ typeof(Escape.EscapeScenarioType),
+ });
int offset = -3;
- int index = newInstructions.FindIndex(instruction => instruction.opcode == OpCodes.Newobj) + offset;
-
+ int index = newInstructions.FindIndex(instruction => instruction.Is(OpCodes.Newobj, plugin_api_constructor)) + offset;
newInstructions.InsertRange(
index,
new[]
@@ -61,18 +74,25 @@ private static IEnumerable Transpiler(IEnumerable
Date: Sat, 31 May 2025 00:00:41 -0400
Subject: [PATCH 2/5] CustomEscapes
---
EXILED/Exiled.Events/Config.cs | 6 ++++++
.../Exiled.Events/EventArgs/Player/EscapingEventArgs.cs | 8 +-------
.../Patches/Events/Player/EscapingAndEscaped.cs | 9 +--------
3 files changed, 8 insertions(+), 15 deletions(-)
diff --git a/EXILED/Exiled.Events/Config.cs b/EXILED/Exiled.Events/Config.cs
index fd244f699b..021f5ef494 100644
--- a/EXILED/Exiled.Events/Config.cs
+++ b/EXILED/Exiled.Events/Config.cs
@@ -81,6 +81,12 @@ public sealed class Config : IConfig
[Description("Indicates whether thrown keycards can affect doors that don't require any permissions")]
public bool CanKeycardThrowAffectDoors { get; set; } = false;
+ ///
+ /// Gets or sets a value indicating whether custom escapes are allowed (Default false).
+ ///
+ [Description("Indicates whether custom escapes are allowed (Default false)")]
+ public bool AllowCustomEscapes { get; set; } = false;
+
///
/// Gets or sets a value indicating whether the SCP079 will recontained if there are no SCPs left.
///
diff --git a/EXILED/Exiled.Events/EventArgs/Player/EscapingEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Player/EscapingEventArgs.cs
index 184776cd0b..38b86390da 100644
--- a/EXILED/Exiled.Events/EventArgs/Player/EscapingEventArgs.cs
+++ b/EXILED/Exiled.Events/EventArgs/Player/EscapingEventArgs.cs
@@ -39,15 +39,9 @@ public EscapingEventArgs(ReferenceHub referenceHub, RoleTypeId newRole, EscapeSc
Player = Player.Get(referenceHub);
NewRole = newRole;
EscapeScenario = escapeScenario;
- IsAllowed = escapeScenario is not EscapeScenario.None and not EscapeScenario.CustomEscape;
- Defer = false;
+ IsAllowed = (escapeScenario is not EscapeScenario.None and not EscapeScenario.CustomEscape) || Events.Instance.Config.AllowCustomEscapes;
}
- ///
- /// Gets or sets a value indicating whether to defer to PluginAPI answer or only use Exiled answer. True (Plugin API call is allowed (Ignores IsAllowed)), False (Instant return, doesn't call Plugin API).
- ///
- public bool Defer { get; set; }
-
///
/// Gets the player who's escaping.
///
diff --git a/EXILED/Exiled.Events/Patches/Events/Player/EscapingAndEscaped.cs b/EXILED/Exiled.Events/Patches/Events/Player/EscapingAndEscaped.cs
index 3c6f508249..bb968f6a97 100644
--- a/EXILED/Exiled.Events/Patches/Events/Player/EscapingAndEscaped.cs
+++ b/EXILED/Exiled.Events/Patches/Events/Player/EscapingAndEscaped.cs
@@ -43,7 +43,6 @@ private static IEnumerable Transpiler(IEnumerable newInstructions = ListPool.Pool.Get(instructions);
Label returnLabel = generator.DefineLabel();
- Label continuePluginApiCode = generator.DefineLabel();
LocalBuilder ev = generator.DeclareLocal(typeof(EscapingEventArgs));
LocalBuilder role = generator.DeclareLocal(typeof(Role));
@@ -80,19 +79,13 @@ private static IEnumerable Transpiler(IEnumerable
Date: Sat, 31 May 2025 00:01:06 -0400
Subject: [PATCH 3/5] .
---
.../Exiled.Events/Patches/Events/Player/EscapingAndEscaped.cs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/EXILED/Exiled.Events/Patches/Events/Player/EscapingAndEscaped.cs b/EXILED/Exiled.Events/Patches/Events/Player/EscapingAndEscaped.cs
index bb968f6a97..ef05e78162 100644
--- a/EXILED/Exiled.Events/Patches/Events/Player/EscapingAndEscaped.cs
+++ b/EXILED/Exiled.Events/Patches/Events/Player/EscapingAndEscaped.cs
@@ -47,7 +47,7 @@ private static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable instruction.Is(OpCodes.Newobj, plugin_api_constructor)) + offset;
+ int index = newInstructions.FindIndex(instruction => instruction.Is(OpCodes.Newobj, pluginAPIConstructor)) + offset;
newInstructions.InsertRange(
index,
new[]
From 2bd130285c58617a6a40626de44d3c906fcbedc9 Mon Sep 17 00:00:00 2001
From: Undid-Iridium <24619207+Undid-Iridium@users.noreply.github.com>
Date: Sat, 31 May 2025 00:02:10 -0400
Subject: [PATCH 4/5] .
---
EXILED/Exiled.Events/Patches/Events/Player/EscapingAndEscaped.cs | 1 -
1 file changed, 1 deletion(-)
diff --git a/EXILED/Exiled.Events/Patches/Events/Player/EscapingAndEscaped.cs b/EXILED/Exiled.Events/Patches/Events/Player/EscapingAndEscaped.cs
index ef05e78162..adbee5c5c8 100644
--- a/EXILED/Exiled.Events/Patches/Events/Player/EscapingAndEscaped.cs
+++ b/EXILED/Exiled.Events/Patches/Events/Player/EscapingAndEscaped.cs
@@ -73,7 +73,6 @@ private static IEnumerable Transpiler(IEnumerable
Date: Sat, 31 May 2025 00:03:17 -0400
Subject: [PATCH 5/5] .
---
.../Exiled.Events/Patches/Events/Player/EscapingAndEscaped.cs | 4 ----
1 file changed, 4 deletions(-)
diff --git a/EXILED/Exiled.Events/Patches/Events/Player/EscapingAndEscaped.cs b/EXILED/Exiled.Events/Patches/Events/Player/EscapingAndEscaped.cs
index adbee5c5c8..bc245bf9ca 100644
--- a/EXILED/Exiled.Events/Patches/Events/Player/EscapingAndEscaped.cs
+++ b/EXILED/Exiled.Events/Patches/Events/Player/EscapingAndEscaped.cs
@@ -14,19 +14,15 @@ namespace Exiled.Events.Patches.Events.Player
using System.Reflection;
using System.Reflection.Emit;
- using API.Enums;
using API.Features;
using API.Features.Pools;
using EventArgs.Player;
using Exiled.API.Features.Roles;
using Exiled.Events.Attributes;
- using global::Scp914;
-
using HarmonyLib;
using PlayerRoles;
- using PlayerRoles.FirstPersonControl;
using static HarmonyLib.AccessTools;