Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't reset balance on Randomize Everything #820

Merged
merged 2 commits into from
Jan 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
13 changes: 7 additions & 6 deletions Content.Shared/Preferences/HumanoidCharacterProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, JobPriority> _jobPriorities;
private readonly List<string> _antagPreferences;
private readonly List<string> _traitPreferences;
Expand Down Expand Up @@ -112,7 +114,7 @@ public HumanoidCharacterProfile() : this(
18,
Sex.Male,
Gender.Male,
25000,
DefaultBalance,
new HumanoidCharacterAppearance(),
ClothingPreference.Jumpsuit,
BackpackPreference.Backpack,
Expand Down Expand Up @@ -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,
Expand All @@ -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<string>? ignoredSpecies = null)
public static HumanoidCharacterProfile Random(HashSet<string>? ignoredSpecies = null, int balance = DefaultBalance)
{
var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
var random = IoCManager.Resolve<IRobustRandom>();
Expand All @@ -165,17 +167,16 @@ public static HumanoidCharacterProfile Random(HashSet<string>? 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<IPrototypeManager>();
var random = IoCManager.Resolve<IRobustRandom>();

var sex = Sex.Unsexed;
var age = 18;
var balance = 25000;
if (prototypeManager.TryIndex<SpeciesPrototype>(species, out var speciesPrototype))
{
sex = random.Pick(speciesPrototype.Sexes);
Expand Down
Loading