When changing species, account for gender changes.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
Signed-off-by: Deukhoofd <Deukhoofd@gmail.com>
This commit is contained in:
parent
50236f4ece
commit
c484c376c3
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue