feat: add verb for smartfridge item insertion (#39807)
This commit is contained in:
@@ -1,15 +1,16 @@
|
|||||||
using Content.Shared.Access.Components;
|
|
||||||
using Content.Shared.Access.Systems;
|
using Content.Shared.Access.Systems;
|
||||||
|
using Content.Shared.Construction.EntitySystems;
|
||||||
using Content.Shared.Hands.EntitySystems;
|
using Content.Shared.Hands.EntitySystems;
|
||||||
using Content.Shared.IdentityManagement;
|
using Content.Shared.IdentityManagement;
|
||||||
using Content.Shared.Interaction;
|
using Content.Shared.Interaction;
|
||||||
using Content.Shared.Popups;
|
using Content.Shared.Popups;
|
||||||
using Content.Shared.Storage.Components;
|
using Content.Shared.Storage.Components;
|
||||||
|
using Content.Shared.Verbs;
|
||||||
using Content.Shared.Whitelist;
|
using Content.Shared.Whitelist;
|
||||||
using Robust.Shared.Audio.Systems;
|
using Robust.Shared.Audio.Systems;
|
||||||
using Robust.Shared.Containers;
|
using Robust.Shared.Containers;
|
||||||
using Robust.Shared.GameObjects;
|
|
||||||
using Robust.Shared.Timing;
|
using Robust.Shared.Timing;
|
||||||
|
using Robust.Shared.Utility;
|
||||||
|
|
||||||
namespace Content.Shared.SmartFridge;
|
namespace Content.Shared.SmartFridge;
|
||||||
|
|
||||||
@@ -27,9 +28,10 @@ public sealed class SmartFridgeSystem : EntitySystem
|
|||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
|
|
||||||
SubscribeLocalEvent<SmartFridgeComponent, InteractUsingEvent>(OnInteractUsing);
|
SubscribeLocalEvent<SmartFridgeComponent, InteractUsingEvent>(OnInteractUsing, after: [typeof(AnchorableSystem)]);
|
||||||
SubscribeLocalEvent<SmartFridgeComponent, EntRemovedFromContainerMessage>(OnItemRemoved);
|
SubscribeLocalEvent<SmartFridgeComponent, EntRemovedFromContainerMessage>(OnItemRemoved);
|
||||||
|
|
||||||
|
SubscribeLocalEvent<SmartFridgeComponent, GetVerbsEvent<AlternativeVerb>>(OnGetAltVerb);
|
||||||
SubscribeLocalEvent<SmartFridgeComponent, GetDumpableVerbEvent>(OnGetDumpableVerb);
|
SubscribeLocalEvent<SmartFridgeComponent, GetDumpableVerbEvent>(OnGetDumpableVerb);
|
||||||
SubscribeLocalEvent<SmartFridgeComponent, DumpEvent>(OnDump);
|
SubscribeLocalEvent<SmartFridgeComponent, DumpEvent>(OnDump);
|
||||||
|
|
||||||
@@ -78,7 +80,7 @@ public sealed class SmartFridgeSystem : EntitySystem
|
|||||||
|
|
||||||
private void OnInteractUsing(Entity<SmartFridgeComponent> ent, ref InteractUsingEvent args)
|
private void OnInteractUsing(Entity<SmartFridgeComponent> ent, ref InteractUsingEvent args)
|
||||||
{
|
{
|
||||||
if (!_hands.CanDrop(args.User, args.Used))
|
if (args.Handled || !_hands.CanDrop(args.User, args.Used))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
args.Handled = DoInsert(ent, args.User, [args.Used], true);
|
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);
|
_popup.PopupPredicted(Loc.GetString("smart-fridge-component-try-eject-out-of-stock"), ent, args.Actor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnGetAltVerb(Entity<SmartFridgeComponent> ent, ref GetVerbsEvent<AlternativeVerb> 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<SmartFridgeComponent> ent, ref GetDumpableVerbEvent args)
|
private void OnGetDumpableVerb(Entity<SmartFridgeComponent> ent, ref GetDumpableVerbEvent args)
|
||||||
{
|
{
|
||||||
if (_accessReader.IsAllowed(args.User, ent))
|
if (_accessReader.IsAllowed(args.User, ent))
|
||||||
|
|||||||
Reference in New Issue
Block a user