AnnounceOnSpawnSystem.cs 724 B

12345678910111213141516171819202122
  1. using Content.Server.Chat;
  2. namespace Content.Server.Chat.Systems;
  3. public sealed class AnnounceOnSpawnSystem : EntitySystem
  4. {
  5. [Dependency] private readonly ChatSystem _chat = default!;
  6. public override void Initialize()
  7. {
  8. base.Initialize();
  9. SubscribeLocalEvent<AnnounceOnSpawnComponent, MapInitEvent>(OnInit);
  10. }
  11. private void OnInit(EntityUid uid, AnnounceOnSpawnComponent comp, MapInitEvent args)
  12. {
  13. var message = Loc.GetString(comp.Message);
  14. var sender = comp.Sender != null ? Loc.GetString(comp.Sender) : Loc.GetString("chat-manager-sender-announcement");
  15. _chat.DispatchGlobalAnnouncement(message, sender, playSound: true, comp.Sound, comp.Color);
  16. }
  17. }