Skip to content

Commit

Permalink
Unique glove fibers (#1455)
Browse files Browse the repository at this point in the history
* make changes

* comments

* commiting a single whitespace so i dont get executed

---------

Co-authored-by: deltanedas <[email protected]>
  • Loading branch information
2 people authored and angelofallars committed Aug 2, 2024
1 parent 8ccbf7e commit b1a1a57
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
3 changes: 3 additions & 0 deletions Content.Server/Forensics/Components/FiberComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@ public sealed partial class FiberComponent : Component

[DataField]
public string? FiberColor;

[DataField]
public string? Fiberprint; // DeltaV, unique glove fibers
}
}
21 changes: 18 additions & 3 deletions Content.Server/Forensics/Systems/ForensicsSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public sealed class ForensicsSystem : EntitySystem
public override void Initialize()
{
SubscribeLocalEvent<FingerprintComponent, ContactInteractionEvent>(OnInteract);
SubscribeLocalEvent<FiberComponent, MapInitEvent>(OnFiberInit); // DeltaV #1455 - unique glove fibers
SubscribeLocalEvent<FingerprintComponent, MapInitEvent>(OnFingerprintInit);
SubscribeLocalEvent<DnaComponent, MapInitEvent>(OnDNAInit);

Expand All @@ -39,6 +40,13 @@ private void OnInteract(EntityUid uid, FingerprintComponent component, ContactIn
ApplyEvidence(uid, args.Other);
}

// DeltaV #1455 - unique glove fibers
private void OnFiberInit(EntityUid uid, FiberComponent component, MapInitEvent args)
{
component.Fiberprint = GenerateFingerprint(length: 7);
}
// End of DeltaV code

private void OnFingerprintInit(EntityUid uid, FingerprintComponent component, MapInitEvent args)
{
component.Fingerprint = GenerateFingerprint();
Expand Down Expand Up @@ -150,9 +158,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) // DeltaV #1455 - allow changing the length of the fingerprint hash
{
var fingerprint = new byte[16];
var fingerprint = new byte[length]; // DeltaV #1455 - allow changing the length of the fingerprint hash
_random.NextBytes(fingerprint);
return Convert.ToHexString(fingerprint);
}
Expand All @@ -178,8 +186,15 @@ private void ApplyEvidence(EntityUid user, EntityUid target)
var component = EnsureComp<ForensicsComponent>(target);
if (_inventory.TryGetSlotEntity(user, "gloves", out var gloves))
{
// DeltaV #1455 - unique glove fibers
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)));
{
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);
}
// End of DeltaV code

if (HasComp<FingerprintMaskComponent>(gloves))
return;
Expand Down

0 comments on commit b1a1a57

Please sign in to comment.