+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;
{
[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()
{
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;
-using Content.Shared.Body.Components;
using Content.Shared.Buckle;
using Content.Shared.Buckle.Components;
+using Content.Shared.Construction.EntitySystems;
+using Content.Shared.Popups;
using Content.Shared.Storage.Components;
using Content.Shared.Verbs;
using Robust.Shared.Containers;
+using Robust.Shared.Physics.Components;
using Robust.Shared.Serialization;
using Robust.Shared.Utility;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly SharedBuckleSystem _buckle = default!;
[Dependency] private readonly SharedContainerSystem _container = default!;
+ [Dependency] private readonly AnchorableSystem _anchorable = default!;
+ [Dependency] private readonly SharedPopupSystem _popup = default!;
public override void Initialize()
{
args.Cancel();
}
- public bool TryToggleFold(EntityUid uid, FoldableComponent comp)
+ public bool TryToggleFold(EntityUid uid, FoldableComponent comp, EntityUid? folder = null)
{
- return TrySetFolded(uid, comp, !comp.IsFolded);
+ var result = TrySetFolded(uid, comp, !comp.IsFolded);
+ if (!result && folder != null)
+ {
+ if (comp.IsFolded)
+ _popup.PopupPredicted(Loc.GetString("foldable-unfold-fail", ("object", uid)), uid, folder.Value);
+ else
+ _popup.PopupPredicted(Loc.GetString("foldable-fold-fail", ("object", uid)), uid, folder.Value);
+ }
+ return result;
}
public bool CanToggleFold(EntityUid uid, FoldableComponent? fold = null)
if (_container.IsEntityInContainer(uid) && !fold.CanFoldInsideContainer)
return false;
+ if (!TryComp(uid, out PhysicsComponent? body) ||
+ !_anchorable.TileFree(Transform(uid).Coordinates, body))
+ return false;
+
var ev = new FoldAttemptEvent(fold);
RaiseLocalEvent(uid, ref ev);
return !ev.Cancelled;
private void AddFoldVerb(EntityUid uid, FoldableComponent component, GetVerbsEvent<AlternativeVerb> args)
{
- if (!args.CanAccess || !args.CanInteract || args.Hands == null || !CanToggleFold(uid, component))
+ if (!args.CanAccess || !args.CanInteract || args.Hands == null)
return;
AlternativeVerb verb = new()
{
- Act = () => TryToggleFold(uid, component),
+ Act = () => TryToggleFold(uid, component, args.User),
Text = component.IsFolded ? Loc.GetString(component.UnfoldVerbText) : Loc.GetString(component.FoldVerbText),
Icon = new SpriteSpecifier.Texture(new ("/Textures/Interface/VerbIcons/fold.svg.192dpi.png")),
{
// If the target is an item, we ignore any colliding entities. Currently done so that if items get stuck
// inside of walls, users can still pick them up.
- ignored.UnionWith(_broadphase.GetEntitiesIntersectingBody(target, (int) collisionMask, false, physics));
+ ignored.UnionWith(_broadphase.GetEntitiesIntersectingBody(target, (int) collisionMask, false, physics)); // Note: This also bypasses items underneath doors, which may be problematic if it'd cause undesirable behavior.
}
else if (_wallMountQuery.TryComp(target, out var wallMount))
{