Refactor drag and drop to use a shared interface (#2012)

* WIP in progress hours

* Cleanup

* Fix bugle

* Fix nullable error

* Merge fixes

* Merge fixes

* Merge fixes
This commit is contained in:
DrSmugleaf
2020-10-14 15:24:07 +02:00
committed by GitHub
parent f715eed63c
commit cdedaeb12e
37 changed files with 527 additions and 377 deletions

View File

@@ -1,12 +1,14 @@
using System;
using Content.Shared.GameObjects.Components.Strap;
using Content.Shared.GameObjects.EntitySystems;
using Content.Shared.Interfaces.GameObjects.Components;
using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Serialization;
namespace Content.Shared.GameObjects.Components.Buckle
{
public abstract class SharedBuckleComponent : Component, IActionBlocker, IEffectBlocker
public abstract class SharedBuckleComponent : Component, IActionBlocker, IEffectBlocker, IDraggable
{
public sealed override string Name => "Buckle";
@@ -17,6 +19,8 @@ namespace Content.Shared.GameObjects.Components.Buckle
/// </summary>
public abstract bool Buckled { get; }
public abstract bool TryBuckle(IEntity user, IEntity to);
bool IActionBlocker.CanMove()
{
return !Buckled;
@@ -31,6 +35,16 @@ namespace Content.Shared.GameObjects.Components.Buckle
{
return !Buckled;
}
bool IDraggable.CanDrop(CanDropEventArgs args)
{
return args.Target.HasComponent<SharedStrapComponent>();
}
public bool Drop(DragDropEventArgs args)
{
return TryBuckle(args.User, args.Dragged);
}
}
[Serializable, NetSerializable]