CreatureLib/src/Library/AttackLibrary.hpp

33 lines
963 B
C++
Raw Normal View History

2019-10-06 11:50:52 +00:00
#ifndef CREATURELIB_ATTACKLIBRARY_HPP
#define CREATURELIB_ATTACKLIBRARY_HPP
#include <string>
#include <unordered_map>
#include "Attacks/AttackData.hpp"
namespace CreatureLib::Library {
class AttackLibrary {
private:
std::unordered_map<std::string, const AttackData*> _attacks;
2019-10-06 11:50:52 +00:00
public:
AttackLibrary(size_t initialCapacity = 32)
: _attacks(std::unordered_map<std::string, const AttackData*>(initialCapacity)){};
2019-10-06 11:50:52 +00:00
~AttackLibrary() {
for (auto attack : _attacks) {
2019-10-31 12:30:22 +00:00
delete attack.second;
}
2019-10-06 11:50:52 +00:00
_attacks.clear();
}
[[nodiscard]] const AttackData* GetAttack(const std::string& name) const;
[[nodiscard]] const AttackData* operator[](const std::string& name) const;
2019-10-06 11:50:52 +00:00
void LoadAttack(const std::string& name, const AttackData* attack);
void DeleteAttack(const std::string& name);
};
}
#endif // CREATURELIB_ATTACKLIBRARY_HPP