Fixed Attachbodypart Console Command (#34577)

* remade command for attachbodypart

* fixed up WriteError
This commit is contained in:
Coolsurf6
2025-04-19 11:23:58 +10:00
committed by GitHub
parent b034a1053f
commit 369eef146f

View File

@@ -100,21 +100,23 @@ namespace Content.Server.Body.Commands
var slotId = $"AttachBodyPartVerb-{partUid}"; var slotId = $"AttachBodyPartVerb-{partUid}";
// ReSharper disable once ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract if (body.RootContainer.ContainedEntity is null && !bodySystem.AttachPartToRoot(bodyId, partUid.Value, body, part))
if (body.RootContainer.ContainedEntity != null)
{ {
bodySystem.AttachPartToRoot(bodyId, partUid.Value, body, part); shell.WriteError("Body container does not have a root entity to attach to the body part!");
} return;
else
{
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;
}
} }
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;
}
shell.WriteLine($"Attached part {_entManager.ToPrettyString(partUid.Value)} to {_entManager.ToPrettyString(bodyId)}"); shell.WriteLine($"Attached part {_entManager.ToPrettyString(partUid.Value)} to {_entManager.ToPrettyString(bodyId)}");
} }
} }