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
All checks were successful
continuous-integration/drone/push Build is passing
Signed-off-by: Deukhoofd <Deukhoofd@gmail.com>
This commit is contained in:
@@ -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 {};
|
||||
}
|
||||
Reference in New Issue
Block a user