Refactor AccentManager to be an entity system, makes accents ECS. (#4825)
This commit is contained in:
committed by
GitHub
parent
55b4edb895
commit
4c80fb9586
32
Content.Server/Speech/EntitySystems/MouseAccentSystem.cs
Normal file
32
Content.Server/Speech/EntitySystems/MouseAccentSystem.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.Speech.Components;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Random;
|
||||
|
||||
namespace Content.Server.Speech.EntitySystems
|
||||
{
|
||||
// TODO: Code in-game languages and make this a language
|
||||
public class MouseAccentSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
|
||||
private static readonly IReadOnlyList<string> Squeek = new List<string>{ "Squeak!", "Piep!", "Chuu!" };
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
SubscribeLocalEvent<MouseAccentComponent, AccentGetEvent>(OnAccent);
|
||||
}
|
||||
|
||||
public string Accentuate(string message)
|
||||
{
|
||||
// TODO: Maybe add more than one squeek when there are more words?
|
||||
return _random.Pick(Squeek);
|
||||
}
|
||||
|
||||
private void OnAccent(EntityUid uid, MouseAccentComponent component, AccentGetEvent args)
|
||||
{
|
||||
args.Message = Accentuate(args.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user