Implement basic library class that other libraries inherit from for performance.
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:
@@ -4,31 +4,11 @@
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include "Attacks/AttackData.hpp"
|
||||
|
||||
#include "BaseLibrary.hpp"
|
||||
namespace CreatureLib::Library {
|
||||
class AttackLibrary {
|
||||
private:
|
||||
std::unordered_map<std::string, const AttackData*> _attacks;
|
||||
|
||||
class AttackLibrary : public BaseLibrary<AttackData> {
|
||||
public:
|
||||
AttackLibrary(size_t initialCapacity = 32)
|
||||
: _attacks(std::unordered_map<std::string, const AttackData*>(initialCapacity)){};
|
||||
|
||||
virtual ~AttackLibrary() {
|
||||
for (auto attack : _attacks) {
|
||||
delete attack.second;
|
||||
}
|
||||
_attacks.clear();
|
||||
}
|
||||
|
||||
[[nodiscard]] bool TryGetAttack(const std::string& name, const AttackData*& move) const;
|
||||
[[nodiscard]] const AttackData* GetAttack(const std::string& name) const;
|
||||
[[nodiscard]] const AttackData* operator[](const std::string& name) const;
|
||||
|
||||
void LoadAttack(const std::string& name, const AttackData* attack);
|
||||
void DeleteAttack(const std::string& name);
|
||||
|
||||
const std::unordered_map<std::string, const AttackData*>& GetIterator() { return _attacks; }
|
||||
AttackLibrary(size_t initialCapacity = 32) : BaseLibrary(initialCapacity){};
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user