Skip to content
This repository was archived by the owner on Jul 8, 2025. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions EXILED/Exiled.Events/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/// <summary>
/// Gets or sets a value indicating whether custom escapes are allowed (Default false).
/// </summary>
[Description("Indicates whether custom escapes are allowed (Default false)")]
public bool AllowCustomEscapes { get; set; } = false;

/// <summary>
/// Gets or sets a value indicating whether the SCP079 will recontained if there are no SCPs left.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion EXILED/Exiled.Events/EventArgs/Player/EscapingEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ 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;
IsAllowed = (escapeScenario is not EscapeScenario.None and not EscapeScenario.CustomEscape) || Events.Instance.Config.AllowCustomEscapes;
}

/// <summary>
Expand Down
18 changes: 13 additions & 5 deletions EXILED/Exiled.Events/Patches/Events/Player/EscapingAndEscaped.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,18 @@ namespace Exiled.Events.Patches.Events.Player
#pragma warning disable IDE0060

using System.Collections.Generic;
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 HarmonyLib;
using PlayerRoles.FirstPersonControl;

using PlayerRoles;

using static HarmonyLib.AccessTools;

Expand All @@ -41,9 +43,15 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
LocalBuilder ev = generator.DeclareLocal(typeof(EscapingEventArgs));
LocalBuilder role = generator.DeclareLocal(typeof(Role));

ConstructorInfo pluginAPIConstructor = 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, pluginAPIConstructor)) + offset;
newInstructions.InsertRange(
index,
new[]
Expand Down Expand Up @@ -72,7 +80,7 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
new(OpCodes.Brfalse, returnLabel),

// roleTypeId = ev.NewRole
new(OpCodes.Ldloc, ev.LocalIndex),
new CodeInstruction(OpCodes.Ldloc, ev.LocalIndex),
new(OpCodes.Callvirt, PropertyGetter(typeof(EscapingEventArgs), nameof(EscapingEventArgs.NewRole))),
new(OpCodes.Stloc_1),

Expand Down
Loading