From e4e66b0330da17c3bbd26edaa7314f13c0f9bf3d Mon Sep 17 00:00:00 2001 From: DEATHB4DEFEAT Date: Sat, 13 Apr 2024 12:59:35 -0700 Subject: [PATCH] rewrite the announce command --- .../Announcements/AnnounceCommand.cs | 85 +++++++++++++++---- 1 file changed, 70 insertions(+), 15 deletions(-) diff --git a/Content.Server/Announcements/AnnounceCommand.cs b/Content.Server/Announcements/AnnounceCommand.cs index cedde3fc14..7774024780 100644 --- a/Content.Server/Announcements/AnnounceCommand.cs +++ b/Content.Server/Announcements/AnnounceCommand.cs @@ -1,8 +1,11 @@ +using System.Linq; using Content.Server.Administration; -using Content.Server.Chat; -using Content.Server.Chat.Systems; +using Content.Server.Parkstation.Announcements.Systems; using Content.Shared.Administration; +using Content.Shared.Parkstation.Announcements.Prototypes; using Robust.Shared.Console; +using Robust.Shared.Player; +using Robust.Shared.Prototypes; namespace Content.Server.Announcements { @@ -11,27 +14,79 @@ public sealed class AnnounceCommand : IConsoleCommand { public string Command => "announce"; public string Description => "Send an in-game announcement."; - public string Help => $"{Command} or {Command} to send announcement as CentCom."; + // Parkstation-RandomAnnouncers-Start // This entire thing was rewritten + public string Help => $"{Command} "; public void Execute(IConsoleShell shell, string argStr, string[] args) { - var chat = IoCManager.Resolve().GetEntitySystem(); + var announcer = IoCManager.Resolve().GetEntitySystem(); + var proto = IoCManager.Resolve(); - if (args.Length == 0) + switch (args.Length) { - shell.WriteError("Not enough arguments! Need at least 1."); - return; + case 0: + shell.WriteError("Not enough arguments! Need at least 1."); + return; + case 1: + announcer.SendAnnouncement(announcer.GetAnnouncementId("CommandReport"), Filter.Broadcast(), + args[0], "Central Command", Color.Gold); + break; + case 2: + announcer.SendAnnouncement(announcer.GetAnnouncementId("CommandReport"), Filter.Broadcast(), + args[1], args[0], Color.Gold); + break; + case 3: + announcer.SendAnnouncement(announcer.GetAnnouncementId(args[2]), Filter.Broadcast(), args[1], + args[0], Color.Gold); + break; + case 4: + if (!proto.TryIndex(args[3], out AnnouncerPrototype? prototype)) + { + shell.WriteError($"No announcer prototype with ID {args[3]} found!"); + return; + } + announcer.SendAnnouncement(args[2], Filter.Broadcast(), args[1], args[0], Color.Gold, null, + prototype); + break; } - if (args.Length == 1) - { - chat.DispatchGlobalAnnouncement(args[0], colorOverride: Color.Gold); - } - else + shell.WriteLine("Sent!"); + } + + public CompletionResult GetCompletion(IConsoleShell shell, string[] args) + { + switch (args.Length) { - var message = string.Join(' ', new ArraySegment(args, 1, args.Length-1)); - chat.DispatchGlobalAnnouncement(message, args[0], colorOverride: Color.Gold); + case 3: + { + var list = new List(); + + foreach (var prototype in IoCManager.Resolve() + .EnumeratePrototypes() + .SelectMany(p => p.Announcements.Select(a => a.ID))) + { + if (!list.Contains(prototype)) + list.Add(prototype); + } + + return CompletionResult.FromHintOptions(list, Loc.GetString("admin-announce-hint-sound")); + } + case 4: + { + var list = new List(); + + foreach (var prototype in IoCManager.Resolve() + .EnumeratePrototypes()) + { + if (!list.Contains(prototype.ID)) + list.Add(prototype.ID); + } + + return CompletionResult.FromHintOptions(list, Loc.GetString("admin-announce-hint-voice")); + } + default: + return CompletionResult.Empty; } - shell.WriteLine("Sent!"); } + // Parkstation-RandomAnnouncers-End } }