2023-12-04 18:04:39 -05:00
|
|
|
using Content.Client.Storage.Systems;
|
2023-09-11 21:20:46 +10:00
|
|
|
using Content.Shared.Storage;
|
2022-09-11 20:42:12 -07:00
|
|
|
using JetBrains.Annotations;
|
2022-04-28 06:11:15 -06:00
|
|
|
|
2023-12-04 18:04:39 -05:00
|
|
|
namespace Content.Client.Storage;
|
2023-09-11 21:20:46 +10:00
|
|
|
|
2023-12-04 18:04:39 -05:00
|
|
|
[UsedImplicitly]
|
|
|
|
|
public sealed class StorageBoundUserInterface : BoundUserInterface
|
|
|
|
|
{
|
|
|
|
|
[Dependency] private readonly IEntityManager _entManager = default!;
|
2022-10-12 18:35:25 +02:00
|
|
|
|
2023-12-04 18:04:39 -05:00
|
|
|
private readonly StorageSystem _storage;
|
2022-10-12 18:35:25 +02:00
|
|
|
|
2023-12-04 18:04:39 -05:00
|
|
|
public StorageBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
|
|
|
|
|
{
|
|
|
|
|
IoCManager.InjectDependencies(this);
|
|
|
|
|
_storage = _entManager.System<StorageSystem>();
|
|
|
|
|
}
|
2022-10-12 18:35:25 +02:00
|
|
|
|
2023-12-04 18:04:39 -05:00
|
|
|
protected override void Dispose(bool disposing)
|
|
|
|
|
{
|
|
|
|
|
base.Dispose(disposing);
|
|
|
|
|
if (!disposing)
|
|
|
|
|
return;
|
2022-04-28 06:11:15 -06:00
|
|
|
|
2023-12-08 13:43:37 -05:00
|
|
|
_storage.CloseStorageWindow(Owner);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void ReceiveMessage(BoundUserInterfaceMessage message)
|
|
|
|
|
{
|
|
|
|
|
base.ReceiveMessage(message);
|
|
|
|
|
|
|
|
|
|
if (message is StorageModifyWindowMessage)
|
|
|
|
|
{
|
|
|
|
|
if (_entManager.TryGetComponent<StorageComponent>(Owner, out var comp))
|
|
|
|
|
_storage.OpenStorageWindow((Owner, comp));
|
|
|
|
|
}
|
2022-04-28 06:11:15 -06:00
|
|
|
}
|
|
|
|
|
}
|
2023-12-04 18:04:39 -05:00
|
|
|
|