mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-19 07:01:09 +03:00
* Move MutingSystem to Shared, update Deathgasp/Vent * dependency alphabetization * test passed a few times locally, new heisentest?
40 lines
1.2 KiB
C#
40 lines
1.2 KiB
C#
using Content.Server.Chat.Systems;
|
|
using Content.Shared.Mobs;
|
|
using Content.Shared.Speech.Muting;
|
|
|
|
namespace Content.Server.Mobs;
|
|
|
|
/// <summary>
|
|
/// A system that handles death gasps, an emote a character makes when they die.
|
|
/// </summary>
|
|
/// <seealso cref="DeathgaspComponent"/>
|
|
public sealed partial class DeathgaspSystem : EntitySystem
|
|
{
|
|
[Dependency] private ChatSystem _chat = default!;
|
|
|
|
[SubscribeLocalEvent]
|
|
private void OnMobStateChanged(Entity<DeathgaspComponent> ent, ref MobStateChangedEvent args)
|
|
{
|
|
// don't deathgasp if they arent going straight from crit to dead
|
|
if (args.NewMobState != MobState.Dead || args.OldMobState != MobState.Critical)
|
|
return;
|
|
|
|
Deathgasp(ent, ent.Comp);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Causes an entity to perform their deathgasp emote, if they have one.
|
|
/// </summary>
|
|
public bool Deathgasp(EntityUid uid, DeathgaspComponent? component = null)
|
|
{
|
|
if (!Resolve(uid, ref component, false))
|
|
return false;
|
|
|
|
if (HasComp<MutedComponent>(uid))
|
|
return false;
|
|
|
|
_chat.TryEmoteWithChat(uid, component.Prototype, ignoreActionBlocker: true);
|
|
|
|
return true;
|
|
}
|
|
}
|