Performance improvement for running turns by reducing the number of lookups for the hitdata.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-04-25 20:20:30 +02:00
parent f602ea9358
commit 94d9d4f3d2
2 changed files with 11 additions and 1 deletions

View File

@@ -69,6 +69,15 @@ namespace CreatureLib::Battling {
throw CreatureException("Invalid target requested.");
}
std::vector<HitData>::iterator GetTargetIteratorBegin(Creature* creature) {
for (size_t i = 0; i < _targets.Count(); i++) {
if (_targets[i] == creature) {
return _hits.begin() + (i * _numberHits);
}
}
throw CreatureException("Invalid target requested.");
}
bool IsCreatureTarget(Creature* creature) noexcept { return _targets.IndexOf(creature) != (size_t)-1; }
const List<Creature*>& GetTargets() noexcept { return _targets; }
uint8_t GetNumberOfHits() const noexcept { return _numberHits; }