2022-12-19 22:53:54 -05:00
|
|
|
using Content.Server.Xenoarchaeology.Equipment.Components;
|
|
|
|
|
using Content.Server.Xenoarchaeology.XenoArtifacts;
|
|
|
|
|
using Content.Shared.Interaction;
|
2024-03-04 09:56:23 +03:00
|
|
|
using Content.Shared.Popups;
|
2022-12-19 22:53:54 -05:00
|
|
|
using Content.Shared.Timing;
|
|
|
|
|
|
|
|
|
|
namespace Content.Server.Xenoarchaeology.Equipment.Systems;
|
|
|
|
|
|
|
|
|
|
public sealed class NodeScannerSystem : EntitySystem
|
|
|
|
|
{
|
|
|
|
|
[Dependency] private readonly UseDelaySystem _useDelay = default!;
|
2024-03-04 09:56:23 +03:00
|
|
|
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
|
2022-12-19 22:53:54 -05:00
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
SubscribeLocalEvent<NodeScannerComponent, AfterInteractEvent>(OnAfterInteract);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnAfterInteract(EntityUid uid, NodeScannerComponent component, AfterInteractEvent args)
|
|
|
|
|
{
|
|
|
|
|
if (!args.CanReach || args.Target == null)
|
|
|
|
|
return;
|
|
|
|
|
|
2023-03-23 22:50:24 -04:00
|
|
|
if (!TryComp<ArtifactComponent>(args.Target, out var artifact) || artifact.CurrentNodeId == null)
|
2022-12-19 22:53:54 -05:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (args.Handled)
|
|
|
|
|
return;
|
|
|
|
|
args.Handled = true;
|
|
|
|
|
|
|
|
|
|
var target = args.Target.Value;
|
2024-01-03 21:33:09 -04:00
|
|
|
|
|
|
|
|
if (TryComp(uid, out UseDelayComponent? useDelay)
|
|
|
|
|
&& !_useDelay.TryResetDelay((uid, useDelay), true))
|
|
|
|
|
return;
|
|
|
|
|
|
2024-02-29 13:36:13 +03:00
|
|
|
// WD edit
|
2024-03-04 09:56:23 +03:00
|
|
|
_popupSystem.PopupEntity(Loc.GetString("node-scan-popup",
|
2024-02-29 13:36:13 +03:00
|
|
|
("id", $"{artifact.CurrentNodeId}")), target, args.User);
|
2022-12-19 22:53:54 -05:00
|
|
|
}
|
|
|
|
|
}
|