Revert "Shuffle body container subs slightly (#21084)" (#22339)

This reverts commit eb49ad11ba.
This commit is contained in:
metalgearsloth
2023-12-11 23:06:56 +11:00
committed by GitHub
parent 000c776f47
commit 1cea5240c0
4 changed files with 130 additions and 117 deletions

View File

@@ -25,11 +25,63 @@ public partial class SharedBodySystem
private void InitializeBody()
{
// Body here to handle root body parts.
SubscribeLocalEvent<BodyComponent, EntInsertedIntoContainerMessage>(OnBodyInserted);
SubscribeLocalEvent<BodyComponent, EntRemovedFromContainerMessage>(OnBodyRemoved);
SubscribeLocalEvent<BodyComponent, ComponentInit>(OnBodyInit);
SubscribeLocalEvent<BodyComponent, MapInitEvent>(OnBodyMapInit);
SubscribeLocalEvent<BodyComponent, CanDragEvent>(OnBodyCanDrag);
}
private void OnBodyInserted(EntityUid uid, BodyComponent component, EntInsertedIntoContainerMessage args)
{
// Root body part?
var slotId = args.Container.ID;
if (slotId != BodyRootContainerId)
return;
var entity = args.Entity;
if (TryComp(entity, out BodyPartComponent? childPart))
{
AddPart(uid, entity, slotId, childPart);
RecursiveBodyUpdate(entity, uid, childPart);
}
if (TryComp(entity, out OrganComponent? organ))
{
AddOrgan(entity, uid, uid, organ);
}
}
private void OnBodyRemoved(EntityUid uid, BodyComponent component, EntRemovedFromContainerMessage args)
{
// TODO: lifestage shenanigans
if (TerminatingOrDeleted(uid))
return;
// Root body part?
var slotId = args.Container.ID;
if (slotId != BodyRootContainerId)
return;
var entity = args.Entity;
if (TryComp(entity, out BodyPartComponent? childPart))
{
RemovePart(uid, entity, slotId, childPart);
RecursiveBodyUpdate(entity, null, childPart);
}
if (TryComp(entity, out OrganComponent? organ))
{
RemoveOrgan(entity, uid, organ);
}
}
private void OnBodyInit(EntityUid bodyId, BodyComponent body, ComponentInit args)
{
// Setup the initial container.
@@ -177,8 +229,6 @@ public partial class SharedBodySystem
yield break;
}
yield return (body.RootContainer.ContainedEntity.Value, rootPart);
foreach (var child in GetBodyPartChildren(body.RootContainer.ContainedEntity.Value, rootPart))
{
yield return child;