CatStation/Content.Server/Vocalization/Systems/DatasetVocalizationSystem.cs
Pieter-Jan Briers 5168b5f3d4
IoC source gen compatibility (#43863)
* 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
2026-05-09 03:29:58 +00:00

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;
}
}