using Content.Server.Chat.Systems;
using Content.Server.Speech.Muting;
using Content.Shared.Mobs;
using Content.Shared.Speech.Muting;
using Robust.Shared.Prototypes;
namespace Content.Server.Mobs;
///
public sealed class DeathgaspSystem: EntitySystem
{
[Dependency] private readonly ChatSystem _chat = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent(OnMobStateChanged);
}
private void OnMobStateChanged(EntityUid uid, DeathgaspComponent component, 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(uid, component);
}
///
/// Causes an entity to perform their deathgasp emote, if they have one.
///
public bool Deathgasp(EntityUid uid, DeathgaspComponent? component = null)
{
if (!Resolve(uid, ref component, false))
return false;
if (HasComp(uid))
return false;
_chat.TryEmoteWithChat(uid, component.Prototype, ignoreActionBlocker: true);
return true;
}
}