From 8206126fb2dfcf4da53aaf903f5016a22337d553 Mon Sep 17 00:00:00 2001 From: Perry Fraser Date: Fri, 22 Aug 2025 16:33:04 -0400 Subject: [PATCH] feat: add verb for smartfridge item insertion (#39807) --- .../SmartFridge/SmartFridgeSystem.cs | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/Content.Shared/SmartFridge/SmartFridgeSystem.cs b/Content.Shared/SmartFridge/SmartFridgeSystem.cs index 1341f6cd03..659689cd8a 100644 --- a/Content.Shared/SmartFridge/SmartFridgeSystem.cs +++ b/Content.Shared/SmartFridge/SmartFridgeSystem.cs @@ -1,15 +1,16 @@ -using Content.Shared.Access.Components; using Content.Shared.Access.Systems; +using Content.Shared.Construction.EntitySystems; using Content.Shared.Hands.EntitySystems; using Content.Shared.IdentityManagement; using Content.Shared.Interaction; using Content.Shared.Popups; using Content.Shared.Storage.Components; +using Content.Shared.Verbs; using Content.Shared.Whitelist; using Robust.Shared.Audio.Systems; using Robust.Shared.Containers; -using Robust.Shared.GameObjects; using Robust.Shared.Timing; +using Robust.Shared.Utility; namespace Content.Shared.SmartFridge; @@ -27,9 +28,10 @@ public sealed class SmartFridgeSystem : EntitySystem { base.Initialize(); - SubscribeLocalEvent(OnInteractUsing); + SubscribeLocalEvent(OnInteractUsing, after: [typeof(AnchorableSystem)]); SubscribeLocalEvent(OnItemRemoved); + SubscribeLocalEvent>(OnGetAltVerb); SubscribeLocalEvent(OnGetDumpableVerb); SubscribeLocalEvent(OnDump); @@ -78,7 +80,7 @@ public sealed class SmartFridgeSystem : EntitySystem private void OnInteractUsing(Entity ent, ref InteractUsingEvent args) { - if (!_hands.CanDrop(args.User, args.Used)) + if (args.Handled || !_hands.CanDrop(args.User, args.Used)) return; args.Handled = DoInsert(ent, args.User, [args.Used], true); @@ -136,6 +138,24 @@ public sealed class SmartFridgeSystem : EntitySystem _popup.PopupPredicted(Loc.GetString("smart-fridge-component-try-eject-out-of-stock"), ent, args.Actor); } + private void OnGetAltVerb(Entity ent, ref GetVerbsEvent args) + { + var user = args.User; + + if (!args.CanInteract + || args.Using is not { } item + || !_hands.CanDrop(user, item) + || !_whitelist.CheckBoth(item, ent.Comp.Blacklist, ent.Comp.Whitelist)) + return; + + args.Verbs.Add(new AlternativeVerb + { + Act = () => DoInsert(ent, user, [item], true), + Text = Loc.GetString("verb-categories-insert"), + Icon = new SpriteSpecifier.Texture(new ResPath("/Textures/Interface/VerbIcons/insert.svg.192dpi.png")), + }); + } + private void OnGetDumpableVerb(Entity ent, ref GetDumpableVerbEvent args) { if (_accessReader.IsAllowed(args.User, ent)) -- 2.51.2