Co-authored-by: fishfish458 <fishfish458> Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
47 lines
1.6 KiB
C#
47 lines
1.6 KiB
C#
using Content.Server.Clothing.Components;
|
|
using Content.Server.Storage.Components;
|
|
using Content.Server.Storage.EntitySystems;
|
|
using Content.Server.Temperature.Systems;
|
|
using Content.Shared.Interaction.Events;
|
|
using Content.Shared.Inventory;
|
|
using Content.Shared.Inventory.Events;
|
|
using InventoryComponent = Content.Shared.Inventory.InventoryComponent;
|
|
|
|
namespace Content.Server.Inventory
|
|
{
|
|
public sealed class ServerInventorySystem : InventorySystem
|
|
{
|
|
[Dependency] private readonly StorageSystem _storageSystem = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<InventoryComponent, ModifyChangedTemperatureEvent>(RelayInventoryEvent);
|
|
|
|
SubscribeLocalEvent<ClothingComponent, UseInHandEvent>(OnUseInHand);
|
|
|
|
SubscribeNetworkEvent<OpenSlotStorageNetworkMessage>(OnOpenSlotStorage);
|
|
}
|
|
|
|
private void OnUseInHand(EntityUid uid, ClothingComponent component, UseInHandEvent args)
|
|
{
|
|
if (args.Handled || !component.QuickEquip)
|
|
return;
|
|
|
|
QuickEquip(uid, component, args);
|
|
}
|
|
|
|
private void OnOpenSlotStorage(OpenSlotStorageNetworkMessage ev, EntitySessionEventArgs args)
|
|
{
|
|
if (args.SenderSession.AttachedEntity is not EntityUid { Valid: true } uid)
|
|
return;
|
|
|
|
if (TryGetSlotEntity(uid, ev.Slot, out var entityUid) && TryComp<ServerStorageComponent>(entityUid, out var storageComponent))
|
|
{
|
|
_storageSystem.OpenStorageUI(entityUid.Value, uid, storageComponent);
|
|
}
|
|
}
|
|
}
|
|
}
|