Move storage binds and slot click handling to shared (#27135)

This commit is contained in:
DrSmugleaf
2024-04-19 23:23:45 -07:00
committed by GitHub
parent 812abd33a0
commit 3c6722bd6f
5 changed files with 52 additions and 54 deletions

View File

@@ -1,21 +1,15 @@
using Content.Server.Storage.EntitySystems;
using Content.Shared.Explosion;
using Content.Shared.Inventory;
using Content.Shared.Inventory.Events;
using Content.Shared.Storage;
namespace Content.Server.Inventory
{
public sealed class ServerInventorySystem : InventorySystem
{
[Dependency] private readonly StorageSystem _storageSystem = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<InventoryComponent, BeforeExplodeEvent>(OnExploded);
SubscribeNetworkEvent<OpenSlotStorageNetworkMessage>(OnOpenSlotStorage);
}
private void OnExploded(Entity<InventoryComponent> ent, ref BeforeExplodeEvent args)
@@ -29,17 +23,6 @@ namespace Content.Server.Inventory
}
}
private void OnOpenSlotStorage(OpenSlotStorageNetworkMessage ev, EntitySessionEventArgs args)
{
if (args.SenderSession.AttachedEntity is not { Valid: true } uid)
return;
if (TryGetSlotEntity(uid, ev.Slot, out var entityUid) && TryComp<StorageComponent>(entityUid, out var storageComponent))
{
_storageSystem.OpenStorageUI(entityUid.Value, uid, storageComponent);
}
}
public void TransferEntityInventories(Entity<InventoryComponent?> source, Entity<InventoryComponent?> target)
{
if (!Resolve(source.Owner, ref source.Comp) || !Resolve(target.Owner, ref target.Comp))