Virtual items cleanup (#23912)
* Virtual items cleanup * Detail * Review --------- Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
@@ -1,20 +0,0 @@
|
||||
using Content.Client.Hands.UI;
|
||||
using Content.Client.Items;
|
||||
using Content.Shared.Hands;
|
||||
using Content.Shared.Hands.Components;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Client.Hands.Systems
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public sealed class HandVirtualItemSystem : SharedHandVirtualItemSystem
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
Subs.ItemStatus<HandVirtualItemComponent>(_ => new HandVirtualItemStatus());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ using Content.Client.Verbs.UI;
|
||||
using Content.Shared.Hands;
|
||||
using Content.Shared.Hands.Components;
|
||||
using Content.Shared.Hands.EntitySystems;
|
||||
using Content.Shared.Inventory.VirtualItem;
|
||||
using Content.Shared.Item;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
@@ -252,7 +253,7 @@ namespace Content.Client.Hands.Systems
|
||||
|
||||
OnPlayerItemAdded?.Invoke(hand.Name, args.Entity);
|
||||
|
||||
if (HasComp<HandVirtualItemComponent>(args.Entity))
|
||||
if (HasComp<VirtualItemComponent>(args.Entity))
|
||||
OnPlayerHandBlocked?.Invoke(hand.Name);
|
||||
}
|
||||
|
||||
@@ -270,7 +271,7 @@ namespace Content.Client.Hands.Systems
|
||||
|
||||
OnPlayerItemRemoved?.Invoke(hand.Name, args.Entity);
|
||||
|
||||
if (HasComp<HandVirtualItemComponent>(args.Entity))
|
||||
if (HasComp<VirtualItemComponent>(args.Entity))
|
||||
OnPlayerHandUnblocked?.Invoke(hand.Name);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ using Content.Shared.Hands.Components;
|
||||
using Content.Shared.IdentityManagement;
|
||||
using Content.Shared.Input;
|
||||
using Content.Shared.Inventory;
|
||||
using Content.Shared.Inventory.VirtualItem;
|
||||
using Content.Shared.Strip.Components;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
@@ -159,7 +160,7 @@ namespace Content.Client.Inventory
|
||||
|
||||
button.Pressed += SlotPressed;
|
||||
|
||||
if (EntMan.TryGetComponent<HandVirtualItemComponent>(hand.HeldEntity, out var virt))
|
||||
if (EntMan.TryGetComponent<VirtualItemComponent>(hand.HeldEntity, out var virt))
|
||||
{
|
||||
button.Blocked = true;
|
||||
if (EntMan.TryGetComponent<CuffableComponent>(Owner, out var cuff) && _cuffable.GetAllCuffs(cuff).Contains(virt.BlockingEntity))
|
||||
@@ -224,7 +225,7 @@ namespace Content.Client.Inventory
|
||||
}
|
||||
|
||||
EntityUid? viewEnt;
|
||||
if (EntMan.TryGetComponent<HandVirtualItemComponent>(entity, out var virt))
|
||||
if (EntMan.TryGetComponent<VirtualItemComponent>(entity, out var virt))
|
||||
viewEnt = EntMan.HasComponent<SpriteComponent>(virt.BlockingEntity) ? virt.BlockingEntity : null;
|
||||
else if (EntMan.HasComponent<SpriteComponent>(entity))
|
||||
viewEnt = entity;
|
||||
|
||||
15
Content.Client/Inventory/VirtualItemSystem.cs
Normal file
15
Content.Client/Inventory/VirtualItemSystem.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using Content.Client.Hands.UI;
|
||||
using Content.Client.Items;
|
||||
using Content.Shared.Inventory.VirtualItem;
|
||||
|
||||
namespace Content.Client.Inventory;
|
||||
|
||||
public sealed class VirtualItemSystem : SharedVirtualItemSystem
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
Subs.ItemStatus<VirtualItemComponent>(_ => new HandVirtualItemStatus());
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ using Content.Client.UserInterface.Systems.Hands.Controls;
|
||||
using Content.Client.UserInterface.Systems.Hotbar.Widgets;
|
||||
using Content.Shared.Hands.Components;
|
||||
using Content.Shared.Input;
|
||||
using Content.Shared.Inventory.VirtualItem;
|
||||
using Content.Shared.Timing;
|
||||
using Robust.Client.Player;
|
||||
using Robust.Client.UserInterface;
|
||||
@@ -117,7 +118,7 @@ public sealed class HandsUIController : UIController, IOnStateEntered<GameplaySt
|
||||
{
|
||||
var handButton = AddHand(name, hand.Location);
|
||||
|
||||
if (_entities.TryGetComponent(hand.HeldEntity, out HandVirtualItemComponent? virt))
|
||||
if (_entities.TryGetComponent(hand.HeldEntity, out VirtualItemComponent? virt))
|
||||
{
|
||||
handButton.SpriteView.SetEntity(virt.BlockingEntity);
|
||||
handButton.Blocked = true;
|
||||
@@ -168,7 +169,7 @@ public sealed class HandsUIController : UIController, IOnStateEntered<GameplaySt
|
||||
if (hand == null)
|
||||
return;
|
||||
|
||||
if (_entities.TryGetComponent(entity, out HandVirtualItemComponent? virt))
|
||||
if (_entities.TryGetComponent(entity, out VirtualItemComponent? virt))
|
||||
{
|
||||
hand.SpriteView.SetEntity(virt.BlockingEntity);
|
||||
hand.Blocked = true;
|
||||
|
||||
@@ -2,6 +2,7 @@ using Content.Client.Items;
|
||||
using Content.Client.Resources;
|
||||
using Content.Shared.Hands.Components;
|
||||
using Content.Shared.IdentityManagement;
|
||||
using Content.Shared.Inventory.VirtualItem;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
@@ -104,7 +105,7 @@ public sealed partial class ItemStatusPanel : BoxContainer
|
||||
return;
|
||||
}
|
||||
|
||||
if (_entityManager.TryGetComponent(_entity, out HandVirtualItemComponent? virtualItem)
|
||||
if (_entityManager.TryGetComponent(_entity, out VirtualItemComponent? virtualItem)
|
||||
&& _entityManager.EntityExists(virtualItem.BlockingEntity))
|
||||
{
|
||||
// Uses identity because we can be blocked by pulling someone
|
||||
|
||||
@@ -12,6 +12,7 @@ using Content.Client.UserInterface.Systems.Inventory.Windows;
|
||||
using Content.Shared.Containers.ItemSlots;
|
||||
using Content.Shared.Hands.Components;
|
||||
using Content.Shared.Input;
|
||||
using Content.Shared.Inventory.VirtualItem;
|
||||
using Content.Shared.Storage;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Client.UserInterface;
|
||||
@@ -423,8 +424,17 @@ public sealed class InventoryUIController : UIController, IOnStateEntered<Gamepl
|
||||
if (_slotGroups.GetValueOrDefault(group)?.GetButton(name) is not { } button)
|
||||
return;
|
||||
|
||||
button.SpriteView.SetEntity(entity);
|
||||
button.StorageButton.Visible = showStorage;
|
||||
if (_entities.TryGetComponent(entity, out VirtualItemComponent? virtb))
|
||||
{
|
||||
button.SpriteView.SetEntity(virtb.BlockingEntity);
|
||||
button.Blocked = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
button.SpriteView.SetEntity(entity);
|
||||
button.Blocked = false;
|
||||
button.StorageButton.Visible = showStorage;
|
||||
}
|
||||
}
|
||||
|
||||
public bool RegisterSlotGroupContainer(ItemSlotButtonContainer slotContainer)
|
||||
|
||||
Reference in New Issue
Block a user