29 lines
1001 B
C++
29 lines
1001 B
C++
#ifndef CREATURELIB_SPECIESLIBRARY_HPP
|
|
#define CREATURELIB_SPECIESLIBRARY_HPP
|
|
|
|
#include "BaseLibrary.hpp"
|
|
#include "CreatureData/CreatureSpecies.hpp"
|
|
|
|
namespace CreatureLib::Library {
|
|
class SpeciesLibrary : public BaseLibrary<CreatureSpecies> {
|
|
private:
|
|
ArbUt::Dictionary<u16, ArbUt::BorrowedPtr<const CreatureSpecies>> _valuesById;
|
|
|
|
public:
|
|
SpeciesLibrary(size_t initialCapacity = 32) : BaseLibrary(initialCapacity){};
|
|
|
|
void Insert(const ArbUt::StringView& key, const CreatureSpecies* value) override {
|
|
BaseLibrary::Insert(key, value);
|
|
_valuesById.Insert(value->GetId(), value);
|
|
}
|
|
void Insert(u32 hashedKey, const CreatureSpecies* value) override {
|
|
BaseLibrary::Insert(hashedKey, value);
|
|
_valuesById.Insert(value->GetId(), value);
|
|
}
|
|
|
|
const ArbUt::BorrowedPtr<const CreatureSpecies>& GetById(u16 id) const { return _valuesById[id]; }
|
|
};
|
|
}
|
|
|
|
#endif // CREATURELIB_SPECIESLIBRARY_HPP
|