Make typelibrary be based around the hash value instead of conststring value.
This commit is contained in:
parent
4341efb54c
commit
671077259e
|
@ -16,6 +16,7 @@ float TypeLibrary::GetSingleEffectiveness(uint8_t attacking, uint8_t defensive)
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t TypeLibrary::GetTypeId(const ConstString& key) const { return _types.at(key); }
|
uint8_t TypeLibrary::GetTypeId(const ConstString& key) const { return _types.at(key); }
|
||||||
|
uint8_t TypeLibrary::GetTypeId(uint32_t s) const { return _types.at(s); }
|
||||||
|
|
||||||
uint8_t TypeLibrary::RegisterType(const ConstString& key) {
|
uint8_t TypeLibrary::RegisterType(const ConstString& key) {
|
||||||
_types.insert({key, _types.size()});
|
_types.insert({key, _types.size()});
|
||||||
|
|
|
@ -8,13 +8,14 @@ using ConstString = Arbutils::CaseInsensitiveConstString;
|
||||||
|
|
||||||
namespace CreatureLib::Library {
|
namespace CreatureLib::Library {
|
||||||
class TypeLibrary {
|
class TypeLibrary {
|
||||||
std::unordered_map<ConstString, uint8_t> _types;
|
std::unordered_map<uint32_t, uint8_t> _types;
|
||||||
std::vector<std::vector<float>> _effectiveness;
|
std::vector<std::vector<float>> _effectiveness;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TypeLibrary(size_t initialCapacity = 20) : _types(std::unordered_map<ConstString, uint8_t>(initialCapacity)) {}
|
TypeLibrary(size_t initialCapacity = 20) : _types(std::unordered_map<uint32_t, uint8_t>(initialCapacity)) {}
|
||||||
|
|
||||||
uint8_t GetTypeId(const ConstString& s) const;
|
uint8_t GetTypeId(const ConstString& s) const;
|
||||||
|
uint8_t GetTypeId(uint32_t s) const;
|
||||||
float GetSingleEffectiveness(uint8_t attacking, uint8_t defensive) const;
|
float GetSingleEffectiveness(uint8_t attacking, uint8_t defensive) const;
|
||||||
float GetEffectiveness(uint8_t attacking, const std::vector<uint8_t>& defensive) const;
|
float GetEffectiveness(uint8_t attacking, const std::vector<uint8_t>& defensive) const;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue