Another rework for scripthooks, for better performance.
All checks were successful
continuous-integration/drone/push Build is passing

This new version caches pointers to the pointers to scripts, so that we can build the data once and then simply iterate over it whenever we want to run a hook.
This commit is contained in:
2019-11-10 17:08:42 +01:00
parent e1a8d80863
commit d8332f9e40
19 changed files with 118 additions and 72 deletions

View File

@@ -31,10 +31,12 @@ namespace CreatureLib::Battling{
return _target;
}
void GetActiveScripts(ScriptAggregator &aggr) const override {
aggr.Add(_attackScript);
GetUser()->GetActiveScripts(aggr);
protected:
void GetActiveScripts(std::vector<ScriptWrapper> &scripts) override {
scripts.emplace_back(&_attackScript);
GetUser()->GetActiveScripts(scripts);
}
};
}

View File

@@ -17,10 +17,6 @@ namespace CreatureLib::Battling{
[[nodiscard]] inline Creature* GetUser() const{
return _user;
}
void GetActiveScripts(ScriptAggregator &aggr) const override {
}
};
}

View File

@@ -12,8 +12,9 @@ namespace CreatureLib::Battling {
return TurnChoiceKind ::Pass;
}
void GetActiveScripts(ScriptAggregator &aggr) const override {
GetUser()->GetActiveScripts(aggr);
protected:
void GetActiveScripts(std::vector<ScriptWrapper> &scripts) override {
GetUser()->GetActiveScripts(scripts);
}
};
}