CatStation/Content.Shared/Research/Systems/SharedResearchStealerSystem.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

63 lines
2.1 KiB
C#

using Content.Shared.DoAfter;
using Content.Shared.Interaction;
using Content.Shared.Ninja.Systems;
using Content.Shared.Popups;
using Content.Shared.Research.Components;
using Robust.Shared.Serialization;
namespace Content.Shared.Research.Systems;
public abstract partial class SharedResearchStealerSystem : EntitySystem
{
[Dependency] private SharedDoAfterSystem _doAfter = default!;
[Dependency] private SharedNinjaGlovesSystem _gloves = default!;
[Dependency] private SharedPopupSystem _popup = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<ResearchStealerComponent, BeforeInteractHandEvent>(OnBeforeInteractHand);
}
/// <summary>
/// Start do after for downloading techs from a r&d server.
/// Will only try if there is at least 1 tech researched.
/// </summary>
private void OnBeforeInteractHand(EntityUid uid, ResearchStealerComponent comp, BeforeInteractHandEvent args)
{
// TODO: generic event
if (args.Handled || !_gloves.AbilityCheck(uid, args, out var target))
return;
// can only hack the server, not a random console
if (!TryComp<TechnologyDatabaseComponent>(target, out var database) || HasComp<ResearchClientComponent>(target))
return;
args.Handled = true;
// fail fast if theres no techs to steal right now
if (database.UnlockedTechnologies.Count == 0)
{
_popup.PopupEntity(Loc.GetString("ninja-download-fail"), uid, uid);
return;
}
var doAfterArgs = new DoAfterArgs(EntityManager, uid, comp.Delay, new ResearchStealDoAfterEvent(), target: target, used: uid, eventTarget: uid)
{
BreakOnDamage = true,
BreakOnMove = true,
MovementThreshold = 0.5f,
};
_doAfter.TryStartDoAfter(doAfterArgs);
}
}
/// <summary>
/// Raised on the research stealer when the doafter completes.
/// </summary>
[Serializable, NetSerializable]
public sealed partial class ResearchStealDoAfterEvent : SimpleDoAfterEvent
{
}