From e11f8409d96d53196e5b4f339cfa4fc71a26210b Mon Sep 17 00:00:00 2001 From: DEATHB4DEFEAT Date: Mon, 19 Aug 2024 15:57:50 -0700 Subject: [PATCH] remove duplicate systems --- .../Corvax/GameTicking/RoundStartedEvent.cs | 11 -- .../Corvax/StationGoal/StationGoalCommand.cs | 55 --------- .../StationGoal/StationGoalPaperComponent.cs | 11 -- .../StationGoal/StationGoalPaperSystem.cs | 113 ------------------ .../StationGoal/StationGoalPrototype.cs | 12 -- .../Speech/Components/RandomBarkComponent.cs | 51 -------- .../Speech/Systems/RandomBarkSystem.cs | 47 -------- Content.Shared/Corvax/CCVars/CCCVars.cs | 18 --- 8 files changed, 318 deletions(-) delete mode 100644 Content.Server/Corvax/GameTicking/RoundStartedEvent.cs delete mode 100644 Content.Server/Corvax/StationGoal/StationGoalCommand.cs delete mode 100644 Content.Server/Corvax/StationGoal/StationGoalPaperComponent.cs delete mode 100644 Content.Server/Corvax/StationGoal/StationGoalPaperSystem.cs delete mode 100644 Content.Server/Corvax/StationGoal/StationGoalPrototype.cs delete mode 100644 Content.Server/Parkstation/Speech/Components/RandomBarkComponent.cs delete mode 100644 Content.Server/Parkstation/Speech/Systems/RandomBarkSystem.cs delete mode 100644 Content.Shared/Corvax/CCVars/CCCVars.cs diff --git a/Content.Server/Corvax/GameTicking/RoundStartedEvent.cs b/Content.Server/Corvax/GameTicking/RoundStartedEvent.cs deleted file mode 100644 index 7a21fcef4b..0000000000 --- a/Content.Server/Corvax/GameTicking/RoundStartedEvent.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace Content.Server.Corvax.GameTicking; - -public sealed class RoundStartedEvent : EntityEventArgs -{ - public int RoundId { get; } - - public RoundStartedEvent(int roundId) - { - RoundId = roundId; - } -} diff --git a/Content.Server/Corvax/StationGoal/StationGoalCommand.cs b/Content.Server/Corvax/StationGoal/StationGoalCommand.cs deleted file mode 100644 index baad64d62c..0000000000 --- a/Content.Server/Corvax/StationGoal/StationGoalCommand.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System.Linq; -using Content.Server.Administration; -using Content.Shared.Administration; -using Robust.Shared.Console; -using Robust.Shared.Prototypes; - -namespace Content.Server.Corvax.StationGoal -{ - [AdminCommand(AdminFlags.Fun)] - public sealed class StationGoalCommand : IConsoleCommand - { - public string Command => "sendstationgoal"; - public string Description => Loc.GetString("send-station-goal-command-description"); - public string Help => Loc.GetString("send-station-goal-command-help-text", ("command", Command)); - - public void Execute(IConsoleShell shell, string argStr, string[] args) - { - if (args.Length != 1) - { - shell.WriteError(Loc.GetString("shell-need-exactly-one-argument")); - return; - } - - var protoId = args[0]; - var prototypeManager = IoCManager.Resolve(); - if (!prototypeManager.TryIndex(protoId, out var proto)) - { - 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(Loc.GetString("send-station-goal-command-error-couldnt-fax")); - return; - } - } - - public CompletionResult GetCompletion(IConsoleShell shell, string[] args) - { - if (args.Length == 1) - { - var options = IoCManager.Resolve() - .EnumeratePrototypes() - .OrderBy(p => p.ID) - .Select(p => new CompletionOption(p.ID)); - - return CompletionResult.FromHintOptions(options, Loc.GetString("send-station-goal-command-arg-id")); - } - - return CompletionResult.Empty; - } - } -} diff --git a/Content.Server/Corvax/StationGoal/StationGoalPaperComponent.cs b/Content.Server/Corvax/StationGoal/StationGoalPaperComponent.cs deleted file mode 100644 index f8ee1b32f1..0000000000 --- a/Content.Server/Corvax/StationGoal/StationGoalPaperComponent.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace Content.Server.Corvax.StationGoal -{ - /// - /// Paper with a written station goal in it. - /// - [RegisterComponent] - public sealed partial class StationGoalPaperComponent : Component - { - } -} - diff --git a/Content.Server/Corvax/StationGoal/StationGoalPaperSystem.cs b/Content.Server/Corvax/StationGoal/StationGoalPaperSystem.cs deleted file mode 100644 index 7e370fd5de..0000000000 --- a/Content.Server/Corvax/StationGoal/StationGoalPaperSystem.cs +++ /dev/null @@ -1,113 +0,0 @@ -using System.Data; -using System.Text.RegularExpressions; -using Content.Server.Corvax.GameTicking; -using Content.Server.Fax; -using Content.Server.Station.Systems; -using Content.Shared.Corvax.CCCVars; -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; - -/// -/// System for station goals -/// -public sealed 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)) - SendRandomGoal(); - } - - /// - /// Send a random station goal to all faxes which are authorized to receive it - /// - /// If the fax was successful - /// Raised when station goal types in the prototype is invalid - public bool SendRandomGoal() - { - // Get the random station goal list - if (!_prototype.TryIndex(RandomPrototype, out var goals)) - { - Log.Error($"StationGoalPaperSystem: Random station goal prototype '{RandomPrototype}' not found"); - return false; - } - - // Get a random goal - var goal = RecursiveRandom(goals); - - // Send the goal - return SendStationGoal(goal); - } - - private StationGoalPrototype RecursiveRandom(WeightedRandomPrototype random) - { - var goal = random.Pick(_random); - - if (_prototype.TryIndex(goal, out var goalPrototype)) - return goalPrototype; - - if (_prototype.TryIndex(goal, out var goalRandom)) - return RecursiveRandom(goalRandom); - - 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)) - { - if (!fax.ReceiveStationGoal || - !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 deleted file mode 100644 index 73289e60c9..0000000000 --- a/Content.Server/Corvax/StationGoal/StationGoalPrototype.cs +++ /dev/null @@ -1,12 +0,0 @@ -using Robust.Shared.Prototypes; - -namespace Content.Server.Corvax.StationGoal -{ - [Serializable, Prototype("stationGoal")] - public sealed class StationGoalPrototype : IPrototype - { - [IdDataFieldAttribute] public string ID { get; } = default!; - - public string Text => Loc.GetString($"station-goal-{ID.ToLower()}"); - } -} diff --git a/Content.Server/Parkstation/Speech/Components/RandomBarkComponent.cs b/Content.Server/Parkstation/Speech/Components/RandomBarkComponent.cs deleted file mode 100644 index 83b1ff216f..0000000000 --- a/Content.Server/Parkstation/Speech/Components/RandomBarkComponent.cs +++ /dev/null @@ -1,51 +0,0 @@ -namespace Content.Server.Parkstation.Speech.Components; - -/// -/// Sends a random message from a list with a provided min/max time. -/// -[RegisterComponent] -public sealed partial class RandomBarkComponent : Component -{ - // Should the message be sent to the chat log? - [DataField, ViewVariables(VVAccess.ReadWrite)] - public bool ChatLog = false; - - // Minimum time an animal will go without speaking - [DataField, ViewVariables(VVAccess.ReadWrite)] - public int MinTime = 45; - - // Maximum time an animal will go without speaking - [DataField, ViewVariables(VVAccess.ReadWrite)] - public int MaxTime = 350; - - // Counter - [DataField, ViewVariables(VVAccess.ReadWrite)] - public float BarkAccumulator = 8f; - - // Multiplier applied to the random time. Good for changing the frequency without having to specify exact values - [DataField, ViewVariables(VVAccess.ReadWrite)] - public float BarkMultiplier = 1f; - - // List of things to be said. Filled with garbage to be modified by an accent, but can be specified in the .yml - [DataField, ViewVariables(VVAccess.ReadWrite)] - public IReadOnlyList Barks = new[] - { - "Bark", - "Boof", - "Woofums", - "Rawrl", - "Eeeeeee", - "Barkums", - "Awooooooooooooooooooo awoo awoooo", - "Grrrrrrrrrrrrrrrrrr", - "Rarrwrarrwr", - "Goddamn I love gold fish crackers", - "Bork bork boof boof bork bork boof boof boof bork", - "Bark", - "Boof", - "Woofums", - "Rawrl", - "Eeeeeee", - "Barkums", - }; -} diff --git a/Content.Server/Parkstation/Speech/Systems/RandomBarkSystem.cs b/Content.Server/Parkstation/Speech/Systems/RandomBarkSystem.cs deleted file mode 100644 index 6f9d1682dd..0000000000 --- a/Content.Server/Parkstation/Speech/Systems/RandomBarkSystem.cs +++ /dev/null @@ -1,47 +0,0 @@ -using Content.Server.Chat.Systems; -using Content.Shared.Mind.Components; -using Robust.Shared.Random; -using Content.Server.Parkstation.Speech.Components; - -namespace Content.Server.Parkstation.Speech.Systems; - -public sealed class RandomBarkSystem : EntitySystem -{ - [Dependency] private readonly IRobustRandom _random = default!; - [Dependency] private readonly ChatSystem _chat = default!; - [Dependency] private readonly EntityManager _entity = default!; - - - public override void Initialize() - { - base.Initialize(); - - SubscribeLocalEvent(OnInit); - } - - - private void OnInit(EntityUid uid, RandomBarkComponent barker, ComponentInit args) - { - barker.BarkAccumulator = _random.NextFloat(barker.MinTime, barker.MaxTime)*barker.BarkMultiplier; - } - - public override void Update(float frameTime) - { - base.Update(frameTime); - - var query = EntityQueryEnumerator(); - while (query.MoveNext(out var uid, out var barker)) - { - barker.BarkAccumulator -= frameTime; - if (barker.BarkAccumulator > 0) - continue; - - barker.BarkAccumulator = _random.NextFloat(barker.MinTime, barker.MaxTime) * barker.BarkMultiplier; - if (_entity.TryGetComponent(uid, out var actComp) && - actComp.HasMind) - continue; - - _chat.TrySendInGameICMessage(uid, _random.Pick(barker.Barks), InGameICChatType.Speak, barker.ChatLog ? ChatTransmitRange.Normal : ChatTransmitRange.HideChat); - } - } -} diff --git a/Content.Shared/Corvax/CCVars/CCCVars.cs b/Content.Shared/Corvax/CCVars/CCCVars.cs deleted file mode 100644 index 371b793d3d..0000000000 --- a/Content.Shared/Corvax/CCVars/CCCVars.cs +++ /dev/null @@ -1,18 +0,0 @@ -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); -}