]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Allow items spawned in the smart fridge to show up as an entry. (#42268)
authorPrincess Cheeseballs <66055347+Princess-Cheeseballs@users.noreply.github.com>
Fri, 9 Jan 2026 00:35:39 +0000 (16:35 -0800)
committerGitHub <noreply@github.com>
Fri, 9 Jan 2026 00:35:39 +0000 (00:35 +0000)
* Allow items spawned in the smart fridge to show up in the view

AAAAAAAAAAAAAAAAAA

---------

Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com>
Content.Client/SmartFridge/SmartFridgeSystem.cs [new file with mode: 0644]
Content.Client/SmartFridge/SmartFridgeUISystem.cs [deleted file]
Content.Server/SmartFridge/SmartFridgeSystem.cs [new file with mode: 0644]
Content.Shared/SmartFridge/SharedSmartFridgeSystem.cs [moved from Content.Shared/SmartFridge/SmartFridgeSystem.cs with 84% similarity]
Content.Shared/SmartFridge/SmartFridgeComponent.cs

diff --git a/Content.Client/SmartFridge/SmartFridgeSystem.cs b/Content.Client/SmartFridge/SmartFridgeSystem.cs
new file mode 100644 (file)
index 0000000..cd3aeb6
--- /dev/null
@@ -0,0 +1,18 @@
+using Content.Shared.SmartFridge;
+
+namespace Content.Client.SmartFridge;
+
+public sealed class SmartFridgeSystem : SharedSmartFridgeSystem
+{
+    [Dependency] private readonly SharedUserInterfaceSystem _uiSystem = default!;
+
+    protected override void UpdateUI(Entity<SmartFridgeComponent> ent)
+    {
+        base.UpdateUI(ent);
+
+        if (!_uiSystem.TryGetOpenUi<SmartFridgeBoundUserInterface>(ent.Owner, SmartFridgeUiKey.Key, out var bui))
+            return;
+
+        bui.Refresh();
+    }
+}
diff --git a/Content.Client/SmartFridge/SmartFridgeUISystem.cs b/Content.Client/SmartFridge/SmartFridgeUISystem.cs
deleted file mode 100644 (file)
index 4068c27..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-using Content.Shared.SmartFridge;
-using Robust.Shared.Analyzers;
-
-namespace Content.Client.SmartFridge;
-
-public sealed class SmartFridgeUISystem : EntitySystem
-{
-    [Dependency] private readonly SharedUserInterfaceSystem _uiSystem = default!;
-
-    public override void Initialize()
-    {
-        base.Initialize();
-
-        SubscribeLocalEvent<SmartFridgeComponent, AfterAutoHandleStateEvent>(OnSmartFridgeAfterState);
-    }
-
-    private void OnSmartFridgeAfterState(Entity<SmartFridgeComponent> ent, ref AfterAutoHandleStateEvent args)
-    {
-        if (!_uiSystem.TryGetOpenUi<SmartFridgeBoundUserInterface>(ent.Owner, SmartFridgeUiKey.Key, out var bui))
-            return;
-
-        bui.Refresh();
-    }
-}
diff --git a/Content.Server/SmartFridge/SmartFridgeSystem.cs b/Content.Server/SmartFridge/SmartFridgeSystem.cs
new file mode 100644 (file)
index 0000000..ec96460
--- /dev/null
@@ -0,0 +1,5 @@
+using Content.Shared.SmartFridge;
+
+namespace Content.Server.SmartFridge;
+
+public sealed class SmartFridgeSystem : SharedSmartFridgeSystem;
similarity index 84%
rename from Content.Shared/SmartFridge/SmartFridgeSystem.cs
rename to Content.Shared/SmartFridge/SharedSmartFridgeSystem.cs
index 659689cd8aa41b6073ac21f904a1b43622072955..a331c3104d30dd5a15fda5994d1f7a99b867b428 100644 (file)
@@ -14,7 +14,7 @@ using Robust.Shared.Utility;
 
 namespace Content.Shared.SmartFridge;
 
-public sealed class SmartFridgeSystem : EntitySystem
+public abstract class SharedSmartFridgeSystem : EntitySystem
 {
     [Dependency] private readonly AccessReaderSystem _accessReader = default!;
     [Dependency] private readonly EntityWhitelistSystem _whitelist = default!;
@@ -29,7 +29,9 @@ public sealed class SmartFridgeSystem : EntitySystem
         base.Initialize();
 
         SubscribeLocalEvent<SmartFridgeComponent, InteractUsingEvent>(OnInteractUsing, after: [typeof(AnchorableSystem)]);
+        SubscribeLocalEvent<SmartFridgeComponent, EntInsertedIntoContainerMessage>(OnItemInserted);
         SubscribeLocalEvent<SmartFridgeComponent, EntRemovedFromContainerMessage>(OnItemRemoved);
+        SubscribeLocalEvent<SmartFridgeComponent, AfterAutoHandleStateEvent>((ent, ref _) => UpdateUI(ent));
 
         SubscribeLocalEvent<SmartFridgeComponent, GetVerbsEvent<AlternativeVerb>>(OnGetAltVerb);
         SubscribeLocalEvent<SmartFridgeComponent, GetDumpableVerbEvent>(OnGetDumpableVerb);
@@ -58,16 +60,6 @@ public sealed class SmartFridgeSystem : EntitySystem
             anyInserted = true;
 
             _container.Insert(used, container);
-            var key = new SmartFridgeEntry(Identity.Name(used, EntityManager));
-            if (!ent.Comp.Entries.Contains(key))
-                ent.Comp.Entries.Add(key);
-
-            ent.Comp.ContainedEntries.TryAdd(key, new());
-            var entries = ent.Comp.ContainedEntries[key];
-            if (!entries.Contains(GetNetEntity(used)))
-                entries.Add(GetNetEntity(used));
-
-            Dirty(ent);
         }
 
         if (anyInserted && playSound)
@@ -86,6 +78,24 @@ public sealed class SmartFridgeSystem : EntitySystem
         args.Handled = DoInsert(ent, args.User, [args.Used], true);
     }
 
+    private void OnItemInserted(Entity<SmartFridgeComponent> ent, ref EntInsertedIntoContainerMessage args)
+    {
+        if (args.Container.ID != ent.Comp.Container || _timing.ApplyingState)
+            return;
+
+        var key = new SmartFridgeEntry(Identity.Name(args.Entity, EntityManager));
+        if (!ent.Comp.Entries.Contains(key))
+            ent.Comp.Entries.Add(key);
+
+        ent.Comp.ContainedEntries.TryAdd(key, new());
+        var entries = ent.Comp.ContainedEntries[key];
+        if (!entries.Contains(GetNetEntity(args.Entity)))
+            entries.Add(GetNetEntity(args.Entity));
+
+        Dirty(ent);
+        UpdateUI(ent);
+    }
+
     private void OnItemRemoved(Entity<SmartFridgeComponent> ent, ref EntRemovedFromContainerMessage args)
     {
         var key = new SmartFridgeEntry(Identity.Name(args.Entity, EntityManager));
@@ -96,6 +106,7 @@ public sealed class SmartFridgeSystem : EntitySystem
         }
 
         Dirty(ent);
+        UpdateUI(ent);
     }
 
     private bool Allowed(Entity<SmartFridgeComponent> machine, EntityUid user)
@@ -131,6 +142,7 @@ public sealed class SmartFridgeSystem : EntitySystem
             _audio.PlayPredicted(ent.Comp.SoundVend, ent, args.Actor);
             contained.Remove(item);
             Dirty(ent);
+            UpdateUI(ent);
             return;
         }
 
@@ -174,4 +186,9 @@ public sealed class SmartFridgeSystem : EntitySystem
 
         DoInsert(ent, args.User, args.DumpQueue, false);
     }
+
+    protected virtual void UpdateUI(Entity<SmartFridgeComponent> ent)
+    {
+
+    }
 }
index a9e9d957531665f2ed8d98bdb42343c7512cd1b1..5bbd58b75d845c6be49734caa18142a50fbba682 100644 (file)
@@ -9,7 +9,7 @@ using Robust.Shared.Serialization;
 namespace Content.Shared.SmartFridge;
 
 [RegisterComponent, NetworkedComponent, AutoGenerateComponentState(true)]
-[Access(typeof(SmartFridgeSystem))]
+[Access(typeof(SharedSmartFridgeSystem))]
 public sealed partial class SmartFridgeComponent : Component
 {
     /// <summary>
@@ -46,7 +46,7 @@ public sealed partial class SmartFridgeComponent : Component
     /// A mapping of smart fridge entries to the actual contained contents
     /// </summary>
     [DataField, AutoNetworkedField]
-    [Access(typeof(SmartFridgeSystem), Other = AccessPermissions.ReadExecute)]
+    [Access(typeof(SharedSmartFridgeSystem), Other = AccessPermissions.ReadExecute)]
     public Dictionary<SmartFridgeEntry, HashSet<NetEntity>> ContainedEntries = new();
 
     /// <summary>