parrotMemory is onGetVerbs now in shared (#39341)

* parrotMemory is onGetVerbs now in shared

* code review

* code review popup on client rename parrotMemoryComponent

* code rev create client system

* forgot usings

* is server now
This commit is contained in:
Token
2025-08-03 05:27:49 +05:00
committed by GitHub
parent c538d7fb2b
commit 9d3edeb641
4 changed files with 71 additions and 40 deletions

View File

@@ -0,0 +1,48 @@
using Content.Shared.Administration.Managers;
using Content.Shared.Animals.Components;
using Content.Shared.Popups;
using Content.Shared.Verbs;
using Robust.Shared.Network;
using Robust.Shared.Utility;
namespace Content.Shared.Animals.Systems;
public abstract class SharedParrotMemorySystem : EntitySystem
{
[Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] private readonly ISharedAdminManager _admin = default!;
[Dependency] private readonly INetManager _net = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<ParrotMemoryComponent, GetVerbsEvent<Verb>>(OnGetVerbs);
}
private void OnGetVerbs(Entity<ParrotMemoryComponent> entity, ref GetVerbsEvent<Verb> args)
{
var user = args.User;
// limit this to admins
if (!_admin.IsAdmin(user))
return;
// simple verb that just clears the memory list
var clearMemoryVerb = new Verb()
{
Text = Loc.GetString("parrot-verb-clear-memory"),
Category = VerbCategory.Admin,
Icon = new SpriteSpecifier.Texture(new("/Textures/Interface/AdminActions/clear-parrot.png")),
Act = () =>
{
_popup.PopupClient(Loc.GetString("parrot-popup-memory-cleared"), entity.Owner, user);
if (_net.IsServer)
entity.Comp.SpeechMemories.Clear();
},
};
args.Verbs.Add(clearMemoryVerb);
}
}