From ac2da605ed3cd2b61a2a1b5cc3c64c764e306ab4 Mon Sep 17 00:00:00 2001 From: MS-crew <100300664+MS-crew@users.noreply.github.com> Date: Thu, 22 Jan 2026 23:48:20 +0300 Subject: [PATCH 1/7] Add CustomGoggles class for custom SCP-1344 --- .../API/Features/CustomGoggles.cs | 182 ++++++++++++++++++ 1 file changed, 182 insertions(+) create mode 100644 EXILED/Exiled.CustomItems/API/Features/CustomGoggles.cs diff --git a/EXILED/Exiled.CustomItems/API/Features/CustomGoggles.cs b/EXILED/Exiled.CustomItems/API/Features/CustomGoggles.cs new file mode 100644 index 000000000..115d768ae --- /dev/null +++ b/EXILED/Exiled.CustomItems/API/Features/CustomGoggles.cs @@ -0,0 +1,182 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) ExMod Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.CustomItems.API.Features +{ + using Exiled.API.Enums; + using Exiled.API.Features; + using Exiled.API.Features.Items; + using Exiled.CustomItems.API.EventArgs; + using Exiled.Events.EventArgs.Player; + using Exiled.Events.EventArgs.Scp1344; + + using InventorySystem.Items.Usables.Scp1344; + + using PlayerRoles.FirstPersonControl.Thirdperson.Subcontrollers.Wearables; + + /// + /// The Custom Goggles base class. + /// + public abstract class CustomGoggles : CustomItem + { + /// + /// Gets or sets the to use for this goggles. + /// This is locked to . + /// + public override ItemType Type + { + get => ItemType.SCP1344; + set + { + base.Type = ItemType.SCP1344; + } + } + + /// + /// Gets or sets the duration, in seconds, that the item has been worn. + /// + public virtual float WearingTime { get; set; } = Scp1344Item.ActivationTime; + + /// + /// Gets or sets the time, in seconds, required to remove the item. + /// + public virtual float RemovingTime { get; set; } = Scp1344Item.DeactivationTime; + + /// + /// Gets or sets a value indicating whether the default SCP-1344 effect should be removed when wearing the goggles. + /// + public virtual bool Remove1344Effect { get; set; } = true; + + /// + /// Gets or sets a value indicating whether the glasses can be safely removed without bad effects. + /// + public virtual bool CanBeRemoveSafely { get; set; } = true; + + /// + protected override void SubscribeEvents() + { + Exiled.Events.Handlers.Player.ItemRemoved += OnInternalItemRemoved; + Exiled.Events.Handlers.Scp1344.ChangedStatus += OnInternalChangedStatus; + Exiled.Events.Handlers.Scp1344.ChangingStatus += OnInternalChangingStatus; + base.SubscribeEvents(); + } + + /// + protected override void UnsubscribeEvents() + { + Exiled.Events.Handlers.Player.ItemRemoved -= OnInternalItemRemoved; + Exiled.Events.Handlers.Scp1344.ChangedStatus -= OnInternalChangedStatus; + Exiled.Events.Handlers.Scp1344.ChangingStatus -= OnInternalChangingStatus; + base.UnsubscribeEvents(); + } + + /// + protected override void OnOwnerChangingRole(OwnerChangingRoleEventArgs ev) + { + if (Item.Get(ev.Item) is not Scp1344 scp1344) + return; + + if (!scp1344.IsWorn) + return; + + InternalRemove(ev.Player, scp1344); + } + + /// + /// Called when the player equips the goggles. + /// + /// The player who equipped the goggles. + /// The item being worn. + protected virtual void OnWornGoggles(Player player, Scp1344 goggles) + { + } + + /// + /// Called when the player removes the goggles. + /// + /// The player who removed the goggles. + /// The item being removed. + protected virtual void OnRemovedGoggles(Player player, Scp1344 goggles) + { + } + + private void OnInternalChangedStatus(ChangedStatusEventArgs ev) + { + Log.Warn(ev.Scp1344Status); + + if (!Check(ev.Item)) + return; + + switch (ev.Scp1344Status) + { + case Scp1344Status.Deactivating: + ev.Scp1344.Base._useTime = Scp1344Item.DeactivationTime - RemovingTime; + break; + + case Scp1344Status.Activating: + ev.Scp1344.Base._useTime = Scp1344Item.ActivationTime - WearingTime; + break; + + case Scp1344Status.Active: + InternalEquip(ev.Player, ev.Scp1344); + break; + + default: + break; + } + } + + private void InternalEquip(Player player, Scp1344 goggles) + { + if (Remove1344Effect) + { + player.DisableEffect(EffectType.Scp1344); + player.ReferenceHub.EnableWearables(WearableElements.Scp1344Goggles); + } + + OnWornGoggles(player, goggles); + } + + private void InternalRemove(Player player, Scp1344 goggles) + { + if (!Remove1344Effect) + player.DisableEffect(EffectType.Scp1344); + + if (CanBeRemoveSafely) + { + player.DisableEffect(EffectType.Blinded); + player.ReferenceHub?.DisableWearables(WearableElements.Scp1344Goggles); + } + + player.CurrentItem = null; + + OnRemovedGoggles(player, goggles); + } + + private void OnInternalItemRemoved(ItemRemovedEventArgs ev) + { + if (!Check(ev.Item)) + return; + + if (ev.Item is not Scp1344 scp1344 || !scp1344.IsWorn) + return; + + InternalRemove(ev.Player, scp1344); + } + + private void OnInternalChangingStatus(ChangingStatusEventArgs ev) + { + if (!Check(ev.Item)) + return; + + if (ev.Scp1344StatusOld != Scp1344Status.Deactivating || ev.Scp1344StatusNew != Scp1344Status.Idle) + return; + + InternalRemove(ev.Player, ev.Scp1344); + } + } +} From ab0c88e132a9ea0af0e27e3ec187a7d0c6a3c15b Mon Sep 17 00:00:00 2001 From: MS-crew <100300664+MS-crew@users.noreply.github.com> Date: Thu, 22 Jan 2026 23:49:17 +0300 Subject: [PATCH 2/7] Create CustomGogglesPathcs.cs --- .../Patches/CustomGogglesPathcs.cs | 107 ++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 EXILED/Exiled.CustomItems/Patches/CustomGogglesPathcs.cs diff --git a/EXILED/Exiled.CustomItems/Patches/CustomGogglesPathcs.cs b/EXILED/Exiled.CustomItems/Patches/CustomGogglesPathcs.cs new file mode 100644 index 000000000..8e84feb98 --- /dev/null +++ b/EXILED/Exiled.CustomItems/Patches/CustomGogglesPathcs.cs @@ -0,0 +1,107 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) ExMod Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- +#pragma warning disable SA1649 +#pragma warning disable SA1313 +#pragma warning disable SA1402 +namespace Exiled.CustomItems.Patches +{ + using Exiled.API.Features.Items; + using Exiled.CustomItems.API.Features; + + using HarmonyLib; + + using InventorySystem.Items; + using InventorySystem.Items.Pickups; + using InventorySystem.Items.Usables.Scp1344; + + /// + /// Patches the property to prevent players from equipping multiple SCP-1344 instances simultaneously. + /// + [HarmonyPatch(typeof(Scp1344Item), nameof(Scp1344Item.CanStartUsing), MethodType.Getter)] + public class CanStartUsingPatch + { + private static void Postfix(Scp1344Item __instance, ref bool __result) + { + if (!__result) + return; + + foreach (ItemBase item in __instance.OwnerInventory.UserInventory.Items.Values) + { + if (item.ItemTypeId != ItemType.SCP1344) + continue; + + if (item is not Scp1344Item scp1344) + continue; + + if (!scp1344.IsWorn) + continue; + + __result = false; + break; + } + } + } + + /// + /// Patches the method to prevent negative effects (blindness/severed eyes) when removing if safe removal is enabled. + /// + [HarmonyPatch(typeof(Scp1344Item), nameof(Scp1344Item.ActivateFinalEffects))] + public class ActivateFinalEffectsPatch + { + private static bool Prefix(Scp1344Item __instance) + { + if (!CustomItem.TryGet(Item.Get(__instance), out CustomItem? customItem)) + return true; + + if (customItem is not CustomGoggles customGoggles) + return true; + + if (!customGoggles.CanBeRemoveSafely) + return true; + + return false; + } + } + + /// + /// Patches the method to prevent the item from being dropped when the deactivation animation finishes, keeping it in the inventory instead. + /// + [HarmonyPatch(typeof(Scp1344Item), nameof(Scp1344Item.ServerDropItem))] + public class ServerDropItemPatch + { + private static bool Prefix(Scp1344Item __instance, bool spawn, ref ItemPickupBase __result) + { + if (!spawn) + return true; + + if (__instance.Status == Scp1344Status.Active) + return true; + + if (!__instance.IsWorn) + return true; + + if (!CustomItem.TryGet(Item.Get(__instance), out CustomItem? customItem)) + return true; + + if (customItem is not CustomGoggles customGoggles) + return true; + + if (!customGoggles.CanBeRemoveSafely) + return true; + + __instance.Status = Scp1344Status.Idle; + __instance._useTime = 0f; + __instance._savedIntensity = 0; + __instance._cancelationTime = 0f; + __instance.OwnerInventory.ServerSelectItem(0); + return false; + } + } +} +#pragma warning restore SA1402 +#pragma warning disable SA1313 +#pragma warning restore SA1649 From a925682dd76803abee2be3d27c38e47e030eb231 Mon Sep 17 00:00:00 2001 From: MS-crew <100300664+MS-crew@users.noreply.github.com> Date: Thu, 22 Jan 2026 23:56:10 +0300 Subject: [PATCH 3/7] oh shit --- EXILED/Exiled.CustomItems/API/Features/CustomGoggles.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/EXILED/Exiled.CustomItems/API/Features/CustomGoggles.cs b/EXILED/Exiled.CustomItems/API/Features/CustomGoggles.cs index 115d768ae..62961d373 100644 --- a/EXILED/Exiled.CustomItems/API/Features/CustomGoggles.cs +++ b/EXILED/Exiled.CustomItems/API/Features/CustomGoggles.cs @@ -106,8 +106,6 @@ protected virtual void OnRemovedGoggles(Player player, Scp1344 goggles) private void OnInternalChangedStatus(ChangedStatusEventArgs ev) { - Log.Warn(ev.Scp1344Status); - if (!Check(ev.Item)) return; From caf34d873d63ec7db9af15cf5105c8f86a609353 Mon Sep 17 00:00:00 2001 From: MS-crew <100300664+MS-crew@users.noreply.github.com> Date: Thu, 22 Jan 2026 23:58:16 +0300 Subject: [PATCH 4/7] shit forgot Removed setting CurrentItem to null when goggles are removed. --- EXILED/Exiled.CustomItems/API/Features/CustomGoggles.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/EXILED/Exiled.CustomItems/API/Features/CustomGoggles.cs b/EXILED/Exiled.CustomItems/API/Features/CustomGoggles.cs index 62961d373..1e194adb4 100644 --- a/EXILED/Exiled.CustomItems/API/Features/CustomGoggles.cs +++ b/EXILED/Exiled.CustomItems/API/Features/CustomGoggles.cs @@ -150,8 +150,6 @@ private void InternalRemove(Player player, Scp1344 goggles) player.ReferenceHub?.DisableWearables(WearableElements.Scp1344Goggles); } - player.CurrentItem = null; - OnRemovedGoggles(player, goggles); } From 09fe60819a59b6f826513dffa3fe27f901ae7249 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mustafa=20SAVA=C5=9E?= Date: Fri, 23 Jan 2026 16:20:40 +0300 Subject: [PATCH 5/7] Update --- .../API/Features/CustomGoggles.cs | 37 ++++++ .../Patches/CustomGogglesPathcs.cs | 107 ------------------ .../Scp1344/DeactivatingEventArgs.cs | 10 +- .../Patches/Events/Scp1344/Deactivating.cs | 30 +++-- 4 files changed, 68 insertions(+), 116 deletions(-) delete mode 100644 EXILED/Exiled.CustomItems/Patches/CustomGogglesPathcs.cs diff --git a/EXILED/Exiled.CustomItems/API/Features/CustomGoggles.cs b/EXILED/Exiled.CustomItems/API/Features/CustomGoggles.cs index 1e194adb4..97664f797 100644 --- a/EXILED/Exiled.CustomItems/API/Features/CustomGoggles.cs +++ b/EXILED/Exiled.CustomItems/API/Features/CustomGoggles.cs @@ -59,7 +59,9 @@ public override ItemType Type /// protected override void SubscribeEvents() { + Exiled.Events.Handlers.Player.UsingItem += OnInternalUsingItem; Exiled.Events.Handlers.Player.ItemRemoved += OnInternalItemRemoved; + Exiled.Events.Handlers.Scp1344.Deactivating += OnInternalDeactivating; Exiled.Events.Handlers.Scp1344.ChangedStatus += OnInternalChangedStatus; Exiled.Events.Handlers.Scp1344.ChangingStatus += OnInternalChangingStatus; base.SubscribeEvents(); @@ -68,7 +70,9 @@ protected override void SubscribeEvents() /// protected override void UnsubscribeEvents() { + Exiled.Events.Handlers.Player.UsingItem -= OnInternalUsingItem; Exiled.Events.Handlers.Player.ItemRemoved -= OnInternalItemRemoved; + Exiled.Events.Handlers.Scp1344.Deactivating -= OnInternalDeactivating; Exiled.Events.Handlers.Scp1344.ChangedStatus -= OnInternalChangedStatus; Exiled.Events.Handlers.Scp1344.ChangingStatus -= OnInternalChangingStatus; base.UnsubscribeEvents(); @@ -104,6 +108,39 @@ protected virtual void OnRemovedGoggles(Player player, Scp1344 goggles) { } + private void OnInternalDeactivating(DeactivatingEventArgs ev) + { + if (!Check(ev.Item)) + return; + + if (!CanBeRemoveSafely) + return; + + ev.NewStatus = Scp1344Status.Idle; + ev.IsAllowed = false; + } + + private void OnInternalUsingItem(UsingItemEventArgs ev) + { + if (ev.Item.Type != ItemType.SCP1344) + return; + + foreach (Item item in ev.Player.Items) + { + if (item.Type != ItemType.SCP1344) + continue; + + if (item is not Scp1344 scp1344) + continue; + + if (!scp1344.IsWorn) + continue; + + ev.IsAllowed = false; + break; + } + } + private void OnInternalChangedStatus(ChangedStatusEventArgs ev) { if (!Check(ev.Item)) diff --git a/EXILED/Exiled.CustomItems/Patches/CustomGogglesPathcs.cs b/EXILED/Exiled.CustomItems/Patches/CustomGogglesPathcs.cs deleted file mode 100644 index 8e84feb98..000000000 --- a/EXILED/Exiled.CustomItems/Patches/CustomGogglesPathcs.cs +++ /dev/null @@ -1,107 +0,0 @@ -// ----------------------------------------------------------------------- -// -// Copyright (c) ExMod Team. All rights reserved. -// Licensed under the CC BY-SA 3.0 license. -// -// ----------------------------------------------------------------------- -#pragma warning disable SA1649 -#pragma warning disable SA1313 -#pragma warning disable SA1402 -namespace Exiled.CustomItems.Patches -{ - using Exiled.API.Features.Items; - using Exiled.CustomItems.API.Features; - - using HarmonyLib; - - using InventorySystem.Items; - using InventorySystem.Items.Pickups; - using InventorySystem.Items.Usables.Scp1344; - - /// - /// Patches the property to prevent players from equipping multiple SCP-1344 instances simultaneously. - /// - [HarmonyPatch(typeof(Scp1344Item), nameof(Scp1344Item.CanStartUsing), MethodType.Getter)] - public class CanStartUsingPatch - { - private static void Postfix(Scp1344Item __instance, ref bool __result) - { - if (!__result) - return; - - foreach (ItemBase item in __instance.OwnerInventory.UserInventory.Items.Values) - { - if (item.ItemTypeId != ItemType.SCP1344) - continue; - - if (item is not Scp1344Item scp1344) - continue; - - if (!scp1344.IsWorn) - continue; - - __result = false; - break; - } - } - } - - /// - /// Patches the method to prevent negative effects (blindness/severed eyes) when removing if safe removal is enabled. - /// - [HarmonyPatch(typeof(Scp1344Item), nameof(Scp1344Item.ActivateFinalEffects))] - public class ActivateFinalEffectsPatch - { - private static bool Prefix(Scp1344Item __instance) - { - if (!CustomItem.TryGet(Item.Get(__instance), out CustomItem? customItem)) - return true; - - if (customItem is not CustomGoggles customGoggles) - return true; - - if (!customGoggles.CanBeRemoveSafely) - return true; - - return false; - } - } - - /// - /// Patches the method to prevent the item from being dropped when the deactivation animation finishes, keeping it in the inventory instead. - /// - [HarmonyPatch(typeof(Scp1344Item), nameof(Scp1344Item.ServerDropItem))] - public class ServerDropItemPatch - { - private static bool Prefix(Scp1344Item __instance, bool spawn, ref ItemPickupBase __result) - { - if (!spawn) - return true; - - if (__instance.Status == Scp1344Status.Active) - return true; - - if (!__instance.IsWorn) - return true; - - if (!CustomItem.TryGet(Item.Get(__instance), out CustomItem? customItem)) - return true; - - if (customItem is not CustomGoggles customGoggles) - return true; - - if (!customGoggles.CanBeRemoveSafely) - return true; - - __instance.Status = Scp1344Status.Idle; - __instance._useTime = 0f; - __instance._savedIntensity = 0; - __instance._cancelationTime = 0f; - __instance.OwnerInventory.ServerSelectItem(0); - return false; - } - } -} -#pragma warning restore SA1402 -#pragma warning disable SA1313 -#pragma warning restore SA1649 diff --git a/EXILED/Exiled.Events/EventArgs/Scp1344/DeactivatingEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Scp1344/DeactivatingEventArgs.cs index 96bcbc211..8ff103fa5 100644 --- a/EXILED/Exiled.Events/EventArgs/Scp1344/DeactivatingEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Scp1344/DeactivatingEventArgs.cs @@ -7,9 +7,12 @@ namespace Exiled.Events.EventArgs.Scp1344 { + using Exiled.API.Features; using Exiled.API.Features.Items; using Exiled.Events.EventArgs.Interfaces; + using InventorySystem.Items.Usables.Scp1344; + /// /// Contains all information before deactivating. /// @@ -36,13 +39,18 @@ public DeactivatingEventArgs(Item item, bool isAllowed = true) /// /// Gets the player in owner of the item. /// - public Exiled.API.Features.Player Player { get; } + public Player Player { get; } /// /// Gets Scp1344 item. /// public Scp1344 Scp1344 { get; } + /// + /// Gets or sets the status of the SCP-1344 after the deactivation process. + /// + public Scp1344Status NewStatus { get; set; } = Scp1344Status.Active; + /// public bool IsAllowed { get; set; } } diff --git a/EXILED/Exiled.Events/Patches/Events/Scp1344/Deactivating.cs b/EXILED/Exiled.Events/Patches/Events/Scp1344/Deactivating.cs index 9cf35fe60..4dae2f986 100644 --- a/EXILED/Exiled.Events/Patches/Events/Scp1344/Deactivating.cs +++ b/EXILED/Exiled.Events/Patches/Events/Scp1344/Deactivating.cs @@ -12,11 +12,16 @@ namespace Exiled.Events.Patches.Events.Scp1344 using Exiled.API.Features.Items; using Exiled.Events.Attributes; using Exiled.Events.EventArgs.Scp1344; + using HarmonyLib; + using InventorySystem.Items.Usables.Scp1344; using InventorySystem.Items.Usables.Scp244; + using UnityEngine; + using static PlayerList; + /// /// Patches . /// Adds the event, @@ -34,7 +39,7 @@ private static bool Prefix(ref Scp1344Item __instance) if (__instance._useTime == 0) { TryingDeactivatingEventArgs ev = new(Item.Get(__instance)); - Exiled.Events.Handlers.Scp1344.OnTryingDeactivating(ev); + Handlers.Scp1344.OnTryingDeactivating(ev); if (!ev.IsAllowed) { @@ -42,31 +47,40 @@ private static bool Prefix(ref Scp1344Item __instance) } } - if (__instance._useTime + Time.deltaTime >= 5.1f) + if (__instance._useTime + Time.deltaTime >= Scp1344Item.DeactivationTime) { DeactivatingEventArgs deactivating = new(Item.Get(__instance)); - Exiled.Events.Handlers.Scp1344.OnDeactivating(deactivating); + Handlers.Scp1344.OnDeactivating(deactivating); if (!deactivating.IsAllowed) { - return StopDeactivation(__instance); + return StopDeactivation(__instance, deactivating.NewStatus); } __instance.ActivateFinalEffects(); __instance.ServerDropItem(__instance); DeactivatedEventArgs ev = new(Item.Get(__instance)); - Exiled.Events.Handlers.Scp1344.OnDeactivated(ev); + Handlers.Scp1344.OnDeactivated(ev); return false; } return true; } - private static bool StopDeactivation(Scp1344Item instance) + private static bool StopDeactivation(Scp1344Item instance, Scp1344Status newStatus = Scp1344Status.Active) { - instance.Status = Scp1344Status.Active; - instance.ServerSetStatus(Scp1344Status.Active); + instance.Status = newStatus; + instance.ServerSetStatus(newStatus); + + if (newStatus == Scp1344Status.Idle) + { + instance._useTime = 0f; + instance._savedIntensity = 0; + instance._cancelationTime = 0f; + instance.OwnerInventory?.ServerSelectItem(0); + } + return false; } } From 19b998fb34fe7ac9ff19ca4350476a4e89c54ed8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mustafa=20SAVA=C5=9E?= Date: Fri, 23 Jan 2026 16:26:28 +0300 Subject: [PATCH 6/7] yamato update --- EXILED/Exiled.Events/Patches/Events/Scp1344/Deactivating.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/EXILED/Exiled.Events/Patches/Events/Scp1344/Deactivating.cs b/EXILED/Exiled.Events/Patches/Events/Scp1344/Deactivating.cs index 4dae2f986..ca0bbe8e3 100644 --- a/EXILED/Exiled.Events/Patches/Events/Scp1344/Deactivating.cs +++ b/EXILED/Exiled.Events/Patches/Events/Scp1344/Deactivating.cs @@ -43,7 +43,7 @@ private static bool Prefix(ref Scp1344Item __instance) if (!ev.IsAllowed) { - return StopDeactivation(__instance); + return StopDeactivation(__instance, Scp1344Status.Active); } } @@ -68,7 +68,7 @@ private static bool Prefix(ref Scp1344Item __instance) return true; } - private static bool StopDeactivation(Scp1344Item instance, Scp1344Status newStatus = Scp1344Status.Active) + private static bool StopDeactivation(Scp1344Item instance, Scp1344Status newStatus) { instance.Status = newStatus; instance.ServerSetStatus(newStatus); From 8b56f0382a994e16beef88e34bea1875ddc11c13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mustafa=20SAVA=C5=9E?= Date: Sat, 24 Jan 2026 13:31:44 +0300 Subject: [PATCH 7/7] rfdd ev isallowed chechks --- .../API/Features/CustomGoggles.cs | 54 +++++++++---------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/EXILED/Exiled.CustomItems/API/Features/CustomGoggles.cs b/EXILED/Exiled.CustomItems/API/Features/CustomGoggles.cs index 97664f797..769f5ad93 100644 --- a/EXILED/Exiled.CustomItems/API/Features/CustomGoggles.cs +++ b/EXILED/Exiled.CustomItems/API/Features/CustomGoggles.cs @@ -7,10 +7,10 @@ namespace Exiled.CustomItems.API.Features { + using EventArgs; using Exiled.API.Enums; using Exiled.API.Features; using Exiled.API.Features.Items; - using Exiled.CustomItems.API.EventArgs; using Exiled.Events.EventArgs.Player; using Exiled.Events.EventArgs.Scp1344; @@ -24,16 +24,13 @@ namespace Exiled.CustomItems.API.Features public abstract class CustomGoggles : CustomItem { /// - /// Gets or sets the to use for this goggles. + /// Gets or sets the to use for these goggles. /// This is locked to . /// public override ItemType Type { get => ItemType.SCP1344; - set - { - base.Type = ItemType.SCP1344; - } + set => base.Type = ItemType.SCP1344; } /// @@ -81,10 +78,10 @@ protected override void UnsubscribeEvents() /// protected override void OnOwnerChangingRole(OwnerChangingRoleEventArgs ev) { - if (Item.Get(ev.Item) is not Scp1344 scp1344) + if (!ev.IsAllowed) return; - if (!scp1344.IsWorn) + if (Item.Get(ev.Item) is not Scp1344 { IsWorn: true } scp1344) return; InternalRemove(ev.Player, scp1344); @@ -108,20 +105,11 @@ protected virtual void OnRemovedGoggles(Player player, Scp1344 goggles) { } - private void OnInternalDeactivating(DeactivatingEventArgs ev) + private void OnInternalUsingItem(UsingItemEventArgs ev) { - if (!Check(ev.Item)) + if (!ev.IsAllowed) return; - if (!CanBeRemoveSafely) - return; - - ev.NewStatus = Scp1344Status.Idle; - ev.IsAllowed = false; - } - - private void OnInternalUsingItem(UsingItemEventArgs ev) - { if (ev.Item.Type != ItemType.SCP1344) return; @@ -130,10 +118,7 @@ private void OnInternalUsingItem(UsingItemEventArgs ev) if (item.Type != ItemType.SCP1344) continue; - if (item is not Scp1344 scp1344) - continue; - - if (!scp1344.IsWorn) + if (item is not Scp1344 { IsWorn: true }) continue; ev.IsAllowed = false; @@ -141,6 +126,21 @@ private void OnInternalUsingItem(UsingItemEventArgs ev) } } + private void OnInternalDeactivating(DeactivatingEventArgs ev) + { + if (!ev.IsAllowed) + return; + + if (!Check(ev.Item)) + return; + + if (!CanBeRemoveSafely) + return; + + ev.NewStatus = Scp1344Status.Idle; + ev.IsAllowed = false; + } + private void OnInternalChangedStatus(ChangedStatusEventArgs ev) { if (!Check(ev.Item)) @@ -159,9 +159,6 @@ private void OnInternalChangedStatus(ChangedStatusEventArgs ev) case Scp1344Status.Active: InternalEquip(ev.Player, ev.Scp1344); break; - - default: - break; } } @@ -195,7 +192,7 @@ private void OnInternalItemRemoved(ItemRemovedEventArgs ev) if (!Check(ev.Item)) return; - if (ev.Item is not Scp1344 scp1344 || !scp1344.IsWorn) + if (ev.Item is not Scp1344 { IsWorn: true } scp1344) return; InternalRemove(ev.Player, scp1344); @@ -203,6 +200,9 @@ private void OnInternalItemRemoved(ItemRemovedEventArgs ev) private void OnInternalChangingStatus(ChangingStatusEventArgs ev) { + if (!ev.IsAllowed) + return; + if (!Check(ev.Item)) return;