Files
Delta-v/Content.Shared/Emoting/EmoteSystem.cs
T
Tayrtahn 11eff87687 Code cleanup: Dirty(Comp) (#26238)
* Replaced uses of Dirty(Component) with Dirty(Uid, Component)
Modified some systems (notably pulling-related) to use uids.

* Missed a few

* Revert changes to pulling

* No

(cherry picked from commit 4a83c36585)
2024-03-24 00:04:13 +01:00

31 lines
729 B
C#

namespace Content.Shared.Emoting;
public sealed class EmoteSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<EmoteAttemptEvent>(OnEmoteAttempt);
}
public void SetEmoting(EntityUid uid, bool value, EmotingComponent? component = null)
{
if (value && !Resolve(uid, ref component))
return;
component = EnsureComp<EmotingComponent>(uid);
if (component.Enabled == value)
return;
Dirty(uid, component);
}
private void OnEmoteAttempt(EmoteAttemptEvent args)
{
if (!TryComp(args.Uid, out EmotingComponent? emote) || !emote.Enabled)
args.Cancel();
}
}