mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 18:31:17 +03:00
* IoC source gen compatibility Can be merged before or after https://github.com/space-wizards/RobustToolbox/pull/6549 doesn't really matter. * Missed a spot
31 lines
898 B
C#
31 lines
898 B
C#
using Content.Server.Vocalization.Components;
|
|
using Content.Shared.Random.Helpers;
|
|
using Robust.Shared.Prototypes;
|
|
using Robust.Shared.Random;
|
|
|
|
namespace Content.Server.Vocalization.Systems;
|
|
|
|
/// <inheritdoc cref="DatasetVocalizerComponent"/>
|
|
public sealed partial class DatasetVocalizationSystem : EntitySystem
|
|
{
|
|
[Dependency] private IPrototypeManager _protoMan = default!;
|
|
[Dependency] private IRobustRandom _random = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<DatasetVocalizerComponent, TryVocalizeEvent>(OnTryVocalize);
|
|
}
|
|
|
|
private void OnTryVocalize(Entity<DatasetVocalizerComponent> ent, ref TryVocalizeEvent args)
|
|
{
|
|
if (args.Handled)
|
|
return;
|
|
|
|
var dataset = _protoMan.Index(ent.Comp.Dataset);
|
|
|
|
args.Message = _random.Pick(dataset);
|
|
args.Handled = true;
|
|
}
|
|
}
|