Store CreatureIndex on Creature, includes helper function to get a creatures party from a battle.
All checks were successful
continuous-integration/drone/push Build is passing

Signed-off-by: Deukhoofd <Deukhoofd@gmail.com>
This commit is contained in:
2021-05-08 11:53:32 +02:00
parent 305eb5efb2
commit 188e88ab80
7 changed files with 35 additions and 7 deletions

View File

@@ -209,3 +209,23 @@ Battle* Battle::Clone() const {
return battle;
}
ArbUt::OptionalBorrowedPtr<BattleParty> Battle::FindPartyForCreature(const ArbUt::BorrowedPtr<Creature>& creature) {
if (creature->IsOnBattleField()) {
auto index = creature->GetBattleIndex();
for (auto& party : _parties) {
if (!party->IsResponsibleForIndex(index)) {
continue;
}
if (party->GetParty()->HasCreature(creature)) {
return party;
}
}
} else {
for (auto& party : _parties) {
if (party->GetParty()->HasCreature(creature)) {
return party;
}
}
}
return {};
}