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
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user