Use hash as key for Species variants, added C interface for Species.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -10,7 +10,10 @@ CreatureSpecies::CreatureSpecies(uint16_t id, const ConstString& name, const Spe
|
||||
bool CreatureSpecies::HasVariant(const ConstString& name) const { return _variants.find(name) != _variants.end(); }
|
||||
|
||||
bool CreatureSpecies::TryGetVariant(const ConstString& name, const SpeciesVariant*& out) const {
|
||||
auto find = _variants.find(name);
|
||||
return TryGetVariant(name.GetHash(), out);
|
||||
}
|
||||
bool CreatureSpecies::TryGetVariant(uint32_t hash, const SpeciesVariant*& out) const {
|
||||
auto find = _variants.find(hash);
|
||||
if (find != _variants.end()) {
|
||||
out = find->second;
|
||||
return true;
|
||||
@@ -18,10 +21,9 @@ bool CreatureSpecies::TryGetVariant(const ConstString& name, const SpeciesVarian
|
||||
return false;
|
||||
}
|
||||
|
||||
const SpeciesVariant* CreatureSpecies::GetVariant(const ConstString& name) const {
|
||||
auto key = name;
|
||||
return _variants.at(key);
|
||||
}
|
||||
const SpeciesVariant* CreatureSpecies::GetVariant(const ConstString& name) const { return _variants.at(name); }
|
||||
const SpeciesVariant* CreatureSpecies::GetVariant(uint32_t key) const { return _variants.at(key); }
|
||||
bool CreatureSpecies::HasVariant(uint32_t hash) const { return _variants.at(hash); }
|
||||
|
||||
void CreatureSpecies::SetVariant(const ConstString& name, const SpeciesVariant* variant) {
|
||||
auto find = _variants.find(name);
|
||||
@@ -37,4 +39,4 @@ Gender CreatureSpecies::GetRandomGender(Arbutils::Random& rand) const {
|
||||
if (val >= this->_genderRate)
|
||||
return Gender ::Female;
|
||||
return Gender ::Male;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user