Add strip verb (#1894)
* Add strip verb * Merge some of the verb and candragdrop checks
This commit is contained in:
@@ -9,6 +9,7 @@ using Content.Server.Interfaces;
|
|||||||
using Content.Server.Utility;
|
using Content.Server.Utility;
|
||||||
using Content.Shared.GameObjects.Components.GUI;
|
using Content.Shared.GameObjects.Components.GUI;
|
||||||
using Content.Shared.GameObjects.EntitySystems;
|
using Content.Shared.GameObjects.EntitySystems;
|
||||||
|
using Content.Shared.GameObjects.Verbs;
|
||||||
using Content.Shared.Interfaces.GameObjects.Components;
|
using Content.Shared.Interfaces.GameObjects.Components;
|
||||||
using Robust.Server.GameObjects.Components.UserInterface;
|
using Robust.Server.GameObjects.Components.UserInterface;
|
||||||
using Robust.Server.Interfaces.GameObjects;
|
using Robust.Server.Interfaces.GameObjects;
|
||||||
@@ -78,10 +79,18 @@ namespace Content.Server.GameObjects.Components.GUI
|
|||||||
UserInterface.SetState(new StrippingBoundUserInterfaceState(inventory, hands, cuffs));
|
UserInterface.SetState(new StrippingBoundUserInterfaceState(inventory, hands, cuffs));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool CanBeStripped(IEntity by)
|
||||||
|
{
|
||||||
|
return by != Owner
|
||||||
|
&& by.HasComponent<HandsComponent>()
|
||||||
|
&& ActionBlockerSystem.CanInteract(by);
|
||||||
|
}
|
||||||
|
|
||||||
public bool CanDragDrop(DragDropEventArgs eventArgs)
|
public bool CanDragDrop(DragDropEventArgs eventArgs)
|
||||||
{
|
{
|
||||||
return eventArgs.User.HasComponent<HandsComponent>()
|
return eventArgs.Target != eventArgs.Dropped
|
||||||
&& eventArgs.Target != eventArgs.Dropped && eventArgs.Target == eventArgs.User;
|
&& eventArgs.Target == eventArgs.User
|
||||||
|
&& CanBeStripped(eventArgs.User);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool DragDrop(DragDropEventArgs eventArgs)
|
public bool DragDrop(DragDropEventArgs eventArgs)
|
||||||
@@ -432,5 +441,31 @@ namespace Content.Server.GameObjects.Components.GUI
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Verb]
|
||||||
|
private sealed class StripVerb : Verb<StrippableComponent>
|
||||||
|
{
|
||||||
|
protected override void GetData(IEntity user, StrippableComponent component, VerbData data)
|
||||||
|
{
|
||||||
|
if (!component.CanBeStripped(user))
|
||||||
|
{
|
||||||
|
data.Visibility = VerbVisibility.Invisible;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
data.Visibility = VerbVisibility.Visible;
|
||||||
|
data.Text = Loc.GetString("Strip");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Activate(IEntity user, StrippableComponent component)
|
||||||
|
{
|
||||||
|
if (!user.TryGetComponent(out IActorComponent? actor))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
component.OpenUserInterface(actor.playerSession);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user