mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-17 05:27:38 +03:00
Implement SpeechWireAction (cherry picked from commit b8de514237c996e85e0c64e8e69edbfe79565683)
34 lines
854 B
C#
34 lines
854 B
C#
namespace Content.Shared.Speech
|
|
{
|
|
public sealed class SpeechSystem : EntitySystem
|
|
{
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<SpeakAttemptEvent>(OnSpeakAttempt);
|
|
}
|
|
|
|
public void SetSpeech(EntityUid uid, bool value, SpeechComponent? component = null)
|
|
{
|
|
if (value && !Resolve(uid, ref component))
|
|
return;
|
|
|
|
component = EnsureComp<SpeechComponent>(uid);
|
|
|
|
if (component.Enabled == value)
|
|
return;
|
|
|
|
component.Enabled = value;
|
|
|
|
Dirty(uid, component);
|
|
}
|
|
|
|
private void OnSpeakAttempt(SpeakAttemptEvent args)
|
|
{
|
|
if (!TryComp(args.Uid, out SpeechComponent? speech) || !speech.Enabled)
|
|
args.Cancel();
|
|
}
|
|
}
|
|
}
|