1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-23 22:37:55 +02:00

API for wandering heroes access

This commit is contained in:
Ivan Savenko
2023-04-17 15:17:15 +03:00
parent 3eac6f323e
commit 5cbd0f8fc8
6 changed files with 119 additions and 80 deletions

View File

@@ -150,3 +150,30 @@ void PlayerLocalState::setHeroAwaken(const CGHeroInstance * hero)
vstd::erase(sleepingHeroes, hero);
}
const std::vector<const CGHeroInstance *> & PlayerLocalState::getWanderingHeroes()
{
return wanderingHeroes;
}
const CGHeroInstance * PlayerLocalState::getWanderingHero(size_t index)
{
if (index < wanderingHeroes.size())
return wanderingHeroes[index];
return nullptr;
}
void PlayerLocalState::addWanderingHero(const CGHeroInstance * hero)
{
assert(hero);
assert(!vstd::contains(wanderingHeroes, hero));
wanderingHeroes.push_back(hero);
}
void PlayerLocalState::removeWanderingHero(const CGHeroInstance * hero)
{
assert(hero);
assert(vstd::contains(wanderingHeroes, hero));
vstd::erase(wanderingHeroes, hero);
vstd::erase(sleepingHeroes, hero);
}