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:
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user