Fix stripping not marking interactions as handled (#28292)
This commit is contained in:
@@ -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<StrippingComponent, CanDropTargetEvent>(OnCanDropOn);
|
||||
SubscribeLocalEvent<StrippableComponent, CanDropDraggedEvent>(OnCanDrop);
|
||||
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)
|
||||
@@ -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<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)
|
||||
|
||||
Reference in New Issue
Block a user