Added functions for battle to manipulate volatile scripts.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
428483e73d
commit
65f054bfab
|
@ -75,6 +75,11 @@ namespace CreatureLib::Battling {
|
|||
inline const BattleResult& GetResult() const { return _battleResult; }
|
||||
|
||||
const std::vector<BattleSide*>& GetSides() const { return _sides; }
|
||||
Script* GetVolatileScript(const std::string& key) const { return _volatile.Get(key); }
|
||||
void AddVolatileScript(const std::string& key) {
|
||||
auto script = _library->LoadScript(ScriptResolver::ScriptCategory::Battle, key);
|
||||
return _volatile.Add(script);
|
||||
}
|
||||
|
||||
void RegisterEventListener(EVENT_HOOK_FUNC(listener)) { this->_eventHook.RegisterListener(listener); }
|
||||
void TriggerEventListener(EventData* data) { this->_eventHook.TriggerEvent(data); }
|
||||
|
|
|
@ -21,12 +21,21 @@ namespace CreatureLib::Battling {
|
|||
auto f = _lookup.find(script->GetName());
|
||||
if (f != _lookup.end()) {
|
||||
_scripts[f.operator*().second]->Stack();
|
||||
delete script;
|
||||
return;
|
||||
}
|
||||
_scripts.push_back(script);
|
||||
_lookup.insert({script->GetName(), _scripts.size() - 1});
|
||||
}
|
||||
|
||||
Script* Get(const std::string& key) const {
|
||||
auto f = _lookup.find(key);
|
||||
if (f != _lookup.end()) {
|
||||
return _scripts[f->second];
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void Remove(const std::string& key) {
|
||||
auto find = _lookup.find(key);
|
||||
if (find != _lookup.end()) {
|
||||
|
|
Loading…
Reference in New Issue