Make LearnedAttack of Creature a smart pointer.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-05-31 17:26:39 +02:00
parent a7069a5960
commit ff181204ae
8 changed files with 25 additions and 21 deletions

View File

@@ -9,7 +9,7 @@
namespace CreatureLib::Battling {
class AttackTurnChoice : public BaseTurnChoice {
LearnedAttack* _attack;
ArbUt::BorrowedPtr<LearnedAttack> _attack;
CreatureIndex _target;
Script* _attackScript = nullptr;
bool _scriptIsTaken = false;
@@ -34,12 +34,13 @@ namespace CreatureLib::Battling {
}
public:
AttackTurnChoice(Creature* user, LearnedAttack* attack, const CreatureIndex& target)
AttackTurnChoice(Creature* user, const ArbUt::BorrowedPtr<LearnedAttack>& attack, const CreatureIndex& target)
: BaseTurnChoice(user), _attack(attack), _target(target) {
AssertNotNull(attack)
ResolveScript();
}
AttackTurnChoice(Creature* user, LearnedAttack* attack, const CreatureIndex& target, Script* script) noexcept
AttackTurnChoice(Creature* user, const ArbUt::BorrowedPtr<LearnedAttack>& attack, const CreatureIndex& target,
Script* script) noexcept
: BaseTurnChoice(user), _attack(attack), _target(target), _attackScript(script) {}
~AttackTurnChoice() {
@@ -48,7 +49,7 @@ namespace CreatureLib::Battling {
}
}
inline LearnedAttack* GetAttack() const noexcept { return _attack; }
inline const ArbUt::BorrowedPtr<LearnedAttack>& GetAttack() const noexcept { return _attack; }
TurnChoiceKind GetKind() const noexcept override { return TurnChoiceKind ::Attack; }