using Content.Server.Popups; using Content.Server.Xenoarchaeology.Equipment.Components; using Content.Server.Xenoarchaeology.XenoArtifacts; using Content.Shared.Interaction; using Content.Shared.Timing; using Content.Shared.Verbs; namespace Content.Server.Xenoarchaeology.Equipment.Systems; public sealed class NodeScannerSystem : EntitySystem { [Dependency] private readonly UseDelaySystem _useDelay = default!; [Dependency] private readonly PopupSystem _popupSystem = default!; /// public override void Initialize() { SubscribeLocalEvent(OnBeforeRangedInteract); SubscribeLocalEvent>(AddScanVerb); } private void OnBeforeRangedInteract(EntityUid uid, NodeScannerComponent component, BeforeRangedInteractEvent args) { if (args.Handled || !args.CanReach || args.Target is not {} target) return; if (!TryComp(target, out var artifact) || artifact.CurrentNodeId == null) return; CreatePopup(uid, target, artifact); args.Handled = true; } private void AddScanVerb(EntityUid uid, NodeScannerComponent component, GetVerbsEvent args) { if (!args.CanAccess) return; if (!TryComp(args.Target, out var artifact) || artifact.CurrentNodeId == null) return; var verb = new UtilityVerb() { Act = () => { CreatePopup(uid, args.Target, artifact); }, Text = Loc.GetString("node-scan-tooltip") }; args.Verbs.Add(verb); } private void CreatePopup(EntityUid uid, EntityUid target, ArtifactComponent artifact) { if (TryComp(uid, out UseDelayComponent? useDelay) && !_useDelay.TryResetDelay((uid, useDelay), true)) return; _popupSystem.PopupEntity(Loc.GetString("node-scan-popup", ("id", $"{artifact.CurrentNodeId}")), target); } }