Fix drag-drop stripping (#3001)
* Fix drag-drop stripping * More robust Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
This commit is contained in:
@@ -302,6 +302,8 @@ namespace Content.Client.GameObjects.EntitySystems
|
|||||||
|
|
||||||
foreach (var entity in entities)
|
foreach (var entity in entities)
|
||||||
{
|
{
|
||||||
|
if (entity == _dragDropHelper.Dragged) continue;
|
||||||
|
|
||||||
// check if it's able to be dropped on by current dragged entity
|
// check if it's able to be dropped on by current dragged entity
|
||||||
var dropArgs = new DragDropEventArgs(_dragger, args.Coordinates, _dragDropHelper.Dragged, entity);
|
var dropArgs = new DragDropEventArgs(_dragger, args.Coordinates, _dragDropHelper.Dragged, entity);
|
||||||
var valid = true;
|
var valid = true;
|
||||||
@@ -381,10 +383,9 @@ namespace Content.Client.GameObjects.EntitySystems
|
|||||||
var pvsEntities = EntityManager.GetEntitiesIntersecting(_eyeManager.CurrentMap, bounds, true);
|
var pvsEntities = EntityManager.GetEntitiesIntersecting(_eyeManager.CurrentMap, bounds, true);
|
||||||
foreach (var pvsEntity in pvsEntities)
|
foreach (var pvsEntity in pvsEntities)
|
||||||
{
|
{
|
||||||
if (!pvsEntity.TryGetComponent(out ISpriteComponent? inRangeSprite)) continue;
|
if (!pvsEntity.TryGetComponent(out ISpriteComponent? inRangeSprite) ||
|
||||||
|
!inRangeSprite.Visible ||
|
||||||
// can't highlight if there's no sprite or it's not visible
|
pvsEntity == _dragDropHelper.Dragged) continue;
|
||||||
if (inRangeSprite.Visible == false) continue;
|
|
||||||
|
|
||||||
var valid = (bool?) null;
|
var valid = (bool?) null;
|
||||||
// check if it's able to be dropped on by current dragged entity
|
// check if it's able to be dropped on by current dragged entity
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
#nullable enable
|
||||||
|
using Content.Shared.Interfaces.GameObjects.Components;
|
||||||
|
using Robust.Shared.GameObjects;
|
||||||
|
|
||||||
|
namespace Content.Shared.GameObjects.Components.GUI
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Give to an entity to say they can strip another entity.
|
||||||
|
/// </summary>
|
||||||
|
[RegisterComponent]
|
||||||
|
public class SharedStrippingComponent : Component, IDragDropOn
|
||||||
|
{
|
||||||
|
public override string Name => "Stripping";
|
||||||
|
|
||||||
|
public bool CanDragDropOn(DragDropEventArgs eventArgs)
|
||||||
|
{
|
||||||
|
if (!eventArgs.Dragged.TryGetComponent(out SharedStrippableComponent? strippable)) return false;
|
||||||
|
return strippable.CanBeStripped(Owner);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool DragDropOn(DragDropEventArgs eventArgs)
|
||||||
|
{
|
||||||
|
// Handled by StrippableComponent
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -196,6 +196,7 @@
|
|||||||
- type: Pullable
|
- type: Pullable
|
||||||
- type: DoAfter
|
- type: DoAfter
|
||||||
- type: CreamPied
|
- type: CreamPied
|
||||||
|
- type: Stripping
|
||||||
- type: Strippable
|
- type: Strippable
|
||||||
- type: UserInterface
|
- type: UserInterface
|
||||||
interfaces:
|
interfaces:
|
||||||
|
|||||||
Reference in New Issue
Block a user