Make animals drop giblets into container or floor when they inserted into container (#37228)
* a * Revert "a" This reverts commit 2b9ba4ea67a9395d30b7ab37c8065f627f1a961a. * auausasuasuausuuAUSTRALIA!!!!!!aausuasusdasda * 77+33!=100
This commit is contained in:
parent
72ebf9e1d5
commit
841aa9d9cd
|
|
@ -41,7 +41,7 @@ public sealed class GibbingSystem : EntitySystem
|
|||
/// /// <param name="logMissingGibable">Should we log if we are missing a gibbableComp when we call this function</param>
|
||||
/// <param name="launchImpulseVariance">The variation in giblet launch impulse (if we are launching them!)</param>
|
||||
/// <returns>True if successful, false if not</returns>
|
||||
public bool TryGibEntity(EntityUid outerEntity, Entity<GibbableComponent?> gibbable, GibType gibType,
|
||||
public bool TryGibEntity(Entity<TransformComponent?> outerEntity, Entity<GibbableComponent?> gibbable, GibType gibType,
|
||||
GibContentsOption gibContentsOption,
|
||||
out HashSet<EntityUid> droppedEntities, bool launchGibs = true,
|
||||
Vector2 launchDirection = default, float launchImpulse = 0f, float launchImpulseVariance = 0f,
|
||||
|
|
@ -77,7 +77,7 @@ public sealed class GibbingSystem : EntitySystem
|
|||
/// <param name="logMissingGibable">Should we log if we are missing a gibbableComp when we call this function</param>
|
||||
/// <returns>True if successful, false if not</returns>
|
||||
public bool TryGibEntityWithRef(
|
||||
EntityUid outerEntity,
|
||||
Entity<TransformComponent?> outerEntity,
|
||||
Entity<GibbableComponent?> 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<BaseContainer> 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<GibbableComponent?>(ent, null), parentXform, randomSpreadMod,
|
||||
DropEntity(new Entity<GibbableComponent?>(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<GibbableComponent?>(ent, null), parentXform, randomSpreadMod,
|
||||
GibEntity(new Entity<GibbableComponent?>(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<GibbableComponent?> gibbable, TransformComponent parentXform, float randomSpreadMod,
|
||||
private void DropEntity(Entity<GibbableComponent?> gibbable, Entity<TransformComponent?> parent, float randomSpreadMod,
|
||||
ref HashSet<EntityUid> 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<EntityUid> GibEntity(Entity<GibbableComponent?> gibbable, TransformComponent parentXform,
|
||||
private List<EntityUid> GibEntity(Entity<GibbableComponent?> gibbable, Entity<TransformComponent?> parent,
|
||||
float randomSpreadMod,
|
||||
ref HashSet<EntityUid> 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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue