]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix trash bag visuals (#32386)
authorbeck-thompson <107373427+beck-thompson@users.noreply.github.com>
Thu, 17 Apr 2025 10:36:23 +0000 (03:36 -0700)
committerGitHub <noreply@github.com>
Thu, 17 Apr 2025 10:36:23 +0000 (20:36 +1000)
* First commit

* Dont even look what I did at first I'm silly

* more negative diff!!

Content.Server/Storage/EntitySystems/StorageFillVisualizerSystem.cs [deleted file]
Content.Shared/Storage/EntitySystems/SharedStorageSystem.cs

diff --git a/Content.Server/Storage/EntitySystems/StorageFillVisualizerSystem.cs b/Content.Server/Storage/EntitySystems/StorageFillVisualizerSystem.cs
deleted file mode 100644 (file)
index 0489446..0000000
+++ /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<StorageFillVisualizerComponent, ComponentStartup>(OnStartup);
-        SubscribeLocalEvent<StorageFillVisualizerComponent, EntInsertedIntoContainerMessage>(OnInserted);
-        SubscribeLocalEvent<StorageFillVisualizerComponent, EntRemovedFromContainerMessage>(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<int>(uid, StorageVisuals.StorageUsed, out var used, appearance))
-            return;
-
-        if (!_appearance.TryGetData<int>(uid, StorageVisuals.Capacity, out var capacity, appearance))
-            return;
-
-        var level = ContentHelpers.RoundToLevels(used, capacity, component.MaxFillLevels);
-        _appearance.SetData(uid, StorageFillVisuals.FillLevel, level, appearance);
-    }
-}
index f2a2031743107c2cf4833c589650564d22915f8b..3bf51f79579efc3f7bebacd1b6f615a9edfd17ae 100644 (file)
@@ -40,6 +40,7 @@ using Robust.Shared.Random;
 using Robust.Shared.Serialization;
 using Robust.Shared.Timing;
 using Robust.Shared.Utility;
+using Content.Shared.Rounding;
 
 namespace Content.Shared.Storage.EntitySystems;
 
@@ -880,6 +881,12 @@ public abstract class SharedStorageSystem : EntitySystem
         _appearance.SetData(uid, StorageVisuals.Open, isOpen, appearance);
         _appearance.SetData(uid, SharedBagOpenVisuals.BagState, isOpen ? SharedBagState.Open : SharedBagState.Closed, appearance);
 
+        if (TryComp<StorageFillVisualizerComponent>(uid, out var storageFillVisualizerComp))
+        {
+            var level = ContentHelpers.RoundToLevels(used, capacity, storageFillVisualizerComp.MaxFillLevels);
+            _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)
         if (storage.HideStackVisualsWhenClosed)