Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unique glove fibers #1455

Merged
merged 6 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -25,6 +25,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 @@ -43,6 +44,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)
WarMechanic marked this conversation as resolved.
Show resolved Hide resolved
{
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 @@ -202,9 +210,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 @@ -230,8 +238,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)
WarMechanic marked this conversation as resolved.
Show resolved Hide resolved
? 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
Loading