Refactor body component to use slots instead of an army of dictionaries (#3749)
* Refactor body component to use slots instead of an army of dictionaries * Update vox * Replace static method call with extension * Add setpart method, replace dispose with shutdown * Fix tests, fix not listening to slot events when setting a part
This commit is contained in:
@@ -469,19 +469,26 @@ namespace Content.Server.GameObjects.Components.Kitchen
|
||||
|
||||
if (victim.TryGetComponent<IBody>(out var body))
|
||||
{
|
||||
var heads = body.GetPartsOfType(BodyPartType.Head);
|
||||
foreach (var head in heads)
|
||||
var headSlots = body.GetSlotsOfType(BodyPartType.Head);
|
||||
|
||||
foreach (var slot in headSlots)
|
||||
{
|
||||
if (!body.TryDropPart(head, out var dropped))
|
||||
var part = slot.Part;
|
||||
|
||||
if (part == null ||
|
||||
!body.TryDropPart(slot, out var dropped))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var droppedHeads = dropped.Where(p => p.PartType == BodyPartType.Head);
|
||||
|
||||
foreach (var droppedHead in droppedHeads)
|
||||
foreach (var droppedPart in dropped.Values)
|
||||
{
|
||||
_storage.Insert(droppedHead.Owner);
|
||||
if (droppedPart.PartType != BodyPartType.Head)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
_storage.Insert(droppedPart.Owner);
|
||||
headCount++;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user