harvesting units of size>1 should work better ( testing is still needed for this! )
This commit is contained in:
parent
8e281e2faf
commit
401a39c3e1
|
@ -248,9 +248,9 @@ bool Map::isInsideSurface(const Vec2i &sPos) const{
|
|||
}
|
||||
|
||||
//returns if there is a resource next to a unit, in "resourcePos" is stored the relative position of the resource
|
||||
bool Map::isResourceNear(const Vec2i &pos, const ResourceType *rt, Vec2i &resourcePos) const{
|
||||
for(int i=-1; i<=1; ++i){
|
||||
for(int j=-1; j<=1; ++j){
|
||||
bool Map::isResourceNear(const Vec2i &pos, const ResourceType *rt, Vec2i &resourcePos, int size) const{
|
||||
for(int i=-1; i<=size; ++i){
|
||||
for(int j=-1; j<=size; ++j){
|
||||
if(isInside(pos.x+i, pos.y+j)){
|
||||
Resource *r= getSurfaceCell(toSurfCoords(Vec2i(pos.x+i, pos.y+j)))->getResource();
|
||||
if(r!=NULL){
|
||||
|
|
|
@ -196,7 +196,7 @@ public:
|
|||
bool isInside(const Vec2i &pos) const;
|
||||
bool isInsideSurface(int sx, int sy) const;
|
||||
bool isInsideSurface(const Vec2i &sPos) const;
|
||||
bool isResourceNear(const Vec2i &pos, const ResourceType *rt, Vec2i &resourcePos) const;
|
||||
bool isResourceNear(const Vec2i &pos, const ResourceType *rt, Vec2i &resourcePos, int size) const;
|
||||
bool isResourceNear(const Vec2i &pos, int size, const ResourceType *rt, Vec2i &resourcePos) const;
|
||||
|
||||
//free cells
|
||||
|
|
|
@ -492,7 +492,7 @@ void UnitUpdater::updateHarvest(Unit *unit){
|
|||
switch(this->game->getGameSettings()->getPathFinderType()) {
|
||||
case pfBasic:
|
||||
canHarvestDestPos = (unit->getPos().dist(command->getPos())<harvestDistance &&
|
||||
map->isResourceNear(unit->getPos(), r->getType(), targetPos));
|
||||
map->isResourceNear(unit->getPos(), r->getType(), targetPos,unit->getType()->getSize()));
|
||||
break;
|
||||
case pfRoutePlanner:
|
||||
canHarvestDestPos = map->isResourceNear(unit->getPos(), unit->getType()->getSize(), r->getType(), targetPos);
|
||||
|
|
Loading…
Reference in New Issue