From 6c6ae35cf8f9b9e4c0f1883ec8998e9adab6752d Mon Sep 17 00:00:00 2001 From: Crude Oil <124208219+CroilBird@users.noreply.github.com> Date: Sun, 21 Jul 2024 07:49:48 +0200 Subject: [PATCH] Add ability to show stack visuals on closed containers (#29309) * add ability to show stack visuals on closed containers * remove container stack visuals logic from sharedstoragesystem * improve comments a bit * move logic for open/closed containers into itemcountersystem * move behavior to storage component * remove unused import * remove old comment * fix comments * fix wrong property name * Update Content.Shared/Storage/EntitySystems/SharedStorageSystem.cs * Rename variable for clarity --------- Co-authored-by: ShadowCommander <10494922+ShadowCommander@users.noreply.github.com> --- Content.Client/Storage/Systems/ItemCounterSystem.cs | 2 +- Content.Shared/Storage/Components/ItemCounterComponent.cs | 2 +- .../Storage/EntitySystems/SharedStorageSystem.cs | 6 +++++- Content.Shared/Storage/StorageComponent.cs | 8 ++++++++ .../Entities/Objects/Consumable/Drinks/drinks_cans.yml | 1 + 5 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Content.Client/Storage/Systems/ItemCounterSystem.cs b/Content.Client/Storage/Systems/ItemCounterSystem.cs index 605f47d3b8..fcb1ca17dc 100644 --- a/Content.Client/Storage/Systems/ItemCounterSystem.cs +++ b/Content.Client/Storage/Systems/ItemCounterSystem.cs @@ -31,7 +31,7 @@ public sealed class ItemCounterSystem : SharedItemCounterSystem if (!_appearanceSystem.TryGetData(uid, StackVisuals.Hide, out var hidden, args.Component)) hidden = false; - + if (comp.IsComposite) ProcessCompositeSprite(uid, actual, maxCount, comp.LayerStates, hidden, sprite: args.Sprite); else diff --git a/Content.Shared/Storage/Components/ItemCounterComponent.cs b/Content.Shared/Storage/Components/ItemCounterComponent.cs index 890bc84e72..6a1444ebf6 100644 --- a/Content.Shared/Storage/Components/ItemCounterComponent.cs +++ b/Content.Shared/Storage/Components/ItemCounterComponent.cs @@ -1,4 +1,4 @@ -using Content.Shared.Storage.EntitySystems; +using Content.Shared.Storage.EntitySystems; using Content.Shared.Whitelist; namespace Content.Shared.Storage.Components diff --git a/Content.Shared/Storage/EntitySystems/SharedStorageSystem.cs b/Content.Shared/Storage/EntitySystems/SharedStorageSystem.cs index 5c2e0080a6..4bb4192fc4 100644 --- a/Content.Shared/Storage/EntitySystems/SharedStorageSystem.cs +++ b/Content.Shared/Storage/EntitySystems/SharedStorageSystem.cs @@ -806,7 +806,11 @@ public abstract class SharedStorageSystem : EntitySystem _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, StackVisuals.Hide, !isOpen, 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) + if (storage.HideStackVisualsWhenClosed) + _appearance.SetData(uid, StackVisuals.Hide, !isOpen, appearance); } /// diff --git a/Content.Shared/Storage/StorageComponent.cs b/Content.Shared/Storage/StorageComponent.cs index 2860f8dacf..a666169f52 100644 --- a/Content.Shared/Storage/StorageComponent.cs +++ b/Content.Shared/Storage/StorageComponent.cs @@ -123,6 +123,14 @@ namespace Content.Shared.Storage [DataField, ViewVariables(VVAccess.ReadWrite)] public StorageDefaultOrientation? DefaultStorageOrientation; + /// + /// If true, sets StackVisuals.Hide to true when the container is closed + /// Used in cases where there are sprites that are shown when the container is open but not + /// when it is closed + /// + [DataField] + public bool HideStackVisualsWhenClosed = true; + [Serializable, NetSerializable] public enum StorageUiKey : byte { diff --git a/Resources/Prototypes/Entities/Objects/Consumable/Drinks/drinks_cans.yml b/Resources/Prototypes/Entities/Objects/Consumable/Drinks/drinks_cans.yml index f5cb260e03..b6488dbe8b 100644 --- a/Resources/Prototypes/Entities/Objects/Consumable/Drinks/drinks_cans.yml +++ b/Resources/Prototypes/Entities/Objects/Consumable/Drinks/drinks_cans.yml @@ -432,6 +432,7 @@ whitelist: tags: - Cola + hideStackVisualsWhenClosed: false - type: StorageFill contents: - id: DrinkColaCan -- 2.51.2