From e200bba3945e8c9edd47a5a09fd1ba3ea099e537 Mon Sep 17 00:00:00 2001 From: DEATHB4DEFEAT Date: Sun, 29 Oct 2023 12:16:03 -0700 Subject: [PATCH] update system and apply review changes --- .../Corvax/StationGoal/StationGoalCommand.cs | 6 +- .../StationGoal/StationGoalPaperSystem.cs | 145 +++++++++++------- .../StationGoal/StationGoalPrototype.cs | 2 +- Content.Shared/Corvax/CCVars/CCCVars.cs | 18 +++ .../station-goal/station-goal-command.ftl | 5 +- .../station-goal/station-goal-component.ftl | 112 +------------- .../Prototypes/Corvax/Objectives/goals.yml | 30 ++-- 7 files changed, 138 insertions(+), 180 deletions(-) create mode 100644 Content.Shared/Corvax/CCVars/CCCVars.cs diff --git a/Content.Server/Corvax/StationGoal/StationGoalCommand.cs b/Content.Server/Corvax/StationGoal/StationGoalCommand.cs index 8f1c451dc9..33a1fc9db3 100644 --- a/Content.Server/Corvax/StationGoal/StationGoalCommand.cs +++ b/Content.Server/Corvax/StationGoal/StationGoalCommand.cs @@ -25,18 +25,18 @@ public void Execute(IConsoleShell shell, string argStr, string[] args) var prototypeManager = IoCManager.Resolve(); if (!prototypeManager.TryIndex(protoId, out var proto)) { - shell.WriteError($"No station goal found with ID {protoId}!"); + shell.WriteError(Loc.GetString("send-station-goal-command-error-no-goal-proto", ("id", protoId))); return; } var stationGoalPaper = IoCManager.Resolve().System(); if (!stationGoalPaper.SendStationGoal(proto)) { - shell.WriteError("Station goal was not sent"); + shell.WriteError(Loc.GetString("send-station-goal-command-error-couldnt-fax")); return; } } - + public CompletionResult GetCompletion(IConsoleShell shell, string[] args) { if (args.Length == 1) diff --git a/Content.Server/Corvax/StationGoal/StationGoalPaperSystem.cs b/Content.Server/Corvax/StationGoal/StationGoalPaperSystem.cs index 8f658f66e0..d5ffdb7d5f 100644 --- a/Content.Server/Corvax/StationGoal/StationGoalPaperSystem.cs +++ b/Content.Server/Corvax/StationGoal/StationGoalPaperSystem.cs @@ -1,79 +1,116 @@ -using System.Linq; +using System.Data; using System.Text.RegularExpressions; using Content.Server.Fax; using Content.Server.Station.Systems; +using Content.Shared.Corvax.CCCVars; using Content.Shared.GameTicking; -using Content.Shared.Paper; +using Content.Shared.Random; +using Content.Shared.Random.Helpers; +using Robust.Shared.Configuration; using Robust.Shared.Prototypes; using Robust.Shared.Random; -namespace Content.Server.Corvax.StationGoal +namespace Content.Server.Corvax.StationGoal; + +/// +/// System to spawn paper with station goal. +/// +public sealed partial class StationGoalPaperSystem : EntitySystem { + [Dependency] private readonly IPrototypeManager _prototype = default!; + [Dependency] private readonly IRobustRandom _random = default!; + [Dependency] private readonly FaxSystem _fax = default!; + [Dependency] private readonly IConfigurationManager _config = default!; + [Dependency] private readonly StationSystem _station = default!; + + private static readonly Regex StationIdRegex = new(@".*-(\d+)$"); + + private const string RandomPrototype = "StationGoals"; + + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(OnRoundStarted); + } + + private void OnRoundStarted(RoundStartedEvent ev) + { + if (_config.GetCVar(CCCVars.StationGoalsEnabled) != true) + return; + + SendRandomGoal(); + } + /// - /// System to spawn paper with station goal. + /// Send a random station goal to all faxes which are authorized to receive it /// - public sealed class StationGoalPaperSystem : EntitySystem + /// If the fax was successful + /// Raised when station goal types in the prototype is invalid + public bool SendRandomGoal() { - [Dependency] private readonly IPrototypeManager _prototype = default!; - [Dependency] private readonly IRobustRandom _random = default!; - [Dependency] private readonly FaxSystem _fax = default!; - [Dependency] private readonly StationSystem _station = default!; + // Get the random station goal list + if (!_prototype.TryIndex(RandomPrototype, out var goals)) + return false; - private static readonly Regex StationIdRegex = new(@".*-(\d+)$"); + // Get a random goal + var goal = RecursiveRandom(goals); - public override void Initialize() - { - base.Initialize(); + // Send the goal + return SendStationGoal(goal); + } - SubscribeLocalEvent(OnRoundStarted); - } + private StationGoalPrototype RecursiveRandom(WeightedRandomPrototype random) + { + var goal = random.Pick(_random); - private void OnRoundStarted(RoundStartedEvent ev) + if (_prototype.TryIndex(goal, out var goalPrototype)) { - SendRandomGoal(); + return goalPrototype; } - public bool SendRandomGoal() + if (_prototype.TryIndex(goal, out var goalRandom)) { - var availableGoals = _prototypeManager.EnumeratePrototypes().ToList(); - var goal = _random.Pick(availableGoals); - return SendStationGoal(goal); + return RecursiveRandom(goalRandom); } - /// - /// Send a station goal to all faxes which are authorized to receive it. - /// - /// True if at least one fax received paper - public bool SendStationGoal(StationGoalPrototype goal) + throw new Exception($"StationGoalPaperSystem: Random station goal could not be found from origin prototype {RandomPrototype}"); + } + + /// + /// Send a station goal to all faxes which are authorized to receive it + /// + /// True if at least one fax received paper + public bool SendStationGoal(StationGoalPrototype goal) + { + var enumerator = EntityManager.EntityQueryEnumerator(); + var wasSent = false; + + while (enumerator.MoveNext(out var uid, out var fax)) { - var enumerator = EntityManager.EntityQueryEnumerator(); - var wasSent = false; - while (enumerator.MoveNext(out var uid, out var fax)) - { - if (!fax.ReceiveStationGoal) continue; - - if (!TryComp(_station.GetOwningStation(uid), out var meta)) - continue; - - var stationId = StationIdRegex.Match(meta.EntityName).Groups[1].Value; - - var printout = new FaxPrintout( - Loc.GetString(goal.Text, - ("date", DateTime.Now.AddYears(1000).ToString("dd.MM.yyyy")), - ("station", string.IsNullOrEmpty(stationId) ? "???" : stationId)), - Loc.GetString("station-goal-fax-paper-name"), - null, - "paper_stamp-centcom", - new List - { - new() { StampedName = Loc.GetString("stamp-component-stamped-name-centcom"), StampedColor = Color.FromHex("#BB3232") }, - }); - _faxSystem.Receive(uid, printout, null, fax); - - wasSent = true; - } - - return wasSent; + if (!fax.ReceiveStationGoal) + continue; + + if (!TryComp(_station.GetOwningStation(uid), out var meta)) + continue; + + var stationId = StationIdRegex.Match(meta.EntityName).Groups[1].Value; + + var printout = new FaxPrintout( + Loc.GetString("station-goal-fax-paper-header", + ("date", DateTime.Now.AddYears(1000).ToString("yyyy MMMM dd")), + ("station", string.IsNullOrEmpty(stationId) ? "???" : stationId), + ("content", goal.Text) + ), + Loc.GetString("station-goal-fax-paper-name"), + "StationGoalPaper" + ); + + _fax.Receive(uid, printout, null, fax); + + wasSent = true; } + + return wasSent; } } diff --git a/Content.Server/Corvax/StationGoal/StationGoalPrototype.cs b/Content.Server/Corvax/StationGoal/StationGoalPrototype.cs index 79d945f5be..73289e60c9 100644 --- a/Content.Server/Corvax/StationGoal/StationGoalPrototype.cs +++ b/Content.Server/Corvax/StationGoal/StationGoalPrototype.cs @@ -7,6 +7,6 @@ public sealed class StationGoalPrototype : IPrototype { [IdDataFieldAttribute] public string ID { get; } = default!; - [DataField("text")] public string Text { get; set; } = string.Empty; + public string Text => Loc.GetString($"station-goal-{ID.ToLower()}"); } } diff --git a/Content.Shared/Corvax/CCVars/CCCVars.cs b/Content.Shared/Corvax/CCVars/CCCVars.cs new file mode 100644 index 0000000000..371b793d3d --- /dev/null +++ b/Content.Shared/Corvax/CCVars/CCCVars.cs @@ -0,0 +1,18 @@ +using Robust.Shared.Configuration; + +namespace Content.Shared.Corvax.CCCVars; + +[CVarDefs] +// ReSharper disable once InconsistentNaming +public sealed class CCCVars +{ + /* + * Station Goals + */ + + /// + /// Enables station goals + /// + public static readonly CVarDef StationGoalsEnabled = + CVarDef.Create("game.station_goals", false, CVar.SERVERONLY); +} diff --git a/Resources/Locale/en-US/corvax/station-goal/station-goal-command.ftl b/Resources/Locale/en-US/corvax/station-goal/station-goal-command.ftl index c3bb480a67..82ed4d5c8a 100644 --- a/Resources/Locale/en-US/corvax/station-goal/station-goal-command.ftl +++ b/Resources/Locale/en-US/corvax/station-goal/station-goal-command.ftl @@ -1,3 +1,6 @@ send-station-goal-command-description = Sends the selected station target to all faxes that can receive it -send-station-goal-command-help-text = Usage: { $command } +send-station-goal-command-help-text = Usage: { $command } send-station-goal-command-arg-id = Goal Prototype ID + +send-station-goal-command-error-no-goal-proto = No station goal found with ID {$id} +send-station-goal-command-error-couldnt-fax = Couldn't send station goal, probably due to a lack of fax machines that are able to recieve it diff --git a/Resources/Locale/en-US/corvax/station-goal/station-goal-component.ftl b/Resources/Locale/en-US/corvax/station-goal/station-goal-component.ftl index 69d1b26bb7..7cfee4c03d 100644 --- a/Resources/Locale/en-US/corvax/station-goal/station-goal-component.ftl +++ b/Resources/Locale/en-US/corvax/station-goal/station-goal-component.ftl @@ -1,6 +1,6 @@ station-goal-fax-paper-name = Station Goal -station-goal-xeno= +station-goal-fax-paper-header = ███╗░░██╗████████╗ ████╗░██║╚══██╔══╝ Form NT-No.{$station}-CC ██╔██╗██║░░░██║░░░ Target Order @@ -8,6 +8,11 @@ station-goal-xeno= ██║░╚███║░░░██║░░░ ╚═╝░░╚══╝░░░╚═╝░░░ ════════════════════════════════════════ + {$content} + ════════════════════════════════════════ + + +station-goal-xeno= Dear station Command, the purpose of your shift is to build a xenobiology lab and then study exotic life forms. Two containment chambers must be constructed according to the following requirements: 1. Must be reinforced well; @@ -26,16 +31,8 @@ station-goal-xeno= Experience Requirements: 1. Experience should be documented in detail; 2. Test activities may include: working with gases, smoke, foam, or injecting experimental reagents (e.g. Cognizine) into captured fauna. - ════════════════════════════════════════ station-goal-museum= - ███╗░░██╗████████╗ - ████╗░██║╚══██╔══╝ Form NT-No.{$station}-CC - ██╔██╗██║░░░██║░░░ Target Order - ██║╚████║░░░██║░░░ Date: {$date} - ██║░╚███║░░░██║░░░ - ╚═╝░░╚══╝░░░╚═╝░░░ - ════════════════════════════════════════ Dear command of the station, the purpose of your shift is to build a museum, the exhibits for which will be unique objects collected from the station. Below are the requirements for the design of the museum: @@ -63,16 +60,8 @@ station-goal-museum= 10. Found treasures or items not available on the market. Upon completion of the museum, it is required to provide the crew with at least 20 minutes of free time from work so that they can visit the museum. - ════════════════════════════════════════ station-goal-area= - ███╗░░██╗████████╗ - ████╗░██║╚══██╔══╝ Form NT-No.{$station}-CC - ██╔██╗██║░░░██║░░░ Target Order - ██║╚████║░░░██║░░░ Date: {$date} - ██║░╚███║░░░██║░░░ - ╚═╝░░╚══╝░░░╚═╝░░░ - ════════════════════════════════════════ Dear station Command, the goal of your shift is to increase the effective use of space at the station. It is required to bring the abandoned premises into proper form and find a use for them. @@ -80,16 +69,8 @@ station-goal-area= Sufficiently spacious maintenance tunnels need to be converted into residential areas. The remaining tunnels should be provided with floor coverings and adequate lighting. In addition, it is necessary to provide a public, well-lit corridor connecting all the restored compartments and new bedrooms. - ════════════════════════════════════════ station-goal-bureaucratic-error = - ███╗░░██╗████████╗ - ████╗░██║╚══██╔══╝ Form NT-No.{$station}-CC - ██╔██╗██║░░░██║░░░ Target Order - ██║╚████║░░░██║░░░ Date: {$date} - ██║░╚███║░░░██║░░░ - ╚═╝░░╚══╝░░░╚═╝░░░ - ════════════════════════════════════════ ACCESS TO THIS DOCUMENT IS PROHIBITED FOR PERSONS WHO DO NOT HAVE LEGAL IMMUNITY Dear station Command, we inform you that the purpose of your shift was lost as a result of a bureaucratic error. @@ -102,16 +83,8 @@ station-goal-bureaucratic-error = Please note that distribution of the contents of this document to persons who do not have legal immunity is strictly prohibited due to the possibility of discrediting the management of the Corporation. Therefore, in order to present a new goal to the crew, the command staff must contact Central Command for approval of your ideas. - ════════════════════════════════════════ station-goal-anomalies= - ███╗░░██╗████████╗ - ████╗░██║╚══██╔══╝ Form NT-No.{$station}-CC - ██╔██╗██║░░░██║░░░ Target Order - ██║╚████║░░░██║░░░ Date: {$date} - ██║░╚███║░░░██║░░░ - ╚═╝░░╚══╝░░░╚═╝░░░ - ════════════════════════════════════════ Dear station Command, the purpose of your shift is to provide new information about anomalies to NanoTrasen. It is necessary to conduct experimental studies aimed at testing the consequences of the collapse of at least 4 unique anomalies. @@ -126,16 +99,8 @@ station-goal-anomalies= 6. Location of the anomaly. The document must be certified by the stamp of the supervisor and faxed to Central Command. - ════════════════════════════════════════ station-goal-combat= - ███╗░░██╗████████╗ - ████╗░██║╚══██╔══╝ Form NT-No.{$station}-CC - ██╔██╗██║░░░██║░░░ Target Order - ██║╚████║░░░██║░░░ Date: {$date} - ██║░╚███║░░░██║░░░ - ╚═╝░░╚══╝░░░╚═╝░░░ - ════════════════════════════════════════ Dear station Command, due to the increase in attacks of pirate ships in this sector, the purpose of your shift is to raise the overall combat readiness of the station. Required: @@ -157,16 +122,8 @@ station-goal-combat= Avoid providing lethal weaponry to unauthorized personnel. 6. Encourage the use of the station boxing ring. If there is no boxing ring, you must create one. - ════════════════════════════════════════ station-goal-shuttle= - ███╗░░██╗████████╗ - ████╗░██║╚══██╔══╝ Form NT-No.{$station}-CC - ██╔██╗██║░░░██║░░░ Target Order - ██║╚████║░░░██║░░░ Date: {$date} - ██║░╚███║░░░██║░░░ - ╚═╝░░╚══╝░░░╚═╝░░░ - ════════════════════════════════════════ Dear station Command, the purpose of your shift is to build a space shuttle capable of being piloted. Shuttle requirements: @@ -186,48 +143,24 @@ station-goal-shuttle= 1 security officer. The shuttle should take on board all the station Command representatives as passengers and, in parallel with the evacuation shuttle, go to the Central Command station. - ════════════════════════════════════════ station-goal-singularity= - ███╗░░██╗████████╗ - ████╗░██║╚══██╔══╝ Form NT-No.{$station}-CC - ██╔██╗██║░░░██║░░░ Target Order - ██║╚████║░░░██║░░░ Date: {$date} - ██║░╚███║░░░██║░░░ - ╚═╝░░╚══╝░░░╚═╝░░░ - ════════════════════════════════════════ Dear station Command, the goal of your shift is to build a generator based on the gravitational singularity. The design requirements are: 1. The structure must be located at a significant distance from the station. 2. The structure must be protected from meteorites and space debris. 3. The containment field must be able to prevent the loss of a class 4 singularity. - ════════════════════════════════════════ station-goal-solar-panels= - ███╗░░██╗████████╗ - ████╗░██║╚══██╔══╝ Form NT-No.{$station}-CC - ██╔██╗██║░░░██║░░░ Target Order - ██║╚████║░░░██║░░░ Date: {$date} - ██║░╚███║░░░██║░░░ - ╚═╝░░╚══╝░░░╚═╝░░░ - ════════════════════════════════════════ Dear station Command, the purpose of your shift is to organize a backup power system. The following work is required: 1. Build two new branches of solar panels. 2. Allocate an area for a compartment with spare batteries. This compartment should accommodate at least 3 fully charged SMES', which should not be connected to the main power system of the station unless needed. - ════════════════════════════════════════ station-goal-artifacts= - ███╗░░██╗████████╗ - ████╗░██║╚══██╔══╝ Form NT-No.{$station}-CC - ██╔██╗██║░░░██║░░░ Target Order - ██║╚████║░░░██║░░░ Date: {$date} - ██║░╚███║░░░██║░░░ - ╚═╝░░╚══╝░░░╚═╝░░░ - ════════════════════════════════════════ Dear station Command, the purpose of your shift is to provide new information about alien artifacts to NanoTrasen. It is required to organize the work of salvagers to search for and deliver artifacts from the wreckage around the station or expeditions. @@ -242,16 +175,8 @@ station-goal-artifacts= 5. Additional notes. The document must be certified by the stamp of the supervisor. - ════════════════════════════════════════ station-goal-storage= - ███╗░░██╗████████╗ - ████╗░██║╚══██╔══╝ Form NT-No.{$station}-CC - ██╔██╗██║░░░██║░░░ Target Order - ██║╚████║░░░██║░░░ Date: {$date} - ██║░╚███║░░░██║░░░ - ╚═╝░░╚══╝░░░╚═╝░░░ - ════════════════════════════════════════ Dear station Command, the purpose of your shift is to build an orbital storage facility with supplies and technology. The storage should be placed in space separately from the main station, make sure its design is strong, a random meteorite should not damage it. @@ -263,16 +188,8 @@ station-goal-storage= - Valuable, but not unique boards. Monitor the safety of the contents in the storage until the end of the shift, a cleanup crew will come retrieve the contents as they prepare the station. - ════════════════════════════════════════ station-goal-zoo= - ███╗░░██╗████████╗ - ████╗░██║╚══██╔══╝ Form NT-No.{$station}-CC - ██╔██╗██║░░░██║░░░ Target Order - ██║╚████║░░░██║░░░ Date: {$date} - ██║░╚███║░░░██║░░░ - ╚═╝░░╚══╝░░░╚═╝░░░ - ════════════════════════════════════════ Dear station Command, the purpose of your shift is to improve the recreational value of the personnel at the station. It is necessary to build a zoo with at least 5 enclosures containing different types of animals ordered from the supply department. @@ -280,16 +197,8 @@ station-goal-zoo= It is also necessary to build a bathhouse for the animals, water vapor must be supplied by Atmospheric Technicians. Upon completion of the zoo, it is required to provide the crew with at least 20 minutes of free time from work so that they can visit the new zoo. - ════════════════════════════════════════ station-goal-labor= - ███╗░░██╗████████╗ - ████╗░██║╚══██╔══╝ Form NT-No.{$station}-CC - ██╔██╗██║░░░██║░░░ Target Order - ██║╚████║░░░██║░░░ Date: {$date} - ██║░╚███║░░░██║░░░ - ╚═╝░░╚══╝░░░╚═╝░░░ - ════════════════════════════════════════ Dear station Command, the purpose of your shift is to increase the motivation of the personnel for the growth of labor productivity. This requires that each of the heads during the shift closely monitors the performance of the duties of their employees and evaluates them. @@ -300,16 +209,8 @@ station-goal-labor= The duration of the shift for a more accurate assessment of the work of the personnel should be set by the Command staff. After the dinner someone must announce the end of the shift and call the evacuation shuttle. - ════════════════════════════════════════ station-goal-lectures= - ███╗░░██╗████████╗ - ████╗░██║╚══██╔══╝ Form NT-No.{$station}-CC - ██╔██╗██║░░░██║░░░ Target Order - ██║╚████║░░░██║░░░ Date: {$date} - ██║░╚███║░░░██║░░░ - ╚═╝░░╚══╝░░░╚═╝░░░ - ════════════════════════════════════════ Dear station Command, the purpose of your shift is to carry out a number of events within the framework of the Corporation's plan to increase the knowledge of its employees. The Command staff are instructed to organize a platform for public lectures, if none exists, create one nearby the bridge entry. @@ -321,4 +222,3 @@ station-goal-lectures= There may be breaks between lectures to allow guests to read brochures and catch their breath. After the end of the event someone must announce the end of the shift and call the evacuation shuttle. - ════════════════════════════════════════ diff --git a/Resources/Prototypes/Corvax/Objectives/goals.yml b/Resources/Prototypes/Corvax/Objectives/goals.yml index 8f4f18384b..65c71a8ec4 100644 --- a/Resources/Prototypes/Corvax/Objectives/goals.yml +++ b/Resources/Prototypes/Corvax/Objectives/goals.yml @@ -1,55 +1,55 @@ - type: stationGoal - id: StationGoalShuttle + id: Shuttle text: station-goal-shuttle - type: stationGoal - id: StationGoalSingularity + id: Singularity text: station-goal-singularity - type: stationGoal - id: StationGoalSolarPanels + id: SolarPanels text: station-goal-solar-panels - type: stationGoal - id: StationGoalArtifacts + id: Artifacts text: station-goal-artifacts - type: stationGoal - id: StationGoalStorage + id: Storage text: station-goal-storage - type: stationGoal - id: StationGoalZoo + id: Zoo text: station-goal-zoo - type: stationGoal - id: StationGoalXeno + id: Xeno text: station-goal-xeno - type: stationGoal - id: StationGoalArea + id: Area text: station-goal-area - type: stationGoal - id: StationGoalBureaucraticError + id: BureaucraticError text: station-goal-bureaucratic-error - type: stationGoal - id: StationGoalMuseum + id: Museum text: station-goal-museum - type: stationGoal - id: StationGoalCombat + id: Combat text: station-goal-combat - type: stationGoal - id: StationGoalSpaceArtifacts + id: SpaceArtifacts text: station-goal-space-artifacts - type: stationGoal - id: StationGoalLabor + id: Labor text: station-goal-labor - type: stationGoal - id: StationGoalLectures - text: station-goal-lectures \ No newline at end of file + id: Lectures + text: station-goal-lectures