From d3413b9a408e13bbe4664eaae668c74afe0ea634 Mon Sep 17 00:00:00 2001 From: ThereDrD0 <88589686+ThereDrD0@users.noreply.github.com> Date: Mon, 1 Jul 2024 14:36:20 +0300 Subject: [PATCH] Hot fix (#406) * Revert "Hot revert (#403)" This reverts commit 65283e1c444f8e7a6277c4a43fb74f4f2e6c9f56. * hotfix --- .../Announcement/ArrivalNotificationSystem.cs | 71 +++++++++++++++++++ Content.Shared/Roles/JobPrototype.cs | 43 +++++------ .../ArrivalNotificationPrototype.cs | 33 +++++++++ .../Locale/ru-RU/_white/announce/announce.ftl | 3 + .../Graphs/clothing/medsec_hud.yml | 7 -- .../Crafting/Graphs/improvised/potato.yml | 7 +- .../Roles/Jobs/Cargo/quartermaster.yml | 1 + .../Prototypes/Roles/Jobs/Command/captain.yml | 1 + .../Roles/Jobs/Command/head_of_personnel.yml | 1 + .../Roles/Jobs/Engineering/chief_engineer.yml | 1 + .../Roles/Jobs/Justice/inspector.yml | 1 + .../Jobs/Medical/chief_medical_officer.yml | 1 + .../Roles/Jobs/Science/research_director.yml | 1 + .../Roles/Jobs/Security/head_of_security.yml | 1 + .../Announcement/ArrivalNotification.yml | 56 +++++++++++++++ 15 files changed, 195 insertions(+), 33 deletions(-) create mode 100644 Content.Server/_White/Announcement/ArrivalNotificationSystem.cs create mode 100644 Content.Shared/_White/Announcement/ArrivalNotificationPrototype.cs create mode 100644 Resources/Locale/ru-RU/_white/announce/announce.ftl create mode 100644 Resources/Prototypes/_White/Announcement/ArrivalNotification.yml diff --git a/Content.Server/_White/Announcement/ArrivalNotificationSystem.cs b/Content.Server/_White/Announcement/ArrivalNotificationSystem.cs new file mode 100644 index 0000000000..36a02e7b7a --- /dev/null +++ b/Content.Server/_White/Announcement/ArrivalNotificationSystem.cs @@ -0,0 +1,71 @@ +using System.Globalization; +using Content.Server.Chat.Systems; +using Content.Server.GameTicking; +using Content.Server.Radio.EntitySystems; +using Content.Shared._White.Announcement; +using Content.Shared.Radio; +using Content.Shared.Roles; +using Robust.Shared.Prototypes; + +namespace Content.Server._White.Announcement; + +public sealed class ArrivalNotificationSystem : EntitySystem +{ + [Dependency] private readonly ChatSystem _chatSystem = default!; + [Dependency] private readonly IPrototypeManager _prototypeManager = default!; + [Dependency] private readonly RadioSystem _radioSystem = default!; + + public override void Initialize() + { + base.Initialize(); + + SubscribeAllEvent(OnPlayerSpawn); + } + + private void OnPlayerSpawn(PlayerSpawnCompleteEvent args) + { + if (args.JobId == null) + return; + + if (!_prototypeManager.TryIndex(args.JobId, out var jobPrototype)) + return; + + if (jobPrototype.AnnouncementPrototype == null) + return; + + if (!_prototypeManager.TryIndex(jobPrototype.AnnouncementPrototype, out var notification)) + return; + + var message = GetMessage(args.Mob, + jobPrototype, + notification.UseGlobalAnnouncement ? notification.GlobalMessage : notification.Message); + + var senderName = Loc.GetString("head-arrived-sender"); + var source = args.Station; + + if (notification.UseGlobalAnnouncement) + _chatSystem.DispatchGlobalAnnouncement(message, senderName, colorOverride: Color.Gold); + else + _chatSystem.DispatchStationAnnouncement(source, message, senderName, false); + + message = GetMessage(args.Mob, jobPrototype, notification.Message); // Changing message type for radio notification + + foreach (var channel in notification.RadioChannelsPrototypes) + { + if (!_prototypeManager.TryIndex(channel, out _)) + continue; + + _radioSystem.SendRadioMessage(source, message, channel, args.Mob); + } + + } + + private string GetMessage(EntityUid mob, JobPrototype jobPrototype, string type) + { + var message = Loc.GetString(type, + ("character", MetaData(mob).EntityName), + ("job", CultureInfo.CurrentCulture.TextInfo.ToTitleCase(Loc.GetString(jobPrototype.Name)))); + + return message; + } +} diff --git a/Content.Shared/Roles/JobPrototype.cs b/Content.Shared/Roles/JobPrototype.cs index 54f5fa4f4c..bd40d0803f 100644 --- a/Content.Shared/Roles/JobPrototype.cs +++ b/Content.Shared/Roles/JobPrototype.cs @@ -19,16 +19,16 @@ namespace Content.Shared.Roles [IdDataField] public string ID { get; private set; } = default!; - [DataField("playTimeTracker", required: true, customTypeSerializer: typeof(PrototypeIdSerializer))] + [DataField(required: true, customTypeSerializer: typeof(PrototypeIdSerializer))] public string PlayTimeTracker { get; private set; } = string.Empty; - [DataField("supervisors")] + [DataField] public string Supervisors { get; private set; } = "nobody"; /// /// The name of this job as displayed to players. /// - [DataField("name")] + [DataField] public string Name { get; private set; } = string.Empty; [ViewVariables(VVAccess.ReadOnly)] @@ -37,22 +37,25 @@ namespace Content.Shared.Roles /// /// The name of this job as displayed to players. /// - [DataField("description")] + [DataField] public string? Description { get; private set; } [ViewVariables(VVAccess.ReadOnly)] public string? LocalizedDescription => Description is null ? null : Loc.GetString(Description); - [DataField("requirements")] + [DataField] public HashSet? Requirements; - [DataField("joinNotifyCrew")] + [DataField] public bool JoinNotifyCrew { get; private set; } = false; - [DataField("requireAdminNotify")] + [DataField] + public string? AnnouncementPrototype; + + [DataField] public bool RequireAdminNotify { get; private set; } = false; - [DataField("setPreference")] + [DataField] public bool SetPreference { get; private set; } = true; /// @@ -62,14 +65,14 @@ namespace Content.Shared.Roles [DataField] public bool? OverrideConsoleVisibility { get; private set; } = null; - [DataField("canBeAntag")] + [DataField] public bool CanBeAntag { get; private set; } = true; /// /// Whether this job is a head. /// The job system will try to pick heads before other jobs on the same priority level. /// - [DataField("weight")] + [DataField] public int Weight { get; private set; } /// @@ -86,10 +89,10 @@ namespace Content.Shared.Roles /// A numerical score for how much easier this job is for antagonists. /// For traitors, reduces starting TC by this amount. Other gamemodes can use it for whatever they find fitting. /// - [DataField("antagAdvantage")] + [DataField] public int AntagAdvantage = 0; - [DataField("startingGear", customTypeSerializer: typeof(PrototypeIdSerializer))] + [DataField(customTypeSerializer: typeof(PrototypeIdSerializer))] public string? StartingGear { get; private set; } /// @@ -97,28 +100,28 @@ namespace Content.Shared.Roles /// Starting gear will be ignored. /// If you want to just add special attributes to a humanoid, use AddComponentSpecial instead. /// - [DataField("jobEntity", customTypeSerializer: typeof(PrototypeIdSerializer))] + [DataField(customTypeSerializer: typeof(PrototypeIdSerializer))] public string? JobEntity = null; - [DataField("icon", customTypeSerializer: typeof(PrototypeIdSerializer))] + [DataField(customTypeSerializer: typeof(PrototypeIdSerializer))] public string Icon { get; private set; } = "JobIconUnknown"; - [DataField("special", serverOnly: true)] + [DataField(serverOnly: true)] public JobSpecial[] Special { get; private set; } = Array.Empty(); - [DataField("access")] + [DataField] public IReadOnlyCollection> Access { get; private set; } = Array.Empty>(); - [DataField("accessGroups")] + [DataField] public IReadOnlyCollection> AccessGroups { get; private set; } = Array.Empty>(); - [DataField("extendedAccess")] + [DataField] public IReadOnlyCollection> ExtendedAccess { get; private set; } = Array.Empty>(); - [DataField("extendedAccessGroups")] + [DataField] public IReadOnlyCollection> ExtendedAccessGroups { get; private set; } = Array.Empty>(); - [DataField("whitelistedSpecies")] + [DataField] public IReadOnlyCollection> WhitelistedSpecies { get; private set; } = Array.Empty>(); } diff --git a/Content.Shared/_White/Announcement/ArrivalNotificationPrototype.cs b/Content.Shared/_White/Announcement/ArrivalNotificationPrototype.cs new file mode 100644 index 0000000000..2dda26fd6e --- /dev/null +++ b/Content.Shared/_White/Announcement/ArrivalNotificationPrototype.cs @@ -0,0 +1,33 @@ +using Robust.Shared.Prototypes; + +namespace Content.Shared._White.Announcement; + +[Prototype("arrivalNotification")] +public sealed partial class ArrivalNotificationPrototype : IPrototype +{ + [IdDataField] public string ID { get; } = default!; + + /// + /// The message that the department will receive upon the player arrival + /// + [DataField(required: true)] + public string Message = default!; + + /// + /// The message that the station will receive upon the player arrival + /// + [DataField] + public string GlobalMessage = default!; + + /// + /// ID of the channel where the player arrival will be announced. + /// + [DataField(required: true)] + public HashSet RadioChannelsPrototypes = default!; + + /// + /// Determines whether the notification will be made to the entire station. If false, the notification will be on the department radio channel + /// + [DataField] + public bool UseGlobalAnnouncement; +} diff --git a/Resources/Locale/ru-RU/_white/announce/announce.ftl b/Resources/Locale/ru-RU/_white/announce/announce.ftl new file mode 100644 index 0000000000..ba3450dcc1 --- /dev/null +++ b/Resources/Locale/ru-RU/_white/announce/announce.ftl @@ -0,0 +1,3 @@ +head-arrived-message = { $character }, { $job }, Глава отдела +head-arrived-message-global = { $job } { $character } на станции +head-arrived-sender = Автоматическая Система Оповещений diff --git a/Resources/Prototypes/Recipes/Construction/Graphs/clothing/medsec_hud.yml b/Resources/Prototypes/Recipes/Construction/Graphs/clothing/medsec_hud.yml index 03a70cb7fe..486df4678e 100644 --- a/Resources/Prototypes/Recipes/Construction/Graphs/clothing/medsec_hud.yml +++ b/Resources/Prototypes/Recipes/Construction/Graphs/clothing/medsec_hud.yml @@ -32,12 +32,5 @@ icon: sprite: Objects/Misc/stock_parts.rsi state: capacitor - doAfter: 5 - - tag: CapacitorStockPart - name: capacitor - icon: - sprite: Objects/Misc/stock_parts.rsi - state: capacitor - doAfter: 5 - node: medsecHud entity: ClothingEyesHudMedSec diff --git a/Resources/Prototypes/Recipes/Crafting/Graphs/improvised/potato.yml b/Resources/Prototypes/Recipes/Crafting/Graphs/improvised/potato.yml index e3f972cfda..39094bfdc7 100644 --- a/Resources/Prototypes/Recipes/Crafting/Graphs/improvised/potato.yml +++ b/Resources/Prototypes/Recipes/Crafting/Graphs/improvised/potato.yml @@ -65,10 +65,5 @@ icon: sprite: Objects/Misc/stock_parts.rsi state: capacitor - - tag: CapacitorStockPart - name: capacitor - icon: - sprite: Objects/Misc/stock_parts.rsi - state: capacitor - node: potatoaichip - entity: PotatoAIChip \ No newline at end of file + entity: PotatoAIChip diff --git a/Resources/Prototypes/Roles/Jobs/Cargo/quartermaster.yml b/Resources/Prototypes/Roles/Jobs/Cargo/quartermaster.yml index c3608cbb00..1806692ac5 100644 --- a/Resources/Prototypes/Roles/Jobs/Cargo/quartermaster.yml +++ b/Resources/Prototypes/Roles/Jobs/Cargo/quartermaster.yml @@ -15,6 +15,7 @@ weight: 10 startingGear: QuartermasterGear icon: "JobIconQuarterMaster" + announcementPrototype: QuartermasterArrivalNotification supervisors: job-supervisors-captain whitelistedSpecies: - Human diff --git a/Resources/Prototypes/Roles/Jobs/Command/captain.yml b/Resources/Prototypes/Roles/Jobs/Command/captain.yml index 93b769d844..7fe051a305 100644 --- a/Resources/Prototypes/Roles/Jobs/Command/captain.yml +++ b/Resources/Prototypes/Roles/Jobs/Command/captain.yml @@ -20,6 +20,7 @@ icon: "JobIconCaptain" requireAdminNotify: true joinNotifyCrew: true + announcementPrototype: CaptainArrivalNotification supervisors: job-supervisors-centcom whitelistedSpecies: - Human diff --git a/Resources/Prototypes/Roles/Jobs/Command/head_of_personnel.yml b/Resources/Prototypes/Roles/Jobs/Command/head_of_personnel.yml index fdc5f38ae5..cde2a2a738 100644 --- a/Resources/Prototypes/Roles/Jobs/Command/head_of_personnel.yml +++ b/Resources/Prototypes/Roles/Jobs/Command/head_of_personnel.yml @@ -19,6 +19,7 @@ startingGear: HoPGear icon: "JobIconHeadOfPersonnel" requireAdminNotify: true + announcementPrototype: HeadOfPersonnelArrivalNotification supervisors: job-supervisors-captain whitelistedSpecies: - Human diff --git a/Resources/Prototypes/Roles/Jobs/Engineering/chief_engineer.yml b/Resources/Prototypes/Roles/Jobs/Engineering/chief_engineer.yml index 9f19e8e622..2be4b76c18 100644 --- a/Resources/Prototypes/Roles/Jobs/Engineering/chief_engineer.yml +++ b/Resources/Prototypes/Roles/Jobs/Engineering/chief_engineer.yml @@ -16,6 +16,7 @@ startingGear: ChiefEngineerGear icon: "JobIconChiefEngineer" requireAdminNotify: true + announcementPrototype: ChiefEngineerArrivalNotification supervisors: job-supervisors-captain whitelistedSpecies: - Human diff --git a/Resources/Prototypes/Roles/Jobs/Justice/inspector.yml b/Resources/Prototypes/Roles/Jobs/Justice/inspector.yml index 780bd76cf0..3176d34bfd 100644 --- a/Resources/Prototypes/Roles/Jobs/Justice/inspector.yml +++ b/Resources/Prototypes/Roles/Jobs/Justice/inspector.yml @@ -14,6 +14,7 @@ time: 36000 #10 hrs startingGear: InspectorGear icon: "JobIconInspector" + announcementPrototype: InspectorArrivalNotification supervisors: job-supervisors-captain access: - Service diff --git a/Resources/Prototypes/Roles/Jobs/Medical/chief_medical_officer.yml b/Resources/Prototypes/Roles/Jobs/Medical/chief_medical_officer.yml index ebcf13b4d9..009c294984 100644 --- a/Resources/Prototypes/Roles/Jobs/Medical/chief_medical_officer.yml +++ b/Resources/Prototypes/Roles/Jobs/Medical/chief_medical_officer.yml @@ -14,6 +14,7 @@ weight: 10 startingGear: CMOGear icon: "JobIconChiefMedicalOfficer" + announcementPrototype: ChiefMedicalOfficerArrivalNotification requireAdminNotify: true supervisors: job-supervisors-captain whitelistedSpecies: diff --git a/Resources/Prototypes/Roles/Jobs/Science/research_director.yml b/Resources/Prototypes/Roles/Jobs/Science/research_director.yml index a731829a46..918c9cb993 100644 --- a/Resources/Prototypes/Roles/Jobs/Science/research_director.yml +++ b/Resources/Prototypes/Roles/Jobs/Science/research_director.yml @@ -13,6 +13,7 @@ startingGear: ResearchDirectorGear icon: "JobIconResearchDirector" requireAdminNotify: true + announcementPrototype: ResearchDirectorArrivalNotification supervisors: job-supervisors-captain whitelistedSpecies: - Human diff --git a/Resources/Prototypes/Roles/Jobs/Security/head_of_security.yml b/Resources/Prototypes/Roles/Jobs/Security/head_of_security.yml index b550081863..be693bb9f4 100644 --- a/Resources/Prototypes/Roles/Jobs/Security/head_of_security.yml +++ b/Resources/Prototypes/Roles/Jobs/Security/head_of_security.yml @@ -16,6 +16,7 @@ startingGear: HoSGear icon: "JobIconHeadOfSecurity" requireAdminNotify: true + announcementPrototype: HeadOfSecurityArrivalNotification supervisors: job-supervisors-captain whitelistedSpecies: - Human diff --git a/Resources/Prototypes/_White/Announcement/ArrivalNotification.yml b/Resources/Prototypes/_White/Announcement/ArrivalNotification.yml new file mode 100644 index 0000000000..52e3b5e13f --- /dev/null +++ b/Resources/Prototypes/_White/Announcement/ArrivalNotification.yml @@ -0,0 +1,56 @@ +- type: arrivalNotification + id: CaptainArrivalNotification + message: head-arrived-message + globalMessage: head-arrived-message-global + radioChannelsPrototypes: + - Command + useGlobalAnnouncement: True + +- type: arrivalNotification + id: HeadOfPersonnelArrivalNotification + message: head-arrived-message + radioChannelsPrototypes: + - Command + - Service + +- type: arrivalNotification + id: HeadOfSecurityArrivalNotification + message: head-arrived-message + radioChannelsPrototypes: + - Command + - Security + +- type: arrivalNotification + id: ChiefMedicalOfficerArrivalNotification + message: head-arrived-message + radioChannelsPrototypes: + - Command + - Medical + +- type: arrivalNotification + id: ChiefEngineerArrivalNotification + message: head-arrived-message + radioChannelsPrototypes: + - Command + - Engineering + +- type: arrivalNotification + id: ResearchDirectorArrivalNotification + message: head-arrived-message + radioChannelsPrototypes: + - Command + - Science + +- type: arrivalNotification + id: QuartermasterArrivalNotification + message: head-arrived-message + radioChannelsPrototypes: + - Command + - Cargo + +- type: arrivalNotification + id: InspectorArrivalNotification + message: head-arrived-message + radioChannelsPrototypes: + - Command + - Security