Fingerprint taking improvements (#31864)
* now using event to check access to fingerprint * Opps actually commiting the changes --------- Co-authored-by: YourUsername <you@example.com> Co-authored-by: beck-thompson <beck314159@hotmail.com>
This commit is contained in:
24
Content.Server/Forensics/Systems/FingerprintMaskSystem.cs
Normal file
24
Content.Server/Forensics/Systems/FingerprintMaskSystem.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using Content.Shared.Forensics;
|
||||
using Content.Shared.Forensics.Components;
|
||||
using Content.Shared.Inventory;
|
||||
|
||||
namespace Content.Server.Forensics;
|
||||
|
||||
public sealed class FingerprintMaskSystem : EntitySystem
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<FingerprintMaskComponent, InventoryRelayedEvent<TryAccessFingerprintEvent>>(OnTryAccessFingerprint);
|
||||
}
|
||||
|
||||
private void OnTryAccessFingerprint(EntityUid uid, FingerprintMaskComponent comp, ref InventoryRelayedEvent<TryAccessFingerprintEvent> args)
|
||||
{
|
||||
if (args.Args.Cancelled)
|
||||
return;
|
||||
|
||||
args.Args.Blocker = uid;
|
||||
args.Args.Cancel();
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,8 @@ namespace Content.Server.Forensics
|
||||
[Dependency] private readonly SharedDoAfterSystem _doAfterSystem = default!;
|
||||
[Dependency] private readonly InventorySystem _inventory = default!;
|
||||
[Dependency] private readonly PopupSystem _popupSystem = default!;
|
||||
[Dependency] private readonly MetaDataSystem _metaData = default!;
|
||||
[Dependency] private readonly ForensicsSystem _forensics = default!;
|
||||
[Dependency] private readonly LabelSystem _label = default!;
|
||||
|
||||
public override void Initialize()
|
||||
@@ -58,9 +60,14 @@ namespace Content.Server.Forensics
|
||||
return;
|
||||
}
|
||||
|
||||
if (_inventory.TryGetSlotEntity(args.Target.Value, "gloves", out var gloves))
|
||||
if (!_forensics.CanAccessFingerprint(args.Target.Value, out var blocker))
|
||||
{
|
||||
_popupSystem.PopupEntity(Loc.GetString("forensic-pad-gloves", ("target", Identity.Entity(args.Target.Value, EntityManager))), args.Target.Value, args.User);
|
||||
|
||||
if (blocker is { } item)
|
||||
_popupSystem.PopupEntity(Loc.GetString("forensic-pad-no-access-due", ("entity", Identity.Entity(item, EntityManager))), args.Target.Value, args.User);
|
||||
else
|
||||
_popupSystem.PopupEntity(Loc.GetString("forensic-pad-no-access"), args.Target.Value, args.User);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -299,11 +299,9 @@ namespace Content.Server.Forensics
|
||||
{
|
||||
if (TryComp<FiberComponent>(gloves, out var fiber) && !string.IsNullOrEmpty(fiber.FiberMaterial))
|
||||
component.Fibers.Add(string.IsNullOrEmpty(fiber.FiberColor) ? Loc.GetString("forensic-fibers", ("material", fiber.FiberMaterial)) : Loc.GetString("forensic-fibers-colored", ("color", fiber.FiberColor), ("material", fiber.FiberMaterial)));
|
||||
|
||||
if (HasComp<FingerprintMaskComponent>(gloves))
|
||||
return;
|
||||
}
|
||||
if (TryComp<FingerprintComponent>(user, out var fingerprint))
|
||||
|
||||
if (TryComp<FingerprintComponent>(user, out var fingerprint) && CanAccessFingerprint(user, out _))
|
||||
component.Fingerprints.Add(fingerprint.Fingerprint ?? "");
|
||||
}
|
||||
|
||||
@@ -364,6 +362,23 @@ namespace Content.Server.Forensics
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if there's a way to access the fingerprint of the target entity.
|
||||
/// </summary>
|
||||
/// <param name="target">The entity with the fingerprint</param>
|
||||
/// <param name="blocker">The entity that blocked accessing the fingerprint</param>
|
||||
public bool CanAccessFingerprint(EntityUid target, out EntityUid? blocker)
|
||||
{
|
||||
var ev = new TryAccessFingerprintEvent();
|
||||
|
||||
RaiseLocalEvent(target, ev);
|
||||
if (!ev.Cancelled && TryComp<InventoryComponent>(target, out var inv))
|
||||
_inventory.RelayEvent((target, inv), ev);
|
||||
|
||||
blocker = ev.Blocker;
|
||||
return !ev.Cancelled;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Content.Shared.DoAfter;
|
||||
using Content.Shared.Inventory;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Forensics;
|
||||
@@ -68,3 +69,16 @@ public record struct GenerateDnaEvent()
|
||||
/// </summary>
|
||||
public required string DNA;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An event to check if the fingerprint is accessible.
|
||||
/// </summary>
|
||||
public sealed class TryAccessFingerprintEvent : CancellableEntityEventArgs, IInventoryRelayEvent
|
||||
{
|
||||
SlotFlags IInventoryRelayEvent.TargetSlots => SlotFlags.WITHOUT_POCKET;
|
||||
|
||||
/// <summary>
|
||||
/// Entity that blocked access.
|
||||
/// </summary>
|
||||
public EntityUid? Blocker;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,8 @@ forensic-scanner-interface-clear = Clear
|
||||
forensic-scanner-report-title = Forensics Report: {$entity}
|
||||
forensic-pad-unused = It hasn't been used.
|
||||
forensic-pad-sample = It has a sample: {$sample}
|
||||
forensic-pad-gloves = {CAPITALIZE($target)} is wearing gloves.
|
||||
forensic-pad-no-access-due = Can't access the fingerprint due to {THE($entity)}.
|
||||
forensic-pad-no-access = Can't access the fingerprint.
|
||||
forensic-pad-start-scan-target = {CAPITALIZE($user)} is trying to take a sample of your fingerprints.
|
||||
forensic-pad-start-scan-user = You start taking a sample of {CAPITALIZE($target)}'s fingerprints.
|
||||
forensic-pad-already-used = This pad has already been used.
|
||||
|
||||
Reference in New Issue
Block a user