Files
wwdpublic/Content.Server/Mobs/DeathgaspSystem.cs
sleepyyapril 3330acd9f2 Revert ""Proper" "Softcrit" "Support" (#1545)" (#1741)
traits need to be updated with new "params"

@RedFoxIV

(cherry picked from commit d62392b2fe2c3e651ad1f8492bbceef6dad5138e)
2025-02-15 00:15:22 +03:00

47 lines
1.3 KiB
C#

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;
/// <see cref="DeathgaspComponent"/>
public sealed class DeathgaspSystem: EntitySystem
{
[Dependency] private readonly ChatSystem _chat = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<DeathgaspComponent, MobStateChangedEvent>(OnMobStateChanged);
}
private void OnMobStateChanged(EntityUid uid, DeathgaspComponent component, MobStateChangedEvent args)
{
// don't deathgasp if they arent going straight from crit to dead
if (component.NeedsCritical && args.OldMobState != MobState.Critical
|| args.NewMobState != MobState.Dead)
return;
Deathgasp(uid, component);
}
/// <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;
}
}