Organ fixes (#20488)

This commit is contained in:
metalgearsloth
2023-09-30 01:01:47 +10:00
committed by GitHub
parent 4313a6ee66
commit 290c2fd502
5 changed files with 24 additions and 49 deletions

View File

@@ -1,6 +1,7 @@
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Content.Shared.Body.Components;
using Content.Shared.Body.Events;
using Content.Shared.Body.Organ;
using Content.Shared.Body.Part;
using Content.Shared.Damage;
@@ -61,7 +62,7 @@ public partial class SharedBodySystem
if (TryComp(entity, out OrganComponent? organ))
{
RemoveOrgan(entity, organ);
RemoveOrgan(entity, uid, organ);
}
}
@@ -85,7 +86,20 @@ public partial class SharedBodySystem
{
if (TryComp(organ, out OrganComponent? organComp))
{
var oldBody = organComp.Body;
organComp.Body = bodyUid;
if (bodyUid != null)
{
var ev = new AddedToPartInBodyEvent(bodyUid.Value, children.Id);
RaiseLocalEvent(organ, ev);
}
else if (oldBody != null)
{
var ev = new RemovedFromPartInBodyEvent(oldBody.Value, children.Id);
RaiseLocalEvent(organ, ev);
}
Dirty(organ, organComp);
}
}