Furter rework on script hooks, simplifying required logic.
This commit is contained in:
@@ -9,6 +9,7 @@ namespace CreatureLib::Battling{
|
||||
class AttackTurnChoice : public BaseTurnChoice {
|
||||
LearnedAttack* _attack;
|
||||
Target _target;
|
||||
Script* _attackScript;
|
||||
public:
|
||||
AttackTurnChoice(Creature* user, LearnedAttack* attack, const Target& target)
|
||||
: BaseTurnChoice(user), _attack(attack), _target(target){}
|
||||
@@ -29,6 +30,11 @@ namespace CreatureLib::Battling{
|
||||
const Target& GetTarget() const{
|
||||
return _target;
|
||||
}
|
||||
|
||||
void GetActiveScripts(ScriptAggregator &aggr) const override {
|
||||
aggr.Add(_attackScript);
|
||||
GetUser()->GetActiveScripts(aggr);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -2,11 +2,12 @@
|
||||
#define CREATURELIB_BASETURNCHOICE_HPP
|
||||
|
||||
#include "TurnChoiceKind.hpp"
|
||||
#include "../ScriptHandling/ScriptSource.hpp"
|
||||
|
||||
namespace CreatureLib::Battling{
|
||||
class Creature;
|
||||
|
||||
class BaseTurnChoice {
|
||||
class BaseTurnChoice : public ScriptSource {
|
||||
Creature* _user;
|
||||
protected:
|
||||
BaseTurnChoice(Creature* user) : _user(user){};
|
||||
@@ -16,6 +17,10 @@ namespace CreatureLib::Battling{
|
||||
[[nodiscard]] inline Creature* GetUser() const{
|
||||
return _user;
|
||||
}
|
||||
|
||||
void GetActiveScripts(ScriptAggregator &aggr) const override {
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,10 @@ namespace CreatureLib::Battling {
|
||||
TurnChoiceKind GetKind() const override {
|
||||
return TurnChoiceKind ::Pass;
|
||||
}
|
||||
|
||||
void GetActiveScripts(ScriptAggregator &aggr) const override {
|
||||
GetUser()->GetActiveScripts(aggr);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user