Make LearnedAttack of Creature a smart pointer.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -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; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user