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:
@@ -5,8 +5,13 @@ using Content.Shared.Body.Organ;
|
||||
using Content.Shared.Body.Part;
|
||||
using Content.Shared.Body.Prototypes;
|
||||
using Content.Shared.DragDrop;
|
||||
using Content.Shared.Gibbing.Components;
|
||||
using Content.Shared.Gibbing.Events;
|
||||
using Content.Shared.Gibbing.Systems;
|
||||
using Content.Shared.Inventory;
|
||||
using Content.Shared.Inventory.Events;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Audio.Systems;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Utility;
|
||||
@@ -23,7 +28,10 @@ public partial class SharedBodySystem
|
||||
*/
|
||||
|
||||
[Dependency] private readonly InventorySystem _inventory = default!;
|
||||
|
||||
[Dependency] private readonly GibbingSystem _gibbingSystem = default!;
|
||||
[Dependency] private readonly SharedAudioSystem _audioSystem = default!;
|
||||
private const float GibletLaunchImpulse = 8;
|
||||
private const float GibletLaunchImpulseVariance = 3;
|
||||
private void InitializeBody()
|
||||
{
|
||||
// Body here to handle root body parts.
|
||||
@@ -263,29 +271,45 @@ public partial class SharedBodySystem
|
||||
}
|
||||
}
|
||||
|
||||
public virtual HashSet<EntityUid> GibBody(EntityUid bodyId, bool gibOrgans = false,
|
||||
BodyComponent? body = null, bool deleteItems = false, bool deleteBrain = false)
|
||||
public virtual 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
|
||||
)
|
||||
{
|
||||
var gibs = new HashSet<EntityUid>();
|
||||
|
||||
if (!Resolve(bodyId, ref body, false))
|
||||
return gibs;
|
||||
|
||||
var root = GetRootPartOrNull(bodyId, body);
|
||||
if (root != null && TryComp(root.Value.Entity, out GibbableComponent? gibbable))
|
||||
{
|
||||
gibSoundOverride ??= gibbable.GibSound;
|
||||
}
|
||||
var parts = GetBodyChildren(bodyId, body).ToArray();
|
||||
gibs.EnsureCapacity(parts.Length);
|
||||
|
||||
foreach (var part in parts)
|
||||
{
|
||||
SharedTransform.AttachToGridOrMap(part.Id);
|
||||
gibs.Add(part.Id);
|
||||
|
||||
_gibbingSystem.TryGibEntityWithRef(bodyId, part.Id, GibType.Gib, GibContentsOption.Skip, ref gibs,
|
||||
playAudio: false, launchGibs:true, launchDirection:splatDirection, launchImpulse: GibletLaunchImpulse * splatModifier,
|
||||
launchImpulseVariance:GibletLaunchImpulseVariance, launchCone: splatCone);
|
||||
|
||||
if (!gibOrgans)
|
||||
continue;
|
||||
|
||||
foreach (var organ in GetPartOrgans(part.Id, part.Component))
|
||||
{
|
||||
SharedTransform.AttachToGridOrMap(organ.Id);
|
||||
gibs.Add(organ.Id);
|
||||
_gibbingSystem.TryGibEntityWithRef(bodyId, organ.Id, GibType.Drop, GibContentsOption.Skip,
|
||||
ref gibs, playAudio: false, launchImpulse: GibletLaunchImpulse * splatModifier,
|
||||
launchImpulseVariance:GibletLaunchImpulseVariance, launchCone: splatCone);
|
||||
}
|
||||
}
|
||||
if(TryComp<InventoryComponent>(bodyId, out var inventory))
|
||||
@@ -296,6 +320,7 @@ public partial class SharedBodySystem
|
||||
gibs.Add(item);
|
||||
}
|
||||
}
|
||||
_audioSystem.PlayPredicted(gibSoundOverride, Transform(bodyId).Coordinates, null);
|
||||
return gibs;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user