Another rework for scripthooks, for better performance.
All checks were successful
continuous-integration/drone/push Build is passing
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:
@@ -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);
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -17,10 +17,6 @@ namespace CreatureLib::Battling{
|
||||
[[nodiscard]] inline Creature* GetUser() const{
|
||||
return _user;
|
||||
}
|
||||
|
||||
void GetActiveScripts(ScriptAggregator &aggr) const override {
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user