From 865277156b4057d3a44ddc88522080d64c2f4b80 Mon Sep 17 00:00:00 2001 From: Princess Cheeseballs <66055347+Princess-Cheeseballs@users.noreply.github.com> Date: Thu, 8 Jan 2026 16:35:39 -0800 Subject: [PATCH] Allow items spawned in the smart fridge to show up as an entry. (#42268) * 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> --- .../_DV/SmartFridge/SmartFridgeSystem.cs | 18 ++++++++++++ .../_DV/SmartFridge/SmartFridgeUISystem.cs | 24 --------------- .../_DV/SmartFridge/SmartFridgeSystem.cs | 5 ++++ .../Storage/EntitySystems/DumpableSystem.cs | 2 +- ...geSystem.cs => SharedSmartFridgeSystem.cs} | 29 ++++++++++++++++++- .../_DV/SmartFridge/SmartFridgeComponent.cs | 2 ++ 6 files changed, 54 insertions(+), 26 deletions(-) create mode 100644 Content.Client/_DV/SmartFridge/SmartFridgeSystem.cs delete mode 100644 Content.Client/_DV/SmartFridge/SmartFridgeUISystem.cs create mode 100644 Content.Server/_DV/SmartFridge/SmartFridgeSystem.cs rename Content.Shared/_DV/SmartFridge/{SmartFridgeSystem.cs => SharedSmartFridgeSystem.cs} (86%) diff --git a/Content.Client/_DV/SmartFridge/SmartFridgeSystem.cs b/Content.Client/_DV/SmartFridge/SmartFridgeSystem.cs new file mode 100644 index 0000000000..e68f0eb598 --- /dev/null +++ b/Content.Client/_DV/SmartFridge/SmartFridgeSystem.cs @@ -0,0 +1,18 @@ +using Content.Shared._DV.SmartFridge; + +namespace Content.Client._DV.SmartFridge; + +public sealed class SmartFridgeSystem : SharedSmartFridgeSystem +{ + [Dependency] private readonly SharedUserInterfaceSystem _uiSystem = default!; + + protected override void UpdateUI(Entity ent) + { + base.UpdateUI(ent); + + if (!_uiSystem.TryGetOpenUi(ent.Owner, SmartFridgeUiKey.Key, out var bui)) + return; + + bui.Refresh(); + } +} diff --git a/Content.Client/_DV/SmartFridge/SmartFridgeUISystem.cs b/Content.Client/_DV/SmartFridge/SmartFridgeUISystem.cs deleted file mode 100644 index 32589dd5f7..0000000000 --- a/Content.Client/_DV/SmartFridge/SmartFridgeUISystem.cs +++ /dev/null @@ -1,24 +0,0 @@ -using Content.Shared._DV.SmartFridge; -using Robust.Shared.Analyzers; - -namespace Content.Client._DV.SmartFridge; - -public sealed class SmartFridgeUISystem : EntitySystem -{ - [Dependency] private readonly SharedUserInterfaceSystem _uiSystem = default!; - - public override void Initialize() - { - base.Initialize(); - - SubscribeLocalEvent(OnSmartFridgeAfterState); - } - - private void OnSmartFridgeAfterState(Entity ent, ref AfterAutoHandleStateEvent args) - { - if (!_uiSystem.TryGetOpenUi(ent.Owner, SmartFridgeUiKey.Key, out var bui)) - return; - - bui.Refresh(); - } -} diff --git a/Content.Server/_DV/SmartFridge/SmartFridgeSystem.cs b/Content.Server/_DV/SmartFridge/SmartFridgeSystem.cs new file mode 100644 index 0000000000..7474a28222 --- /dev/null +++ b/Content.Server/_DV/SmartFridge/SmartFridgeSystem.cs @@ -0,0 +1,5 @@ +using Content.Shared._DV.SmartFridge; + +namespace Content.Server._DV.SmartFridge; + +public sealed class SmartFridgeSystem : SharedSmartFridgeSystem; diff --git a/Content.Shared/Storage/EntitySystems/DumpableSystem.cs b/Content.Shared/Storage/EntitySystems/DumpableSystem.cs index 83987c1498..734d3abc56 100644 --- a/Content.Shared/Storage/EntitySystems/DumpableSystem.cs +++ b/Content.Shared/Storage/EntitySystems/DumpableSystem.cs @@ -26,7 +26,7 @@ public sealed class DumpableSystem : EntitySystem [Dependency] private readonly SharedDisposalUnitSystem _disposalUnitSystem = default!; [Dependency] private readonly SharedDoAfterSystem _doAfterSystem = default!; [Dependency] private readonly SharedTransformSystem _transformSystem = default!; - [Dependency] private readonly SmartFridgeSystem _fridge = default!; // DeltaV - ough why do you not use events for this + [Dependency] private readonly SharedSmartFridgeSystem _fridge = default!; // DeltaV - ough why do you not use events for this private EntityQuery _itemQuery; diff --git a/Content.Shared/_DV/SmartFridge/SmartFridgeSystem.cs b/Content.Shared/_DV/SmartFridge/SharedSmartFridgeSystem.cs similarity index 86% rename from Content.Shared/_DV/SmartFridge/SmartFridgeSystem.cs rename to Content.Shared/_DV/SmartFridge/SharedSmartFridgeSystem.cs index e7406e0a29..a27050c8f1 100644 --- a/Content.Shared/_DV/SmartFridge/SmartFridgeSystem.cs +++ b/Content.Shared/_DV/SmartFridge/SharedSmartFridgeSystem.cs @@ -10,7 +10,7 @@ using Robust.Shared.Timing; namespace Content.Shared._DV.SmartFridge; -public sealed class SmartFridgeSystem : EntitySystem +public abstract class SharedSmartFridgeSystem : EntitySystem { [Dependency] private readonly IGameTiming _timing = default!; [Dependency] private readonly AccessReaderSystem _accessReader = default!; @@ -25,7 +25,9 @@ public sealed class SmartFridgeSystem : EntitySystem base.Initialize(); SubscribeLocalEvent(OnInteractUsing); + SubscribeLocalEvent(OnItemInserted); SubscribeLocalEvent(OnItemRemoved); + SubscribeLocalEvent((ent, ref _) => UpdateUI(ent)); Subs.BuiEvents(SmartFridgeUiKey.Key, sub => @@ -119,6 +121,24 @@ public sealed class SmartFridgeSystem : EntitySystem _audio.PlayPredicted(ent.Comp.InsertSound, ent, args.User); } + private void OnItemInserted(Entity 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 ent, ref EntRemovedFromContainerMessage args) { var key = new SmartFridgeEntry(Identity.Name(args.Entity, EntityManager)); @@ -129,6 +149,7 @@ public sealed class SmartFridgeSystem : EntitySystem } Dirty(ent); + UpdateUI(ent); } private bool Allowed(Entity machine, EntityUid user) @@ -162,6 +183,7 @@ public sealed class SmartFridgeSystem : EntitySystem contained.Remove(item); ent.Comp.EjectEnd = _timing.CurTime + ent.Comp.EjectCooldown; Dirty(ent); + UpdateUI(ent); return; } @@ -182,4 +204,9 @@ public sealed class SmartFridgeSystem : EntitySystem ent.Comp.Entries.Remove(args.Entry); Dirty(ent); } + + protected virtual void UpdateUI(Entity ent) + { + + } } diff --git a/Content.Shared/_DV/SmartFridge/SmartFridgeComponent.cs b/Content.Shared/_DV/SmartFridge/SmartFridgeComponent.cs index f85ca5708f..7268dded55 100644 --- a/Content.Shared/_DV/SmartFridge/SmartFridgeComponent.cs +++ b/Content.Shared/_DV/SmartFridge/SmartFridgeComponent.cs @@ -10,6 +10,7 @@ using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom; namespace Content.Shared._DV.SmartFridge; [RegisterComponent, NetworkedComponent, AutoGenerateComponentState(true), AutoGenerateComponentPause] +[Access(typeof(SharedSmartFridgeSystem))] public sealed partial class SmartFridgeComponent : Component { [DataField] @@ -28,6 +29,7 @@ public sealed partial class SmartFridgeComponent : Component public HashSet Entries = new(); [DataField, AutoNetworkedField] + [Access(typeof(SharedSmartFridgeSystem), Other = AccessPermissions.ReadExecute)] public Dictionary> ContainedEntries = new(); [DataField]