Click Drag Functionality + Refactor Interaction Interfaces (#1125)
Co-authored-by: Víctor Aguilera Puerto <6766154+Zumorica@users.noreply.github.com> Co-authored-by: ComicIronic <comicironic@gmail.com> Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
This commit is contained in:
@@ -3,7 +3,8 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Content.Server.GameObjects.Components;
|
||||
using Content.Server.GameObjects.Components.Items.Storage;
|
||||
using Content.Server.GameObjects.EntitySystems;
|
||||
using Content.Server.GameObjects.EntitySystems.Click;
|
||||
using Content.Server.Interfaces.GameObjects.Components.Interaction;
|
||||
using Content.Server.Interfaces.GameObjects;
|
||||
using Content.Server.Utility;
|
||||
using Content.Shared.GameObjects.Components.Storage;
|
||||
@@ -21,6 +22,7 @@ using Robust.Shared.Interfaces.Map;
|
||||
using Robust.Shared.Interfaces.Network;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Players;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
@@ -32,7 +34,8 @@ namespace Content.Server.GameObjects
|
||||
[RegisterComponent]
|
||||
[ComponentReference(typeof(IActivate))]
|
||||
[ComponentReference(typeof(IStorageComponent))]
|
||||
public class ServerStorageComponent : SharedStorageComponent, IInteractUsing, IUse, IActivate, IStorageComponent, IDestroyAct, IExAct
|
||||
public class ServerStorageComponent : SharedStorageComponent, IInteractUsing, IUse, IActivate, IStorageComponent, IDestroyAct, IExAct,
|
||||
IDragDrop
|
||||
{
|
||||
#pragma warning disable 649
|
||||
[Dependency] private readonly IMapManager _mapManager;
|
||||
@@ -409,5 +412,26 @@ namespace Content.Server.GameObjects
|
||||
Owner.PopupMessage(player, "Can't insert.");
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool DragDrop(DragDropEventArgs eventArgs)
|
||||
{
|
||||
if (eventArgs.Target.TryGetComponent<PlaceableSurfaceComponent>(out var placeableSurface))
|
||||
{
|
||||
if (!placeableSurface.IsPlaceable) return false;
|
||||
|
||||
// empty everything out
|
||||
foreach (var storedEntity in StoredEntities.ToList())
|
||||
{
|
||||
if (Remove(storedEntity))
|
||||
{
|
||||
storedEntity.Transform.WorldPosition = eventArgs.DropLocation.Position;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user