using System;
using Robust.Shared.Analyzers;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
namespace Content.Shared.Interfaces.GameObjects.Components
{
///
/// This interface allows a local client to initiate dragging of the component's
/// entity by mouse, for drag and drop interactions.
///
[RequiresExplicitImplementation]
public interface IDraggable
{
///
/// Invoked when an user is attempting to initiate a drag with
/// this component's entity in range. It's fine to return true even if there
/// wouldn't be any valid targets - just return true if this entity is in a
/// "draggable" state.
///
///
/// The information about the drag, such as who is doing it.
///
/// True if the drag should be initiated, false otherwise.
bool CanStartDrag(StartDragDropEventArgs args)
{
return true;
}
///
/// Invoked on entities visible to the user to check if this component's
/// entity can be dropped on the indicated target entity.
/// No need to check range / reachability in here.
/// Returning true will cause the target entity to be highlighted as
/// a potential target and allow dropping when in range.
///
///
/// True if target is a valid target to be dropped on by this component's
/// entity, false otherwise.
///
bool CanDrop(CanDropEventArgs args);
///
/// Invoked when this component's entity is being dropped on another.
/// Other drag and drop interactions may be attempted if this one fails.
///
///
/// The information about the drag, such as who is doing it.
///
///
/// True if an interaction occurred and no further interaction should
/// be processed for this drop, false otherwise.
///
bool Drop(DragDropEventArgs args)
{
return false;
}
}
public class StartDragDropEventArgs : EventArgs
{
///
/// Creates a new instance of .
///
/// The entity doing the drag and drop.
/// The entity that is being dragged and dropped.
public StartDragDropEventArgs(IEntity user, IEntity dragged)
{
User = user;
Dragged = dragged;
}
///
/// The entity doing the drag and drop.
///
public IEntity User { get; }
///
/// The entity that is being dragged.
///
public IEntity Dragged { get; }
}
public class CanDropEventArgs : StartDragDropEventArgs
{
///
/// Creates a new instance of .
///
/// The entity doing the drag and drop.
/// The entity that is being dragged and dropped.
/// The entity that is being dropped onto.
public CanDropEventArgs(IEntity user, IEntity dragged, IEntity target) : base(user, dragged)
{
Target = target;
}
///
/// The entity that
/// is being dropped onto.
///
public IEntity Target { get; }
}
public class DragDropEventArgs : CanDropEventArgs
{
///
/// Creates a new instance of .
///
/// The entity doing the drag and drop.
/// The location where is being dropped.
/// The entity that is being dragged and dropped.
/// The entity that is being dropped onto.
public DragDropEventArgs(IEntity user, EntityCoordinates dropLocation, IEntity dragged, IEntity target) : base(user, dragged, target)
{
DropLocation = dropLocation;
}
///
/// The location where
/// is being dropped.
///
public EntityCoordinates DropLocation { get; }
}
}