Files
tbd-station-14/Content.Server/Speech/EntitySystems/ReplacementAccentSystem.cs
2022-02-16 18:23:23 +11:00

31 lines
1.0 KiB
C#

using Content.Server.Speech.Components;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
namespace Content.Server.Speech.EntitySystems
{
// TODO: Code in-game languages and make this a language
/// <summary>
/// Replaces any spoken sentences with a random word.
/// </summary>
public sealed class ReplacementAccentSystem : EntitySystem
{
[Dependency] private readonly IPrototypeManager _proto = default!;
[Dependency] private readonly IRobustRandom _random = default!;
public override void Initialize()
{
SubscribeLocalEvent<ReplacementAccentComponent, AccentGetEvent>(OnAccent);
}
private void OnAccent(EntityUid uid, ReplacementAccentComponent component, AccentGetEvent args)
{
var words = _proto.Index<ReplacementAccentPrototype>(component.Accent).Words;
args.Message = words.Length != 0 ? _random.Pick(words) : "";
}
}
}