diff --git a/Content.Server/Strip/StrippableSystem.cs b/Content.Server/Strip/StrippableSystem.cs index 6f0a1ecb32..397396de50 100644 --- a/Content.Server/Strip/StrippableSystem.cs +++ b/Content.Server/Strip/StrippableSystem.cs @@ -1,7 +1,6 @@ using System.Linq; using Content.Server.Administration.Logs; using Content.Server.Ensnaring; -using Content.Shared.CombatMode; using Content.Shared.Cuffs; using Content.Shared.Cuffs.Components; using Content.Shared.Database; @@ -10,7 +9,6 @@ using Content.Shared.Ensnaring.Components; using Content.Shared.Hands.Components; using Content.Shared.Hands.EntitySystems; using Content.Shared.IdentityManagement; -using Content.Shared.Interaction; using Content.Shared.Interaction.Events; using Content.Shared.Inventory; using Content.Shared.Inventory.VirtualItem; @@ -18,7 +16,6 @@ using Content.Shared.Popups; using Content.Shared.Strip; using Content.Shared.Strip.Components; using Content.Shared.Verbs; -using Robust.Server.GameObjects; using Robust.Shared.Player; using Robust.Shared.Utility; @@ -28,7 +25,6 @@ namespace Content.Server.Strip { [Dependency] private readonly InventorySystem _inventorySystem = default!; [Dependency] private readonly EnsnareableSystem _ensnaringSystem = default!; - [Dependency] private readonly UserInterfaceSystem _userInterfaceSystem = default!; [Dependency] private readonly SharedCuffableSystem _cuffableSystem = default!; [Dependency] private readonly SharedDoAfterSystem _doAfterSystem = default!; @@ -45,7 +41,6 @@ namespace Content.Server.Strip SubscribeLocalEvent>(AddStripVerb); SubscribeLocalEvent>(AddStripExamineVerb); - SubscribeLocalEvent(OnActivateInWorld); // BUI SubscribeLocalEvent(OnStripButtonPressed); @@ -68,7 +63,7 @@ namespace Content.Server.Strip { Text = Loc.GetString("strip-verb-get-data-text"), Icon = new SpriteSpecifier.Texture(new("/Textures/Interface/VerbIcons/outfit.svg.192dpi.png")), - Act = () => StartOpeningStripper(args.User, (uid, component), true), + Act = () => TryOpenStrippingUi(args.User, (uid, component), true), }; args.Verbs.Add(verb); @@ -86,37 +81,13 @@ namespace Content.Server.Strip { Text = Loc.GetString("strip-verb-get-data-text"), Icon = new SpriteSpecifier.Texture(new("/Textures/Interface/VerbIcons/outfit.svg.192dpi.png")), - Act = () => StartOpeningStripper(args.User, (uid, component), true), + Act = () => TryOpenStrippingUi(args.User, (uid, component), true), Category = VerbCategory.Examine, }; args.Verbs.Add(verb); } - private void OnActivateInWorld(EntityUid uid, StrippableComponent component, ActivateInWorldEvent args) - { - if (args.Target == args.User) - return; - - if (!HasComp(args.User)) - return; - - StartOpeningStripper(args.User, (uid, component)); - } - - public override void StartOpeningStripper(EntityUid user, Entity strippable, bool openInCombat = false) - { - base.StartOpeningStripper(user, strippable, openInCombat); - - if (TryComp(user, out var mode) && mode.IsInCombatMode && !openInCombat) - return; - - if (HasComp(user)) - { - _userInterfaceSystem.OpenUi(strippable.Owner, StrippingUiKey.Key, user); - } - } - private void OnStripButtonPressed(Entity strippable, ref StrippingSlotButtonPressed args) { if (args.Actor is not { Valid: true } user || diff --git a/Content.Shared/Strip/SharedStrippableSystem.cs b/Content.Shared/Strip/SharedStrippableSystem.cs index 59b24ec943..075cf81a4c 100644 --- a/Content.Shared/Strip/SharedStrippableSystem.cs +++ b/Content.Shared/Strip/SharedStrippableSystem.cs @@ -1,17 +1,31 @@ +using Content.Shared.CombatMode; using Content.Shared.DragDrop; using Content.Shared.Hands.Components; +using Content.Shared.Interaction; using Content.Shared.Strip.Components; namespace Content.Shared.Strip; public abstract class SharedStrippableSystem : EntitySystem { + [Dependency] private readonly SharedUserInterfaceSystem _ui = default!; + public override void Initialize() { base.Initialize(); SubscribeLocalEvent(OnCanDropOn); SubscribeLocalEvent(OnCanDrop); SubscribeLocalEvent(OnDragDrop); + SubscribeLocalEvent(OnActivateInWorld); + } + + private void OnActivateInWorld(EntityUid uid, StrippableComponent component, ActivateInWorldEvent args) + { + if (args.Handled || args.Target == args.User) + return; + + if (TryOpenStrippingUi(args.User, (uid, component))) + args.Handled = true; } public (TimeSpan Time, bool Stealth) GetStripTimeModifiers(EntityUid user, EntityUid target, TimeSpan initialTime) @@ -29,13 +43,20 @@ public abstract class SharedStrippableSystem : EntitySystem if (args.Handled || args.Target != args.User) return; - StartOpeningStripper(args.User, (uid, component)); - args.Handled = true; + if (TryOpenStrippingUi(args.User, (uid, component))) + args.Handled = true; } - public virtual void StartOpeningStripper(EntityUid user, Entity component, bool openInCombat = false) + public bool TryOpenStrippingUi(EntityUid user, Entity target, bool openInCombat = false) { + if (!openInCombat && TryComp(user, out var mode) && mode.IsInCombatMode) + return false; + if (!HasComp(user)) + return false; + + _ui.OpenUi(target.Owner, StrippingUiKey.Key, user); + return true; } private void OnCanDropOn(EntityUid uid, StrippingComponent component, ref CanDropTargetEvent args)