Deukhoofd c3bfbb569e
All checks were successful
continuous-integration/drone/push Build is passing
Initial setup for script hooks (likely to be revamped)
2019-11-08 18:45:43 +01:00

35 lines
848 B
C++

#ifndef CREATURELIB_SCRIPTSET_HPP
#define CREATURELIB_SCRIPTSET_HPP
#include <any>
#include <unordered_map>
#include "Script.hpp"
namespace CreatureLib::Battling{
class ScriptSet{
std::unordered_map<std::string, Script*> _scripts;
public:
void Execute(Hook hook, const std::vector<std::any>& args){
for (auto s: _scripts){
s.second->Execute(hook, args);
}
}
void Add(Script* script){
auto f = _scripts.find(script->GetName());
if (f != _scripts.end()){
f->second->Stack();
}
else{
_scripts.insert({script->GetName(), script});
}
}
void Remove(const std::string& key){
_scripts.erase(key);
}
};
}
#endif //CREATURELIB_SCRIPTSET_HPP