Furter rework on script hooks, simplifying required logic.

This commit is contained in:
2019-11-10 14:32:05 +01:00
parent f72fd5f905
commit 3488784409
18 changed files with 79 additions and 37 deletions

View File

@@ -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);
}
};
}

View File

@@ -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 {
}
};
}

View File

@@ -11,6 +11,10 @@ namespace CreatureLib::Battling {
TurnChoiceKind GetKind() const override {
return TurnChoiceKind ::Pass;
}
void GetActiveScripts(ScriptAggregator &aggr) const override {
GetUser()->GetActiveScripts(aggr);
}
};
}