diff --git a/Content.Server/Storage/EntitySystems/StorageFillVisualizerSystem.cs b/Content.Server/Storage/EntitySystems/StorageFillVisualizerSystem.cs deleted file mode 100644 index 04894461edf070..00000000000000 --- a/Content.Server/Storage/EntitySystems/StorageFillVisualizerSystem.cs +++ /dev/null @@ -1,53 +0,0 @@ -using Content.Shared.Rounding; -using Content.Shared.Storage; -using Content.Shared.Storage.Components; -using Robust.Shared.Containers; - -namespace Content.Server.Storage.EntitySystems; - -public sealed class StorageFillVisualizerSystem : EntitySystem -{ - [Dependency] private readonly SharedAppearanceSystem _appearance = default!; - - public override void Initialize() - { - base.Initialize(); - SubscribeLocalEvent(OnStartup); - SubscribeLocalEvent(OnInserted); - SubscribeLocalEvent(OnRemoved); - } - - private void OnStartup(EntityUid uid, StorageFillVisualizerComponent component, ComponentStartup args) - { - UpdateAppearance(uid, component: component); - } - - private void OnInserted(EntityUid uid, StorageFillVisualizerComponent component, EntInsertedIntoContainerMessage args) - { - UpdateAppearance(uid, component: component); - } - - private void OnRemoved(EntityUid uid, StorageFillVisualizerComponent component, EntRemovedFromContainerMessage args) - { - UpdateAppearance(uid, component: component); - } - - private void UpdateAppearance(EntityUid uid, StorageComponent? storage = null, AppearanceComponent? appearance = null, - StorageFillVisualizerComponent? component = null) - { - if (!Resolve(uid, ref storage, ref appearance, ref component, false)) - return; - - if (component.MaxFillLevels < 1) - return; - - if (!_appearance.TryGetData(uid, StorageVisuals.StorageUsed, out var used, appearance)) - return; - - if (!_appearance.TryGetData(uid, StorageVisuals.Capacity, out var capacity, appearance)) - return; - - var level = ContentHelpers.RoundToLevels(used, capacity, component.MaxFillLevels); - _appearance.SetData(uid, StorageFillVisuals.FillLevel, level, appearance); - } -} diff --git a/Content.Shared/Storage/EntitySystems/SharedStorageSystem.cs b/Content.Shared/Storage/EntitySystems/SharedStorageSystem.cs index d6fde292a14786..5018be46ce1f60 100644 --- a/Content.Shared/Storage/EntitySystems/SharedStorageSystem.cs +++ b/Content.Shared/Storage/EntitySystems/SharedStorageSystem.cs @@ -36,6 +36,8 @@ using Robust.Shared.Random; using Robust.Shared.Serialization; using Robust.Shared.Utility; +using Content.Shared.Rounding; +using Content.Shared.Storage; namespace Content.Shared.Storage.EntitySystems; @@ -738,11 +740,11 @@ private void OnInsertAttempt(EntityUid uid, StorageComponent component, Containe } } - public void UpdateAppearance(Entity entity) + public void UpdateAppearance(Entity entity) { // TODO STORAGE remove appearance data and just use the data on the component. - var (uid, storage, appearance) = entity; - if (!Resolve(uid, ref storage, ref appearance, false)) + var (uid, storage, appearance, storageFillVis) = entity; + if (!Resolve(uid, ref storage, ref appearance, ref storageFillVis, false)) return; // ReSharper disable once ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract @@ -751,6 +753,7 @@ public void UpdateAppearance(Entity ent var capacity = storage.Grid.GetArea(); var used = GetCumulativeItemAreas((uid, storage)); + var level = ContentHelpers.RoundToLevels(used, capacity, storageFillVis.MaxFillLevels); var isOpen = _ui.IsUiOpen(entity.Owner, StorageComponent.StorageUiKey.Key); @@ -758,6 +761,7 @@ public void UpdateAppearance(Entity ent _appearance.SetData(uid, StorageVisuals.Capacity, capacity, appearance); _appearance.SetData(uid, StorageVisuals.Open, isOpen, appearance); _appearance.SetData(uid, SharedBagOpenVisuals.BagState, isOpen ? SharedBagState.Open : SharedBagState.Closed, appearance); + _appearance.SetData(uid, StorageFillVisuals.FillLevel, level, appearance); // HideClosedStackVisuals true sets the StackVisuals.Hide to the open state of the storage. // This is for containers that only show their contents when open. (e.g. donut boxes)