Skip to content

Commit

Permalink
Feat: Anomaly Scanner Data Copying (DeltaV-Station#1250)
Browse files Browse the repository at this point in the history
# Description
Makes it so that using one anomaly scanner on another transfers the
anomaly data onto the used scanner.

<details><summary><h1>Media</h1></summary>
<p>


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

</p>
</details>

# Changelog
:cl:
- add: You can now touch one anomaly scanner with another to copy the
anomaly scan data from it.
  • Loading branch information
Mnemotechnician authored Nov 22, 2024
1 parent 8d54aa2 commit 0574be4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
23 changes: 15 additions & 8 deletions Content.Server/Anomaly/AnomalySystem.Scanner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<AnomalyComponent>(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<AnomalyComponent>(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<AnomalyScannerComponent>(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)
Expand Down
5 changes: 3 additions & 2 deletions Resources/Locale/en-US/anomaly/anomaly.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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]
Expand All @@ -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]
anomaly-behavior-moving = [color=crimson]Coordinate instability was detected.[/color]

0 comments on commit 0574be4

Please sign in to comment.