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

@@ -9,50 +9,26 @@ namespace Content.Shared.Body.Systems;
public partial class SharedBodySystem
{
private void InitializeOrgans()
private void AddOrgan(EntityUid uid, EntityUid bodyUid, EntityUid parentPartUid, OrganComponent component)
{
SubscribeLocalEvent<OrganComponent, EntGotInsertedIntoContainerMessage>(OnOrganInserted);
SubscribeLocalEvent<OrganComponent, EntGotRemovedFromContainerMessage>(OnOrganRemoved);
component.Body = bodyUid;
RaiseLocalEvent(uid, new AddedToPartEvent(parentPartUid));
if (component.Body != null)
RaiseLocalEvent(uid, new AddedToPartInBodyEvent(component.Body.Value, parentPartUid));
Dirty(uid, component);
}
private void OnOrganInserted(EntityUid uid, OrganComponent component, EntGotInsertedIntoContainerMessage args)
private void RemoveOrgan(EntityUid uid, EntityUid parentPartUid, OrganComponent component)
{
// No recursive updates for these as you can't insert organs into organsTM.
var parentUid = args.Container.Owner;
RaiseLocalEvent(uid, new RemovedFromPartEvent(parentPartUid));
if (HasComp<BodyComponent>(parentUid))
if (component.Body != null)
{
component.Body = parentUid;
Dirty(uid, component);
RaiseLocalEvent(uid, new RemovedFromPartInBodyEvent(component.Body.Value, parentPartUid));
}
// Organ inserted into body part.
if (TryComp(parentUid, out BodyPartComponent? partComp))
{
RaiseLocalEvent(uid, new AddedToPartEvent(parentUid));
if (partComp.Body != null)
{
component.Body = partComp.Body;
RaiseLocalEvent(uid, new AddedToPartInBodyEvent(partComp.Body.Value, parentUid));
Dirty(uid, component);
}
}
}
private void OnOrganRemoved(EntityUid uid, OrganComponent component, EntGotRemovedFromContainerMessage args)
{
// Lifestage shenanigans.
if (component.Body != null && TerminatingOrDeleted(component.Body.Value))
return;
if (HasComp<BodyPartComponent>(args.Container.Owner))
RaiseLocalEvent(uid, new RemovedFromPartEvent(args.Container.Owner));
if (component.Body == null)
return;
RaiseLocalEvent(uid, new RemovedFromPartInBodyEvent(component.Body.Value, args.Container.Owner));
component.Body = null;
Dirty(uid, component);
}