@@ -7,9 +7,7 @@ using Content.Client.Items.Managers;
|
|||||||
using Content.Client.Items.Components;
|
using Content.Client.Items.Components;
|
||||||
using Content.Client.UserInterface.Controls;
|
using Content.Client.UserInterface.Controls;
|
||||||
using Content.Shared.DragDrop;
|
using Content.Shared.DragDrop;
|
||||||
using Content.Shared.Stacks;
|
|
||||||
using Content.Shared.Storage;
|
using Content.Shared.Storage;
|
||||||
using Content.Shared.Storage.Components;
|
|
||||||
using Robust.Client.GameObjects;
|
using Robust.Client.GameObjects;
|
||||||
using Robust.Client.Graphics;
|
using Robust.Client.Graphics;
|
||||||
using Robust.Client.Player;
|
using Robust.Client.Player;
|
||||||
@@ -43,14 +41,6 @@ namespace Content.Client.Storage
|
|||||||
|
|
||||||
public override IReadOnlyList<IEntity> StoredEntities => _storedEntities;
|
public override IReadOnlyList<IEntity> StoredEntities => _storedEntities;
|
||||||
|
|
||||||
protected override void Initialize()
|
|
||||||
{
|
|
||||||
base.Initialize();
|
|
||||||
|
|
||||||
// Hide stackVisualizer on start
|
|
||||||
ChangeStorageVisualization(SharedBagState.Close);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnAdd()
|
protected override void OnAdd()
|
||||||
{
|
{
|
||||||
base.OnAdd();
|
base.OnAdd();
|
||||||
@@ -142,36 +132,14 @@ namespace Content.Client.Storage
|
|||||||
if (_window == null) return;
|
if (_window == null) return;
|
||||||
|
|
||||||
if (_window.IsOpen)
|
if (_window.IsOpen)
|
||||||
{
|
|
||||||
_window.Close();
|
_window.Close();
|
||||||
ChangeStorageVisualization(SharedBagState.Close);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
_window.OpenCentered();
|
_window.OpenCentered();
|
||||||
ChangeStorageVisualization(SharedBagState.Open);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CloseUI()
|
private void CloseUI()
|
||||||
{
|
{
|
||||||
if (_window == null) return;
|
_window?.Close();
|
||||||
|
|
||||||
_window.Close();
|
|
||||||
ChangeStorageVisualization(SharedBagState.Close);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ChangeStorageVisualization(SharedBagState state)
|
|
||||||
{
|
|
||||||
if (Owner.TryGetComponent<AppearanceComponent>(out var appearanceComponent))
|
|
||||||
{
|
|
||||||
appearanceComponent.SetData(SharedBagOpenVisuals.BagState, state);
|
|
||||||
if (Owner.HasComponent<ItemCounterComponent>())
|
|
||||||
{
|
|
||||||
appearanceComponent.SetData(StackVisuals.Hide, state == SharedBagState.Close);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -14,7 +14,9 @@ using Content.Shared.Item;
|
|||||||
using Content.Shared.Placeable;
|
using Content.Shared.Placeable;
|
||||||
using Content.Shared.Popups;
|
using Content.Shared.Popups;
|
||||||
using Content.Shared.Sound;
|
using Content.Shared.Sound;
|
||||||
|
using Content.Shared.Stacks;
|
||||||
using Content.Shared.Storage;
|
using Content.Shared.Storage;
|
||||||
|
using Content.Shared.Storage.Components;
|
||||||
using Content.Shared.Whitelist;
|
using Content.Shared.Whitelist;
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
using Robust.Server.Player;
|
using Robust.Server.Player;
|
||||||
@@ -41,6 +43,8 @@ namespace Content.Server.Storage.Components
|
|||||||
[ComponentReference(typeof(IStorageComponent))]
|
[ComponentReference(typeof(IStorageComponent))]
|
||||||
public class ServerStorageComponent : SharedStorageComponent, IInteractUsing, IUse, IActivate, IStorageComponent, IDestroyAct, IExAct, IAfterInteract
|
public class ServerStorageComponent : SharedStorageComponent, IInteractUsing, IUse, IActivate, IStorageComponent, IDestroyAct, IExAct, IAfterInteract
|
||||||
{
|
{
|
||||||
|
[Dependency] private readonly IEntityManager _entityManager = default!;
|
||||||
|
|
||||||
private const string LoggerName = "Storage";
|
private const string LoggerName = "Storage";
|
||||||
|
|
||||||
private Container? _storage;
|
private Container? _storage;
|
||||||
@@ -86,6 +90,20 @@ namespace Content.Server.Storage.Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void UpdateStorageVisualization()
|
||||||
|
{
|
||||||
|
if (!_entityManager.TryGetComponent(OwnerUid, out AppearanceComponent appearance))
|
||||||
|
return;
|
||||||
|
|
||||||
|
bool open = SubscribedSessions.Count != 0;
|
||||||
|
|
||||||
|
appearance.SetData(StorageVisuals.Open, open);
|
||||||
|
appearance.SetData(SharedBagOpenVisuals.BagState, open ? SharedBagState.Open : SharedBagState.Closed);
|
||||||
|
|
||||||
|
if (_entityManager.HasComponent<ItemCounterComponent>(OwnerUid))
|
||||||
|
appearance.SetData(StackVisuals.Hide, !open);
|
||||||
|
}
|
||||||
|
|
||||||
private void EnsureInitialCalculated()
|
private void EnsureInitialCalculated()
|
||||||
{
|
{
|
||||||
if (_storageInitialCalculated)
|
if (_storageInitialCalculated)
|
||||||
@@ -341,9 +359,10 @@ namespace Content.Server.Storage.Components
|
|||||||
|
|
||||||
session.PlayerStatusChanged += HandlePlayerSessionChangeEvent;
|
session.PlayerStatusChanged += HandlePlayerSessionChangeEvent;
|
||||||
SubscribedSessions.Add(session);
|
SubscribedSessions.Add(session);
|
||||||
|
|
||||||
UpdateDoorState();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (SubscribedSessions.Count == 1)
|
||||||
|
UpdateStorageVisualization();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -360,9 +379,10 @@ namespace Content.Server.Storage.Components
|
|||||||
#pragma warning disable 618
|
#pragma warning disable 618
|
||||||
SendNetworkMessage(new CloseStorageUIMessage(), session.ConnectedClient);
|
SendNetworkMessage(new CloseStorageUIMessage(), session.ConnectedClient);
|
||||||
#pragma warning restore 618
|
#pragma warning restore 618
|
||||||
|
|
||||||
UpdateDoorState();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (SubscribedSessions.Count == 0)
|
||||||
|
UpdateStorageVisualization();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandlePlayerSessionChangeEvent(object? obj, SessionStatusEventArgs sessionStatus)
|
private void HandlePlayerSessionChangeEvent(object? obj, SessionStatusEventArgs sessionStatus)
|
||||||
@@ -375,14 +395,6 @@ namespace Content.Server.Storage.Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateDoorState()
|
|
||||||
{
|
|
||||||
if (Owner.TryGetComponent(out AppearanceComponent? appearance))
|
|
||||||
{
|
|
||||||
appearance.SetData(StorageVisuals.Open, SubscribedSessions.Count != 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Initialize()
|
protected override void Initialize()
|
||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
@@ -390,6 +402,7 @@ namespace Content.Server.Storage.Components
|
|||||||
// ReSharper disable once StringLiteralTypo
|
// ReSharper disable once StringLiteralTypo
|
||||||
_storage = Owner.EnsureContainer<Container>("storagebase");
|
_storage = Owner.EnsureContainer<Container>("storagebase");
|
||||||
_storage.OccludesLight = _occludesLight;
|
_storage.OccludesLight = _occludesLight;
|
||||||
|
UpdateStorageVisualization();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Obsolete("Component Messages are deprecated, use Entity Events instead.")]
|
[Obsolete("Component Messages are deprecated, use Entity Events instead.")]
|
||||||
|
|||||||
@@ -13,6 +13,6 @@ namespace Content.Shared.Storage.Components
|
|||||||
public enum SharedBagState : byte
|
public enum SharedBagState : byte
|
||||||
{
|
{
|
||||||
Open,
|
Open,
|
||||||
Close,
|
Closed,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user