Skip to content

Commit

Permalink
Add ability to show stack visuals on closed containers (#29309)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
CroilBird and ShadowCommander authored Jul 21, 2024
1 parent b0c4c45 commit 6c6ae35
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Content.Client/Storage/Systems/ItemCounterSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ private void OnAppearanceChange(EntityUid uid, ItemCounterComponent comp, ref Ap

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
Expand Down
2 changes: 1 addition & 1 deletion Content.Shared/Storage/Components/ItemCounterComponent.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Content.Shared.Storage.EntitySystems;
using Content.Shared.Storage.EntitySystems;
using Content.Shared.Whitelist;

namespace Content.Shared.Storage.Components
Expand Down
6 changes: 5 additions & 1 deletion Content.Shared/Storage/EntitySystems/SharedStorageSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,11 @@ public void UpdateAppearance(Entity<StorageComponent?, AppearanceComponent?> 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, 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>
Expand Down
8 changes: 8 additions & 0 deletions Content.Shared/Storage/StorageComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,14 @@ public sealed partial class StorageComponent : Component
[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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@
whitelist:
tags:
- Cola
hideStackVisualsWhenClosed: false
- type: StorageFill
contents:
- id: DrinkColaCan
Expand Down

0 comments on commit 6c6ae35

Please sign in to comment.