From: osjarw <62134478+osjarw@users.noreply.github.com>
Date: Fri, 14 Jun 2024 02:01:32 +0000 (+0300)
Subject: Nodescanner now works with right click (#26873)
X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=ad3f1f77b7ebd940b93f3966e3a49e79188703ae;p=space-station-14.git
Nodescanner now works with right click (#26873)
---
diff --git a/Content.Server/Xenoarchaeology/Equipment/Systems/NodeScannerSystem.cs b/Content.Server/Xenoarchaeology/Equipment/Systems/NodeScannerSystem.cs
index fc9ab28942..b388f3a6d4 100644
--- a/Content.Server/Xenoarchaeology/Equipment/Systems/NodeScannerSystem.cs
+++ b/Content.Server/Xenoarchaeology/Equipment/Systems/NodeScannerSystem.cs
@@ -3,6 +3,7 @@ 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;
@@ -14,23 +15,44 @@ public sealed class NodeScannerSystem : EntitySystem
///
public override void Initialize()
{
- SubscribeLocalEvent(OnAfterInteract);
+ SubscribeLocalEvent(OnBeforeRangedInteract);
+ SubscribeLocalEvent>(AddScanVerb);
}
- private void OnAfterInteract(EntityUid uid, NodeScannerComponent component, AfterInteractEvent args)
+ private void OnBeforeRangedInteract(EntityUid uid, NodeScannerComponent component, BeforeRangedInteractEvent args)
{
- if (!args.CanReach || args.Target == null)
+ if (args.Handled || !args.CanReach || args.Target is not {} target)
return;
- if (!TryComp(args.Target, out var artifact) || artifact.CurrentNodeId == null)
+ if (!TryComp(target, out var artifact) || artifact.CurrentNodeId == null)
return;
- if (args.Handled)
- return;
+ CreatePopup(uid, target, artifact);
args.Handled = true;
+ }
+
+ private void AddScanVerb(EntityUid uid, NodeScannerComponent component, GetVerbsEvent args)
+ {
+ if (!args.CanAccess)
+ return;
- var target = args.Target.Value;
+ 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;
diff --git a/Resources/Locale/en-US/xenoarchaeology/node-scanner.ftl b/Resources/Locale/en-US/xenoarchaeology/node-scanner.ftl
index 14b07941a6..4a05414c46 100644
--- a/Resources/Locale/en-US/xenoarchaeology/node-scanner.ftl
+++ b/Resources/Locale/en-US/xenoarchaeology/node-scanner.ftl
@@ -1 +1,2 @@
-node-scan-popup = The node ID is {$id}
\ No newline at end of file
+node-scan-popup = The node ID is {$id}
+node-scan-tooltip = Scan artifact