Skip to content

Commit

Permalink
don't reset balance on Randomize Everything (#820)
Browse files Browse the repository at this point in the history
* don't reset balance on Randomize Everything

* fix typo
  • Loading branch information
lizelive authored Jan 6, 2024
1 parent a3e6322 commit 9fbf4e0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
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

0 comments on commit 9fbf4e0

Please sign in to comment.