When changing species, account for gender changes.
continuous-integration/drone/push Build is passing Details

Signed-off-by: Deukhoofd <Deukhoofd@gmail.com>
This commit is contained in:
Deukhoofd 2020-08-13 12:23:49 +02:00
parent 50236f4ece
commit c484c376c3
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
1 changed files with 16 additions and 0 deletions

View File

@ -37,6 +37,22 @@ namespace CreatureLib::Battling {
AssertNotNull(variant);
_species = species;
ChangeVariant(variant);
// If the creature is genderless, but it's new species is not, we want to set its gender
if (_gender != CreatureLib::Library::Gender::Genderless && _species->GetGenderRate() != -1) {
// If we are currently in battle, use the battle random so we can get predictable events.
if (!_battle.IsNull()) {
_gender = _species->GetRandomGender(_battle->GetRandom()->GetRNG());
}
// Else create a new random.
else {
ArbUt::Random rand;
_gender = _species->GetRandomGender(rand);
}
} // Else if the new species is genderless, but the creature has a gender, make the creature genderless.
else if (_species->GetGenderRate() == -1 && _gender != CreatureLib::Library::Gender::Genderless) {
_gender = CreatureLib::Library::Gender::Genderless;
}
}
void Creature::ChangeVariant(const ArbUt::BorrowedPtr<const Library::SpeciesVariant>& variant) {