]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Add ability to show stack visuals on closed containers (#29309)
authorCrude Oil <124208219+CroilBird@users.noreply.github.com>
Sun, 21 Jul 2024 05:49:48 +0000 (07:49 +0200)
committerGitHub <noreply@github.com>
Sun, 21 Jul 2024 05:49:48 +0000 (22:49 -0700)
* 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
Content.Shared/Storage/Components/ItemCounterComponent.cs
Content.Shared/Storage/EntitySystems/SharedStorageSystem.cs
Content.Shared/Storage/StorageComponent.cs
Resources/Prototypes/Entities/Objects/Consumable/Drinks/drinks_cans.yml

index 605f47d3b8ab3b4e3d9b1f296168a2ff406060d7..fcb1ca17dc66f3e4c79b252af248928d44cd9117 100644 (file)
@@ -31,7 +31,7 @@ public sealed class ItemCounterSystem : SharedItemCounterSystem
 
         if (!_appearanceSystem.TryGetData<bool>(uid, StackVisuals.Hide, out var hidden, args.Component))
             hidden = false;
-        
+
         if (comp.IsComposite)
             ProcessCompositeSprite(uid, actual, maxCount, comp.LayerStates, hidden, sprite: args.Sprite);
         else
index 890bc84e721bd78df58cfe490bda3237847c44b5..6a1444ebf629dde627e52ba38f07af8bdad32074 100644 (file)
@@ -1,4 +1,4 @@
-using Content.Shared.Storage.EntitySystems;
+using Content.Shared.Storage.EntitySystems;
 using Content.Shared.Whitelist;
 
 namespace Content.Shared.Storage.Components
index 5c2e0080a69fed2982607e0734eafeddebffe33c..4bb4192fc45195323044fa5829af7f2dd54db3cc 100644 (file)
@@ -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);
     }
 
     /// <summary>
index 2860f8dacfe82cbcfe1ef65f6a442fc26d837ddf..a666169f529481a1a6296e60849f4b24d7b2c73d 100644 (file)
@@ -123,6 +123,14 @@ namespace Content.Shared.Storage
         [DataField, ViewVariables(VVAccess.ReadWrite)]
         public StorageDefaultOrientation? DefaultStorageOrientation;
 
+        /// <summary>
+        /// 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
+        /// </summary>
+        [DataField]
+        public bool HideStackVisualsWhenClosed = true;
+
         [Serializable, NetSerializable]
         public enum StorageUiKey : byte
         {
index f5cb260e03bdc720322b3047477f935fa8a04e5c..b6488dbe8bf0285767b8431624c3eae0c0535569 100644 (file)
     whitelist:
       tags:
         - Cola
+    hideStackVisualsWhenClosed: false
   - type: StorageFill
     contents:
       - id: DrinkColaCan