diff --git a/Content.Server/_CorvaxNext/StationEvents/Components/SpaceLawChangeRuleComponent.cs b/Content.Server/_CorvaxNext/StationEvents/Components/SpaceLawChangeRuleComponent.cs new file mode 100644 index 00000000000..b8cbb2ddd9a --- /dev/null +++ b/Content.Server/_CorvaxNext/StationEvents/Components/SpaceLawChangeRuleComponent.cs @@ -0,0 +1,32 @@ +using Content.Server._CorvaxNext.StationEvents.Events; +using Content.Shared.Dataset; +using Robust.Shared.Prototypes; + +namespace Content.Server._CorvaxNext.StationEvents.Components +{ + [RegisterComponent, Access(typeof(SpaceLawChangeRule))] + public sealed partial class SpaceLawChangeRuleComponent : Component + { + /// + /// Localization key of a random message selected for the current event + /// + /// + /// Do not set an initial value for this field! + /// + [DataField] + public string? RandomMessage { get; set; } + + /// + /// A localized dataset containing the initial list of all laws for the event + /// + [DataField] + public ProtoId LawLocalizedDataset { get; set; } + + /// + /// Time before changes to the law come into force. + /// Necessary for establish the delay in sending information about the law coming into force + /// + [DataField] + public int AdaptationTime { get; set; } = 10; + } +} diff --git a/Content.Server/_CorvaxNext/StationEvents/Events/SpaceLawChange.cs b/Content.Server/_CorvaxNext/StationEvents/Events/SpaceLawChange.cs new file mode 100644 index 00000000000..e8a1960ff8d --- /dev/null +++ b/Content.Server/_CorvaxNext/StationEvents/Events/SpaceLawChange.cs @@ -0,0 +1,149 @@ +using System.Linq; +using Content.Server.Chat.Systems; +using Content.Server.Fax; +using Content.Shared.GameTicking.Components; +using Content.Server.GameTicking; +using Content.Shared._CorvaxNext.NextVars; +using Content.Shared.Paper; +using Content.Shared.Dataset; +using Robust.Shared.Random; +using Content.Shared.Fax.Components; +using Content.Server.StationEvents.Events; +using Robust.Shared.Timing; +using Robust.Shared.Prototypes; +using Robust.Shared.Configuration; +using Content.Server._CorvaxNext.StationEvents.Components; + +namespace Content.Server._CorvaxNext.StationEvents.Events +{ + public sealed class SpaceLawChangeRule : StationEventSystem + { + [Dependency] private readonly ChatSystem _chat = default!; + [Dependency] private readonly IRobustRandom _robustRandom = default!; + [Dependency] private readonly FaxSystem _faxSystem = default!; + [Dependency] private readonly IEntityManager _entityManager = default!; + [Dependency] private readonly IPrototypeManager _prototypeManager = default!; + [Dependency] private readonly GameTicker _gameTicker = default!; + [Dependency] private readonly IGameTiming _gameTiming = default!; + [Dependency] private readonly IConfigurationManager _cfg = default!; + + /// + /// Sequence of laws to be used for the current event + /// + private List _sequenceLaws = new(); + + protected override void Started(EntityUid uid, SpaceLawChangeRuleComponent component, + GameRuleComponent gameRule, GameRuleStartedEvent args) + { + base.Started(uid, component, gameRule, args); + + if (!_cfg.GetCVar(NextVars.LRPEnabled)) + return; + + // Loading a prototype dataset + if (!_prototypeManager.TryIndex(component.LawLocalizedDataset, out var dataset)) + { + Logger.Error($"LocalizedDatasetPrototype not found: {component.LawLocalizedDataset}"); + return; + } + + + // Initializing the list of laws if it is empty + if (_sequenceLaws.Count == 0) + { + _sequenceLaws.AddRange(dataset.Values); + } + // Getting active laws from currently active rules + var activeLaws = GetActiveSpaceLaws(); + + // Excluding active laws from selection + var availableLaws = _sequenceLaws.Except(activeLaws).ToArray(); + if (availableLaws.Count == 0) + { + availableLaws = _sequenceLaws; + } + + // Selecting a random law from the available ones + var randomLaw = _robustRandom.Pick(availableLaws); + component.RandomMessage = randomLaw; + + var stationTime = _gameTiming.CurTime.Subtract(_gameTicker.RoundStartTimeSpan); + + var message = Loc.GetString("station-event-space-law-change-announcement", + ("essence", Loc.GetString(component.RandomMessage)), + ("time", component.AdaptationTime)); + + var faxMessage = Loc.GetString("station-event-space-law-change-fax-announcement", + ("faxEssence", message), + ("stationTime", stationTime.ToString("hh\\:mm\\:ss"))); + + // Sending a global announcement + _chat.DispatchGlobalAnnouncement(message, playSound: true, colorOverride: Color.Gold); + SendSpaceLawChangeFax(faxMessage); + + // Start a timer to send a confirmation message after AdaptationTime minutes + Timer.Spawn(TimeSpan.FromMinutes(component.AdaptationTime), () => SendConfirmationMessage(uid)); + } + + /// + /// Getting active laws from currently active rules + /// + private List GetActiveSpaceLaws() + { + var activeLaws = new List(); + foreach (var rule in _gameTicker.GetActiveGameRules()) + { + if (_entityManager.TryGetComponent(rule, out SpaceLawChangeRuleComponent? spaceLawComponent)) + { + if (!string.IsNullOrEmpty(spaceLawComponent.RandomMessage)) + { + activeLaws.Add(spaceLawComponent.RandomMessage); + } + } + } + return activeLaws; + } + + /// + /// Sending a confirmation message about the entry into force of changes in Space Law + /// + private void SendConfirmationMessage(EntityUid uid) + { + if (!_entityManager.TryGetComponent(uid, out SpaceLawChangeRuleComponent? component) || component.RandomMessage == null) + { + Logger.Error($"Failed to send confirmation message for SpaceLawChangeRule for entity {uid}: Component or RandomMessage is null."); + return; + } + + var confirmationMessage = Loc.GetString("station-event-space-law-change-announcement-confirmation", ("essence", Loc.GetString(component.RandomMessage))); + var faxConfirmationMessage = Loc.GetString("station-event-space-law-change-announcement-fax-confirmation", ("faxEssence", confirmationMessage)); + _chat.DispatchGlobalAnnouncement(confirmationMessage, playSound: true, colorOverride: Color.Gold); + SendSpaceLawChangeFax(faxConfirmationMessage); + } + + /// + /// Sending a fax announcing changes in Space Law + /// + private void SendSpaceLawChangeFax(string message) + { + var printout = new FaxPrintout( + message, + Loc.GetString("materials-paper"), + null, + null, + "paper_stamp-centcom", + new List + { + new() { StampedName = Loc.GetString("stamp-component-stamped-name-centcom"), StampedColor = Color.FromHex("#006600") } + }); + + var faxes = _entityManager.EntityQuery(); + foreach (var fax in faxes) + { + if (!fax.ReceiveStationGoal) + continue; + _faxSystem.Receive(fax.Owner, printout, Loc.GetString("station-event-space-law-change-fax-sender"), fax); + } + } + } +} diff --git a/Content.Shared/_CorvaxNext/NextVars.cs b/Content.Shared/_CorvaxNext/NextVars.cs index 9f355adbfec..8d2780dc8ea 100644 --- a/Content.Shared/_CorvaxNext/NextVars.cs +++ b/Content.Shared/_CorvaxNext/NextVars.cs @@ -41,4 +41,10 @@ public sealed class NextVars // public static readonly CVarDef OfferModeIndicatorsPointShow = // CVarDef.Create("hud.offer_mode_indicators_point_show", true, CVar.ARCHIVE | CVar.CLIENTONLY); + + /// + /// LRP CVar + /// + public static readonly CVarDef LRPEnabled = + CVarDef.Create("lrp.enabled", false, CVar.SERVERONLY); } diff --git a/Resources/ConfigPresets/Corvax/main.toml b/Resources/ConfigPresets/Corvax/main.toml index 4b91f6fbc92..bda7655b27a 100644 --- a/Resources/ConfigPresets/Corvax/main.toml +++ b/Resources/ConfigPresets/Corvax/main.toml @@ -25,3 +25,6 @@ time = 180.0 [hub] advertise = true tags = "lang:ru,rp:low,rp:med,region:eu_e,tts" + +[lrp] # Corvax-Next-LRP +enabled = true diff --git a/Resources/Locale/ru-RU/_CorvaxNext/station-events/events/space-law-change.ftl b/Resources/Locale/ru-RU/_CorvaxNext/station-events/events/space-law-change.ftl new file mode 100644 index 00000000000..dafed049c31 --- /dev/null +++ b/Resources/Locale/ru-RU/_CorvaxNext/station-events/events/space-law-change.ftl @@ -0,0 +1,56 @@ +station-event-space-law-change-fax-start = [color=#b8972d]███[/color][color=#1d7a1d]░███░░░░██░░░░[/color][color=#b8972d] ★ ★ ★[/color][color=#1d7a1d] + ░██░████░░░██░░░░ [head=3]Бланк документа[/head] + ░░█░██░██░░██░█░░ [head=3]NanoTrasen[/head] + ░░░░██░░██░██░██░ [bold]ЦК-КОМ[/bold] + ░░░░██░░░████░[/color][color=#b8972d]███[/color][color=#b8972d] ★ ★ ★[/color] + ==================================================[bold] + УВЕДОМЛЕНИЕ О ИЗМЕНЕНИИ КОРПОРАТИВНОГО ЗАКОНА[/bold] + ================================================== +station-event-space-law-change-fax-end = + Слава NanoTrasen! + ==================================================[italic] + Место для печати[/italic] + +station-event-space-law-change-fax-sender = Центральное Командование + + +# Уведомление о начале переходного периода +station-event-space-law-change-fax-announcement = + { station-event-space-law-change-fax-start } + { $faxEssence } + Продолжительность смены на момент отправки факса: { $stationTime } + { station-event-space-law-change-fax-end } + +station-event-space-law-change-announcement = В связи с последними изменениями в корпоративной политике, { $essence } теперь признается (или признаются) незаконным(-ыми) по кодовому номеру «XX1» Корпоративного закона. В ваших интересах незамедлительно исправить ситуацию до вступления изменений в силу через { $time } минут. Служба безопасности и Командование обязаны приложить все возможные усилия для обеспечения полного соответствия станции требованиям закона к моменту окончания периода адаптации. + + +# Уведомление о завершении переходного периода +station-event-space-law-change-announcement-fax-confirmation = + { station-event-space-law-change-fax-start } + { $faxEssence } + { station-event-space-law-change-fax-end } + +station-event-space-law-change-announcement-confirmation = Уведомляем вас о вступлении в силу изменений в Корпоративном законе, связанных с недавними изменениями в корпоративной политике. Теперь { $essence } признается (или признаются) незаконным(-ыми) по кодовому номеру «XX1» Корпоративного закона. + + +# spaceLawChangeLaws localizedDataset +station-event-space-law-change-essence-1 = юбки и шорты +station-event-space-law-change-essence-2 = кухонные ножи +station-event-space-law-change-essence-3 = шляпы и береты +station-event-space-law-change-essence-4 = зимние куртки +station-event-space-law-change-essence-5 = алкогольные напитки +station-event-space-law-change-essence-6 = сигареты +station-event-space-law-change-essence-7 = острая пища +station-event-space-law-change-essence-8 = деятельность руководителей отделов, которые не уделяют должного внимания патриотическому воспитанию своих сотрудников во славу NanoTrasen +station-event-space-law-change-essence-9 = не ношение головного убора +station-event-space-law-change-essence-10 = неисполнение главой отдела личного приветствия каждого члена экипажа, посещающего его отдел +station-event-space-law-change-essence-11 = безработица +station-event-space-law-change-essence-12 = обувь +station-event-space-law-change-essence-13 = ведение бумажной документации +station-event-space-law-change-essence-14 = общение не шепотом вне каналов связи +station-event-space-law-change-essence-15 = попытки убедить Капитана станции в существовании мировых заговоров +station-event-space-law-change-essence-16 = введение в оборот фруктов и овощей нового урожая без предварительной дегустации каждого вида Главой персонала +station-event-space-law-change-essence-17 = неисполнение приветствия "Привет, товарищи" при входе в Бриг +station-event-space-law-change-essence-18 = рассказы о событиях, которые противоречат официальным отчетам отдела Службы безопасности +station-event-space-law-change-essence-19 = перерывы +station-event-space-law-change-essence-20 = проведение хирургических операций diff --git a/Resources/Prototypes/_CorvaxNext/Datasets/space_law_change.yml b/Resources/Prototypes/_CorvaxNext/Datasets/space_law_change.yml new file mode 100644 index 00000000000..257317676ec --- /dev/null +++ b/Resources/Prototypes/_CorvaxNext/Datasets/space_law_change.yml @@ -0,0 +1,5 @@ +- type: localizedDataset + id: spaceLawChangeLaws + values: + prefix: station-event-space-law-change-essence- + count: 20 diff --git a/Resources/Prototypes/_CorvaxNext/GameRules/events.yml b/Resources/Prototypes/_CorvaxNext/GameRules/events.yml new file mode 100644 index 00000000000..bfde4a88eee --- /dev/null +++ b/Resources/Prototypes/_CorvaxNext/GameRules/events.yml @@ -0,0 +1,14 @@ +- type: entity + id: SpaceLawChange + parent: BaseGameRule + abstract: true + components: + - type: StationEvent + weight: 5 + maxOccurrences: 1 # can only happen 1 time per round + duration: null # the rule has to last the whole round + - type: GameRule + minPlayers: 50 + - type: SpaceLawChangeRule + lawLocalizedDataset: spaceLawChangeLaws + adaptationTime: 10