Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
Co-authored-by: Paul <ritter.paul1@googlemail.com>
This commit is contained in:
Pancake
2021-12-21 12:31:20 -08:00
committed by GitHub
parent f4d8ec1b35
commit f334f4a4b9
9 changed files with 160 additions and 1 deletions

View File

@@ -0,0 +1,30 @@
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 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) : "";
}
}
}