Dumpable component to use a doafter to empty storage into a disposal unit, placeable surface, or the ground (#7792)

This commit is contained in:
Rane
2022-05-03 23:00:22 -04:00
committed by GitHub
parent 40ae7cc285
commit cfd00e74ca
11 changed files with 240 additions and 72 deletions

View File

@@ -9,7 +9,7 @@ using Robust.Shared.Serialization;
namespace Content.Shared.Storage
{
[NetworkedComponent()]
public abstract class SharedStorageComponent : Component, IDraggable
public abstract class SharedStorageComponent : Component
{
[Serializable, NetSerializable]
public sealed class StorageBoundUserInterfaceState : BoundUserInterfaceState
@@ -56,32 +56,6 @@ namespace Content.Shared.Storage
/// <param name="entity">The entity to remove</param>
/// <returns>True if no longer in storage, false otherwise</returns>
public abstract bool Remove(EntityUid entity);
bool IDraggable.CanDrop(CanDropEvent args)
{
return _entMan.TryGetComponent(args.Target, out PlaceableSurfaceComponent? placeable) &&
placeable.IsPlaceable;
}
bool IDraggable.Drop(DragDropEvent eventArgs)
{
if (!EntitySystem.Get<ActionBlockerSystem>().CanInteract(eventArgs.User, eventArgs.Target))
return false;
var storedEntities = StoredEntities?.ToArray();
if (storedEntities == null)
return false;
// empty everything out
foreach (var storedEntity in storedEntities)
{
if (Remove(storedEntity))
_entMan.GetComponent<TransformComponent>(storedEntity).WorldPosition = eventArgs.DropLocation.Position;
}
return true;
}
}
/// <summary>