From ef0ac9f2e5a306788a208cfeafa82d4b53e957d3 Mon Sep 17 00:00:00 2001 From: ThereDrD <88589686+ThereDrD0@users.noreply.github.com> Date: Wed, 28 Aug 2024 08:20:16 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B5=D1=84=D0=B0=D0=BA=D1=82=D0=BE?= =?UTF-8?q?=D1=80=20=D0=B0=D1=81=D0=BF=D0=B5=D0=BA=D1=82=D0=BE=D0=B2,=20?= =?UTF-8?q?=D0=BD=D0=B5=D0=BC=D0=BD=D0=BE=D0=B3=D0=BE=20=D0=BF=D0=BE=D1=82?= =?UTF-8?q?=D1=8B=D0=BA=D0=B0=D0=BB=20=D0=B7=D0=BD=D0=B0=D1=87=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B9=20(#670)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * aspects update * aspects mini refactor --- .../AspectsSystem/Aspects/AiRunLockAspect.cs | 1 - .../AspectsSystem/Base/AspectComponent.cs | 40 ++- .../AspectsSystem/Commands/AspectCommands.cs | 251 ++++++++++-------- .../AspectsSystem/Managers/AspectManager.cs | 8 + .../Prototypes/_White/Aspects/Aspects.yml | 136 +++++----- 5 files changed, 235 insertions(+), 201 deletions(-) diff --git a/Content.Server/_White/AspectsSystem/Aspects/AiRunLockAspect.cs b/Content.Server/_White/AspectsSystem/Aspects/AiRunLockAspect.cs index 84f7ea3816..b9c956fbf9 100644 --- a/Content.Server/_White/AspectsSystem/Aspects/AiRunLockAspect.cs +++ b/Content.Server/_White/AspectsSystem/Aspects/AiRunLockAspect.cs @@ -1,4 +1,3 @@ -using Content.Server.GameTicking.Rules.Components; using Content.Server._White.AspectsSystem.Aspects.Components; using Content.Server._White.AspectsSystem.Base; using Content.Server.GameTicking.Components; diff --git a/Content.Server/_White/AspectsSystem/Base/AspectComponent.cs b/Content.Server/_White/AspectsSystem/Base/AspectComponent.cs index 6424def8ef..0caf162d08 100644 --- a/Content.Server/_White/AspectsSystem/Base/AspectComponent.cs +++ b/Content.Server/_White/AspectsSystem/Base/AspectComponent.cs @@ -1,39 +1,29 @@ using Robust.Shared.Audio; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom; -namespace Content.Server._White.AspectsSystem.Base +namespace Content.Server._White.AspectsSystem.Base; + +[RegisterComponent] +public sealed partial class AspectComponent : Component { - [RegisterComponent] - public sealed partial class AspectComponent : Component - { - [DataField("name")] - public string? Name; + [DataField] public string? Name; - [DataField("description")] - public string? Description; + [DataField] public string? Description; - [DataField("requires")] - public string? Requires; + [DataField] public string? Requires; - [DataField("weight")] - public float Weight = 1.0f; + [DataField] public float Weight = 1.0f; - [DataField("forbidden")] - public bool IsForbidden; + [DataField] public bool IsForbidden; - [DataField("hidden")] - public bool IsHidden; + [DataField] public bool IsHidden; - [DataField("startAudio")] - public SoundSpecifier? StartAudio; + [DataField] public SoundSpecifier? StartAudio; - [DataField("endAudio")] - public SoundSpecifier? EndAudio; + [DataField] public SoundSpecifier? EndAudio; - [DataField("startDelay")] - public TimeSpan StartDelay = TimeSpan.Zero; + [DataField] public TimeSpan StartDelay = TimeSpan.Zero; - [DataField("startTime", customTypeSerializer: typeof(TimeOffsetSerializer))] - public TimeSpan StartTime; - } + [DataField(customTypeSerializer: typeof(TimeOffsetSerializer))] + public TimeSpan StartTime; } diff --git a/Content.Server/_White/AspectsSystem/Commands/AspectCommands.cs b/Content.Server/_White/AspectsSystem/Commands/AspectCommands.cs index 8cc4ee35ad..0888d77ff9 100644 --- a/Content.Server/_White/AspectsSystem/Commands/AspectCommands.cs +++ b/Content.Server/_White/AspectsSystem/Commands/AspectCommands.cs @@ -1,145 +1,182 @@ +using System.Linq; using Content.Server.Administration; using Content.Server.GameTicking; using Content.Server._White.AspectsSystem.Managers; using Content.Shared.Administration; using Robust.Shared.Console; -namespace Content.Server._White.AspectsSystem.Commands +namespace Content.Server._White.AspectsSystem.Commands; + +[AdminCommand(AdminFlags.Fun)] +public sealed class ForceAspectCommand : IConsoleCommand { - [AdminCommand(AdminFlags.Fun)] - public sealed class ForceAspectCommand : IConsoleCommand + [Dependency] private readonly IEntityManager _entityManager = default!; + + public string Command => "forceaspect"; + public string Description => "Принудительно форсит аспект по его ID."; + public string Help => "forceaspect "; + + public void Execute(IConsoleShell shell, string argStr, string[] args) { - public string Command => "forceaspect"; - public string Description => "Принудительно форсит аспект по его ID."; - public string Help => "forceaspect "; + var ticker = _entityManager.System(); - public void Execute(IConsoleShell shell, string argStr, string[] args) + if (ticker.RunLevel != GameRunLevel.PreRoundLobby) { - var ticker = EntitySystem.Get(); - if (ticker.RunLevel != GameRunLevel.PreRoundLobby) - { - shell.WriteLine("This can only be executed while the game is in the pre-round lobby."); - return; - } - - if (args.Length != 1) - { - shell.WriteError("Использование: forceaspect "); - return; - } - - var aspectId = args[0]; - var aspectManager = EntitySystem.Get(); - var result = aspectManager.ForceAspect(aspectId); - shell.WriteLine(result); + shell.WriteLine("This can only be executed while the game is in the pre-round lobby."); + return; } + + if (args.Length != 1) + { + shell.WriteError("Использование: forceaspect "); + return; + } + + var aspectManager = _entityManager.System(); + + var aspectId = args[0]; + var result = aspectManager.ForceAspect(aspectId); + shell.WriteLine(result); } - [AdminCommand(AdminFlags.Fun)] - public sealed class DeForceAspectCommand : IConsoleCommand + public CompletionResult GetCompletion(IConsoleShell shell, string[] args) { - public string Command => "deforceaspect"; - public string Description => "Дефорсит принудительно установленный аспект."; - public string Help => "deforceaspect"; + if (args.Length != 1) + return CompletionResult.Empty; - public void Execute(IConsoleShell shell, string argStr, string[] args) - { - var ticker = EntitySystem.Get(); - if (ticker.RunLevel != GameRunLevel.PreRoundLobby) - { - shell.WriteLine("This can only be executed while the game is in the pre-round lobby."); - return; - } + var aspectManager = _entityManager.System(); - var aspectManager = EntitySystem.Get(); - var result = aspectManager.DeForceAspect(); - shell.WriteLine(result); - } + var options = aspectManager + .GetAspectsPrototypesId() + .Select(p => new CompletionOption(p.Key.ID, p.Value.Name)) + .OrderBy(p => p.Value); + + return CompletionResult.FromHintOptions(options, Loc.GetString("forcemap-command-arg-map")); } +} - [AdminCommand(AdminFlags.Fun)] - public sealed class GetForcedAspectCommand : IConsoleCommand +[AdminCommand(AdminFlags.Fun)] +public sealed class DeForceAspectCommand : IConsoleCommand +{ + [Dependency] private readonly IEntityManager _entityManager = default!; + + public string Command => "deforceaspect"; + public string Description => "Дефорсит принудительно установленный аспект."; + public string Help => "deforceaspect"; + + public void Execute(IConsoleShell shell, string argStr, string[] args) { - public string Command => "getforcedaspect"; - public string Description => "Получает информацию о принудительно установленном аспекте."; - public string Help => "getforcedaspect"; + var ticker = _entityManager.System(); - public void Execute(IConsoleShell shell, string argStr, string[] args) + if (ticker.RunLevel != GameRunLevel.PreRoundLobby) { - var ticker = EntitySystem.Get(); - if (ticker.RunLevel != GameRunLevel.PreRoundLobby) - { - shell.WriteLine("This can only be executed while the game is in the pre-round lobby."); - return; - } - - var aspectManager = EntitySystem.Get(); - var result = aspectManager.GetForcedAspect(); - shell.WriteLine(result); + shell.WriteLine("This can only be executed while the game is in the pre-round lobby."); + return; } + + var aspectManager = _entityManager.System(); + + var result = aspectManager.DeForceAspect(); + shell.WriteLine(result); } +} - [AdminCommand(AdminFlags.Fun)] - public sealed class ListAspectsCommand : IConsoleCommand +[AdminCommand(AdminFlags.Fun)] +public sealed class GetForcedAspectCommand : IConsoleCommand +{ + [Dependency] private readonly IEntityManager _entityManager = default!; + + public string Command => "getforcedaspect"; + public string Description => "Получает информацию о принудительно установленном аспекте."; + public string Help => "getforcedaspect"; + + public void Execute(IConsoleShell shell, string argStr, string[] args) { - public string Command => "listaspects"; - public string Description => "Список всех доступных аспектов."; - public string Help => "listaspects"; + var ticker = _entityManager.System(); - public void Execute(IConsoleShell shell, string argStr, string[] args) + if (ticker.RunLevel != GameRunLevel.PreRoundLobby) { - var aspectManager = EntitySystem.Get(); - var aspectIds = aspectManager.GetAllAspectIds(); - - if (aspectIds.Count == 0) - { - shell.WriteLine("Нет доступных аспектов."); - } - else - { - shell.WriteLine("Список доступных аспектов:"); - foreach (var aspectId in aspectIds) - { - shell.WriteLine(aspectId); - } - } + shell.WriteLine("This can only be executed while the game is in the pre-round lobby."); + return; } + + var aspectManager = _entityManager.System(); + + var result = aspectManager.GetForcedAspect(); + shell.WriteLine(result); } +} - [AdminCommand(AdminFlags.Fun)] - public sealed class RunAspectCommand : IConsoleCommand +[AdminCommand(AdminFlags.Fun)] +public sealed class ListAspectsCommand : IConsoleCommand +{ + [Dependency] private readonly IEntityManager _entityManager = default!; + + public string Command => "listaspects"; + public string Description => "Список всех доступных аспектов."; + public string Help => "listaspects"; + + public void Execute(IConsoleShell shell, string argStr, string[] args) { - public string Command => "runaspect"; - public string Description => "Запускает аспект по его ID."; - public string Help => "runaspect "; + var aspectManager = _entityManager.System(); - public void Execute(IConsoleShell shell, string argStr, string[] args) + var aspectIds = aspectManager.GetAllAspectIds(); + + if (aspectIds.Count == 0) { - if (args.Length != 1) - { - shell.WriteError("Использование: runaspect "); - return; - } - - var aspectId = args[0]; - var aspectManager = EntitySystem.Get(); - var result = aspectManager.RunAspect(aspectId); - shell.WriteLine(result); + shell.WriteLine("Нет доступных аспектов."); } - } - - [AdminCommand(AdminFlags.Fun)] - public sealed class RunRandomAspectCommand : IConsoleCommand - { - public string Command => "runrandomaspect"; - public string Description => "Запускает случайный аспект."; - public string Help => "runrandomaspect"; - - public void Execute(IConsoleShell shell, string argStr, string[] args) + else { - var aspectManager = EntitySystem.Get(); - var result = aspectManager.RunRandomAspect(); - shell.WriteLine(result); + shell.WriteLine("Список доступных аспектов:"); + foreach (var aspectId in aspectIds) + { + shell.WriteLine(aspectId); + } } } } + +[AdminCommand(AdminFlags.Fun)] +public sealed class RunAspectCommand : IConsoleCommand +{ + [Dependency] private readonly IEntityManager _entityManager = default!; + + public string Command => "runaspect"; + public string Description => "Запускает аспект по его ID."; + public string Help => "runaspect "; + + public void Execute(IConsoleShell shell, string argStr, string[] args) + { + if (args.Length != 1) + { + shell.WriteError("Использование: runaspect "); + return; + } + + var aspectId = args[0]; + + var aspectManager = _entityManager.System(); + + var result = aspectManager.RunAspect(aspectId); + shell.WriteLine(result); + } +} + +[AdminCommand(AdminFlags.Fun)] +public sealed class RunRandomAspectCommand : IConsoleCommand +{ + [Dependency] private readonly IEntityManager _entityManager = default!; + + public string Command => "runrandomaspect"; + public string Description => "Запускает случайный аспект."; + public string Help => "runrandomaspect"; + + public void Execute(IConsoleShell shell, string argStr, string[] args) + { + var aspectManager = _entityManager.System(); + + var result = aspectManager.RunRandomAspect(); + shell.WriteLine(result); + } +} diff --git a/Content.Server/_White/AspectsSystem/Managers/AspectManager.cs b/Content.Server/_White/AspectsSystem/Managers/AspectManager.cs index 53e4b24a85..fb750f95c8 100644 --- a/Content.Server/_White/AspectsSystem/Managers/AspectManager.cs +++ b/Content.Server/_White/AspectsSystem/Managers/AspectManager.cs @@ -1,3 +1,4 @@ +using System.Linq; using Content.Server.GameTicking; using Content.Server._White.AspectsSystem.Base; using Content.Shared.GameTicking; @@ -193,6 +194,13 @@ namespace Content.Server._White.AspectsSystem.Managers return aspectIds; } + public Dictionary GetAspectsPrototypesId() + { + var availableAspects = AllAspects(); + + return availableAspects; + } + /// /// Runs the specified aspect and adds it as a game rule. /// diff --git a/Resources/Prototypes/_White/Aspects/Aspects.yml b/Resources/Prototypes/_White/Aspects/Aspects.yml index 13037e37de..720599bdf0 100644 --- a/Resources/Prototypes/_White/Aspects/Aspects.yml +++ b/Resources/Prototypes/_White/Aspects/Aspects.yml @@ -4,8 +4,8 @@ noSpawn: true components: - type: Aspect - name: "Акценты вне контроля" - description: "Всегда интересно, какой акцент вы услышите следующим." + name: Акценты вне контроля + description: Всегда интересно, какой акцент вы услышите следующим weight: 3 startAudio: path: /Audio/White/Aspects/accent.ogg @@ -17,8 +17,8 @@ noSpawn: true components: - type: Aspect - name: "Fast and Furious" - description: "Люди спешат и не важно куда." + name: Fast and Furious + description: Люди спешат и не важно куда weight: 3 startAudio: path: /Audio/White/Aspects/accent.ogg @@ -30,8 +30,8 @@ noSpawn: true components: - type: Aspect - name: "Random appearance" - description: "Экипаж перестал узнавать друг-друга в лицо." + name: Random appearance + description: Экипаж перестал узнавать друг-друга в лицо weight: 3 startAudio: path: /Audio/White/Aspects/accent.ogg @@ -43,9 +43,9 @@ noSpawn: true components: - type: Aspect - name: "Bombass" - description: "Кто-то заложил мины на станции!" - weight: 1 + name: Bombass + description: Кто-то заложил мины на станции! + weight: 2 startAudio: path: /Audio/White/Aspects/accent.ogg - type: BombassAspect @@ -56,8 +56,8 @@ noSpawn: true components: - type: Aspect - name: "Drunk" - description: "На станции стоит явный запах вчерашнего веселья... и кажется оно только начинается." + name: Drunk + description: На станции стоит явный запах вчерашнего веселья... и кажется оно только начинается weight: 3 startAudio: path: /Audio/White/Aspects/accent.ogg @@ -69,8 +69,8 @@ noSpawn: true components: - type: Aspect - name: "Cargo Rich" - description: "Карго работало усердно в прошлую смену, за что они и были награждены премией в размере 100000 кредитов." + name: Cargo Rich + description: Карго работало усердно в прошлую смену, за что они и были награждены премией в размере 100000 кредитов weight: 2 startAudio: path: /Audio/White/Aspects/accent.ogg @@ -82,11 +82,11 @@ noSpawn: true components: - type: Aspect - name: "Traitored" - description: "Кто-то сдал всех предателей!" - requires: "Traitors" + name: Traitored + description: Кто-то сдал всех предателей! + requires: Traitors weight: 1 - hidden: true + isHidden: true - type: TraitoredAspect - type: entity @@ -95,8 +95,8 @@ noSpawn: true components: - type: Aspect - name: "Weak Walls" - description: "На стенах явно экономили." + name: Weak Walls + description: На стенах явно экономили weight: 2 startAudio: path: /Audio/White/Aspects/accent.ogg @@ -108,8 +108,8 @@ noSpawn: true components: - type: Aspect - name: "No engine" - description: "Какой-то смышлённый агент синдиката решил украсть все ваши генераторы энергии целиком." + name: No engine + description: Какой-то смышлённый агент синдиката решил украсть все ваши генераторы энергии целиком weight: 2 startAudio: path: /Audio/White/Aspects/accent.ogg @@ -121,11 +121,12 @@ noSpawn: true components: - type: Aspect - name: "Airunlock" - description: "Кого волнует безопасность? Экипаж свободно может ходить по всем отсекам, ведь все шлюзы теперь для них доступны." + name: Airunlock + description: Кого волнует безопасность? Экипаж свободно может ходить по всем отсекам, ведь все шлюзы теперь для них доступны weight: 2 startAudio: path: /Audio/White/Aspects/accent.ogg + isForbidden: true - type: AiRunLockAspect - type: entity @@ -134,9 +135,9 @@ noSpawn: true components: - type: Aspect - name: "Bloody" - description: "В эту смену любая незначительная травма может оказаться летальной." - weight: 1 + name: Bloody + description: В эту смену любая незначительная травма может оказаться летальной + weight: 2 startAudio: path: /Audio/White/Aspects/accent.ogg - type: BloodyAspect @@ -147,8 +148,8 @@ noSpawn: true components: - type: Aspect - name: "Weak" - description: "Удары стали слабее. Пули мягче. К чему это приведёт?" + name: Weak + description: Удары стали слабее. Пули мягче. К чему это приведёт? weight: 1 startAudio: path: /Audio/White/Aspects/accent.ogg @@ -160,8 +161,8 @@ noSpawn: true components: - type: Aspect - name: "Battled" - description: "Люди очень насторожены и готовы дать отпор в любую секунду." + name: Battled + description: Люди очень насторожены и готовы дать отпор в любую секунду weight: 1 startAudio: path: /Audio/White/Aspects/accent.ogg @@ -173,8 +174,8 @@ noSpawn: true components: - type: Aspect - name: "I Have Two Butts But I must Seat" - description: "Стулья украли!" + name: I Have Two Butts But I must Seat + description: Стулья украли! weight: 3 startAudio: path: /Audio/White/Aspects/accent.ogg @@ -186,9 +187,9 @@ noSpawn: true components: - type: Aspect - name: "Presents" - description: "А вы верите в Деда Мороза?" - weight: 2 + name: Presents + description: А вы верите в Деда Мороза? + weight: 3 startAudio: path: /Audio/White/Aspects/accent.ogg - type: PresentAspect @@ -199,12 +200,11 @@ noSpawn: true components: - type: Aspect - name: "Dance" - description: "Танцуют все!" + name: Dance + description: Танцуют все! weight: 3 startAudio: path: /Audio/White/Aspects/accent.ogg - forbidden: true - type: DancingAspect - type: entity @@ -213,8 +213,8 @@ noSpawn: true components: - type: Aspect - name: "Reflect" - description: "Ваше отражение повсюду." + name: Reflect + description: Ваше отражение повсюду weight: 2 startAudio: path: /Audio/White/Aspects/accent.ogg @@ -226,8 +226,8 @@ noSpawn: true components: - type: Aspect - name: "Slippery" - description: "Постарайтесь не поскальзываться!" + name: Slippery + description: Постарайтесь не поскальзываться! weight: 2 startAudio: path: /Audio/White/Aspects/accent.ogg @@ -239,11 +239,11 @@ noSpawn: true components: - type: Aspect - name: "Extra TC" - description: "Синдикат выделил 10 дополнительных телекристаллов для предателей." - requires: "Traitors" - weight: 2 - hidden: true + name: Extra TC + description: Синдикат выделил 10 дополнительных телекристаллов для предателей + requires: Traitors + weight: 3 + isHidden: true - type: TraitorRichAspect - type: entity @@ -252,12 +252,12 @@ noSpawn: true components: - type: Aspect - name: "Whisper" - description: "Из-за боли в горле речь дается вам с трудом." + name: Whisper + description: Из-за боли в горле речь дается вам с трудом weight: 3 startAudio: path: /Audio/White/Aspects/accent.ogg - forbidden: true + isForbidden: true - type: WhisperAspect - type: entity @@ -266,8 +266,8 @@ noSpawn: true components: - type: Aspect - name: "Darkness" - description: "Почему все так темно?" + name: Darkness + description: Почему все так темно? weight: 2 startAudio: path: /Audio/White/Aspects/accent.ogg @@ -279,8 +279,8 @@ noSpawn: true components: - type: Aspect - name: "Stolen Floor" - description: "Рабочие забыли положить плитку при строительстве станции." + name: Stolen Floor + description: Рабочие забыли положить плитку при строительстве станции weight: 3 startAudio: path: /Audio/White/Aspects/accent.ogg @@ -292,8 +292,8 @@ noSpawn: true components: - type: Aspect - name: "Are We In Dungeon" - description: "В связи с невероятной хрупкостью окон было решено заменить их на стены." + name: Are We In Dungeon + description: В связи с невероятной хрупкостью окон было решено заменить их на стены weight: 3 startAudio: path: /Audio/White/Aspects/accent.ogg @@ -305,8 +305,8 @@ noSpawn: true components: - type: Aspect - name: "Cat Ears And Tail" - description: "Из-за ошибки в системе клонирования на ЦК все члены экипажа стали походить на фелинидов." + name: Cat Ears And Tail + description: Из-за ошибки в системе клонирования на ЦК все члены экипажа стали походить на фелинидов weight: 3 startAudio: path: /Audio/White/Aspects/accent.ogg @@ -318,11 +318,11 @@ noSpawn: true components: - type: Aspect - name: "Nothing" - description: "Ничего." + name: Nothing + description: Ничего weight: 3 - forbidden: true - hidden: true + isForbidden: true + isHidden: true - type: NothingAspect - type: entity @@ -331,8 +331,8 @@ noSpawn: true components: - type: Aspect - name: "Random item" - description: "ЦК выдало каждому члену экипажа определённый предмет." + name: Random item + description: ЦК выдало каждому члену экипажа определённый предмет weight: 3 startAudio: path: /Audio/White/Aspects/accent.ogg @@ -344,8 +344,8 @@ noSpawn: true components: - type: Aspect - name: "Immersive" - description: "В связи с недавними трагичными событиями экипаж станции погрузился в себя" + name: Immersive + description: В связи с недавними трагичными событиями экипаж станции погрузился в себя weight: 3 startAudio: path: /Audio/White/Aspects/accent.ogg @@ -358,8 +358,8 @@ # noSpawn: true # components: # - type: Aspect -# name: "Skeletons" -# description: "АЧК АЧК!" +# name: Skeletons +# description: АЧК АЧК! # weight: 1 # startAudio: # path: /Audio/White/Aspects/accent.ogg