Enable cancellation of gibbing due to parts
This commit is contained in:
parent
28101bfba0
commit
d9ddb0abc2
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
Loading…
Reference in New Issue