Gibbing refactor (Per-part gibbing and giblet throwing!) (#24989)

* Moving Gibbing rework out from medrefactor into it's own PR

* Re-enabled warning for missing gibbable on TryGibEntity

* Implemented better logic for gibbing failover and better logging

* Allowing audio params and drop scattering customization per component. Created UnGibbable organ base types and made brains ungibbable.
Removed delete brain from gibBody function. Artifact crusher does not destroy brains anymore. It only destroyed brains before not other organs which was wierd.

* Update Content.Shared/Body/Systems/SharedBodySystem.Body.cs

Fixing space for multiplication

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>

* Added event raised when attempting to gib contained entities to allow modification of allowed and excluded container ids

* removing audioParams var from component (sound specifier includes it)

* Fixing signature

---------

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
Jezithyr
2024-02-10 15:37:06 -08:00
committed by GitHub
parent 2a9fa67a7f
commit 541d8f8715
12 changed files with 493 additions and 35 deletions

View File

@@ -15,6 +15,7 @@ using Robust.Shared.Player;
using Robust.Shared.Random;
using Robust.Shared.Timing;
using System.Numerics;
using Content.Shared.Gibbing.Components;
using Content.Shared.Movement.Systems;
using Robust.Shared.Audio.Systems;
@@ -106,7 +107,17 @@ public sealed class BodySystem : SharedBodySystem
_humanoidSystem.SetLayersVisibility(bodyUid, layers, false, true, humanoid);
}
public override HashSet<EntityUid> GibBody(EntityUid bodyId, bool gibOrgans = false, BodyComponent? body = null, bool deleteItems = false, bool deleteBrain = false)
public override HashSet<EntityUid> GibBody(
EntityUid bodyId,
bool gibOrgans = false,
BodyComponent? body = null ,
bool deleteItems = false,
bool launchGibs = true,
Vector2? splatDirection = null,
float splatModifier = 1,
Angle splatCone = default,
SoundSpecifier? gibSoundOverride = null
)
{
if (!Resolve(bodyId, ref body, false))
return new HashSet<EntityUid>();
@@ -118,28 +129,8 @@ public sealed class BodySystem : SharedBodySystem
if (xform.MapUid == null)
return new HashSet<EntityUid>();
var gibs = base.GibBody(bodyId, gibOrgans, body, deleteItems, deleteBrain);
var coordinates = xform.Coordinates;
var filter = Filter.Pvs(bodyId, entityManager: EntityManager);
var audio = AudioParams.Default.WithVariation(0.025f);
_audio.PlayStatic(body.GibSound, filter, coordinates, true, audio);
foreach (var entity in gibs)
{
if (deleteItems)
{
if (!HasComp<BrainComponent>(entity) || deleteBrain)
{
QueueDel(entity);
}
}
else
{
SharedTransform.SetCoordinates(entity, coordinates.Offset(_random.NextVector2(.3f)));
}
}
var gibs = base.GibBody(bodyId, gibOrgans, body, deleteItems, launchGibs: launchGibs,
splatDirection: splatDirection, splatModifier: splatModifier, splatCone:splatCone);
RaiseLocalEvent(bodyId, new BeingGibbedEvent(gibs));
QueueDel(bodyId);