DNA basics (#14724)
* DNA component * Commit numba 2 * Added DNA into Station Records Computer * commit numba 3 * commit numba 4 * Vomit also contain DNA component now * fixed DNA field not clearing after scanning another item * commit numba 10 Drinking leaves DNA on an object. Breaking glasses, bottles and beakers leave DNA and leave fingerprints/fibers with 40% chance on glass shards. + lotta fixes * 11 * 12 * 14 * Added DNA guide entry * FIX
This commit is contained in:
11
Content.Server/Forensics/Components/DnaComponent.cs
Normal file
11
Content.Server/Forensics/Components/DnaComponent.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace Content.Server.Forensics;
|
||||
|
||||
/// <summary>
|
||||
/// This component is for mobs that have DNA.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
public sealed class DnaComponent : Component
|
||||
{
|
||||
[DataField("dna"), ViewVariables(VVAccess.ReadWrite)]
|
||||
public string DNA = String.Empty;
|
||||
}
|
||||
@@ -20,6 +20,12 @@ namespace Content.Server.Forensics
|
||||
[ViewVariables(VVAccess.ReadOnly)]
|
||||
public List<string> Fibers = new();
|
||||
|
||||
/// <summary>
|
||||
/// DNA that the forensic scanner found from the <see cref="DNAComponent"/> on an entity.
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadOnly)]
|
||||
public List<string> DNAs = new();
|
||||
|
||||
/// <summary>
|
||||
/// What is the name of the entity that was scanned last?
|
||||
/// </summary>
|
||||
|
||||
@@ -8,5 +8,8 @@ namespace Content.Server.Forensics
|
||||
|
||||
[DataField("fibers")]
|
||||
public HashSet<string> Fibers = new();
|
||||
|
||||
[DataField("dnas")]
|
||||
public HashSet<string> DNAs = new();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ namespace Content.Server.Forensics
|
||||
var state = new ForensicScannerBoundUserInterfaceState(
|
||||
component.Fingerprints,
|
||||
component.Fibers,
|
||||
component.DNAs,
|
||||
component.LastScannedName,
|
||||
component.PrintCooldown,
|
||||
component.PrintReadyAt);
|
||||
@@ -69,12 +70,14 @@ namespace Content.Server.Forensics
|
||||
{
|
||||
scanner.Fingerprints = new();
|
||||
scanner.Fibers = new();
|
||||
scanner.DNAs = new();
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
scanner.Fingerprints = forensics.Fingerprints.ToList();
|
||||
scanner.Fibers = forensics.Fibers.ToList();
|
||||
scanner.DNAs = forensics.DNAs.ToList();
|
||||
}
|
||||
|
||||
scanner.LastScannedName = MetaData(args.Args.Target.Value).EntityName;
|
||||
@@ -211,6 +214,12 @@ namespace Content.Server.Forensics
|
||||
{
|
||||
text.AppendLine(fiber);
|
||||
}
|
||||
text.AppendLine();
|
||||
text.AppendLine(Loc.GetString("forensic-scanner-interface-dnas"));
|
||||
foreach (var dna in component.DNAs)
|
||||
{
|
||||
text.AppendLine(dna);
|
||||
}
|
||||
|
||||
_paperSystem.SetContent(printed, text.ToString());
|
||||
_audioSystem.PlayPvs(component.SoundPrint, uid,
|
||||
@@ -230,6 +239,7 @@ namespace Content.Server.Forensics
|
||||
|
||||
component.Fingerprints = new();
|
||||
component.Fibers = new();
|
||||
component.DNAs = new();
|
||||
component.LastScannedName = string.Empty;
|
||||
|
||||
UpdateUserInterface(uid, component);
|
||||
|
||||
@@ -11,7 +11,8 @@ namespace Content.Server.Forensics
|
||||
public override void Initialize()
|
||||
{
|
||||
SubscribeLocalEvent<FingerprintComponent, ContactInteractionEvent>(OnInteract);
|
||||
SubscribeLocalEvent<FingerprintComponent, ComponentInit>(OnInit);
|
||||
SubscribeLocalEvent<FingerprintComponent, ComponentInit>(OnFingeprintInit);
|
||||
SubscribeLocalEvent<DnaComponent, ComponentInit>(OnDNAInit);
|
||||
}
|
||||
|
||||
private void OnInteract(EntityUid uid, FingerprintComponent component, ContactInteractionEvent args)
|
||||
@@ -19,11 +20,16 @@ namespace Content.Server.Forensics
|
||||
ApplyEvidence(uid, args.Other);
|
||||
}
|
||||
|
||||
private void OnInit(EntityUid uid, FingerprintComponent component, ComponentInit args)
|
||||
private void OnFingeprintInit(EntityUid uid, FingerprintComponent component, ComponentInit args)
|
||||
{
|
||||
component.Fingerprint = GenerateFingerprint();
|
||||
}
|
||||
|
||||
private void OnDNAInit(EntityUid uid, DnaComponent component, ComponentInit args)
|
||||
{
|
||||
component.DNA = GenerateDNA();
|
||||
}
|
||||
|
||||
private string GenerateFingerprint()
|
||||
{
|
||||
byte[] fingerprint = new byte[16];
|
||||
@@ -31,6 +37,19 @@ namespace Content.Server.Forensics
|
||||
return Convert.ToHexString(fingerprint);
|
||||
}
|
||||
|
||||
private string GenerateDNA()
|
||||
{
|
||||
var letters = new List<string> { "A", "C", "G", "T" };
|
||||
string DNA = String.Empty;
|
||||
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
DNA += letters[_random.Next(letters.Count)];
|
||||
}
|
||||
|
||||
return DNA;
|
||||
}
|
||||
|
||||
private void ApplyEvidence(EntityUid user, EntityUid target)
|
||||
{
|
||||
var component = EnsureComp<ForensicsComponent>(target);
|
||||
|
||||
Reference in New Issue
Block a user