2023-09-28 16:20:29 -07:00
|
|
|
|
namespace Content.Shared.Emoting;
|
2022-12-28 04:03:25 +11:00
|
|
|
|
|
2023-09-28 16:20:29 -07:00
|
|
|
|
public sealed class EmoteSystem : EntitySystem
|
2021-06-19 10:03:24 +02:00
|
|
|
|
{
|
2023-09-28 16:20:29 -07:00
|
|
|
|
public override void Initialize()
|
2021-06-19 10:03:24 +02:00
|
|
|
|
{
|
2023-09-28 16:20:29 -07:00
|
|
|
|
base.Initialize();
|
2021-06-19 10:03:24 +02:00
|
|
|
|
|
2023-09-28 16:20:29 -07:00
|
|
|
|
SubscribeLocalEvent<EmoteAttemptEvent>(OnEmoteAttempt);
|
|
|
|
|
|
}
|
2022-12-28 04:03:25 +11:00
|
|
|
|
|
2023-09-28 16:20:29 -07:00
|
|
|
|
public void SetEmoting(EntityUid uid, bool value, EmotingComponent? component = null)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (value && !Resolve(uid, ref component))
|
|
|
|
|
|
return;
|
2022-12-28 04:03:25 +11:00
|
|
|
|
|
2023-09-28 16:20:29 -07:00
|
|
|
|
component = EnsureComp<EmotingComponent>(uid);
|
2021-06-19 10:03:24 +02:00
|
|
|
|
|
2023-09-28 16:20:29 -07:00
|
|
|
|
if (component.Enabled == value)
|
|
|
|
|
|
return;
|
2022-12-28 04:03:25 +11:00
|
|
|
|
|
2024-03-19 23:27:02 -04:00
|
|
|
|
Dirty(uid, component);
|
2023-09-28 16:20:29 -07:00
|
|
|
|
}
|
2022-12-28 04:03:25 +11:00
|
|
|
|
|
2023-09-28 16:20:29 -07:00
|
|
|
|
private void OnEmoteAttempt(EmoteAttemptEvent args)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!TryComp(args.Uid, out EmotingComponent? emote) || !emote.Enabled)
|
|
|
|
|
|
args.Cancel();
|
2021-06-19 10:03:24 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|