Refactoring body system to use containers and general body cleanup (#20202)

Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
Jezithyr
2023-09-21 00:23:02 -07:00
committed by GitHub
parent d888d9ad67
commit 31b2c9f830
38 changed files with 1298 additions and 1098 deletions

View File

@@ -27,28 +27,4 @@ public sealed class BodyPrototype : IPrototype
}
[DataRecord]
public sealed record BodyPrototypeSlot
{
[DataField("part", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
public string? Part;
public readonly HashSet<string> Connections = new();
public readonly Dictionary<string, string> Organs = new();
public BodyPrototypeSlot() : this(null, null, null)
{
}
public BodyPrototypeSlot(string? part, HashSet<string>? connections, Dictionary<string, string>? organs)
{
Part = part;
Connections = connections ?? new HashSet<string>();
Organs = organs ?? new Dictionary<string, string>();
}
public void Deconstruct(out string? part, out HashSet<string> connections, out Dictionary<string, string> organs)
{
part = Part;
connections = Connections;
organs = Organs;
}
}
public sealed record BodyPrototypeSlot(EntProtoId? Part, HashSet<string> Connections, Dictionary<string, string> Organs);

View File

@@ -179,9 +179,10 @@ public sealed class BodyPrototypeSerializer : ITypeReader<BodyPrototype, Mapping
}
var slots = new Dictionary<string, BodyPrototypeSlot>();
foreach (var (slotId, (part, connections, organs)) in allConnections)
{
var slot = new BodyPrototypeSlot(part, connections, organs);
var slot = new BodyPrototypeSlot(part != null ? new EntProtoId(part) : null!, connections ?? new HashSet<string>(), organs ?? new Dictionary<string, string>());
slots.Add(slotId, slot);
}