Prevent certain foldable items from being unfolded on structures (#36687)

initial commit
This commit is contained in:
SlamBamActionman
2025-04-19 04:17:13 +02:00
committed by GitHub
parent 4d25907ba4
commit b6e101b96f
5 changed files with 41 additions and 7 deletions

View File

@@ -1,7 +1,10 @@
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;
@@ -9,6 +12,8 @@ public sealed class DeployFoldableSystem : EntitySystem
{
[Dependency] private readonly SharedHandsSystem _hands = default!;
[Dependency] private readonly FoldableSystem _foldable = default!;
[Dependency] private readonly AnchorableSystem _anchorable = default!;
[Dependency] private readonly SharedPopupSystem _popup = default!;
public override void Initialize()
{
@@ -57,6 +62,13 @@ public sealed class DeployFoldableSystem : EntitySystem
if (!TryComp<FoldableComponent>(ent, out var foldable))
return;
if (!TryComp(ent.Owner, out PhysicsComponent? anchorBody)
|| !_anchorable.TileFree(args.ClickLocation, anchorBody))
{
_popup.PopupPredicted(Loc.GetString("foldable-deploy-fail", ("object", ent)), ent, args.User);
return;
}
if (!TryComp(args.User, out HandsComponent? hands)
|| !_hands.TryDrop(args.User, args.Used, targetDropLocation: args.ClickLocation, handsComp: hands))
return;