This commit is contained in:
Leon Friedrich
2022-03-17 20:13:31 +13:00
committed by GitHub
parent 7b84362901
commit bfd95c493b
94 changed files with 1454 additions and 2185 deletions

View File

@@ -8,6 +8,7 @@ using Content.Server.Hands.Components;
using Content.Server.Interaction;
using Content.Shared.Acts;
using Content.Shared.Coordinates;
using Content.Shared.Hands.EntitySystems;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Helpers;
using Content.Shared.Item;
@@ -46,6 +47,7 @@ namespace Content.Server.Storage.Components
public sealed class ServerStorageComponent : SharedStorageComponent, IInteractUsing, IActivate, IStorageComponent, IDestroyAct, IExAct, IAfterInteract
{
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IEntitySystemManager _sysMan = default!;
private const string LoggerName = "Storage";
@@ -243,22 +245,24 @@ namespace Content.Server.Storage.Components
EnsureInitialCalculated();
if (!_entityManager.TryGetComponent(player, out HandsComponent? hands) ||
hands.GetActiveHandItem == null)
hands.ActiveHandEntity == null)
{
return false;
}
var toInsert = hands.GetActiveHandItem;
var toInsert = hands.ActiveHandEntity;
if (!hands.Drop(toInsert.Owner))
var handSys = _sysMan.GetEntitySystem<SharedHandsSystem>();
if (!handSys.TryDrop(player, toInsert.Value, handsComp: hands))
{
Owner.PopupMessage(player, "Can't insert.");
return false;
}
if (!Insert(toInsert.Owner))
if (!Insert(toInsert.Value))
{
hands.PutInHand(toInsert);
handSys.PickupOrDrop(player, toInsert.Value, handsComp: hands);
Owner.PopupMessage(player, "Can't insert.");
return false;
}
@@ -475,18 +479,7 @@ namespace Content.Server.Storage.Components
break;
}
if (!_entityManager.TryGetComponent(remove.EntityUid, out SharedItemComponent? item) || !_entityManager.TryGetComponent(player, out HandsComponent? hands))
{
break;
}
if (!hands.CanPutInHand(item))
{
break;
}
hands.PutInHand(item);
_sysMan.GetEntitySystem<SharedHandsSystem>().TryPickupAnyHand(player, remove.EntityUid);
break;
}
case InsertEntityMessage _:

View File

@@ -1,8 +1,8 @@
using Content.Server.Clothing.Components;
using Content.Server.Popups;
using Content.Server.Storage.Components;
using Content.Shared.Acts;
using Content.Shared.Hands.Components;
using Content.Shared.Hands.EntitySystems;
using Content.Shared.Item;
using Robust.Shared.Containers;
using Robust.Shared.Player;
@@ -12,6 +12,7 @@ namespace Content.Server.Storage.EntitySystems
public sealed class SecretStashSystem : EntitySystem
{
[Dependency] private readonly PopupSystem _popupSystem = default!;
[Dependency] private readonly SharedHandsSystem _handsSystem = default!;
public override void Initialize()
{
@@ -83,7 +84,7 @@ namespace Content.Server.Storage.EntitySystems
}
// try to move item from hands to stash container
if (!hands.Drop(itemToHideUid, container))
if (!_handsSystem.TryDropIntoContainer(userUid, itemToHideUid, container))
{
return false;
}
@@ -115,13 +116,7 @@ namespace Content.Server.Storage.EntitySystems
return false;
}
// get item inside container
var itemUid = container.ContainedEntity;
if (!EntityManager.TryGetComponent(itemUid, out SharedItemComponent? item))
{
return false;
}
hands.PutInHandOrDrop(item);
_handsSystem.PickupOrDrop(userUid, container.ContainedEntity.Value, handsComp: hands);
// show success message
var successMsg = Loc.GetString("comp-secret-stash-action-get-item-found-something",

View File

@@ -1,10 +1,7 @@
using System.Collections.Generic;
using Content.Server.Storage.Components;
using Content.Shared.Hands.Components;
using Content.Shared.Hands.EntitySystems;
using Content.Shared.Interaction.Events;
using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Player;
using Robust.Shared.Random;
@@ -13,6 +10,7 @@ namespace Content.Server.Storage.EntitySystems
public sealed class SpawnItemsOnUseSystem : EntitySystem
{
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly SharedHandsSystem _handsSystem = default!;
public override void Initialize()
{
@@ -57,10 +55,9 @@ namespace Content.Server.Storage.EntitySystems
EntityManager.DeleteEntity(uid);
}
if (entityToPlaceInHands != null
&& EntityManager.TryGetComponent<SharedHandsComponent?>(args.User, out var hands))
if (entityToPlaceInHands != null)
{
hands.TryPutInAnyHand(entityToPlaceInHands.Value);
_handsSystem.PickupOrDrop(args.User, entityToPlaceInHands.Value);
}
}
}