]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix BodySystem and Gibbing (#20460)
authorPsychpsyo <60073468+Psychpsyo@users.noreply.github.com>
Mon, 25 Sep 2023 06:53:04 +0000 (08:53 +0200)
committerGitHub <noreply@github.com>
Mon, 25 Sep 2023 06:53:04 +0000 (23:53 -0700)
* Fix gibbing & body system

Makes it so that bodies no longer have two sets of torso organs and that gibbed bodies get spread around on the floor again.

* Actually fix the double torso problem

* rootSlot in cameFrom

* Remove SetCoordinates inside GibBody()

* Don't use entity.RandomOffset() in GibBody()

* Gibbing now uses _random.NextVector2()

Content.Server/Body/Systems/BodySystem.cs
Content.Shared/Body/Prototypes/BodyPrototype.cs
Content.Shared/Body/Systems/SharedBodySystem.Body.cs
Content.Shared/Body/Systems/SharedBodySystem.cs

index 512d22d01b175deedc9f873df000f3a70ac41796..2010537e34bf946cb53808dbde7db4a869d4b3ea 100644 (file)
@@ -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)
+            {
+                QueueDel(entity);
+            }
+            else
             {
-                if (deleteItems)
-                {
-                    QueueDel(entity);
-                }
-                else
-                {
-                    container.Remove(entity, EntityManager, force: true);
-                    SharedTransform.SetCoordinates(entity,coordinates);
-                    entity.RandomOffset(0.25f);
-                }
+                SharedTransform.SetCoordinates(entity, coordinates.Offset(_random.NextVector2(.3f)));
             }
         }
         RaiseLocalEvent(bodyId, new BeingGibbedEvent(gibs));
index 97ee0ba2173be40f55e4b106c1f686e1c93d4288..a1105dae5ca86f4c5f3dbc1deb2669d2a3e127e4 100644 (file)
@@ -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;
 
index f68899c8eee1ccc8c9adcaaf3cbb32e1e6cfc66d..9356224f4129f47c6d9cba4e58c719868a1f0722 100644 (file)
@@ -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<string, string>();
+        cameFrom[rootSlot] = rootSlot;
         // Maps slot to its relevant entity.
         var cameFromEntities = new Dictionary<string, EntityUid>();
         cameFromEntities[rootSlot] = rootPartId;
index 1cc891f05d2698d5354dc6bff5e7e1941a3d7e3b..602c8f015b6bd3f25e5e2110daa6caaaf71aed6a 100644 (file)
@@ -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);