Fix wallmount board dropping at random side of the wall (#21920)

* empty wallmount board at user

* change to DropNextTo

* add emptyAtUser to doors
This commit is contained in:
qwerltaz
2023-12-06 04:03:31 +01:00
committed by GitHub
parent 55c8ad04cd
commit daa70fc92c
13 changed files with 127 additions and 72 deletions

View File

@@ -3,7 +3,10 @@ using Content.Shared.Construction;
using Content.Shared.Hands.Components;
using JetBrains.Annotations;
using Robust.Server.Containers;
using Robust.Server.GameObjects;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
namespace Content.Server.Construction.Completions
{
@@ -14,9 +17,15 @@ namespace Content.Server.Construction.Completions
/// <summary>
/// Whether or not the user should attempt to pick up the removed entities.
/// </summary>
[DataField("pickup")]
[DataField]
public bool Pickup = false;
/// <summary>
/// Whether or not to empty the container at the user's location.
/// </summary>
[DataField]
public bool EmptyAtUser = false;
public void PerformAction(EntityUid uid, EntityUid? userUid, IEntityManager entityManager)
{
if (!entityManager.TryGetComponent(uid, out ContainerManagerComponent? containerManager))
@@ -24,6 +33,7 @@ namespace Content.Server.Construction.Completions
var containerSys = entityManager.EntitySysManager.GetEntitySystem<ContainerSystem>();
var handSys = entityManager.EntitySysManager.GetEntitySystem<HandsSystem>();
var transformSys = entityManager.EntitySysManager.GetEntitySystem<TransformSystem>();
HandsComponent? hands = null;
var pickup = Pickup && entityManager.TryGetComponent(userUid, out hands);
@@ -32,6 +42,9 @@ namespace Content.Server.Construction.Completions
{
foreach (var ent in containerSys.EmptyContainer(container, true, reparent: !pickup))
{
if (EmptyAtUser && userUid is not null)
transformSys.DropNextTo(ent, (EntityUid) userUid);
if (pickup)
handSys.PickupOrDrop(userUid, ent, handsComp: hands);
}