Fix stripping not marking interactions as handled (#28292)
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Content.Server.Administration.Logs;
|
using Content.Server.Administration.Logs;
|
||||||
using Content.Server.Ensnaring;
|
using Content.Server.Ensnaring;
|
||||||
using Content.Shared.CombatMode;
|
|
||||||
using Content.Shared.Cuffs;
|
using Content.Shared.Cuffs;
|
||||||
using Content.Shared.Cuffs.Components;
|
using Content.Shared.Cuffs.Components;
|
||||||
using Content.Shared.Database;
|
using Content.Shared.Database;
|
||||||
@@ -10,7 +9,6 @@ using Content.Shared.Ensnaring.Components;
|
|||||||
using Content.Shared.Hands.Components;
|
using Content.Shared.Hands.Components;
|
||||||
using Content.Shared.Hands.EntitySystems;
|
using Content.Shared.Hands.EntitySystems;
|
||||||
using Content.Shared.IdentityManagement;
|
using Content.Shared.IdentityManagement;
|
||||||
using Content.Shared.Interaction;
|
|
||||||
using Content.Shared.Interaction.Events;
|
using Content.Shared.Interaction.Events;
|
||||||
using Content.Shared.Inventory;
|
using Content.Shared.Inventory;
|
||||||
using Content.Shared.Inventory.VirtualItem;
|
using Content.Shared.Inventory.VirtualItem;
|
||||||
@@ -18,7 +16,6 @@ using Content.Shared.Popups;
|
|||||||
using Content.Shared.Strip;
|
using Content.Shared.Strip;
|
||||||
using Content.Shared.Strip.Components;
|
using Content.Shared.Strip.Components;
|
||||||
using Content.Shared.Verbs;
|
using Content.Shared.Verbs;
|
||||||
using Robust.Server.GameObjects;
|
|
||||||
using Robust.Shared.Player;
|
using Robust.Shared.Player;
|
||||||
using Robust.Shared.Utility;
|
using Robust.Shared.Utility;
|
||||||
|
|
||||||
@@ -28,7 +25,6 @@ namespace Content.Server.Strip
|
|||||||
{
|
{
|
||||||
[Dependency] private readonly InventorySystem _inventorySystem = default!;
|
[Dependency] private readonly InventorySystem _inventorySystem = default!;
|
||||||
[Dependency] private readonly EnsnareableSystem _ensnaringSystem = default!;
|
[Dependency] private readonly EnsnareableSystem _ensnaringSystem = default!;
|
||||||
[Dependency] private readonly UserInterfaceSystem _userInterfaceSystem = default!;
|
|
||||||
|
|
||||||
[Dependency] private readonly SharedCuffableSystem _cuffableSystem = default!;
|
[Dependency] private readonly SharedCuffableSystem _cuffableSystem = default!;
|
||||||
[Dependency] private readonly SharedDoAfterSystem _doAfterSystem = default!;
|
[Dependency] private readonly SharedDoAfterSystem _doAfterSystem = default!;
|
||||||
@@ -45,7 +41,6 @@ namespace Content.Server.Strip
|
|||||||
|
|
||||||
SubscribeLocalEvent<StrippableComponent, GetVerbsEvent<Verb>>(AddStripVerb);
|
SubscribeLocalEvent<StrippableComponent, GetVerbsEvent<Verb>>(AddStripVerb);
|
||||||
SubscribeLocalEvent<StrippableComponent, GetVerbsEvent<ExamineVerb>>(AddStripExamineVerb);
|
SubscribeLocalEvent<StrippableComponent, GetVerbsEvent<ExamineVerb>>(AddStripExamineVerb);
|
||||||
SubscribeLocalEvent<StrippableComponent, ActivateInWorldEvent>(OnActivateInWorld);
|
|
||||||
|
|
||||||
// BUI
|
// BUI
|
||||||
SubscribeLocalEvent<StrippableComponent, StrippingSlotButtonPressed>(OnStripButtonPressed);
|
SubscribeLocalEvent<StrippableComponent, StrippingSlotButtonPressed>(OnStripButtonPressed);
|
||||||
@@ -68,7 +63,7 @@ namespace Content.Server.Strip
|
|||||||
{
|
{
|
||||||
Text = Loc.GetString("strip-verb-get-data-text"),
|
Text = Loc.GetString("strip-verb-get-data-text"),
|
||||||
Icon = new SpriteSpecifier.Texture(new("/Textures/Interface/VerbIcons/outfit.svg.192dpi.png")),
|
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);
|
args.Verbs.Add(verb);
|
||||||
@@ -86,37 +81,13 @@ namespace Content.Server.Strip
|
|||||||
{
|
{
|
||||||
Text = Loc.GetString("strip-verb-get-data-text"),
|
Text = Loc.GetString("strip-verb-get-data-text"),
|
||||||
Icon = new SpriteSpecifier.Texture(new("/Textures/Interface/VerbIcons/outfit.svg.192dpi.png")),
|
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,
|
Category = VerbCategory.Examine,
|
||||||
};
|
};
|
||||||
|
|
||||||
args.Verbs.Add(verb);
|
args.Verbs.Add(verb);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnActivateInWorld(EntityUid uid, StrippableComponent component, ActivateInWorldEvent args)
|
|
||||||
{
|
|
||||||
if (args.Target == args.User)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!HasComp<ActorComponent>(args.User))
|
|
||||||
return;
|
|
||||||
|
|
||||||
StartOpeningStripper(args.User, (uid, component));
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void StartOpeningStripper(EntityUid user, Entity<StrippableComponent> strippable, bool openInCombat = false)
|
|
||||||
{
|
|
||||||
base.StartOpeningStripper(user, strippable, openInCombat);
|
|
||||||
|
|
||||||
if (TryComp<CombatModeComponent>(user, out var mode) && mode.IsInCombatMode && !openInCombat)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (HasComp<StrippingComponent>(user))
|
|
||||||
{
|
|
||||||
_userInterfaceSystem.OpenUi(strippable.Owner, StrippingUiKey.Key, user);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnStripButtonPressed(Entity<StrippableComponent> strippable, ref StrippingSlotButtonPressed args)
|
private void OnStripButtonPressed(Entity<StrippableComponent> strippable, ref StrippingSlotButtonPressed args)
|
||||||
{
|
{
|
||||||
if (args.Actor is not { Valid: true } user ||
|
if (args.Actor is not { Valid: true } user ||
|
||||||
|
|||||||
@@ -1,17 +1,31 @@
|
|||||||
|
using Content.Shared.CombatMode;
|
||||||
using Content.Shared.DragDrop;
|
using Content.Shared.DragDrop;
|
||||||
using Content.Shared.Hands.Components;
|
using Content.Shared.Hands.Components;
|
||||||
|
using Content.Shared.Interaction;
|
||||||
using Content.Shared.Strip.Components;
|
using Content.Shared.Strip.Components;
|
||||||
|
|
||||||
namespace Content.Shared.Strip;
|
namespace Content.Shared.Strip;
|
||||||
|
|
||||||
public abstract class SharedStrippableSystem : EntitySystem
|
public abstract class SharedStrippableSystem : EntitySystem
|
||||||
{
|
{
|
||||||
|
[Dependency] private readonly SharedUserInterfaceSystem _ui = default!;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
SubscribeLocalEvent<StrippingComponent, CanDropTargetEvent>(OnCanDropOn);
|
SubscribeLocalEvent<StrippingComponent, CanDropTargetEvent>(OnCanDropOn);
|
||||||
SubscribeLocalEvent<StrippableComponent, CanDropDraggedEvent>(OnCanDrop);
|
SubscribeLocalEvent<StrippableComponent, CanDropDraggedEvent>(OnCanDrop);
|
||||||
SubscribeLocalEvent<StrippableComponent, DragDropDraggedEvent>(OnDragDrop);
|
SubscribeLocalEvent<StrippableComponent, DragDropDraggedEvent>(OnDragDrop);
|
||||||
|
SubscribeLocalEvent<StrippableComponent, ActivateInWorldEvent>(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)
|
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)
|
if (args.Handled || args.Target != args.User)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
StartOpeningStripper(args.User, (uid, component));
|
if (TryOpenStrippingUi(args.User, (uid, component)))
|
||||||
args.Handled = true;
|
args.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void StartOpeningStripper(EntityUid user, Entity<StrippableComponent> component, bool openInCombat = false)
|
public bool TryOpenStrippingUi(EntityUid user, Entity<StrippableComponent> target, bool openInCombat = false)
|
||||||
{
|
{
|
||||||
|
if (!openInCombat && TryComp<CombatModeComponent>(user, out var mode) && mode.IsInCombatMode)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!HasComp<StrippingComponent>(user))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
_ui.OpenUi(target.Owner, StrippingUiKey.Key, user);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnCanDropOn(EntityUid uid, StrippingComponent component, ref CanDropTargetEvent args)
|
private void OnCanDropOn(EntityUid uid, StrippingComponent component, ref CanDropTargetEvent args)
|
||||||
|
|||||||
Reference in New Issue
Block a user