diff --git a/EXILED/Exiled.Events/Config.cs b/EXILED/Exiled.Events/Config.cs index 006be02b2..b141cd17e 100644 --- a/EXILED/Exiled.Events/Config.cs +++ b/EXILED/Exiled.Events/Config.cs @@ -80,6 +80,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 the SCP079 will recontained if there are no SCPs left. + /// + [Description("Indicates whether the SCP079 will recontained if there are no SCPs left.")] + public bool RecontainScp079IfNoScpsLeft { get; set; } = true; + /// /// Gets or sets a value indicating whether configs has to be reloaded every time a round restarts. /// @@ -90,7 +96,7 @@ public sealed class Config : IConfig /// Gets or sets a value indicating whether translations has to be reloaded every time a round restarts. /// [Description("Indicates whether translations has to be reloaded every round restart")] - public bool ShouldReloadTranslationsAtRoundRestart { get; set; } + public bool ShouldReloadTranslationsAtRoundRestart { get; set; } = false; /// /// Gets a value indicating whether bans should be logged or not. diff --git a/EXILED/Exiled.Events/Patches/Events/Player/ActivatingWorkstation.cs b/EXILED/Exiled.Events/Patches/Events/Player/ActivatingWorkstation.cs index 4ee58f8ec..28edd3803 100644 --- a/EXILED/Exiled.Events/Patches/Events/Player/ActivatingWorkstation.cs +++ b/EXILED/Exiled.Events/Patches/Events/Player/ActivatingWorkstation.cs @@ -78,7 +78,7 @@ private static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable +// Copyright (c) Exiled Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.Patches.Generic.Scp079API +{ + using System.Collections.Generic; + using System.Reflection.Emit; + + using API.Features.Pools; + + using HarmonyLib; + + using PlayerRoles.PlayableScps.Scp079; + + using static HarmonyLib.AccessTools; + + /// + /// Patches . + /// Adds the support. + /// + [HarmonyPatch(typeof(Scp079Recontainer), nameof(Scp079Recontainer.OnServerRoleChanged))] + internal class Scp079Recontain + { + private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) + { + List newInstructions = ListPool.Pool.Get(instructions); + + Label ret = generator.DefineLabel(); + + newInstructions.InsertRange( + 0, + new[] + { + // if (!Events.Instance.Config.ShouldScp079RecontainedWhenNoScps) + // return; + new CodeInstruction(OpCodes.Call, PropertyGetter(typeof(Exiled.Events.Events), nameof(Exiled.Events.Events.Instance))), + new(OpCodes.Callvirt, PropertyGetter(typeof(Exiled.Events.Events), nameof(Exiled.Events.Events.Config))), + new(OpCodes.Callvirt, PropertyGetter(typeof(Exiled.Events.Config), nameof(Exiled.Events.Config.RecontainScp079IfNoScpsLeft))), + new(OpCodes.Brfalse_S, ret), + }); + + newInstructions[newInstructions.Count - 1].labels.Add(ret); + + for (int z = 0; z < newInstructions.Count; z++) + yield return newInstructions[z]; + + ListPool.Pool.Return(newInstructions); + } + } +} \ No newline at end of file