Dragdrop fold rollerbed (#30002)

* Deploy foldable

* Add NetworkedComponent and access to the component

* Add handled to afterinteract

* Use drop target location instead of setcoordinates

* Put back in hand after failed deploy

This prevents dropping the bed when clicking while inside a locker.

* Created BaseDeployFoldable for folding chairs, body bags, and rollerbeds

* Add dragdrop to fold rollerbed to hand
This commit is contained in:
ShadowCommander
2024-08-07 02:19:10 -07:00
committed by GitHub
parent d86438c22b
commit 6a5cc883ce
3 changed files with 42 additions and 5 deletions

View File

@@ -1,3 +1,4 @@
using Content.Shared.DragDrop;
using Content.Shared.Hands.Components;
using Content.Shared.Hands.EntitySystems;
using Content.Shared.Interaction;
@@ -14,6 +15,38 @@ public sealed class DeployFoldableSystem : EntitySystem
base.Initialize();
SubscribeLocalEvent<DeployFoldableComponent, AfterInteractEvent>(OnAfterInteract);
SubscribeLocalEvent<DeployFoldableComponent, CanDragEvent>(OnCanDrag);
SubscribeLocalEvent<DeployFoldableComponent, DragDropDraggedEvent>(OnDragDropDragged);
SubscribeLocalEvent<DeployFoldableComponent, CanDropDraggedEvent>(OnCanDropDragged);
}
private void OnCanDropDragged(Entity<DeployFoldableComponent> ent, ref CanDropDraggedEvent args)
{
if (args.User != args.Target)
return;
args.Handled = true;
args.CanDrop = true;
}
private void OnDragDropDragged(Entity<DeployFoldableComponent> ent, ref DragDropDraggedEvent args)
{
if (!TryComp<FoldableComponent>(ent, out var foldable)
|| !_foldable.TrySetFolded(ent, foldable, true))
return;
_hands.PickupOrDrop(args.User, ent.Owner);
args.Handled = true;
}
private void OnCanDrag(Entity<DeployFoldableComponent> ent, ref CanDragEvent args)
{
if (!TryComp<FoldableComponent>(ent, out var foldable)
|| foldable.IsFolded)
return;
args.Handled = true;
}
private void OnAfterInteract(Entity<DeployFoldableComponent> ent, ref AfterInteractEvent args)