Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to show stack visuals on closed containers #29309

Merged
merged 13 commits into from
Jul 21, 2024
Merged
7 changes: 6 additions & 1 deletion Content.Client/Storage/Systems/ItemCounterSystem.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Content.Shared.Rounding;
using Content.Shared.Stacks;
using Content.Shared.Storage;
using Content.Shared.Storage.Components;
using Content.Shared.Storage.EntitySystems;
using Robust.Client.GameObjects;
Expand Down Expand Up @@ -31,7 +32,11 @@ private void OnAppearanceChange(EntityUid uid, ItemCounterComponent comp, ref Ap

if (!_appearanceSystem.TryGetData<bool>(uid, StackVisuals.Hide, out var hidden, args.Component))
hidden = false;


// try and use the container state if there is one
if (_appearanceSystem.TryGetData<bool>(uid, StorageVisuals.Open, out var openContainer, args.Component))
hidden = !openContainer && comp.OpenContainerOnly;

if (comp.IsComposite)
ProcessCompositeSprite(uid, actual, maxCount, comp.LayerStates, hidden, sprite: args.Sprite);
else
Expand Down
11 changes: 10 additions & 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 All @@ -14,6 +14,7 @@ namespace Content.Shared.Storage.Components
/// amount: 6 # Note: this field can be omitted.
/// count:
/// tags: [Cigarette]
/// openContainerOnly: true
/// </code>
[RegisterComponent]
[Access(typeof(SharedItemCounterSystem))]
Expand Down Expand Up @@ -56,5 +57,13 @@ public sealed partial class ItemCounterComponent : Component
[DataField("layerStates")]
[ViewVariables(VVAccess.ReadWrite)]
public List<string> LayerStates = new();

/// <summary>
/// If the component has a storage component, show sprite layers for counting on open storage only,
/// Defaults to true
/// </summary>
[DataField("openContainerOnly")]
[ViewVariables(VVAccess.ReadWrite)]
public bool OpenContainerOnly = true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,6 @@ 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);
CroilBird marked this conversation as resolved.
Show resolved Hide resolved
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@
count:
tags: [Cola]
composite: true
openContainerOnly: false
layerStates:
- 6pack1
- 6pack2
Expand Down
Loading