From c1439eb6fcf665095c2d3cac913bf8fead1e8ac6 Mon Sep 17 00:00:00 2001 From: RavMorgan <48182970+RavMorgan@users.noreply.github.com> Date: Tue, 16 May 2023 14:55:14 +0300 Subject: [PATCH] =?UTF-8?q?=D0=92=D1=81=D1=8F=D0=BA=D0=BE=D0=B5=20(#66)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Mona Hmiza <> --- .../UI/HumanoidProfileEditor.Random.cs | 9 +++- .../UI/HumanoidProfileEditor.xaml.cs | 43 +++++++++++++------ 2 files changed, 39 insertions(+), 13 deletions(-) diff --git a/Content.Client/Preferences/UI/HumanoidProfileEditor.Random.cs b/Content.Client/Preferences/UI/HumanoidProfileEditor.Random.cs index c2510a3582..8bdea84c9c 100644 --- a/Content.Client/Preferences/UI/HumanoidProfileEditor.Random.cs +++ b/Content.Client/Preferences/UI/HumanoidProfileEditor.Random.cs @@ -1,3 +1,5 @@ +using System.Linq; +using Content.Shared.Humanoid.Prototypes; using Content.Shared.Preferences; using Robust.Shared.Prototypes; @@ -9,7 +11,12 @@ namespace Content.Client.Preferences.UI private void RandomizeEverything() { - Profile = HumanoidCharacterProfile.Random(); + var species = _prototypeManager.EnumeratePrototypes(); + + //Пиздец + var ignoredSpecies = species.Except(_speciesList).Select(x=> x.ID).ToHashSet(); + + Profile = HumanoidCharacterProfile.Random(ignoredSpecies); UpdateControls(); IsDirty = true; } diff --git a/Content.Client/Preferences/UI/HumanoidProfileEditor.xaml.cs b/Content.Client/Preferences/UI/HumanoidProfileEditor.xaml.cs index f8dfca1bad..e6431c9da5 100644 --- a/Content.Client/Preferences/UI/HumanoidProfileEditor.xaml.cs +++ b/Content.Client/Preferences/UI/HumanoidProfileEditor.xaml.cs @@ -207,24 +207,41 @@ namespace Content.Client.Preferences.UI #region Species + //WD EDIT _speciesList = prototypeManager.EnumeratePrototypes().Where(o => o.RoundStart).ToList(); + if (_sponsorsManager.TryGetInfo(out var sponsor)) + { + for (int i = _speciesList.Count - 1; i >= 0; i--) + { + var specie = _speciesList[i]; + + if (specie.SponsorOnly && !sponsor.AllowedMarkings.Contains(specie.ID)) + { + _speciesList.RemoveAt(i); + } + } + } + else + { + for (int i = _speciesList.Count - 1; i >= 0; i--) + { + var specie = _speciesList[i]; + + if (specie.SponsorOnly) + { + _speciesList.RemoveAt(i); + } + } + } + //WD EDIT END + for (var i = 0; i < _speciesList.Count; i++) { - //WD EDIT - var specie = _speciesList[i]; + + var specie = _speciesList[i]; // WD EDIT var name = Loc.GetString(specie.Name); - if (specie.SponsorOnly) - { - if(_sponsorsManager.TryGetInfo(out var info) && info.AllowedMarkings.Contains(specie.ID)) - { - CSpeciesButton.AddItem(name, i); - } - continue; - } - - //WD EDIT CSpeciesButton.AddItem(name, i); } @@ -1005,6 +1022,8 @@ namespace Content.Client.Preferences.UI return; } + var species = _prototypeManager.EnumeratePrototypes(); + CSpeciesButton.Select(_speciesList.FindIndex(x => x.ID == Profile.Species)); }