diff --git a/Content.Server/Body/Systems/BodySystem.cs b/Content.Server/Body/Systems/BodySystem.cs index 512d22d01b..2010537e34 100644 --- a/Content.Server/Body/Systems/BodySystem.cs +++ b/Content.Server/Body/Systems/BodySystem.cs @@ -1,12 +1,8 @@ -using System.Diagnostics.CodeAnalysis; -using System.Linq; using Content.Server.Body.Components; using Content.Server.GameTicking; using Content.Server.Humanoid; using Content.Server.Kitchen.Components; -using Content.Server.Mind; using Content.Shared.Body.Components; -using Content.Shared.Body.Organ; using Content.Shared.Body.Part; using Content.Shared.Body.Systems; using Content.Shared.Humanoid; @@ -14,13 +10,11 @@ using Content.Shared.Kitchen.Components; using Content.Shared.Mind; using Content.Shared.Mobs.Systems; using Content.Shared.Movement.Events; -using Content.Shared.Random.Helpers; using Robust.Shared.Audio; -using Robust.Shared.Containers; -using Robust.Shared.Map; using Robust.Shared.Player; +using Robust.Shared.Random; using Robust.Shared.Timing; -using Robust.Shared.Utility; +using System.Numerics; namespace Content.Server.Body.Systems; @@ -33,6 +27,7 @@ public sealed class BodySystem : SharedBodySystem [Dependency] private readonly SharedAudioSystem _audio = default!; [Dependency] private readonly SharedAppearanceSystem _appearance = default!; [Dependency] private readonly SharedMindSystem _mindSystem = default!; + [Dependency] private readonly IRobustRandom _random = default!; public override void Initialize() { @@ -136,22 +131,15 @@ public sealed class BodySystem : SharedBodySystem _audio.Play(body.GibSound, filter, coordinates, true, audio); - var containers = GetBodyContainers(bodyId, body: body).ToList(); - - foreach (var container in containers) + foreach (var entity in gibs) { - foreach (var entity in container.ContainedEntities) + if (deleteItems) { - if (deleteItems) - { - QueueDel(entity); - } - else - { - container.Remove(entity, EntityManager, force: true); - SharedTransform.SetCoordinates(entity,coordinates); - entity.RandomOffset(0.25f); - } + QueueDel(entity); + } + else + { + SharedTransform.SetCoordinates(entity, coordinates.Offset(_random.NextVector2(.3f))); } } RaiseLocalEvent(bodyId, new BeingGibbedEvent(gibs)); diff --git a/Content.Shared/Body/Prototypes/BodyPrototype.cs b/Content.Shared/Body/Prototypes/BodyPrototype.cs index 97ee0ba217..a1105dae5c 100644 --- a/Content.Shared/Body/Prototypes/BodyPrototype.cs +++ b/Content.Shared/Body/Prototypes/BodyPrototype.cs @@ -1,5 +1,4 @@ -using Robust.Shared.Prototypes; -using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; +using Robust.Shared.Prototypes; namespace Content.Shared.Body.Prototypes; diff --git a/Content.Shared/Body/Systems/SharedBodySystem.Body.cs b/Content.Shared/Body/Systems/SharedBodySystem.Body.cs index f68899c8ee..9356224f41 100644 --- a/Content.Shared/Body/Systems/SharedBodySystem.Body.cs +++ b/Content.Shared/Body/Systems/SharedBodySystem.Body.cs @@ -1,4 +1,4 @@ -using System.Linq; +using System.Linq; using System.Numerics; using Content.Shared.Body.Components; using Content.Shared.Body.Organ; @@ -156,6 +156,7 @@ public partial class SharedBodySystem // Child -> Parent connection. var cameFrom = new Dictionary(); + cameFrom[rootSlot] = rootSlot; // Maps slot to its relevant entity. var cameFromEntities = new Dictionary(); cameFromEntities[rootSlot] = rootPartId; diff --git a/Content.Shared/Body/Systems/SharedBodySystem.cs b/Content.Shared/Body/Systems/SharedBodySystem.cs index 1cc891f05d..602c8f015b 100644 --- a/Content.Shared/Body/Systems/SharedBodySystem.cs +++ b/Content.Shared/Body/Systems/SharedBodySystem.cs @@ -1,4 +1,4 @@ -using Content.Shared.Damage; +using Content.Shared.Damage; using Content.Shared.Movement.Systems; using Content.Shared.Standing; using Robust.Shared.Containers; @@ -50,7 +50,7 @@ public abstract partial class SharedBodySystem : EntitySystem // This is blursed var slotIndex = containerSlotId.IndexOf(PartSlotContainerIdPrefix, StringComparison.Ordinal); - if (slotIndex < -1) + if (slotIndex < 0) return null; var slotId = containerSlotId.Remove(slotIndex, PartSlotContainerIdPrefix.Length);