From 9fbf4e02ac943a09a349d224b0ec9f99089929a0 Mon Sep 17 00:00:00 2001 From: lizelive Date: Sat, 6 Jan 2024 11:48:34 -0800 Subject: [PATCH] don't reset balance on Randomize Everything (#820) * don't reset balance on Randomize Everything * fix typo --- .../Preferences/UI/HumanoidProfileEditor.Random.cs | 2 +- .../Preferences/HumanoidCharacterProfile.cs | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Content.Client/Preferences/UI/HumanoidProfileEditor.Random.cs b/Content.Client/Preferences/UI/HumanoidProfileEditor.Random.cs index c9e184dfc23..b82ce91f45b 100644 --- a/Content.Client/Preferences/UI/HumanoidProfileEditor.Random.cs +++ b/Content.Client/Preferences/UI/HumanoidProfileEditor.Random.cs @@ -9,7 +9,7 @@ public sealed partial class HumanoidProfileEditor private void RandomizeEverything() { - Profile = HumanoidCharacterProfile.Random(); + Profile = HumanoidCharacterProfile.Random(balance : Profile?.BankBalance ?? HumanoidCharacterProfile.DefaultBalance); UpdateControls(); IsDirty = true; } diff --git a/Content.Shared/Preferences/HumanoidCharacterProfile.cs b/Content.Shared/Preferences/HumanoidCharacterProfile.cs index 77e0d60645c..ba138dd3a12 100644 --- a/Content.Shared/Preferences/HumanoidCharacterProfile.cs +++ b/Content.Shared/Preferences/HumanoidCharacterProfile.cs @@ -27,6 +27,8 @@ public sealed partial class HumanoidCharacterProfile : ICharacterProfile public const int MaxNameLength = 32; public const int MaxDescLength = 512; + public const int DefaultBalance = 25000; + private readonly Dictionary _jobPriorities; private readonly List _antagPreferences; private readonly List _traitPreferences; @@ -112,7 +114,7 @@ public HumanoidCharacterProfile() : this( 18, Sex.Male, Gender.Male, - 25000, + DefaultBalance, new HumanoidCharacterAppearance(), ClothingPreference.Jumpsuit, BackpackPreference.Backpack, @@ -140,7 +142,7 @@ public static HumanoidCharacterProfile DefaultWithSpecies(string species = Share 18, Sex.Male, Gender.Male, - 25000, + DefaultBalance, HumanoidCharacterAppearance.DefaultWithSpecies(species), ClothingPreference.Jumpsuit, BackpackPreference.Backpack, @@ -154,7 +156,7 @@ public static HumanoidCharacterProfile DefaultWithSpecies(string species = Share } // TODO: This should eventually not be a visual change only. - public static HumanoidCharacterProfile Random(HashSet? ignoredSpecies = null) + public static HumanoidCharacterProfile Random(HashSet? ignoredSpecies = null, int balance = DefaultBalance) { var prototypeManager = IoCManager.Resolve(); var random = IoCManager.Resolve(); @@ -165,17 +167,16 @@ public static HumanoidCharacterProfile Random(HashSet? ignoredSpecies = .ToArray() ).ID; - return RandomWithSpecies(species); + return RandomWithSpecies(species: species, balance: balance); } - public static HumanoidCharacterProfile RandomWithSpecies(string species = SharedHumanoidAppearanceSystem.DefaultSpecies) + public static HumanoidCharacterProfile RandomWithSpecies(string species = SharedHumanoidAppearanceSystem.DefaultSpecies, int balance = DefaultBalance) { var prototypeManager = IoCManager.Resolve(); var random = IoCManager.Resolve(); var sex = Sex.Unsexed; var age = 18; - var balance = 25000; if (prototypeManager.TryIndex(species, out var speciesPrototype)) { sex = random.Pick(speciesPrototype.Sexes);