mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
- ResourceManager now returns abstract goal so it can be decomposed many times
This commit is contained in:
parent
1450d408a2
commit
e5b979d4ad
@ -716,6 +716,7 @@ TGoalVec Explore::getAllPossibleSubgoals()
|
||||
}
|
||||
}
|
||||
|
||||
auto primaryHero = ai->primaryHero().h;
|
||||
for(auto h : heroes)
|
||||
{
|
||||
auto sm = ai->getCachedSectorMap(h);
|
||||
@ -734,15 +735,18 @@ TGoalVec Explore::getAllPossibleSubgoals()
|
||||
}
|
||||
else
|
||||
{
|
||||
ai->markHeroUnableToExplore(h); //there is no freely accessible tile, do not poll this hero anymore
|
||||
//possible issues when gathering army to break
|
||||
|
||||
if(hero.h == h || (!hero && h == ai->primaryHero().h)) //check this only ONCE, high cost
|
||||
//FIXME: possible issues when gathering army to break
|
||||
if(hero.h == h || //exporation is assigned to this hero
|
||||
(!hero && h == primaryHero)) //not assigned to specific hero, let our main hero do the job
|
||||
{
|
||||
t = ai->explorationDesperate(h);
|
||||
if(t.valid()) //don't waste time if we are completely blocked
|
||||
t = ai->explorationDesperate(h); //check this only ONCE, high cost
|
||||
if (t.valid()) //don't waste time if we are completely blocked
|
||||
{
|
||||
ret.push_back(sptr(Goals::ClearWayTo(t, h).setisAbstract(true)));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
ai->markHeroUnableToExplore(h); //there is no freely accessible tile, do not poll this hero anymore
|
||||
}
|
||||
}
|
||||
//we either don't have hero yet or none of heroes can explore
|
||||
|
@ -150,7 +150,8 @@ Goals::TSubgoal ResourceManager::collectResourcesForOurGoal(ResourceObjective &o
|
||||
if (resourceType == Res::GOLD)
|
||||
goalPriority *= 1000;
|
||||
|
||||
return Goals::sptr(Goals::CollectRes(resourceType, amountToCollect));
|
||||
//this is abstract goal and might take soem time to complete
|
||||
return Goals::sptr(Goals::CollectRes(resourceType, amountToCollect).setisAbstract(true));
|
||||
}
|
||||
|
||||
Goals::TSubgoal ResourceManager::whatToDo() const //suggest any goal
|
||||
|
Loading…
Reference in New Issue
Block a user