From 8768df79121f3ccead72d97cba143cec49c9a369 Mon Sep 17 00:00:00 2001 From: Angelo Fallaria Date: Wed, 7 Aug 2024 06:03:35 +0800 Subject: [PATCH] Unique Glove Fibers (#642) # Description Cherry-picked from Delta-V, originally by @WarMechanic (https://github.com/DeltaV-Station/Delta-v/pull/1455). Original Description: > Every pair of gloves now has its own fingerprint, so items can be traced back to gloves which can then be traced back to people. > > ## Why / Balance > > Evidence is very important to court cases running smoothly, so detectives now have more evidence that can certify whether or not John Syndicate's behaviour is valid. Traitors are now encouraged to either clean evidence off syndicate gear regardless of glove status, or use a disposable pair of gloves specifically for handling syndicate gear to be disposed of later. > > Aside from being required to obfuscate evidence you leave behind, there is now a value proposition to searching glove prints of departments. Wearing gloves that does not correspond your department can punish an unknowing detective into searching the wrong people. > > ## Technical details > > `FiberComponent.cs` now stores a Fiberprint variable like `FingerprintComponent.cs`. The code for assigning a fiberprint is the same as the fingerprint. When evidence is placed on an object, the fiberprint is concatenated to its localised fiber type.

Original Media

> hm ok we have these specific gloves on an akms >
> > > > hm well we found the gloves and they have fingerprints >
> > > > gotem >
> >

# Changelog :cl: WarMechanic - add: Gloves now have unique fingerprints. Items can be traced back to gloves, which can then be traced back to people. --------- Signed-off-by: Angelo Fallaria Co-authored-by: WarMechanic <69510347+WarMechanic@users.noreply.github.com> Co-authored-by: deltanedas <39013340+deltanedas@users.noreply.github.com> Co-authored-by: Danger Revolution! <142105406+DangerRevolution@users.noreply.github.com> Co-authored-by: VMSolidus --- .../Forensics/Components/FiberComponent.cs | 3 +++ .../Forensics/Systems/ForensicsSystem.cs | 17 ++++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/Content.Server/Forensics/Components/FiberComponent.cs b/Content.Server/Forensics/Components/FiberComponent.cs index 2086c958702..4cbb1e7be7f 100644 --- a/Content.Server/Forensics/Components/FiberComponent.cs +++ b/Content.Server/Forensics/Components/FiberComponent.cs @@ -12,5 +12,8 @@ public sealed partial class FiberComponent : Component [DataField] public string? FiberColor; + + [DataField] + public string? Fiberprint; } } diff --git a/Content.Server/Forensics/Systems/ForensicsSystem.cs b/Content.Server/Forensics/Systems/ForensicsSystem.cs index a081429fd3a..1663c20fedb 100644 --- a/Content.Server/Forensics/Systems/ForensicsSystem.cs +++ b/Content.Server/Forensics/Systems/ForensicsSystem.cs @@ -23,6 +23,7 @@ public sealed class ForensicsSystem : EntitySystem public override void Initialize() { SubscribeLocalEvent(OnInteract); + SubscribeLocalEvent(OnFiberInit); SubscribeLocalEvent(OnFingerprintInit); SubscribeLocalEvent(OnDNAInit); @@ -39,6 +40,11 @@ private void OnInteract(EntityUid uid, FingerprintComponent component, ContactIn ApplyEvidence(uid, args.Other); } + private void OnFiberInit(EntityUid uid, FiberComponent component, MapInitEvent args) + { + component.Fiberprint = GenerateFingerprint(length: 7); + } + private void OnFingerprintInit(EntityUid uid, FingerprintComponent component, MapInitEvent args) { component.Fingerprint = GenerateFingerprint(); @@ -150,9 +156,9 @@ private void OnCleanForensicsDoAfter(EntityUid uid, ForensicsComponent component targetComp.Residues.Add(string.IsNullOrEmpty(residue.ResidueColor) ? Loc.GetString("forensic-residue", ("adjective", residue.ResidueAdjective)) : Loc.GetString("forensic-residue-colored", ("color", residue.ResidueColor), ("adjective", residue.ResidueAdjective))); } - public string GenerateFingerprint() + public string GenerateFingerprint(int length = 16) { - var fingerprint = new byte[16]; + var fingerprint = new byte[Math.Clamp(length, 0, 255)]; _random.NextBytes(fingerprint); return Convert.ToHexString(fingerprint); } @@ -179,7 +185,12 @@ private void ApplyEvidence(EntityUid user, EntityUid target) if (_inventory.TryGetSlotEntity(user, "gloves", out var gloves)) { if (TryComp(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))); + { + var fiberLocale = string.IsNullOrEmpty(fiber.FiberColor) + ? Loc.GetString("forensic-fibers", ("material", fiber.FiberMaterial)) + : Loc.GetString("forensic-fibers-colored", ("color", fiber.FiberColor), ("material", fiber.FiberMaterial)); + component.Fibers.Add(fiberLocale + " ; " + fiber.Fiberprint); + } if (HasComp(gloves)) return;