Ensure grappled entities cleanup grapples when they crit/die (#4546)
* Ensure grappled entities cleanup grapples when they crit/die
This commit is contained in:
parent
35cfe960ab
commit
150af3cc6a
|
|
@ -57,6 +57,7 @@ public sealed partial class GrapplingSystem : SharedGrapplingSystem
|
|||
SubscribeLocalEvent<GrapplerComponent, EscapeGrappleAlertEvent>(OnEscapeGrapplerAlert);
|
||||
SubscribeLocalEvent<GrapplerComponent, MobStateChangedEvent>(OnGrapplerStateChanged);
|
||||
|
||||
SubscribeLocalEvent<GrappledComponent, MobStateChangedEvent>(OnGrappledStateChanged);
|
||||
SubscribeLocalEvent<GrappledComponent, MoveInputEvent>(OnGrappledMove);
|
||||
SubscribeLocalEvent<GrappledComponent, GrappledEscapeDoAfter>(OnEscapeDoAfter);
|
||||
SubscribeLocalEvent<GrappledComponent, EscapeGrappleAlertEvent>(OnEscapeGrappledAlert);
|
||||
|
|
@ -429,6 +430,24 @@ public sealed partial class GrapplingSystem : SharedGrapplingSystem
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles when a grappled entity enters crit or dies while being held by a grappler, releasing the
|
||||
/// grappler for them.
|
||||
/// </summary>
|
||||
/// <param name="grappled">Grappled entity which has entered crit or death.</param>
|
||||
/// <param name="args">Args for the event.</param>
|
||||
private void OnGrappledStateChanged(Entity<GrappledComponent> grappled, ref MobStateChangedEvent args)
|
||||
{
|
||||
if (grappled.Comp.Grappler == EntityUid.Invalid)
|
||||
return;
|
||||
|
||||
if (args.NewMobState == MobState.Critical ||
|
||||
args.NewMobState == MobState.Dead)
|
||||
{
|
||||
ReleaseGrapple(grappled.Comp.Grappler, manualRelease: true);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles releasing the effects of a grapple from both entities.
|
||||
/// </summary>
|
||||
|
|
|
|||
Loading…
Reference in New Issue