2022-05-10 01:08:52 -07:00
|
|
|
using Content.Client.Interactable;
|
|
|
|
|
using Content.Shared.Climbing;
|
|
|
|
|
using Content.Shared.DragDrop;
|
|
|
|
|
|
2022-06-24 17:44:30 +10:00
|
|
|
namespace Content.Client.Movement.Systems;
|
2022-05-10 01:08:52 -07:00
|
|
|
|
|
|
|
|
public sealed class ClimbSystem : SharedClimbSystem
|
|
|
|
|
{
|
|
|
|
|
[Dependency] private readonly InteractionSystem _interactionSystem = default!;
|
2022-06-24 17:44:30 +10:00
|
|
|
|
2022-05-10 01:08:52 -07:00
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
base.Initialize();
|
2023-02-14 00:29:34 +11:00
|
|
|
SubscribeLocalEvent<ClimbableComponent, CanDropTargetEvent>(OnCanDragDropOn);
|
2022-05-10 01:08:52 -07:00
|
|
|
}
|
|
|
|
|
|
2023-02-14 00:29:34 +11:00
|
|
|
protected override void OnCanDragDropOn(EntityUid uid, ClimbableComponent component, ref CanDropTargetEvent args)
|
2022-05-10 01:08:52 -07:00
|
|
|
{
|
2023-02-14 00:29:34 +11:00
|
|
|
base.OnCanDragDropOn(uid, component, ref args);
|
2022-05-10 01:08:52 -07:00
|
|
|
|
|
|
|
|
if (!args.CanDrop)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
var user = args.User;
|
2023-02-14 00:29:34 +11:00
|
|
|
var target = uid;
|
2022-05-10 01:08:52 -07:00
|
|
|
var dragged = args.Dragged;
|
|
|
|
|
bool Ignored(EntityUid entity) => entity == target || entity == user || entity == dragged;
|
|
|
|
|
|
|
|
|
|
args.CanDrop = _interactionSystem.InRangeUnobstructed(user, target, component.Range, predicate: Ignored)
|
|
|
|
|
&& _interactionSystem.InRangeUnobstructed(user, dragged, component.Range, predicate: Ignored);
|
|
|
|
|
args.Handled = true;
|
|
|
|
|
}
|
|
|
|
|
}
|