From 596b6f8891c2a8a62c8f0918d46a79c49387295c Mon Sep 17 00:00:00 2001 From: JDtrimble Date: Fri, 7 Jun 2024 12:23:21 +0300 Subject: [PATCH] added announcement about greenshift. Also added event preset for admins. --- .../Components/AnnounceRuleComponent.cs | 23 +++++++++++ .../StationEvents/Events/AnnounceRule.cs | 38 +++++++++++++++++++ Resources/Changelog/ChangelogSunrise.yml | 8 ++++ .../prototypes/game-ticking/preset-event.ftl | 2 + .../prototypes/gamerules/greenshift.ftl | 1 + .../game-presets/preset-event.ftl | 2 + .../station-events/events/greenshift.ftl | 1 + Resources/Prototypes/GameRules/roundstart.yml | 10 +++++ .../Prototypes/_Sunrise/game_presets.yml | 11 ++++++ Resources/Prototypes/game_presets.yml | 1 + 10 files changed, 97 insertions(+) create mode 100644 Content.Server/_Sunrise/StationEvents/Components/AnnounceRuleComponent.cs create mode 100644 Content.Server/_Sunrise/StationEvents/Events/AnnounceRule.cs create mode 100644 Resources/Locale/en-US/ss14-ru/prototypes/game-ticking/preset-event.ftl create mode 100644 Resources/Locale/en-US/ss14-ru/prototypes/gamerules/greenshift.ftl create mode 100644 Resources/Locale/ru-RU/game-ticking/game-presets/preset-event.ftl create mode 100644 Resources/Locale/ru-RU/station-events/events/greenshift.ftl create mode 100644 Resources/Prototypes/_Sunrise/game_presets.yml diff --git a/Content.Server/_Sunrise/StationEvents/Components/AnnounceRuleComponent.cs b/Content.Server/_Sunrise/StationEvents/Components/AnnounceRuleComponent.cs new file mode 100644 index 00000000000..b97761b7bc4 --- /dev/null +++ b/Content.Server/_Sunrise/StationEvents/Components/AnnounceRuleComponent.cs @@ -0,0 +1,23 @@ +using Content.Server.StationEvents.Events; +using Robust.Shared.Audio; +using System.Threading; + +namespace Content.Server.StationEvents.Components; + +[RegisterComponent] +public sealed partial class AnnounceRuleComponent : Component +{ + [DataField] + public bool EnableAnnouncement; + + [DataField] + public SoundSpecifier? AnnounceAudio; + + [DataField("roundStartAnnouncementDelay")] + public int RoundStartAnnouncementDelay = 60; // 1 minute from roundstart by default + + [DataField("announcementText")] + public string? AnnouncementText; + + public CancellationToken TimerCancel = new(); +} diff --git a/Content.Server/_Sunrise/StationEvents/Events/AnnounceRule.cs b/Content.Server/_Sunrise/StationEvents/Events/AnnounceRule.cs new file mode 100644 index 00000000000..8f77ec545ad --- /dev/null +++ b/Content.Server/_Sunrise/StationEvents/Events/AnnounceRule.cs @@ -0,0 +1,38 @@ +using System.Threading; +using Content.Server.Chat.Systems; +using Content.Shared.GameTicking.Components; +using Content.Server.StationEvents.Components; +using Robust.Shared.Player; +using Timer = Robust.Shared.Timing.Timer; + +namespace Content.Server.StationEvents.Events; + +public sealed class AnnounceRule : StationEventSystem +{ + [Dependency] private readonly EventManagerSystem _event = default!; + [Dependency] private readonly ChatSystem _chat = default!; + + protected override void Started(EntityUid uid, AnnounceRuleComponent component, GameRuleComponent gameRule, GameRuleStartedEvent args) + { + base.Started(uid, component, gameRule, args); + Timer.Spawn(component.RoundStartAnnouncementDelay * 1000, () => DispatchAnnouncement(uid, component, gameRule, args), component.TimerCancel); + } + + protected override void Ended(EntityUid uid, AnnounceRuleComponent component, GameRuleComponent gameRule, GameRuleEndedEvent args) + { + base.Ended(uid, component, gameRule, args); + } + + private void DispatchAnnouncement(EntityUid uid, AnnounceRuleComponent component, GameRuleComponent gameRule, GameRuleStartedEvent args) + { + if (component.EnableAnnouncement) + { + if (component.AnnouncementText != null) + _chat.DispatchGlobalAnnouncement(Loc.GetString(component.AnnouncementText), playSound: true, colorOverride: Color.Green); + + if (component.AnnounceAudio != null) + Audio.PlayGlobal(component.AnnounceAudio, Filter.Broadcast(), true); + } + component.TimerCancel = new CancellationToken(); + } +} diff --git a/Resources/Changelog/ChangelogSunrise.yml b/Resources/Changelog/ChangelogSunrise.yml index d59b61cc59d..33d8ef9a114 100644 --- a/Resources/Changelog/ChangelogSunrise.yml +++ b/Resources/Changelog/ChangelogSunrise.yml @@ -247,3 +247,11 @@ Entries: type: Tweak id: 21 time: '2024-06-05T16:26:42.210195+00:00' +- author: pacable + changes: + - message: "\u0414\u043E\u0431\u0430\u0432\u043B\u0435\u043D\u043E \u043E\u0431\u044A\ + \u044F\u0432\u043B\u0435\u043D\u0438\u0435 \u043E \u0433\u0440\u0438\u043D\u0448\ + \u0438\u0444\u0442\u0435 \u043D\u0430 \u0441\u0442\u0430\u043D\u0446\u0438\u0438" + type: Add + id: 22 + time: '2024-06-07T09:00:36.645770+00:00' diff --git a/Resources/Locale/en-US/ss14-ru/prototypes/game-ticking/preset-event.ftl b/Resources/Locale/en-US/ss14-ru/prototypes/game-ticking/preset-event.ftl new file mode 100644 index 00000000000..a68b3167277 --- /dev/null +++ b/Resources/Locale/en-US/ss14-ru/prototypes/game-ticking/preset-event.ftl @@ -0,0 +1,2 @@ +event-title = Event +event-description = Game masters are running an event. There are no threats, including random ones. diff --git a/Resources/Locale/en-US/ss14-ru/prototypes/gamerules/greenshift.ftl b/Resources/Locale/en-US/ss14-ru/prototypes/gamerules/greenshift.ftl new file mode 100644 index 00000000000..412c9d9c0d2 --- /dev/null +++ b/Resources/Locale/en-US/ss14-ru/prototypes/gamerules/greenshift.ftl @@ -0,0 +1 @@ +station-event-greenshift = Thanks to the tireless efforts of our security and intelligence divisions, there are currently no credible threats to Space Station 14. Have a secure shift! diff --git a/Resources/Locale/ru-RU/game-ticking/game-presets/preset-event.ftl b/Resources/Locale/ru-RU/game-ticking/game-presets/preset-event.ftl new file mode 100644 index 00000000000..80621a37413 --- /dev/null +++ b/Resources/Locale/ru-RU/game-ticking/game-presets/preset-event.ftl @@ -0,0 +1,2 @@ +event-title = Ивент +event-description = Гейм-мастеры проводят ивент. Отсутсвуют любые угрозы, включая случайные. diff --git a/Resources/Locale/ru-RU/station-events/events/greenshift.ftl b/Resources/Locale/ru-RU/station-events/events/greenshift.ftl new file mode 100644 index 00000000000..5b6aec1c10d --- /dev/null +++ b/Resources/Locale/ru-RU/station-events/events/greenshift.ftl @@ -0,0 +1 @@ +station-event-greenshift = Благодаря неустанным усилиям наших отделов Службы Безопасности, в настоящее время нет никаких достоверных угроз для космической станции 14. Удачной смены! diff --git a/Resources/Prototypes/GameRules/roundstart.yml b/Resources/Prototypes/GameRules/roundstart.yml index 88f80fd4f6a..3e6096ea9b0 100644 --- a/Resources/Prototypes/GameRules/roundstart.yml +++ b/Resources/Prototypes/GameRules/roundstart.yml @@ -245,6 +245,16 @@ - type: InitialInfectedRole prototype: InitialInfected +- type: entity + id: GreenshiftAnnouncement + parent: BaseGameRule + noSpawn: true + components: + - type: AnnounceRule # Sunrise + enableAnnouncement: true + announcementText: station-event-greenshift + roundStartAnnouncementDelay: 120 + # event schedulers - type: entity id: BasicStationEventScheduler diff --git a/Resources/Prototypes/_Sunrise/game_presets.yml b/Resources/Prototypes/_Sunrise/game_presets.yml new file mode 100644 index 00000000000..86f6273e2d9 --- /dev/null +++ b/Resources/Prototypes/_Sunrise/game_presets.yml @@ -0,0 +1,11 @@ +- type: gamePreset + id: Event + alias: + - event + - ivent + - SilentGreenshift + name: event-title + showInVote: false + description: event-description + rules: + - BasicRoundstartVariation diff --git a/Resources/Prototypes/game_presets.yml b/Resources/Prototypes/game_presets.yml index 3bc6ae6208c..1989c51f54a 100644 --- a/Resources/Prototypes/game_presets.yml +++ b/Resources/Prototypes/game_presets.yml @@ -43,6 +43,7 @@ description: greenshift-description rules: - BasicRoundstartVariation + - GreenshiftAnnouncement - type: gamePreset id: Secret