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

@@ -94,7 +94,7 @@ namespace Content.Server.Body.Commands
}
var bodySystem = _entManager.System<BodySystem>();
if (bodySystem.BodyHasChild(bodyId, partUid, body, part))
if (bodySystem.BodyHasChild(bodyId, partUid.Value, body, part))
{
shell.WriteLine($"Body part {_entManager.GetComponent<MetaDataComponent>(partUid.Value).EntityName} with uid {partUid} is already attached to entity {_entManager.GetComponent<MetaDataComponent>(bodyId).EntityName} with uid {bodyId}");
return;
@@ -103,16 +103,14 @@ namespace Content.Server.Body.Commands
var slotId = $"AttachBodyPartVerb-{partUid}";
// ReSharper disable once ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract
if (bodySystem.TryCreateBodyRootSlot(bodyId, slotId, out var rootSlot, body))
if (body.RootContainer.ContainedEntity != null)
{
bodySystem.DropPart(partUid, part);
bodySystem.AttachPart(partUid, rootSlot, part);
bodySystem.AttachPartToRoot(bodyId,partUid.Value, body ,part);
}
else
{
var attachAt = bodySystem.GetBodyChildren(bodyId, body).First();
if (!bodySystem.TryCreatePartSlotAndAttach(attachAt.Id, slotId, partUid, attachAt.Component, part))
var (rootPartId,rootPart) = bodySystem.GetRootPartOrNull(bodyId, body)!.Value;
if (!bodySystem.TryCreatePartSlotAndAttach(rootPartId, slotId, partUid.Value, part.PartType, rootPart, part))
{
shell.WriteError($"Could not create slot {slotId} on entity {_entManager.ToPrettyString(bodyId)}");
return;