Merge remote-tracking branch 'upstream/master' into ups

This commit is contained in:
Jabak
2024-07-24 19:13:19 +03:00
88 changed files with 2043 additions and 422 deletions

View File

@@ -227,16 +227,31 @@ namespace Content.Shared.Preferences
}
// 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, bool includeSponsor = false)
{
var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
var random = IoCManager.Resolve<IRobustRandom>();
// WD edit - fix free sponsor species
var speciesToIgnore = ignoredSpecies != null
? new HashSet<string>(ignoredSpecies)
: new HashSet<string>();
if (!includeSponsor)
{
var sponsorSpecies = prototypeManager.EnumeratePrototypes<SpeciesPrototype>()
.Where(x => x.SponsorOnly)
.Select(x => x.ID);
speciesToIgnore.UnionWith(sponsorSpecies);
}
var species = random.Pick(prototypeManager
.EnumeratePrototypes<SpeciesPrototype>()
.Where(x => ignoredSpecies == null ? x.RoundStart : x.RoundStart && !ignoredSpecies.Contains(x.ID))
.Where(x => !x.SponsorOnly && x.RoundStart && !speciesToIgnore.Contains(x.ID))
.ToArray()
).ID;
// WD edit end
return RandomWithSpecies(species);
}