Overhaul memory model to new Arbutils memory.
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
Signed-off-by: Deukhoofd <Deukhoofd@gmail.com>
This commit is contained in:
@@ -35,10 +35,10 @@ namespace CreatureLib::Battling {
|
||||
ArbUt::BorrowedPtr<Creature> _user;
|
||||
ArbUt::BorrowedPtr<LearnedAttack> _attack;
|
||||
std::unique_ptr<Script> _script = nullptr;
|
||||
ArbUt::List<ArbUt::BorrowedPtr<Creature>> _targets;
|
||||
ArbUt::List<ArbUt::OptionalBorrowedPtr<Creature>> _targets;
|
||||
|
||||
public:
|
||||
ExecutingAttack(const ArbUt::List<ArbUt::BorrowedPtr<Creature>>& targets, uint8_t numberHits,
|
||||
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)
|
||||
: _numberHits(numberHits), _hits(std::make_unique<HitData[]>(targets.Count() * numberHits)), _user(user),
|
||||
@@ -55,7 +55,10 @@ namespace CreatureLib::Battling {
|
||||
|
||||
HitData& GetHitData(ArbUt::BorrowedPtr<Creature> creature, uint8_t hit) {
|
||||
for (uint8_t i = 0; i < _targets.Count(); i++) {
|
||||
if (_targets[i] == creature) {
|
||||
if (!_targets[i].HasValue()) {
|
||||
continue;
|
||||
}
|
||||
if (_targets[i].GetValue() == creature) {
|
||||
return _hits[i * _numberHits + hit];
|
||||
}
|
||||
}
|
||||
@@ -64,7 +67,10 @@ namespace CreatureLib::Battling {
|
||||
|
||||
HitData* GetTargetIteratorBegin(ArbUt::BorrowedPtr<Creature> creature) {
|
||||
for (uint8_t i = 0; i < _targets.Count(); i++) {
|
||||
if (_targets[i] == creature) {
|
||||
if (!_targets[i].HasValue()) {
|
||||
continue;
|
||||
}
|
||||
if (_targets[i].GetValue() == creature) {
|
||||
return &_hits[i * _numberHits];
|
||||
}
|
||||
}
|
||||
@@ -73,7 +79,10 @@ namespace CreatureLib::Battling {
|
||||
|
||||
bool IsCreatureTarget(ArbUt::BorrowedPtr<Creature> creature) noexcept {
|
||||
for (uint8_t i = 0; i < _targets.Count(); i++) {
|
||||
if (_targets[i] == creature) {
|
||||
if (!_targets[i].HasValue()) {
|
||||
continue;
|
||||
}
|
||||
if (_targets[i].GetValue() == creature) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -82,7 +91,7 @@ namespace CreatureLib::Battling {
|
||||
|
||||
inline uint8_t GetTargetCount() const noexcept { return _targets.Count(); }
|
||||
|
||||
inline const ArbUt::List<ArbUt::BorrowedPtr<Creature>>& GetTargets() const noexcept { return _targets; }
|
||||
inline const ArbUt::List<ArbUt::OptionalBorrowedPtr<Creature>>& GetTargets() const noexcept { return _targets; }
|
||||
inline uint8_t GetNumberOfHits() const noexcept { return _numberHits; }
|
||||
|
||||
inline const ArbUt::BorrowedPtr<Creature>& GetUser() noexcept { return _user; }
|
||||
|
||||
Reference in New Issue
Block a user