CatStation/Content.Shared/Singularity/EntitySystems/SharedEmitterSystem.cs
Whatstone a88d2c5164
Cleanup: Resolve remaining PopupSystem warnings in Content.Shared (#44685)
* PopupClient to PopupEntity/Coordinates

* PopupPredictedX to PopupEntity/Cursor/Coordinates

* The rest of the damn owl

* nullability fixes

* Buckle cleanup

* cleanup, address PR comments

* ExecutionSystem: one popup method

* correct my filthy lies

* Apply most of ajcm's suggestions

* return user to SharedItemRecallSystem.cs

* Fix lingering Ensnarable broadcast popups

* targeted drain popups

* fix lingering untargeted Guardian popups

I read the comment on GuardianHostRecall.  Oops.

* target stethoscope popups

* fix the PDA vibration popup

* Fix target for encryption key removal popup

* anomaly scanner: args.User, not uid

* disposal unit comment, bcast pda vibration popup
2026-07-16 21:54:33 +00:00

65 lines
2 KiB
C#

using Content.Shared.Database;
using Content.Shared.Examine;
using Content.Shared.Lock;
using Content.Shared.Popups;
using Content.Shared.Singularity.Components;
using Content.Shared.Verbs;
using Robust.Shared.Prototypes;
namespace Content.Shared.Singularity.EntitySystems;
public abstract partial class SharedEmitterSystem : EntitySystem
{
[Dependency] private SharedPopupSystem _popup = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<EmitterComponent, ExaminedEvent>(OnExamined);
SubscribeLocalEvent<EmitterComponent, GetVerbsEvent<Verb>>(OnGetVerb);
}
private void OnGetVerb(Entity<EmitterComponent> ent, ref GetVerbsEvent<Verb> args)
{
if (!args.CanAccess || !args.CanInteract || !args.CanComplexInteract || args.Hands == null)
return;
if (TryComp<LockComponent>(ent.Owner, out var lockComp) && lockComp.Locked)
return;
if (ent.Comp.SelectableTypes.Count < 2)
return;
foreach (var type in ent.Comp.SelectableTypes)
{
var proto = ProtoMan.Index(type);
var v = new Verb
{
Priority = 1,
Category = VerbCategory.SelectType,
Text = proto.Name,
Disabled = type == ent.Comp.BoltType,
Impact = LogImpact.Medium,
DoContactInteraction = true,
Act = () =>
{
ent.Comp.BoltType = type;
Dirty(ent);
_popup.PopupEntity(Loc.GetString("emitter-component-type-set", ("type", proto.Name)), ent.Owner, ent.Owner);
},
};
args.Verbs.Add(v);
}
}
private void OnExamined(Entity<EmitterComponent> ent, ref ExaminedEvent args)
{
if (ent.Comp.SelectableTypes.Count < 2)
return;
var proto = ProtoMan.Index(ent.Comp.BoltType);
args.PushMarkup(Loc.GetString("emitter-component-current-type", ("type", proto.Name)));
}
}