Better DNA forensics & ReagentData (#26699)

* Added the ability for blood to track DNA using ReagentData; Forensic Scanner now accounts for solution DNA, non-DNA holders have "Unknown DNA"

* Removes touch DNA for puddles, adds DNA to vomit

* DNA now leaves traces in containers and those marked without don't show DNA on scan (except for puddles), gibbed parts have DNA

* Fix stupid metamorphic glass bug grrr

* Removed SpillableComponent since DnaSubstanceTraceComponent is used instead

* Removes data field from maps, adds DNA tracking for some missed items

* Give default value, fix missing values.

* Fixes recipe bug

* Review changes

* Make the Data list into a nullable type

* Revert map changes

* Move gibbed unknown DNA to forensicssystem
This commit is contained in:
SlamBamActionman
2024-08-09 01:27:27 +02:00
committed by GitHub
parent c43fcdfa06
commit 07174d0aaf
45 changed files with 307 additions and 66 deletions

View File

@@ -1,6 +1,7 @@
using Content.Shared.FixedPoint;
using Content.Shared.FixedPoint;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
using System.Linq;
namespace Content.Shared.Chemistry.Reagent;
@@ -20,17 +21,23 @@ public partial struct ReagentId : IEquatable<ReagentId>
/// Any additional data that is unique to this reagent type. E.g., for blood this could be DNA data.
/// </summary>
[DataField("data")]
public ReagentData? Data { get; private set; }
public List<ReagentData>? Data { get; private set; } = new();
public ReagentId(string prototype, ReagentData? data)
public ReagentId(string prototype, List<ReagentData>? data)
{
Prototype = prototype;
Data = data;
Data = data ?? new();
}
public ReagentId()
{
Prototype = default!;
Data = new();
}
public List<ReagentData> EnsureReagentData()
{
return (Data != null) ? Data : new List<ReagentData>();
}
public bool Equals(ReagentId other)
@@ -44,13 +51,13 @@ public partial struct ReagentId : IEquatable<ReagentId>
if (other.Data == null)
return false;
if (Data.GetType() != other.Data.GetType())
if (Data.Except(other.Data).Any() || other.Data.Except(Data).Any() || Data.Count != other.Data.Count)
return false;
return Data.Equals(other.Data);
return true;
}
public bool Equals(string prototype, ReagentData? otherData = null)
public bool Equals(string prototype, List<ReagentData>? otherData = null)
{
if (Prototype != prototype)
return false;
@@ -73,12 +80,12 @@ public partial struct ReagentId : IEquatable<ReagentId>
public string ToString(FixedPoint2 quantity)
{
return Data?.ToString(Prototype, quantity) ?? $"{Prototype}:{quantity}";
return $"{Prototype}:{quantity}";
}
public override string ToString()
{
return Data?.ToString(Prototype) ?? Prototype;
return $"{Prototype}";
}
public static bool operator ==(ReagentId left, ReagentId right)