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

@@ -5,6 +5,7 @@ using Content.Server.Traitor.Uplink.Components;
using Content.Server.UserInterface;
using Content.Shared.ActionBlocker;
using Content.Shared.Hands.Components;
using Content.Shared.Hands.EntitySystems;
using Content.Shared.Interaction;
using Content.Shared.Inventory;
using Content.Shared.Item;
@@ -28,6 +29,7 @@ namespace Content.Server.Traitor.Uplink
private readonly UplinkListingSytem _listing = default!;
[Dependency] private readonly InventorySystem _inventorySystem = default!;
[Dependency] private readonly SharedHandsSystem _handsSystem = default!;
public override void Initialize()
{
@@ -123,11 +125,7 @@ namespace Content.Server.Traitor.Uplink
return;
}
if (EntityManager.TryGetComponent(player, out HandsComponent? hands) &&
EntityManager.TryGetComponent(entity.Value, out SharedItemComponent? item))
{
hands.PutInHandOrDrop(item);
}
_handsSystem.PickupOrDrop(player, entity.Value);
SoundSystem.Play(Filter.SinglePlayer(message.Session), uplink.BuySuccessSound.GetSound(),
uplink.Owner, AudioParams.Default.WithVolume(-8f));
@@ -149,8 +147,7 @@ namespace Content.Server.Traitor.Uplink
return;
// try to put it into players hands
if (EntityManager.TryGetComponent(player, out SharedHandsComponent? hands))
hands.TryPutInAnyHand(tcUid.Value);
_handsSystem.PickupOrDrop(player, tcUid.Value);
// play buying sound
SoundSystem.Play(Filter.SinglePlayer(args.Session), uplink.BuySuccessSound.GetSound(),
@@ -217,14 +214,10 @@ namespace Content.Server.Traitor.Uplink
}
// Also check hands
if (EntityManager.TryGetComponent(user, out HandsComponent? hands))
foreach (var item in _handsSystem.EnumerateHeld(user))
{
var heldItems = hands.GetAllHeldItems();
foreach (var item in heldItems)
{
if (EntityManager.HasComponent<PDAComponent>(item.Owner))
return item.Owner;
}
if (HasComp<PDAComponent>(item))
return item;
}
return null;