diff --git a/Content.Server/Polymorph/Components/PolymorphedEntityComponent.cs b/Content.Server/Polymorph/Components/PolymorphedEntityComponent.cs index 7e3437a908..03ab7b6c1f 100644 --- a/Content.Server/Polymorph/Components/PolymorphedEntityComponent.cs +++ b/Content.Server/Polymorph/Components/PolymorphedEntityComponent.cs @@ -20,6 +20,12 @@ public sealed partial class PolymorphedEntityComponent : Component [DataField(required: true)] public EntityUid? Parent; + /// + /// Whether this polymorph has been reverted. + /// + [DataField] + public bool Reverted; + /// /// The amount of time that has passed since the entity was created /// used for tracking the duration diff --git a/Content.Server/Polymorph/Systems/PolymorphSystem.cs b/Content.Server/Polymorph/Systems/PolymorphSystem.cs index ee7fdf2b22..b9453d2924 100644 --- a/Content.Server/Polymorph/Systems/PolymorphSystem.cs +++ b/Content.Server/Polymorph/Systems/PolymorphSystem.cs @@ -128,12 +128,11 @@ public sealed partial class PolymorphSystem : EntitySystem private void OnBeforeFullySliced(Entity ent, ref BeforeFullySlicedEvent args) { - var (_, comp) = ent; - if (comp.Configuration.RevertOnEat) - { - args.Cancel(); - Revert((ent, ent)); - } + if (ent.Comp.Reverted || !ent.Comp.Configuration.RevertOnEat) + return; + + args.Cancel(); + Revert((ent, ent)); } /// @@ -142,14 +141,17 @@ public sealed partial class PolymorphSystem : EntitySystem /// private void OnDestruction(Entity ent, ref DestructionEventArgs args) { - if (ent.Comp.Configuration.RevertOnDeath) - { - Revert((ent, ent)); - } + if (ent.Comp.Reverted || !ent.Comp.Configuration.RevertOnDeath) + return; + + Revert((ent, ent)); } private void OnPolymorphedTerminating(Entity ent, ref EntityTerminatingEvent args) { + if (ent.Comp.Reverted) + return; + if (ent.Comp.Configuration.RevertOnDelete) Revert(ent.AsNullable()); @@ -298,8 +300,6 @@ public sealed partial class PolymorphSystem : EntitySystem if (component.Parent is not { } parent) return null; - // Clear our reference to the original entity - component.Parent = null; if (Deleted(parent)) return null; @@ -316,6 +316,8 @@ public sealed partial class PolymorphSystem : EntitySystem _transform.SetParent(parent, parentXform, uidXform.ParentUid); _transform.SetCoordinates(parent, parentXform, uidXform.Coordinates, uidXform.LocalRotation); + component.Reverted = true; + if (component.Configuration.TransferDamage && TryComp(parent, out var damageParent) && _mobThreshold.GetScaledDamage(uid, parent, out var damage) &&