diff --git a/Content.Shared/Gibbing/Systems/GibbingSystem.cs b/Content.Shared/Gibbing/Systems/GibbingSystem.cs
index f3d982977a..8c83de0cf2 100644
--- a/Content.Shared/Gibbing/Systems/GibbingSystem.cs
+++ b/Content.Shared/Gibbing/Systems/GibbingSystem.cs
@@ -41,7 +41,7 @@ public sealed class GibbingSystem : EntitySystem
/// /// Should we log if we are missing a gibbableComp when we call this function
/// The variation in giblet launch impulse (if we are launching them!)
/// True if successful, false if not
- public bool TryGibEntity(EntityUid outerEntity, Entity gibbable, GibType gibType,
+ public bool TryGibEntity(Entity outerEntity, Entity gibbable, GibType gibType,
GibContentsOption gibContentsOption,
out HashSet droppedEntities, bool launchGibs = true,
Vector2 launchDirection = default, float launchImpulse = 0f, float launchImpulseVariance = 0f,
@@ -77,7 +77,7 @@ public sealed class GibbingSystem : EntitySystem
/// Should we log if we are missing a gibbableComp when we call this function
/// True if successful, false if not
public bool TryGibEntityWithRef(
- EntityUid outerEntity,
+ Entity outerEntity,
Entity gibbable,
GibType gibType,
GibContentsOption gibContentsOption,
@@ -95,7 +95,7 @@ public sealed class GibbingSystem : EntitySystem
{
if (!Resolve(gibbable, ref gibbable.Comp, logMissing: false))
{
- DropEntity(gibbable, Transform(outerEntity), randomSpreadMod, ref droppedEntities,
+ DropEntity(gibbable, (outerEntity, Transform(outerEntity)), randomSpreadMod, ref droppedEntities,
launchGibs, launchDirection, launchImpulse, launchImpulseVariance, launchCone);
if (logMissingGibable)
{
@@ -113,7 +113,6 @@ public sealed class GibbingSystem : EntitySystem
randomSpreadMod = 0;
}
- var parentXform = Transform(outerEntity);
HashSet validContainers = new();
var gibContentsAttempt =
new AttemptEntityContentsGibEvent(gibbable, gibContentsOption, allowedContainers, excludedContainers);
@@ -140,7 +139,7 @@ public sealed class GibbingSystem : EntitySystem
{
foreach (var ent in container.ContainedEntities)
{
- DropEntity(new Entity(ent, null), parentXform, randomSpreadMod,
+ DropEntity(new Entity(ent, null), outerEntity, randomSpreadMod,
ref droppedEntities, launchGibs,
launchDirection, launchImpulse, launchImpulseVariance, launchCone);
}
@@ -154,7 +153,7 @@ public sealed class GibbingSystem : EntitySystem
{
foreach (var ent in container.ContainedEntities)
{
- GibEntity(new Entity(ent, null), parentXform, randomSpreadMod,
+ GibEntity(new Entity(ent, null), outerEntity, randomSpreadMod,
ref droppedEntities, launchGibs,
launchDirection, launchImpulse, launchImpulseVariance, launchCone);
}
@@ -170,13 +169,13 @@ public sealed class GibbingSystem : EntitySystem
break;
case GibType.Drop:
{
- DropEntity(gibbable, parentXform, randomSpreadMod, ref droppedEntities, launchGibs,
+ DropEntity(gibbable, outerEntity, randomSpreadMod, ref droppedEntities, launchGibs,
launchDirection, launchImpulse, launchImpulseVariance, launchCone);
break;
}
case GibType.Gib:
{
- GibEntity(gibbable, parentXform, randomSpreadMod, ref droppedEntities, launchGibs,
+ GibEntity(gibbable, outerEntity, randomSpreadMod, ref droppedEntities, launchGibs,
launchDirection, launchImpulse, launchImpulseVariance, launchCone);
break;
}
@@ -184,7 +183,7 @@ public sealed class GibbingSystem : EntitySystem
if (playAudio)
{
- _audioSystem.PlayPredicted(gibbable.Comp.GibSound, parentXform.Coordinates, null);
+ _audioSystem.PlayPredicted(gibbable.Comp.GibSound, outerEntity, null);
}
if (gibType == GibType.Gib)
@@ -192,7 +191,7 @@ public sealed class GibbingSystem : EntitySystem
return true;
}
- private void DropEntity(Entity gibbable, TransformComponent parentXform, float randomSpreadMod,
+ private void DropEntity(Entity gibbable, Entity parent, float randomSpreadMod,
ref HashSet droppedEntities, bool flingEntity, Vector2? scatterDirection, float scatterImpulse,
float scatterImpulseVariance, Angle scatterCone)
{
@@ -202,6 +201,9 @@ public sealed class GibbingSystem : EntitySystem
gibCount = gibbable.Comp.GibCount;
}
+ if (!Resolve(parent, ref parent.Comp, logMissing: false))
+ return;
+
var gibAttemptEvent = new AttemptEntityGibEvent(gibbable, gibCount, GibType.Drop);
RaiseLocalEvent(gibbable, ref gibAttemptEvent);
switch (gibAttemptEvent.GibType)
@@ -209,13 +211,12 @@ public sealed class GibbingSystem : EntitySystem
case GibType.Skip:
return;
case GibType.Gib:
- GibEntity(gibbable, parentXform, randomSpreadMod, ref droppedEntities, flingEntity, scatterDirection,
+ GibEntity(gibbable, parent, randomSpreadMod, ref droppedEntities, flingEntity, scatterDirection,
scatterImpulse, scatterImpulseVariance, scatterCone, deleteTarget: false);
return;
}
- _transformSystem.AttachToGridOrMap(gibbable);
- _transformSystem.SetCoordinates(gibbable, parentXform.Coordinates);
+ _transformSystem.DropNextTo(gibbable.Owner, parent);
_transformSystem.SetWorldRotation(gibbable, _random.NextAngle());
droppedEntities.Add(gibbable);
if (flingEntity)
@@ -227,7 +228,7 @@ public sealed class GibbingSystem : EntitySystem
RaiseLocalEvent(gibbable, ref gibbedEvent);
}
- private List GibEntity(Entity gibbable, TransformComponent parentXform,
+ private List GibEntity(Entity gibbable, Entity parent,
float randomSpreadMod,
ref HashSet droppedEntities, bool flingEntity, Vector2? scatterDirection, float scatterImpulse,
float scatterImpulseVariance, Angle scatterCone, bool deleteTarget = true)
@@ -241,6 +242,9 @@ public sealed class GibbingSystem : EntitySystem
gibProtoCount = gibbable.Comp.GibPrototypes.Count;
}
+ if (!Resolve(parent, ref parent.Comp, logMissing: false))
+ return [];
+
var gibAttemptEvent = new AttemptEntityGibEvent(gibbable, gibCount, GibType.Drop);
RaiseLocalEvent(gibbable, ref gibAttemptEvent);
switch (gibAttemptEvent.GibType)
@@ -248,7 +252,7 @@ public sealed class GibbingSystem : EntitySystem
case GibType.Skip:
return localGibs;
case GibType.Drop:
- DropEntity(gibbable, parentXform, randomSpreadMod, ref droppedEntities, flingEntity,
+ DropEntity(gibbable, parent, randomSpreadMod, ref droppedEntities, flingEntity,
scatterDirection, scatterImpulse, scatterImpulseVariance, scatterCone);
localGibs.Add(gibbable);
return localGibs;
@@ -260,7 +264,7 @@ public sealed class GibbingSystem : EntitySystem
{
for (var i = 0; i < gibAttemptEvent.GibletCount; i++)
{
- if (!TryCreateRandomGiblet(gibbable.Comp, parentXform.Coordinates, false, out var giblet,
+ if (!TryCreateRandomGiblet(gibbable.Comp, parent.Comp.Coordinates, false, out var giblet,
randomSpreadMod))
continue;
FlingDroppedEntity(giblet.Value, scatterDirection, scatterImpulse, scatterImpulseVariance,
@@ -272,7 +276,7 @@ public sealed class GibbingSystem : EntitySystem
{
for (var i = 0; i < gibAttemptEvent.GibletCount; i++)
{
- if (TryCreateRandomGiblet(gibbable.Comp, parentXform.Coordinates, false, out var giblet,
+ if (TryCreateRandomGiblet(gibbable.Comp, parent.Comp.Coordinates, false, out var giblet,
randomSpreadMod))
droppedEntities.Add(giblet.Value);
}