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:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user