Files
tbd-station-14/Content.Server/Vocalization/Systems/DatasetVocalizationSystem.cs
Tayrtahn ecbff409b6 Replace AdvertiseComponent with DatasetVocalizerComponent (#38887)
* Replace AdvertiseComponent with DatasetVocalizerComponent

* No vocalizing while broken or without power

* Kill AdvertiseComponent/System

* This really shouldn't be here

* xmldoc for VocalizerRequiresPowerComponent

* TryIndex -> Index
2025-07-10 11:12:24 -07:00

32 lines
908 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 class DatasetVocalizationSystem : EntitySystem
{
[Dependency] private readonly IPrototypeManager _protoMan = default!;
[Dependency] private readonly 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;
}
}