From: Princess Cheeseballs <66055347+Princess-Cheeseballs@users.noreply.github.com> Date: Fri, 9 Jan 2026 00:35:39 +0000 (-0800) Subject: Allow items spawned in the smart fridge to show up as an entry. (#42268) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=8ec4669bf93155bbc81aa365ad2143ad62989ab2;p=space-station-14.git 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> --- diff --git a/Content.Client/SmartFridge/SmartFridgeSystem.cs b/Content.Client/SmartFridge/SmartFridgeSystem.cs new file mode 100644 index 0000000000..cd3aeb6958 --- /dev/null +++ b/Content.Client/SmartFridge/SmartFridgeSystem.cs @@ -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 ent) + { + base.UpdateUI(ent); + + if (!_uiSystem.TryGetOpenUi(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 index 4068c27e05..0000000000 --- a/Content.Client/SmartFridge/SmartFridgeUISystem.cs +++ /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(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/SmartFridge/SmartFridgeSystem.cs b/Content.Server/SmartFridge/SmartFridgeSystem.cs new file mode 100644 index 0000000000..ec9646028b --- /dev/null +++ b/Content.Server/SmartFridge/SmartFridgeSystem.cs @@ -0,0 +1,5 @@ +using Content.Shared.SmartFridge; + +namespace Content.Server.SmartFridge; + +public sealed class SmartFridgeSystem : SharedSmartFridgeSystem; diff --git a/Content.Shared/SmartFridge/SmartFridgeSystem.cs b/Content.Shared/SmartFridge/SharedSmartFridgeSystem.cs similarity index 84% rename from Content.Shared/SmartFridge/SmartFridgeSystem.cs rename to Content.Shared/SmartFridge/SharedSmartFridgeSystem.cs index 659689cd8a..a331c3104d 100644 --- a/Content.Shared/SmartFridge/SmartFridgeSystem.cs +++ b/Content.Shared/SmartFridge/SharedSmartFridgeSystem.cs @@ -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(OnInteractUsing, after: [typeof(AnchorableSystem)]); + SubscribeLocalEvent(OnItemInserted); SubscribeLocalEvent(OnItemRemoved); + SubscribeLocalEvent((ent, ref _) => UpdateUI(ent)); SubscribeLocalEvent>(OnGetAltVerb); SubscribeLocalEvent(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 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)); @@ -96,6 +106,7 @@ public sealed class SmartFridgeSystem : EntitySystem } Dirty(ent); + UpdateUI(ent); } private bool Allowed(Entity 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 ent) + { + + } } diff --git a/Content.Shared/SmartFridge/SmartFridgeComponent.cs b/Content.Shared/SmartFridge/SmartFridgeComponent.cs index a9e9d95753..5bbd58b75d 100644 --- a/Content.Shared/SmartFridge/SmartFridgeComponent.cs +++ b/Content.Shared/SmartFridge/SmartFridgeComponent.cs @@ -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 { /// @@ -46,7 +46,7 @@ public sealed partial class SmartFridgeComponent : Component /// A mapping of smart fridge entries to the actual contained contents /// [DataField, AutoNetworkedField] - [Access(typeof(SmartFridgeSystem), Other = AccessPermissions.ReadExecute)] + [Access(typeof(SharedSmartFridgeSystem), Other = AccessPermissions.ReadExecute)] public Dictionary> ContainedEntries = new(); ///