Update to latest Arbutils, include stacktrace.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Signed-off-by: Deukhoofd <Deukhoofd@gmail.com>
This commit is contained in:
@@ -103,13 +103,14 @@ namespace CreatureLib::Battling {
|
||||
|
||||
void RegisterEventListener(EventHook::EventHookFunc listener) { this->_eventHook.RegisterListener(listener); }
|
||||
template <EventDataType T, class... parameters> void TriggerEventListener(parameters... args) {
|
||||
this->_eventHook.Trigger<T>(args...);
|
||||
try_creature(this->_eventHook.Trigger<T>(args...);, "Exception occurred during event trigger.");
|
||||
}
|
||||
EventHook& GetEventHook() noexcept { return _eventHook; }
|
||||
const EventHook& GetEventHook() const noexcept { return _eventHook; }
|
||||
|
||||
template <HistoryElementType T, class... parameters> void RegisterHistoryElement(parameters... args) {
|
||||
this->_historyHolder.Register<T>(args...);
|
||||
try_creature(this->_historyHolder.Register<T>(args...);
|
||||
, "Exception occurred during history element registration.");
|
||||
}
|
||||
const HistoryHolder& GetHistory() const noexcept { return _historyHolder; }
|
||||
};
|
||||
|
||||
@@ -36,20 +36,19 @@ namespace CreatureLib::Battling {
|
||||
};
|
||||
|
||||
private:
|
||||
const ArbUt::BorrowedPtr<Creature>* _targets;
|
||||
uint8_t _targetCount;
|
||||
uint8_t _numberHits;
|
||||
std::unique_ptr<HitData[]> _hits;
|
||||
ArbUt::BorrowedPtr<Creature> _user;
|
||||
ArbUt::BorrowedPtr<LearnedAttack> _attack;
|
||||
std::unique_ptr<Script> _script = nullptr;
|
||||
ArbUt::List<ArbUt::BorrowedPtr<Creature>> _targets;
|
||||
|
||||
public:
|
||||
ExecutingAttack(const ArbUt::List<ArbUt::BorrowedPtr<Creature>>& targets, uint8_t numberHits,
|
||||
ArbUt::BorrowedPtr<Creature> user, const ArbUt::BorrowedPtr<LearnedAttack>& attack,
|
||||
const std::unique_ptr<Script>& script)
|
||||
: _targets(targets.RawData()), _targetCount(targets.Count()), _numberHits(numberHits),
|
||||
_hits(std::make_unique<HitData[]>(targets.Count() * numberHits)), _user(user), _attack(attack) {
|
||||
: _numberHits(numberHits), _hits(std::make_unique<HitData[]>(targets.Count() * numberHits)), _user(user),
|
||||
_attack(attack), _targets(targets) {
|
||||
AssertNotNull(user)
|
||||
AssertNotNull(attack)
|
||||
// Take ownership of the script of the attack choice, and give attack choice our initial nullptr.
|
||||
@@ -61,7 +60,7 @@ namespace CreatureLib::Battling {
|
||||
virtual ~ExecutingAttack() noexcept = default;
|
||||
|
||||
HitData& GetHitData(ArbUt::BorrowedPtr<Creature> creature, uint8_t hit) {
|
||||
for (uint8_t i = 0; i < _targetCount; i++) {
|
||||
for (uint8_t i = 0; i < _targets.Count(); i++) {
|
||||
if (_targets[i] == creature) {
|
||||
return _hits[i * _numberHits + hit];
|
||||
}
|
||||
@@ -70,7 +69,7 @@ namespace CreatureLib::Battling {
|
||||
}
|
||||
|
||||
HitData* GetTargetIteratorBegin(ArbUt::BorrowedPtr<Creature> creature) {
|
||||
for (uint8_t i = 0; i < _targetCount; i++) {
|
||||
for (uint8_t i = 0; i < _targets.Count(); i++) {
|
||||
if (_targets[i] == creature) {
|
||||
return &_hits[i * _numberHits];
|
||||
}
|
||||
@@ -79,7 +78,7 @@ namespace CreatureLib::Battling {
|
||||
}
|
||||
|
||||
bool IsCreatureTarget(ArbUt::BorrowedPtr<Creature> creature) noexcept {
|
||||
for (uint8_t i = 0; i < _targetCount; i++) {
|
||||
for (uint8_t i = 0; i < _targets.Count(); i++) {
|
||||
if (_targets[i] == creature) {
|
||||
return true;
|
||||
}
|
||||
@@ -87,9 +86,9 @@ namespace CreatureLib::Battling {
|
||||
return false;
|
||||
}
|
||||
|
||||
inline uint8_t GetTargetCount() const noexcept { return _targetCount; }
|
||||
inline uint8_t GetTargetCount() const noexcept { return _targets.Count(); }
|
||||
|
||||
inline const ArbUt::BorrowedPtr<Creature>* GetTargets() const noexcept { return _targets; }
|
||||
inline const ArbUt::List<ArbUt::BorrowedPtr<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