Enable cancellation of gibbing due to parts

This commit is contained in:
BarryNorfolk 2026-02-10 19:37:28 +01:00
parent 28101bfba0
commit d9ddb0abc2
2 changed files with 25 additions and 0 deletions

View File

@ -59,6 +59,7 @@ public partial class SharedBodySystem
SubscribeLocalEvent<BodyComponent, IsEquippingAttemptEvent>(OnBeingEquippedAttempt); // Shitmed Change
SubscribeLocalEvent<BodyComponent, BeingGibbedEvent>(OnBeingGibbed);
SubscribeLocalEvent<BodyPartComponent, BeforeGibbedEvent>(OnPartBeforeGibbed); // Shitmed Change
SubscribeLocalEvent<BodyPartComponent, BeingGibbedEvent>(OnPartBeingGibbed); // Shitmed Change
}
@ -327,6 +328,17 @@ public partial class SharedBodySystem
}
// Shitmed Change Start
private void OnPartBeforeGibbed(Entity<BodyPartComponent> part, ref BeforeGibbedEvent args)
{
// Double check this is a root part, if it is then we can't gib it directly so cancel the whole
// gib event.
if (part.Comp.Body is { } bodyEnt)
{
if (IsPartRoot(bodyEnt, part, part: part) || !part.Comp.CanSever)
args.Cancel();
}
}
private void OnPartBeingGibbed(Entity<BodyPartComponent> part, ref BeingGibbedEvent args)
{
if (part.Comp.Body is { } bodyEnt)

View File

@ -34,6 +34,14 @@ public sealed class GibbingSystem : EntitySystem
if (!_net.IsServer)
return new();
// Shitmed Start
var beforeGibbed = new BeforeGibbedEvent();
RaiseLocalEvent(ent, ref beforeGibbed);
if (beforeGibbed.Cancelled)
return new();
// Shitmed End
if (!_destructible.DestroyEntity(ent))
return new();
@ -69,6 +77,11 @@ public sealed class GibbingSystem : EntitySystem
}
}
// Shitmed Start
[ByRefEvent]
public sealed class BeforeGibbedEvent() : CancellableEntityEventArgs;
// Shitmed End
/// <summary>
/// Raised on an entity when it is being gibbed.
/// </summary>