Renamed Script --> BattleScript, some cleanup on it.
All checks were successful
continuous-integration/drone/push Build is passing

Signed-off-by: Deukhoofd <Deukhoofd@gmail.com>
This commit is contained in:
2021-03-07 10:26:41 +01:00
parent d70c6a224a
commit 5178d5dcc0
25 changed files with 204 additions and 182 deletions

View File

@@ -34,17 +34,17 @@ namespace CreatureLib::Battling {
std::unique_ptr<HitData[]> _hits;
ArbUt::BorrowedPtr<Creature> _user;
ArbUt::BorrowedPtr<LearnedAttack> _attack;
std::unique_ptr<Script> _script = nullptr;
std::unique_ptr<BattleScript> _script = nullptr;
ArbUt::List<ArbUt::OptionalBorrowedPtr<Creature>> _targets;
public:
ExecutingAttack(const ArbUt::List<ArbUt::OptionalBorrowedPtr<Creature>>& targets, uint8_t numberHits,
ArbUt::BorrowedPtr<Creature> user, const ArbUt::BorrowedPtr<LearnedAttack>& attack,
const std::unique_ptr<Script>& script)
const std::unique_ptr<BattleScript>& script)
: _numberHits(numberHits), _hits(std::make_unique<HitData[]>(targets.Count() * numberHits)), _user(user),
_attack(attack), _targets(targets) {
// Take ownership of the script of the attack choice, and give attack choice our initial nullptr.
_script.swap(const_cast<std::unique_ptr<Script>&>(script));
_script.swap(const_cast<std::unique_ptr<BattleScript>&>(script));
}
ExecutingAttack(const ExecutingAttack&) = delete;
ExecutingAttack& operator=(const ExecutingAttack&) = delete;
@@ -97,7 +97,7 @@ namespace CreatureLib::Battling {
inline const ArbUt::BorrowedPtr<LearnedAttack>& GetAttack() noexcept { return _attack; }
size_t ScriptCount() const override { return _user->ScriptCount() + 1; }
inline ArbUt::BorrowedPtr<Script> GetScript() const noexcept { return _script; }
inline ArbUt::BorrowedPtr<BattleScript> GetScript() const noexcept { return _script; }
protected:
void GetActiveScripts(ArbUt::List<ScriptWrapper>& scripts) override {