diff --git a/Exiled.Events/EventArgs/Scp049/FindingTargetEventArgs.cs b/Exiled.Events/EventArgs/Scp049/FindingTargetEventArgs.cs deleted file mode 100644 index f4bef1f217..0000000000 --- a/Exiled.Events/EventArgs/Scp049/FindingTargetEventArgs.cs +++ /dev/null @@ -1,49 +0,0 @@ -// ----------------------------------------------------------------------- -// -// Copyright (c) Exiled Team. All rights reserved. -// Licensed under the CC BY-SA 3.0 license. -// -// ----------------------------------------------------------------------- - -namespace Exiled.Events.EventArgs.Scp049 -{ - using Exiled.API.Features; - using Exiled.API.Features.Roles; - using Exiled.Events.EventArgs.Interfaces; - - /// - /// Contains all information before SCP-049 find a target to activate good sense of the doctor. - /// - public class FindingTargetEventArgs : IScp049Event, IDeniableEvent - { - /// - /// Initializes a new instance of the class. - /// - /// - /// - public FindingTargetEventArgs(Player player, Player target) - { - Player = player; - Scp049 = player.Role.As(); - Target = target; - } - - /// - public Scp049Role Scp049 { get; } - - /// - /// Gets the player who is playing as SCP-049. - /// - public Player Player { get; } - - /// - /// Gets the player who will be affected by the sense ability. - /// - public Player Target { get; } - - /// - /// Gets or sets a value indicating whether or not the target can be affected. - /// - public bool IsAllowed { get; set; } = true; - } -} \ No newline at end of file diff --git a/Exiled.Events/Handlers/Scp049.cs b/Exiled.Events/Handlers/Scp049.cs index dbe35a8ca7..62f4766dce 100644 --- a/Exiled.Events/Handlers/Scp049.cs +++ b/Exiled.Events/Handlers/Scp049.cs @@ -27,11 +27,6 @@ public static class Scp049 /// public static Event StartingRecall { get; set; } = new(); - /// - /// Invoked before SCP-049 find a target to activate good sense of the doctor. - /// - public static Event FindingTarget { get; set; } = new(); - /// /// Invoked before SCP-049 uses the good sense of the doctor ability. /// @@ -59,12 +54,6 @@ public static class Scp049 /// The instance. public static void OnStartingRecall(StartingRecallEventArgs ev) => StartingRecall.InvokeSafely(ev); - /// - /// Called before SCP-049 finds a target to activate good sense of the doctor. - /// - /// The instance. - public static void OnFindingTarget(FindingTargetEventArgs ev) => FindingTarget.InvokeSafely(ev); - /// /// Called before SCP-049 starts the good sense of the doctor ability. /// diff --git a/Exiled.Events/Patches/Events/Scp049/FindingTarget.cs b/Exiled.Events/Patches/Events/Scp049/FindingTarget.cs deleted file mode 100644 index 95f4953b13..0000000000 --- a/Exiled.Events/Patches/Events/Scp049/FindingTarget.cs +++ /dev/null @@ -1,68 +0,0 @@ -// ----------------------------------------------------------------------- -// -// Copyright (c) Exiled Team. All rights reserved. -// Licensed under the CC BY-SA 3.0 license. -// -// ----------------------------------------------------------------------- - -namespace Exiled.Events.Patches.Events.Scp049 -{ - using System.Collections.Generic; - using System.Reflection.Emit; - - using Exiled.API.Features.Core.Generic.Pools; - using Exiled.Events.Attributes; - using Exiled.Events.EventArgs.Scp049; - using Exiled.Events.Handlers; - using HarmonyLib; - using PlayerRoles.PlayableScps.Scp049; - - using static HarmonyLib.AccessTools; - - /// - /// Patches - /// to add event. - /// - [EventPatch(typeof(Scp049), nameof(Scp049.FindingTarget))] - [HarmonyPatch(typeof(Scp049SenseAbility), nameof(Scp049SenseAbility.CanFindTarget))] - internal class FindingTarget - { - private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) - { - List newInstructions = ListPool.Pool.Get(instructions); - - int index = newInstructions.FindLastIndex(i => i.Calls(Method(typeof(HashSet.Enumerator), nameof(HashSet.Enumerator.MoveNext)))); - Label continueLabel = newInstructions[index - 1].labels[0]; - - index = newInstructions.FindLastIndex(i => i.opcode == OpCodes.Ldloc_S && i.operand is byte and 12); - - newInstructions.InsertRange(index, new CodeInstruction[] - { - // player - new(OpCodes.Ldarg_0), - new(OpCodes.Call, PropertyGetter(typeof(Scp049SenseAbility), nameof(Scp049SenseAbility.Owner))), - - // target - new(OpCodes.Ldloc_S, 6), - new(OpCodes.Call, Method(typeof(API.Features.Player), nameof(API.Features.Player.Get), new[] { typeof(ReferenceHub) })), - - // FindingTargetEventArgs ev = new(player, target) - new(OpCodes.Newobj, GetDeclaredConstructors(typeof(FindingTargetEventArgs))[0]), - new(OpCodes.Dup), - - // Handlers.Scp049.OnFindingTarget(ev) - new(OpCodes.Call, Method(typeof(Handlers.Scp049), nameof(Handlers.Scp049.OnFindingTarget))), - - // if (!ev.IsAllowed) - // continue; - new(OpCodes.Callvirt, PropertyGetter(typeof(FindingTargetEventArgs), nameof(FindingTargetEventArgs.IsAllowed))), - new(OpCodes.Brfalse_S, continueLabel), - }); - - for (int z = 0; z < newInstructions.Count; z++) - yield return newInstructions[z]; - - ListPool.Pool.Return(newInstructions); - } - } -} \ No newline at end of file