Organ fixes (#20488)
This commit is contained in:
@@ -74,7 +74,7 @@ public partial class SharedBodySystem
|
||||
|
||||
if (TryComp(entity, out OrganComponent? organ))
|
||||
{
|
||||
RemoveOrgan(entity, uid, uid, organ);
|
||||
RemoveOrgan(entity, uid, organ);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ public partial class SharedBodySystem
|
||||
private void AddOrgan(EntityUid uid, EntityUid bodyUid, EntityUid parentPartUid, OrganComponent component)
|
||||
{
|
||||
component.Body = bodyUid;
|
||||
RaiseLocalEvent(uid, new AddedToPartEvent(bodyUid));
|
||||
RaiseLocalEvent(uid, new AddedToPartEvent(parentPartUid));
|
||||
|
||||
if (component.Body != null)
|
||||
RaiseLocalEvent(uid, new AddedToPartInBodyEvent(component.Body.Value, parentPartUid));
|
||||
@@ -20,12 +20,14 @@ public partial class SharedBodySystem
|
||||
Dirty(uid, component);
|
||||
}
|
||||
|
||||
private void RemoveOrgan(EntityUid uid, EntityUid bodyUid, EntityUid parentPartUid, OrganComponent component)
|
||||
private void RemoveOrgan(EntityUid uid, EntityUid parentPartUid, OrganComponent component)
|
||||
{
|
||||
RaiseLocalEvent(uid, new RemovedFromPartEvent(bodyUid));
|
||||
RaiseLocalEvent(uid, new RemovedFromPartEvent(parentPartUid));
|
||||
|
||||
if (component.Body != null)
|
||||
{
|
||||
RaiseLocalEvent(uid, new RemovedFromPartInBodyEvent(component.Body.Value, parentPartUid));
|
||||
}
|
||||
|
||||
component.Body = null;
|
||||
Dirty(uid, component);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user