2019-10-06 11:50:52 +00:00
|
|
|
#ifndef CREATURELIB_SPECIESLIBRARY_HPP
|
|
|
|
#define CREATURELIB_SPECIESLIBRARY_HPP
|
|
|
|
|
2020-02-15 17:51:21 +00:00
|
|
|
#include "BaseLibrary.hpp"
|
2019-10-06 11:50:52 +00:00
|
|
|
#include "CreatureData/CreatureSpecies.hpp"
|
|
|
|
|
|
|
|
namespace CreatureLib::Library {
|
2020-02-15 17:51:21 +00:00
|
|
|
class SpeciesLibrary : public BaseLibrary<CreatureSpecies> {
|
2019-10-06 11:50:52 +00:00
|
|
|
private:
|
2022-03-23 12:56:45 +00:00
|
|
|
ArbUt::Dictionary<u16, ArbUt::BorrowedPtr<const CreatureSpecies>> _valuesById;
|
2020-08-22 11:24:08 +00:00
|
|
|
|
2019-10-06 11:50:52 +00:00
|
|
|
public:
|
2020-02-15 17:51:21 +00:00
|
|
|
SpeciesLibrary(size_t initialCapacity = 32) : BaseLibrary(initialCapacity){};
|
2020-08-22 11:24:08 +00:00
|
|
|
|
2022-03-23 17:30:35 +00:00
|
|
|
void Insert(const ArbUt::StringView& key, const CreatureSpecies* non_null value) override {
|
2020-08-22 11:24:08 +00:00
|
|
|
BaseLibrary::Insert(key, value);
|
|
|
|
_valuesById.Insert(value->GetId(), value);
|
|
|
|
}
|
2022-03-23 17:30:35 +00:00
|
|
|
void Insert(u32 hashedKey, const CreatureSpecies* non_null value) override {
|
2020-08-22 11:24:08 +00:00
|
|
|
BaseLibrary::Insert(hashedKey, value);
|
|
|
|
_valuesById.Insert(value->GetId(), value);
|
|
|
|
}
|
|
|
|
|
2022-03-23 12:56:45 +00:00
|
|
|
const ArbUt::BorrowedPtr<const CreatureSpecies>& GetById(u16 id) const { return _valuesById[id]; }
|
2019-10-06 11:50:52 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2019-11-28 11:55:22 +00:00
|
|
|
#endif // CREATURELIB_SPECIESLIBRARY_HPP
|