From 0574be444b90137808c07f85e10b59c464f054cf Mon Sep 17 00:00:00 2001 From: Mnemotechnican <69920617+Mnemotechnician@users.noreply.github.com> Date: Fri, 22 Nov 2024 04:02:13 +0300 Subject: [PATCH] Feat: Anomaly Scanner Data Copying (#1250) # Description Makes it so that using one anomaly scanner on another transfers the anomaly data onto the used scanner.

Media

![image](https://github.com/user-attachments/assets/b212e6e8-58a3-4a64-a216-3ba496a81d4a)

# Changelog :cl: - add: You can now touch one anomaly scanner with another to copy the anomaly scan data from it. --- .../Anomaly/AnomalySystem.Scanner.cs | 23 ++++++++++++------- Resources/Locale/en-US/anomaly/anomaly.ftl | 5 ++-- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/Content.Server/Anomaly/AnomalySystem.Scanner.cs b/Content.Server/Anomaly/AnomalySystem.Scanner.cs index 39c0d08b55e..b9c0beb04e6 100644 --- a/Content.Server/Anomaly/AnomalySystem.Scanner.cs +++ b/Content.Server/Anomaly/AnomalySystem.Scanner.cs @@ -87,17 +87,24 @@ private void OnScannerUiOpened(EntityUid uid, AnomalyScannerComponent component, private void OnScannerAfterInteract(EntityUid uid, AnomalyScannerComponent component, AfterInteractEvent args) { - if (args.Target is not { } target) - return; - if (!HasComp(target)) - return; - if (!args.CanReach) + if (args.Target is not { } target || !args.CanReach) return; - _doAfter.TryStartDoAfter(new DoAfterArgs(EntityManager, args.User, component.ScanDoAfterDuration, new ScannerDoAfterEvent(), uid, target: target, used: uid) + // If interacting with an anomaly, start a scan do-after + if (HasComp(target)) + _doAfter.TryStartDoAfter(new DoAfterArgs(EntityManager, args.User, component.ScanDoAfterDuration, new ScannerDoAfterEvent(), uid, target: target, used: uid) + { + DistanceThreshold = 2f + }); + + // If interacting with another scanner, copy the anomaly data + if (component.ScannedAnomaly is not { Valid: true } + && TryComp(args.Target, out var otherScanner) + && otherScanner.ScannedAnomaly is {} otherAnomaly) { - DistanceThreshold = 2f - }); + UpdateScannerWithNewAnomaly(uid, otherAnomaly, component); + Popup.PopupEntity(Loc.GetString("anomaly-scanner-scan-copied"), uid); + } } private void OnDoAfter(EntityUid uid, AnomalyScannerComponent component, DoAfterEvent args) diff --git a/Resources/Locale/en-US/anomaly/anomaly.ftl b/Resources/Locale/en-US/anomaly/anomaly.ftl index 1609d77d914..cce9488b2f6 100644 --- a/Resources/Locale/en-US/anomaly/anomaly.ftl +++ b/Resources/Locale/en-US/anomaly/anomaly.ftl @@ -12,6 +12,7 @@ anomaly-particles-omega = Omega particles anomaly-particles-sigma = Sigma particles anomaly-scanner-component-scan-complete = Scan complete! +anomaly-scanner-scan-copied = Copied anomaly scan data! anomaly-scanner-ui-title = anomaly scanner anomaly-scanner-no-anomaly = No anomaly currently scanned. @@ -79,7 +80,7 @@ anomaly-generator-flavor-right = v1.1 anomaly-behavior-unknown = [color=red]ERROR. Cannot be read.[/color] anomaly-behavior-title = behavior deviation analysis: -anomaly-behavior-point =[color=gold]Anomaly produces {$mod}% of the points[/color] +anomaly-behavior-point =[color=gold]Anomaly produces {$mod}% of the points[/color] anomaly-behavior-safe = [color=forestgreen]The anomaly is extremely stable. Extremely rare pulsations.[/color] anomaly-behavior-slow = [color=forestgreen]The frequency of pulsations is much less frequent.[/color] @@ -94,4 +95,4 @@ anomaly-behavior-secret = Interference detected. Some data cannot be read anomaly-behavior-inconstancy = [color=crimson]Impermanence has been detected. Particle types can change over time.[/color] anomaly-behavior-fast = [color=crimson]The pulsation frequency is strongly increased.[/color] anomaly-behavior-strenght = [color=crimson]The pulsation power is significantly increased.[/color] -anomaly-behavior-moving = [color=crimson]Coordinate instability was detected.[/color] \ No newline at end of file +anomaly-behavior-moving = [color=crimson]Coordinate instability was detected.[/color]