MCPcopy Create free account
hub / github.com/bwapi/bwapi / hasPath

Method hasPath

bwapi/BWAPILIB/Source/Unit.cpp:158–188  ·  view source on GitHub ↗

--------------------------------------------- HAS PATH ---------------------------------------------------

Source from the content-addressed store, hash-verified

156 }
157 //--------------------------------------------- HAS PATH ---------------------------------------------------
158 bool UnitInterface::hasPath(Position target) const
159 {
160 Broodwar->setLastError();
161 // Return error if the position is invalid
162 if (!target)
163 return Broodwar->setLastError(Errors::Invalid_Parameter);
164
165 // Return true if this unit is an air unit
166 if (this->isFlying())
167 return true;
168
169 // Return error if this does not exist
170 if (!exists())
171 return Broodwar->setLastError(Errors::Unit_Not_Visible);
172
173 // Check the center of the unit (most common behaviour)
174 if (Broodwar->hasPath(this->getPosition(), target))
175 return true;
176
177 // Otherwise check all four corners of the unit, in case it accidentally fell out of its region
178 if (Broodwar->hasPath(Position(getLeft(), getTop()), target))
179 return true;
180
181 if (Broodwar->hasPath(Position(getRight(), getTop()), target))
182 return true;
183
184 if (Broodwar->hasPath(Position(getLeft(), getBottom()), target))
185 return true;
186
187 return Broodwar->hasPath(Position(getRight(), getBottom()), target);
188 }
189 bool UnitInterface::hasPath(Unit target) const
190 {
191 Broodwar->setLastError();

Callers

nothing calls this directly

Calls 5

isFlyingMethod · 0.95
setLastErrorMethod · 0.80
PositionClass · 0.50
getPositionMethod · 0.45
existsMethod · 0.45

Tested by

no test coverage detected