Drag changes (#2487)

* Drag changes

* Higlights only show near cursor
* Don't highlight un-droppable entities
* Fixes invalid highlights issue

* Also the scanner

* 2 months fix

* Address reviews

Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
This commit is contained in:
metalgearsloth
2021-01-11 22:14:01 +11:00
committed by GitHub
parent 067397c713
commit acb3c72d99
28 changed files with 335 additions and 131 deletions

View File

@@ -1,6 +1,11 @@
#nullable enable
using System;
using System.Collections.Generic;
using Content.Shared.GameObjects.Components.Body;
using Content.Shared.GameObjects.Components.Damage;
using Content.Shared.GameObjects.Components.Mobs.State;
using Content.Shared.GameObjects.Components.Storage;
using Content.Shared.Interfaces.GameObjects.Components;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Components;
using Robust.Shared.GameObjects.Components.UserInterface;
@@ -12,7 +17,7 @@ using Robust.Shared.ViewVariables;
namespace Content.Shared.GameObjects.Components.Disposal
{
public abstract class SharedDisposalUnitComponent : Component, ICollideSpecial
public abstract class SharedDisposalUnitComponent : Component, ICollideSpecial, IDragDropOn
{
public override string Name => "DisposalUnit";
@@ -160,5 +165,34 @@ namespace Content.Shared.GameObjects.Components.Disposal
{
Key
}
public virtual bool CanInsert(IEntity entity)
{
if (!Anchored)
return false;
if (!entity.TryGetComponent(out IPhysicsComponent? physics) ||
!physics.CanCollide)
{
if (!(entity.TryGetComponent(out IMobStateComponent? damageState) && damageState.IsDead())) {
return false;
}
}
if (!entity.HasComponent<SharedStorableComponent>() &&
!entity.HasComponent<IBody>())
{
return false;
}
return true;
}
public virtual bool CanDragDropOn(DragDropEventArgs eventArgs)
{
return CanInsert(eventArgs.Dragged);
}
public abstract bool DragDropOn(DragDropEventArgs eventArgs);
}
}