Fix forensic scanner UI. (#12398)
* Add missing Dispose method to ForensicScannerBoundUserInterface. * Remove old code from ForensicScanner. * Prevent forensic scanner from being used on the floor and allow its window to stay open when active hand is swapped. * Use more standardized UI code for ForensicScanner. * Add a delay to ForensicScanner printing. * Show name of what was scanned on ForensicScanner UI. * Add a print sound for ForensicScanner. * Add more error reporting for ForensicScanner. * Centralize common logic in ForensicScannerSystem. * Allow ForensicScanner blank printouts. * Tweak ForensicScanner audio parameters.
This commit is contained in:
@@ -1,12 +1,17 @@
|
|||||||
using Content.Shared.Forensics;
|
|
||||||
using Robust.Client.GameObjects;
|
using Robust.Client.GameObjects;
|
||||||
|
using Robust.Shared.Timing;
|
||||||
|
using Content.Shared.Forensics;
|
||||||
|
|
||||||
namespace Content.Client.Forensics
|
namespace Content.Client.Forensics
|
||||||
{
|
{
|
||||||
public sealed class ForensicScannerBoundUserInterface : BoundUserInterface
|
public sealed class ForensicScannerBoundUserInterface : BoundUserInterface
|
||||||
{
|
{
|
||||||
|
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||||
|
|
||||||
private ForensicScannerMenu? _window;
|
private ForensicScannerMenu? _window;
|
||||||
|
|
||||||
|
private TimeSpan _printCooldown;
|
||||||
|
|
||||||
public ForensicScannerBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
|
public ForensicScannerBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -17,24 +22,61 @@ namespace Content.Client.Forensics
|
|||||||
_window = new ForensicScannerMenu();
|
_window = new ForensicScannerMenu();
|
||||||
_window.OnClose += Close;
|
_window.OnClose += Close;
|
||||||
_window.Print.OnPressed += _ => Print();
|
_window.Print.OnPressed += _ => Print();
|
||||||
|
_window.Clear.OnPressed += _ => Clear();
|
||||||
_window.OpenCentered();
|
_window.OpenCentered();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Print()
|
private void Print()
|
||||||
{
|
{
|
||||||
SendMessage(new ForensicScannerPrintMessage());
|
SendMessage(new ForensicScannerPrintMessage());
|
||||||
_window?.Close();
|
|
||||||
|
if (_window != null)
|
||||||
|
_window.UpdatePrinterState(true);
|
||||||
|
|
||||||
|
// This UI does not require pinpoint accuracy as to when the Print
|
||||||
|
// button is available again, so spawning client-side timers is
|
||||||
|
// fine. The server will make sure the cooldown is honored.
|
||||||
|
Timer.Spawn(_printCooldown, () =>
|
||||||
|
{
|
||||||
|
if (_window != null)
|
||||||
|
_window.UpdatePrinterState(false);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void ReceiveMessage(BoundUserInterfaceMessage message)
|
private void Clear()
|
||||||
{
|
{
|
||||||
|
SendMessage(new ForensicScannerClearMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void UpdateState(BoundUserInterfaceState state)
|
||||||
|
{
|
||||||
|
base.UpdateState(state);
|
||||||
|
|
||||||
if (_window == null)
|
if (_window == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (message is not ForensicScannerUserMessage cast)
|
if (state is not ForensicScannerBoundUserInterfaceState cast)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_window.Populate(cast);
|
_printCooldown = cast.PrintCooldown;
|
||||||
|
|
||||||
|
if (cast.PrintReadyAt > _gameTiming.CurTime)
|
||||||
|
Timer.Spawn(cast.PrintReadyAt - _gameTiming.CurTime, () =>
|
||||||
|
{
|
||||||
|
if (_window != null)
|
||||||
|
_window.UpdatePrinterState(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
_window.UpdateState(cast);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
base.Dispose(disposing);
|
||||||
|
if (!disposing)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_window?.Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,25 @@
|
|||||||
<DefaultWindow xmlns="https://spacestation14.io"
|
<DefaultWindow xmlns="https://spacestation14.io"
|
||||||
Title="{Loc 'forensic-scanner-interface-title'}"
|
Title="{Loc 'forensic-scanner-interface-title'}"
|
||||||
MinSize="250 100"
|
MinSize="350 200"
|
||||||
SetSize="250 100">
|
SetSize="350 500">
|
||||||
<BoxContainer Orientation="Vertical">
|
<BoxContainer Orientation="Vertical">
|
||||||
<Button Name="Print"
|
<BoxContainer Orientation="Horizontal">
|
||||||
|
<Button Name="Print"
|
||||||
|
TextAlign="Center"
|
||||||
|
HorizontalExpand="True"
|
||||||
Access="Public"
|
Access="Public"
|
||||||
Disabled="True"
|
Disabled="True"
|
||||||
Text="{Loc 'forensic-scanner-interface-print'}" />
|
Text="{Loc 'forensic-scanner-interface-print'}" />
|
||||||
|
<Button Name="Clear"
|
||||||
|
TextAlign="Center"
|
||||||
|
HorizontalExpand="True"
|
||||||
|
Access="Public"
|
||||||
|
Disabled="True"
|
||||||
|
Text="{Loc 'forensic-scanner-interface-clear'}" />
|
||||||
|
</BoxContainer>
|
||||||
|
<Label
|
||||||
|
Name="Name"
|
||||||
|
Align="Center" />
|
||||||
<Label
|
<Label
|
||||||
Name="Diagnostics"
|
Name="Diagnostics"
|
||||||
Text="{Loc forensic-scanner-interface-no-data}"/>
|
Text="{Loc forensic-scanner-interface-no-data}"/>
|
||||||
|
|||||||
@@ -1,22 +1,44 @@
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using Content.Shared.Forensics;
|
|
||||||
using Robust.Client.AutoGenerated;
|
using Robust.Client.AutoGenerated;
|
||||||
using Robust.Client.UserInterface.CustomControls;
|
using Robust.Client.UserInterface.CustomControls;
|
||||||
using Robust.Client.UserInterface.XAML;
|
using Robust.Client.UserInterface.XAML;
|
||||||
|
using Robust.Shared.Timing;
|
||||||
|
using Content.Shared.Forensics;
|
||||||
|
|
||||||
namespace Content.Client.Forensics
|
namespace Content.Client.Forensics
|
||||||
{
|
{
|
||||||
[GenerateTypedNameReferences]
|
[GenerateTypedNameReferences]
|
||||||
public sealed partial class ForensicScannerMenu : DefaultWindow
|
public sealed partial class ForensicScannerMenu : DefaultWindow
|
||||||
{
|
{
|
||||||
|
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||||
|
|
||||||
public ForensicScannerMenu()
|
public ForensicScannerMenu()
|
||||||
{
|
{
|
||||||
RobustXamlLoader.Load(this);
|
RobustXamlLoader.Load(this);
|
||||||
|
IoCManager.InjectDependencies(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Populate(ForensicScannerUserMessage msg)
|
public void UpdatePrinterState(bool disabled)
|
||||||
{
|
{
|
||||||
Print.Disabled = false;
|
Print.Disabled = disabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpdateState(ForensicScannerBoundUserInterfaceState msg)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(msg.LastScannedName))
|
||||||
|
{
|
||||||
|
Print.Disabled = true;
|
||||||
|
Clear.Disabled = true;
|
||||||
|
Name.Text = string.Empty;
|
||||||
|
Diagnostics.Text = string.Empty;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Print.Disabled = (msg.PrintReadyAt > _gameTiming.CurTime);
|
||||||
|
Clear.Disabled = false;
|
||||||
|
|
||||||
|
Name.Text = msg.LastScannedName;
|
||||||
|
|
||||||
var text = new StringBuilder();
|
var text = new StringBuilder();
|
||||||
|
|
||||||
text.AppendLine(Loc.GetString("forensic-scanner-interface-fingerprints"));
|
text.AppendLine(Loc.GetString("forensic-scanner-interface-fingerprints"));
|
||||||
@@ -31,7 +53,6 @@ namespace Content.Client.Forensics
|
|||||||
text.AppendLine(fiber);
|
text.AppendLine(fiber);
|
||||||
}
|
}
|
||||||
Diagnostics.Text = text.ToString();
|
Diagnostics.Text = text.ToString();
|
||||||
SetSize = (350, 600);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
using Robust.Shared.Audio;
|
||||||
|
|
||||||
namespace Content.Server.Forensics
|
namespace Content.Server.Forensics
|
||||||
{
|
{
|
||||||
@@ -12,18 +13,58 @@ namespace Content.Server.Forensics
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[ViewVariables(VVAccess.ReadOnly)]
|
[ViewVariables(VVAccess.ReadOnly)]
|
||||||
public List<string> Fingerprints = new();
|
public List<string> Fingerprints = new();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A list of glove fibers that the forensic scanner found from the <see cref="ForensicsComponent"/> on an entity.
|
/// A list of glove fibers that the forensic scanner found from the <see cref="ForensicsComponent"/> on an entity.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[ViewVariables(VVAccess.ReadOnly)]
|
[ViewVariables(VVAccess.ReadOnly)]
|
||||||
public List<string> Fibers = new();
|
public List<string> Fibers = new();
|
||||||
|
|
||||||
public string LastScanned = string.Empty;
|
/// <summary>
|
||||||
|
/// What is the name of the entity that was scanned last?
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// This will be used for the title of the printout and displayed to players.
|
||||||
|
/// </remarks>
|
||||||
|
[ViewVariables(VVAccess.ReadOnly)]
|
||||||
|
public string LastScannedName = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// When will the scanner be ready to print again?
|
||||||
|
/// </summary>
|
||||||
|
[ViewVariables(VVAccess.ReadOnly)]
|
||||||
|
public TimeSpan PrintReadyAt = TimeSpan.Zero;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The time (in seconds) that it takes to scan an entity.
|
/// The time (in seconds) that it takes to scan an entity.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DataField("scanDelay")]
|
[DataField("scanDelay")]
|
||||||
public float ScanDelay = 3.0f;
|
public float ScanDelay = 3.0f;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// How often can the scanner print out reports?
|
||||||
|
/// </summary>
|
||||||
|
[DataField("printCooldown")]
|
||||||
|
public TimeSpan PrintCooldown = TimeSpan.FromSeconds(5);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The sound that's played when there's a match between a scan and an
|
||||||
|
/// inserted forensic pad.
|
||||||
|
/// </summary>
|
||||||
|
[DataField("soundMatch")]
|
||||||
|
public SoundSpecifier SoundMatch = new SoundPathSpecifier("/Audio/Machines/Nuke/angry_beep.ogg");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The sound that's played when there's no match between a scan and an
|
||||||
|
/// inserted forensic pad.
|
||||||
|
/// </summary>
|
||||||
|
[DataField("soundNoMatch")]
|
||||||
|
public SoundSpecifier SoundNoMatch = new SoundPathSpecifier("/Audio/Machines/airlock_deny.ogg");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The sound that's played when the scanner prints off a report.
|
||||||
|
/// </summary>
|
||||||
|
[DataField("soundPrint")]
|
||||||
|
public SoundSpecifier SoundPrint = new SoundPathSpecifier("/Audio/Machines/short_print_and_rip.ogg");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,43 +1,70 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text; // todo: remove this stinky LINQy
|
using System.Text; // todo: remove this stinky LINQy
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
using Robust.Server.GameObjects;
|
||||||
|
using Robust.Shared.Audio;
|
||||||
|
using Robust.Shared.Player;
|
||||||
|
using Robust.Shared.Timing;
|
||||||
using Content.Server.DoAfter;
|
using Content.Server.DoAfter;
|
||||||
using Content.Server.Paper;
|
using Content.Server.Paper;
|
||||||
using Content.Server.Popups;
|
using Content.Server.Popups;
|
||||||
|
using Content.Server.UserInterface;
|
||||||
using Content.Shared.Forensics;
|
using Content.Shared.Forensics;
|
||||||
using Content.Shared.Hands.EntitySystems;
|
using Content.Shared.Hands.EntitySystems;
|
||||||
using Content.Shared.Interaction;
|
using Content.Shared.Interaction;
|
||||||
using Content.Shared.Verbs;
|
using Content.Shared.Verbs;
|
||||||
using Robust.Server.GameObjects;
|
|
||||||
using Robust.Shared.Audio;
|
|
||||||
using Robust.Shared.Player;
|
|
||||||
|
|
||||||
namespace Content.Server.Forensics
|
namespace Content.Server.Forensics
|
||||||
{
|
{
|
||||||
public sealed class ForensicScannerSystem : EntitySystem
|
public sealed class ForensicScannerSystem : EntitySystem
|
||||||
{
|
{
|
||||||
|
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||||
[Dependency] private readonly DoAfterSystem _doAfterSystem = default!;
|
[Dependency] private readonly DoAfterSystem _doAfterSystem = default!;
|
||||||
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
|
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
|
||||||
[Dependency] private readonly PopupSystem _popupSystem = default!;
|
[Dependency] private readonly PopupSystem _popupSystem = default!;
|
||||||
[Dependency] private readonly PaperSystem _paperSystem = default!;
|
[Dependency] private readonly PaperSystem _paperSystem = default!;
|
||||||
[Dependency] private readonly SharedHandsSystem _handsSystem = default!;
|
[Dependency] private readonly SharedHandsSystem _handsSystem = default!;
|
||||||
|
[Dependency] private readonly SharedAudioSystem _audioSystem = default!;
|
||||||
|
|
||||||
|
private ISawmill _sawmill = default!;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
|
|
||||||
|
_sawmill = Logger.GetSawmill("forensics.scanner");
|
||||||
|
|
||||||
SubscribeLocalEvent<ForensicScannerComponent, AfterInteractEvent>(OnAfterInteract);
|
SubscribeLocalEvent<ForensicScannerComponent, AfterInteractEvent>(OnAfterInteract);
|
||||||
SubscribeLocalEvent<ForensicScannerComponent, AfterInteractUsingEvent>(OnAfterInteractUsing);
|
SubscribeLocalEvent<ForensicScannerComponent, AfterInteractUsingEvent>(OnAfterInteractUsing);
|
||||||
|
SubscribeLocalEvent<ForensicScannerComponent, BeforeActivatableUIOpenEvent>(OnBeforeActivatableUIOpen);
|
||||||
SubscribeLocalEvent<ForensicScannerComponent, GetVerbsEvent<UtilityVerb>>(OnUtilityVerb);
|
SubscribeLocalEvent<ForensicScannerComponent, GetVerbsEvent<UtilityVerb>>(OnUtilityVerb);
|
||||||
SubscribeLocalEvent<ForensicScannerComponent, ForensicScannerPrintMessage>(OnPrint);
|
SubscribeLocalEvent<ForensicScannerComponent, ForensicScannerPrintMessage>(OnPrint);
|
||||||
|
SubscribeLocalEvent<ForensicScannerComponent, ForensicScannerClearMessage>(OnClear);
|
||||||
SubscribeLocalEvent<TargetScanSuccessfulEvent>(OnTargetScanSuccessful);
|
SubscribeLocalEvent<TargetScanSuccessfulEvent>(OnTargetScanSuccessful);
|
||||||
SubscribeLocalEvent<ScanCancelledEvent>(OnScanCancelled);
|
SubscribeLocalEvent<ScanCancelledEvent>(OnScanCancelled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void UpdateUserInterface(EntityUid uid, ForensicScannerComponent component)
|
||||||
|
{
|
||||||
|
var state = new ForensicScannerBoundUserInterfaceState(
|
||||||
|
component.Fingerprints,
|
||||||
|
component.Fibers,
|
||||||
|
component.LastScannedName,
|
||||||
|
component.PrintCooldown,
|
||||||
|
component.PrintReadyAt);
|
||||||
|
|
||||||
|
if (!_uiSystem.TrySetUiState(uid, ForensicScannerUiKey.Key, state))
|
||||||
|
{
|
||||||
|
_sawmill.Warning($"{ToPrettyString(uid)} was unable to set UI state.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void OnScanCancelled(ScanCancelledEvent ev)
|
private void OnScanCancelled(ScanCancelledEvent ev)
|
||||||
{
|
{
|
||||||
if (!EntityManager.TryGetComponent(ev.Scanner, out ForensicScannerComponent? scanner))
|
if (!EntityManager.TryGetComponent(ev.Scanner, out ForensicScannerComponent? scanner))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
scanner.CancelToken = null;
|
scanner.CancelToken = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,14 +76,38 @@ namespace Content.Server.Forensics
|
|||||||
scanner.CancelToken = null;
|
scanner.CancelToken = null;
|
||||||
|
|
||||||
if (!TryComp<ForensicsComponent>(ev.Target, out var forensics))
|
if (!TryComp<ForensicsComponent>(ev.Target, out var forensics))
|
||||||
return;
|
{
|
||||||
|
scanner.Fingerprints = new();
|
||||||
|
scanner.Fibers = new();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
scanner.Fingerprints = forensics.Fingerprints.ToList();
|
||||||
|
scanner.Fibers = forensics.Fibers.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
scanner.LastScannedName = MetaData(ev.Target).EntityName;
|
||||||
|
|
||||||
scanner.Fingerprints = forensics.Fingerprints.ToList();
|
|
||||||
scanner.Fibers = forensics.Fibers.ToList();
|
|
||||||
scanner.LastScanned = MetaData(ev.Target).EntityName;
|
|
||||||
OpenUserInterface(ev.User, scanner);
|
OpenUserInterface(ev.User, scanner);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <remarks>
|
||||||
|
/// Hosts logic common between OnUtilityVerb and OnAfterInteract.
|
||||||
|
/// </remarks>
|
||||||
|
private void StartScan(EntityUid uid, ForensicScannerComponent component, EntityUid user, EntityUid target)
|
||||||
|
{
|
||||||
|
component.CancelToken = new CancellationTokenSource();
|
||||||
|
_doAfterSystem.DoAfter(new DoAfterEventArgs(user, component.ScanDelay, component.CancelToken.Token, target: target)
|
||||||
|
{
|
||||||
|
BroadcastFinishedEvent = new TargetScanSuccessfulEvent(user, (EntityUid) target, component.Owner),
|
||||||
|
BroadcastCancelledEvent = new ScanCancelledEvent(component.Owner),
|
||||||
|
BreakOnTargetMove = true,
|
||||||
|
BreakOnUserMove = true,
|
||||||
|
BreakOnStun = true,
|
||||||
|
NeedHand = true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private void OnUtilityVerb(EntityUid uid, ForensicScannerComponent component, GetVerbsEvent<UtilityVerb> args)
|
private void OnUtilityVerb(EntityUid uid, ForensicScannerComponent component, GetVerbsEvent<UtilityVerb> args)
|
||||||
{
|
{
|
||||||
if (!args.CanInteract || !args.CanAccess || component.CancelToken != null)
|
if (!args.CanInteract || !args.CanAccess || component.CancelToken != null)
|
||||||
@@ -64,19 +115,8 @@ namespace Content.Server.Forensics
|
|||||||
|
|
||||||
var verb = new UtilityVerb()
|
var verb = new UtilityVerb()
|
||||||
{
|
{
|
||||||
Act = () =>
|
Act = () => StartScan(uid, component, args.User, args.Target),
|
||||||
{
|
IconEntity = uid,
|
||||||
component.CancelToken = new CancellationTokenSource();
|
|
||||||
_doAfterSystem.DoAfter(new DoAfterEventArgs(args.User, component.ScanDelay, component.CancelToken.Token, target: args.Target)
|
|
||||||
{
|
|
||||||
BroadcastFinishedEvent = new TargetScanSuccessfulEvent(args.User, (EntityUid) args.Target, component.Owner),
|
|
||||||
BroadcastCancelledEvent = new ScanCancelledEvent(component.Owner),
|
|
||||||
BreakOnTargetMove = true,
|
|
||||||
BreakOnUserMove = true,
|
|
||||||
BreakOnStun = true,
|
|
||||||
NeedHand = true
|
|
||||||
});
|
|
||||||
},
|
|
||||||
Text = Loc.GetString("forensic-scanner-verb-text"),
|
Text = Loc.GetString("forensic-scanner-verb-text"),
|
||||||
Message = Loc.GetString("forensic-scanner-verb-message")
|
Message = Loc.GetString("forensic-scanner-verb-message")
|
||||||
};
|
};
|
||||||
@@ -89,16 +129,7 @@ namespace Content.Server.Forensics
|
|||||||
if (component.CancelToken != null || args.Target == null || !args.CanReach)
|
if (component.CancelToken != null || args.Target == null || !args.CanReach)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
component.CancelToken = new CancellationTokenSource();
|
StartScan(uid, component, args.User, args.Target.Value);
|
||||||
_doAfterSystem.DoAfter(new DoAfterEventArgs(args.User, component.ScanDelay, component.CancelToken.Token, target: args.Target)
|
|
||||||
{
|
|
||||||
BroadcastFinishedEvent = new TargetScanSuccessfulEvent(args.User, (EntityUid) args.Target, component.Owner),
|
|
||||||
BroadcastCancelledEvent = new ScanCancelledEvent(component.Owner),
|
|
||||||
BreakOnTargetMove = true,
|
|
||||||
BreakOnUserMove = true,
|
|
||||||
BreakOnStun = true,
|
|
||||||
NeedHand = true
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnAfterInteractUsing(EntityUid uid, ForensicScannerComponent component, AfterInteractUsingEvent args)
|
private void OnAfterInteractUsing(EntityUid uid, ForensicScannerComponent component, AfterInteractUsingEvent args)
|
||||||
@@ -113,7 +144,7 @@ namespace Content.Server.Forensics
|
|||||||
{
|
{
|
||||||
if (fiber == pad.Sample)
|
if (fiber == pad.Sample)
|
||||||
{
|
{
|
||||||
SoundSystem.Play("/Audio/Machines/Nuke/angry_beep.ogg", Filter.Pvs(uid), uid);
|
_audioSystem.PlayPvs(component.SoundMatch, uid);
|
||||||
_popupSystem.PopupEntity(Loc.GetString("forensic-scanner-match-fiber"), uid, Filter.Entities(args.User));
|
_popupSystem.PopupEntity(Loc.GetString("forensic-scanner-match-fiber"), uid, Filter.Entities(args.User));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -123,38 +154,60 @@ namespace Content.Server.Forensics
|
|||||||
{
|
{
|
||||||
if (fingerprint == pad.Sample)
|
if (fingerprint == pad.Sample)
|
||||||
{
|
{
|
||||||
SoundSystem.Play("/Audio/Machines/Nuke/angry_beep.ogg", Filter.Pvs(uid), uid);
|
_audioSystem.PlayPvs(component.SoundMatch, uid);
|
||||||
_popupSystem.PopupEntity(Loc.GetString("forensic-scanner-match-fingerprint"), uid, Filter.Entities(args.User));
|
_popupSystem.PopupEntity(Loc.GetString("forensic-scanner-match-fingerprint"), uid, Filter.Entities(args.User));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SoundSystem.Play("/Audio/Machines/airlock_deny.ogg", Filter.Pvs(uid), uid);
|
|
||||||
|
_audioSystem.PlayPvs(component.SoundNoMatch, uid);
|
||||||
_popupSystem.PopupEntity(Loc.GetString("forensic-scanner-match-none"), uid, Filter.Entities(args.User));
|
_popupSystem.PopupEntity(Loc.GetString("forensic-scanner-match-none"), uid, Filter.Entities(args.User));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnBeforeActivatableUIOpen(EntityUid uid, ForensicScannerComponent component, BeforeActivatableUIOpenEvent args)
|
||||||
|
{
|
||||||
|
UpdateUserInterface(uid, component);
|
||||||
|
}
|
||||||
|
|
||||||
private void OpenUserInterface(EntityUid user, ForensicScannerComponent component)
|
private void OpenUserInterface(EntityUid user, ForensicScannerComponent component)
|
||||||
{
|
{
|
||||||
if (!TryComp<ActorComponent>(user, out var actor))
|
if (!TryComp<ActorComponent>(user, out var actor))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var ui = _uiSystem.GetUi(component.Owner, ForensicScannerUiKey.Key);
|
UpdateUserInterface(component.Owner, component);
|
||||||
|
|
||||||
ui.Open(actor.PlayerSession);
|
_uiSystem.TryOpen(component.Owner, ForensicScannerUiKey.Key, actor.PlayerSession);
|
||||||
ui.SendMessage(new ForensicScannerUserMessage(component.Fingerprints, component.Fibers, component.LastScanned));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnPrint(EntityUid uid, ForensicScannerComponent component, ForensicScannerPrintMessage args)
|
private void OnPrint(EntityUid uid, ForensicScannerComponent component, ForensicScannerPrintMessage args)
|
||||||
{
|
{
|
||||||
if (!args.Session.AttachedEntity.HasValue || (component.Fibers.Count == 0 && component.Fingerprints.Count == 0)) return;
|
if (!args.Session.AttachedEntity.HasValue)
|
||||||
|
{
|
||||||
|
_sawmill.Warning($"{ToPrettyString(uid)} got OnPrint without Session.AttachedEntity");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// spawn a piece of paper.
|
var user = args.Session.AttachedEntity.Value;
|
||||||
var printed = EntityManager.SpawnEntity("Paper", Transform(args.Session.AttachedEntity.Value).Coordinates);
|
|
||||||
|
if (_gameTiming.CurTime < component.PrintReadyAt)
|
||||||
|
{
|
||||||
|
// This shouldn't occur due to the UI guarding against it, but
|
||||||
|
// if it does, tell the user why nothing happened.
|
||||||
|
_popupSystem.PopupEntity(Loc.GetString("forensic-scanner-printer-not-ready"), uid, Filter.Entities(user));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Spawn a piece of paper.
|
||||||
|
var printed = EntityManager.SpawnEntity("Paper", Transform(uid).Coordinates);
|
||||||
_handsSystem.PickupOrDrop(args.Session.AttachedEntity, printed, checkActionBlocker: false);
|
_handsSystem.PickupOrDrop(args.Session.AttachedEntity, printed, checkActionBlocker: false);
|
||||||
|
|
||||||
if (!TryComp<PaperComponent>(printed, out var paper))
|
if (!TryComp<PaperComponent>(printed, out var paper))
|
||||||
|
{
|
||||||
|
_sawmill.Error("Printed paper did not have PaperComponent.");
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
MetaData(printed).EntityName = Loc.GetString("forensic-scanner-report-title", ("entity", component.LastScanned));
|
MetaData(printed).EntityName = Loc.GetString("forensic-scanner-report-title", ("entity", component.LastScannedName));
|
||||||
|
|
||||||
var text = new StringBuilder();
|
var text = new StringBuilder();
|
||||||
|
|
||||||
@@ -171,6 +224,26 @@ namespace Content.Server.Forensics
|
|||||||
}
|
}
|
||||||
|
|
||||||
_paperSystem.SetContent(printed, text.ToString());
|
_paperSystem.SetContent(printed, text.ToString());
|
||||||
|
_audioSystem.PlayPvs(component.SoundPrint, uid,
|
||||||
|
AudioParams.Default
|
||||||
|
.WithVariation(0.25f)
|
||||||
|
.WithVolume(3f)
|
||||||
|
.WithRolloffFactor(2.8f)
|
||||||
|
.WithMaxDistance(4.5f));
|
||||||
|
|
||||||
|
component.PrintReadyAt = _gameTiming.CurTime + component.PrintCooldown;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnClear(EntityUid uid, ForensicScannerComponent component, ForensicScannerClearMessage args)
|
||||||
|
{
|
||||||
|
if (!args.Session.AttachedEntity.HasValue)
|
||||||
|
return;
|
||||||
|
|
||||||
|
component.Fingerprints = new();
|
||||||
|
component.Fibers = new();
|
||||||
|
component.LastScannedName = string.Empty;
|
||||||
|
|
||||||
|
UpdateUserInterface(uid, component);
|
||||||
}
|
}
|
||||||
|
|
||||||
private sealed class ScanCancelledEvent : EntityEventArgs
|
private sealed class ScanCancelledEvent : EntityEventArgs
|
||||||
|
|||||||
@@ -3,17 +3,26 @@ using Robust.Shared.Serialization;
|
|||||||
namespace Content.Shared.Forensics
|
namespace Content.Shared.Forensics
|
||||||
{
|
{
|
||||||
[Serializable, NetSerializable]
|
[Serializable, NetSerializable]
|
||||||
public sealed class ForensicScannerUserMessage : BoundUserInterfaceMessage
|
public sealed class ForensicScannerBoundUserInterfaceState : BoundUserInterfaceState
|
||||||
{
|
{
|
||||||
public readonly List<string> Fingerprints = new();
|
public readonly List<string> Fingerprints = new();
|
||||||
public readonly List<string> Fibers = new();
|
public readonly List<string> Fibers = new();
|
||||||
public readonly string LastScanned = string.Empty;
|
public readonly string LastScannedName = string.Empty;
|
||||||
|
public readonly TimeSpan PrintCooldown = TimeSpan.Zero;
|
||||||
|
public readonly TimeSpan PrintReadyAt = TimeSpan.Zero;
|
||||||
|
|
||||||
public ForensicScannerUserMessage(List<string> fingerprints, List<string> fibers, string lastScanned)
|
public ForensicScannerBoundUserInterfaceState(
|
||||||
|
List<string> fingerprints,
|
||||||
|
List<string> fibers,
|
||||||
|
string lastScannedName,
|
||||||
|
TimeSpan printCooldown,
|
||||||
|
TimeSpan printReadyAt)
|
||||||
{
|
{
|
||||||
Fingerprints = fingerprints;
|
Fingerprints = fingerprints;
|
||||||
Fibers = fibers;
|
Fibers = fibers;
|
||||||
LastScanned = lastScanned;
|
LastScannedName = lastScannedName;
|
||||||
|
PrintCooldown = printCooldown;
|
||||||
|
PrintReadyAt = printReadyAt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -27,4 +36,9 @@ namespace Content.Shared.Forensics
|
|||||||
public sealed class ForensicScannerPrintMessage : BoundUserInterfaceMessage
|
public sealed class ForensicScannerPrintMessage : BoundUserInterfaceMessage
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Serializable, NetSerializable]
|
||||||
|
public sealed class ForensicScannerClearMessage : BoundUserInterfaceMessage
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
4
Resources/Audio/Machines/attributions.yml
Normal file
4
Resources/Audio/Machines/attributions.yml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
- files: ["short_print_and_rip.ogg"]
|
||||||
|
license: "CC0-1.0"
|
||||||
|
copyright: "receipt printing.wav by 13F_Panska_Tlolkova_Matilda. This version is cleaned up, shortened, and converted to OGG."
|
||||||
|
source: "https://freesound.org/people/13F_Panska_Tlolkova_Matilda/sounds/378331"
|
||||||
BIN
Resources/Audio/Machines/short_print_and_rip.ogg
Normal file
BIN
Resources/Audio/Machines/short_print_and_rip.ogg
Normal file
Binary file not shown.
@@ -3,6 +3,7 @@ forensic-scanner-interface-fingerprints = Fingerprints
|
|||||||
forensic-scanner-interface-fibers = Fibers
|
forensic-scanner-interface-fibers = Fibers
|
||||||
forensic-scanner-interface-no-data = No scan data available
|
forensic-scanner-interface-no-data = No scan data available
|
||||||
forensic-scanner-interface-print = Print
|
forensic-scanner-interface-print = Print
|
||||||
|
forensic-scanner-interface-clear = Clear
|
||||||
forensic-scanner-report-title = Forensics Report: {$entity}
|
forensic-scanner-report-title = Forensics Report: {$entity}
|
||||||
forensic-pad-unused = It hasn't been used.
|
forensic-pad-unused = It hasn't been used.
|
||||||
forensic-pad-sample = It has a sample: {$sample}
|
forensic-pad-sample = It has a sample: {$sample}
|
||||||
@@ -13,6 +14,7 @@ forensic-pad-already-used = This pad has already been used.
|
|||||||
forensic-scanner-match-fiber = Match in fiber found!
|
forensic-scanner-match-fiber = Match in fiber found!
|
||||||
forensic-scanner-match-fingerprint = Match in fingerprint found!
|
forensic-scanner-match-fingerprint = Match in fingerprint found!
|
||||||
forensic-scanner-match-none = No matches found!
|
forensic-scanner-match-none = No matches found!
|
||||||
|
forensic-scanner-printer-not-ready = Printer is not ready yet.
|
||||||
forensic-scanner-verb-text = Scan
|
forensic-scanner-verb-text = Scan
|
||||||
forensic-scanner-verb-message = Perform a forensic scan
|
forensic-scanner-verb-message = Perform a forensic scan
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,8 @@
|
|||||||
- Belt
|
- Belt
|
||||||
- type: ActivatableUI
|
- type: ActivatableUI
|
||||||
key: enum.ForensicScannerUiKey.Key
|
key: enum.ForensicScannerUiKey.Key
|
||||||
|
inHandsOnly: true
|
||||||
|
closeOnHandDeselect: false
|
||||||
- type: UserInterface
|
- type: UserInterface
|
||||||
interfaces:
|
interfaces:
|
||||||
- key: enum.ForensicScannerUiKey.Key
|
- key: enum.ForensicScannerUiKey.Key
|
||||||
|
|||||||
Reference in New Issue
Block a user