Nodescanner now works with right click (#26873)
This commit is contained in:
@@ -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
|
||||
/// <inheritdoc/>
|
||||
public override void Initialize()
|
||||
{
|
||||
SubscribeLocalEvent<NodeScannerComponent, AfterInteractEvent>(OnAfterInteract);
|
||||
SubscribeLocalEvent<NodeScannerComponent, BeforeRangedInteractEvent>(OnBeforeRangedInteract);
|
||||
SubscribeLocalEvent<NodeScannerComponent, GetVerbsEvent<UtilityVerb>>(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<ArtifactComponent>(target, out var artifact) || artifact.CurrentNodeId == null)
|
||||
return;
|
||||
|
||||
CreatePopup(uid, target, artifact);
|
||||
args.Handled = true;
|
||||
}
|
||||
|
||||
private void AddScanVerb(EntityUid uid, NodeScannerComponent component, GetVerbsEvent<UtilityVerb> args)
|
||||
{
|
||||
if (!args.CanAccess)
|
||||
return;
|
||||
|
||||
if (!TryComp<ArtifactComponent>(args.Target, out var artifact) || artifact.CurrentNodeId == null)
|
||||
return;
|
||||
|
||||
if (args.Handled)
|
||||
return;
|
||||
args.Handled = true;
|
||||
var verb = new UtilityVerb()
|
||||
{
|
||||
Act = () =>
|
||||
{
|
||||
CreatePopup(uid, args.Target, artifact);
|
||||
},
|
||||
Text = Loc.GetString("node-scan-tooltip")
|
||||
};
|
||||
|
||||
var target = args.Target.Value;
|
||||
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;
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
node-scan-popup = The node ID is {$id}
|
||||
node-scan-popup = The node ID is {$id}
|
||||
node-scan-tooltip = Scan artifact
|
||||
|
||||
Reference in New Issue
Block a user