mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 10:21:18 +03:00
* PopupClient to PopupEntity/Coordinates * PopupPredictedX to PopupEntity/Cursor/Coordinates * The rest of the damn owl * nullability fixes * Buckle cleanup * cleanup, address PR comments * ExecutionSystem: one popup method * correct my filthy lies * Apply most of ajcm's suggestions * return user to SharedItemRecallSystem.cs * Fix lingering Ensnarable broadcast popups * targeted drain popups * fix lingering untargeted Guardian popups I read the comment on GuardianHostRecall. Oops. * target stethoscope popups * fix the PDA vibration popup * Fix target for encryption key removal popup * anomaly scanner: args.User, not uid * disposal unit comment, bcast pda vibration popup
88 lines
2.9 KiB
C#
88 lines
2.9 KiB
C#
using Content.Shared.Construction.EntitySystems;
|
|
using Content.Shared.DragDrop;
|
|
using Content.Shared.Hands.Components;
|
|
using Content.Shared.Hands.EntitySystems;
|
|
using Content.Shared.Interaction;
|
|
using Content.Shared.Popups;
|
|
using Robust.Shared.Physics.Components;
|
|
|
|
namespace Content.Shared.Foldable;
|
|
|
|
public sealed partial class DeployFoldableSystem : EntitySystem
|
|
{
|
|
[Dependency] private SharedHandsSystem _hands = default!;
|
|
[Dependency] private FoldableSystem _foldable = default!;
|
|
[Dependency] private AnchorableSystem _anchorable = default!;
|
|
[Dependency] private SharedPopupSystem _popup = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
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, args.User))
|
|
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)
|
|
{
|
|
if (args.Handled || !args.CanReach)
|
|
return;
|
|
|
|
// Don't do anything unless you clicked on the floor.
|
|
if (args.Target.HasValue)
|
|
return;
|
|
|
|
if (!TryComp<FoldableComponent>(ent, out var foldable))
|
|
return;
|
|
|
|
if (!TryComp(ent.Owner, out PhysicsComponent? anchorBody)
|
|
|| !_anchorable.TileFree(args.ClickLocation, anchorBody))
|
|
{
|
|
_popup.PopupEntity(Loc.GetString("foldable-deploy-fail", ("object", ent)), ent, args.User);
|
|
return;
|
|
}
|
|
|
|
if (!TryComp(args.User, out HandsComponent? hands)
|
|
|| !_hands.TryDrop((args.User, hands), args.Used, targetDropLocation: args.ClickLocation))
|
|
return;
|
|
|
|
if (!_foldable.TrySetFolded(ent, foldable, false, args.User))
|
|
{
|
|
_hands.TryPickup(args.User, args.Used, handsComp: hands);
|
|
return;
|
|
}
|
|
|
|
args.Handled = true;
|
|
}
|
|
}
|