62 switch (
m_Path->CalculationStep(a_Chunk))
118 if (
m_Path->NoMoreWayPoints())
182 if ((Chunk ==
nullptr) || !Chunk->
IsValid())
193 int YBelowUs =
FloorC(a_Vector.
y) - 1;
202 bool InTheAir =
true;
204 for (z = -1; z <= 1; ++z)
206 for (x = -1; x <= 1; ++x)
208 if ((x == 0) && (z == 0))
213 if ((Chunk ==
nullptr) || !Chunk->
IsValid())
234 while (a_Vector.
y > 0)
275 size_t acceptableDeviation =
m_Path->WayPointsLeft() / 2;
276 if (acceptableDeviation == 0)
278 acceptableDeviation = 1;
bool IsValid(void) const
Returns true iff the chunk block data is valid (loaded / generated)
Vector3d m_DeviationOrigin
When FinalDestination is too far from this, we recalculate.
static bool IsSolid(BLOCKTYPE a_Type)
void GetBlockTypeMeta(Vector3i a_RelPos, BLOCKTYPE &a_BlockType, NIBBLETYPE &a_BlockMeta) const
unsigned char BLOCKTYPE
The datatype used by blockdata.
double m_Height
The height of the Mob which owns this PathFinder.
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
Vector3d m_FinalDestination
Coordinates for where we should go.
bool EnsureProperPoint(Vector3d &a_Vector, cChunk &a_Chunk)
Ensures the location is not in the air or under water.
double m_Width
The width of the Mob which owns this PathFinder.
int m_GiveUpCounter
If 0, will give up reaching the next m_WayPoint and will recalculate path.
bool m_NoPathToTarget
True if there's no path to target and we're walking to a nearby location instead. ...
bool IsWaterOrSolid(BLOCKTYPE a_BlockType)
Return true the the blocktype is either water or solid.
Vector3d m_PathDestination
Coordinates for where we are practically going.
Vector3d m_WayPoint
Coordinates of the next position that should be reached.
bool PathIsTooOld() const
Is the path too old and should be recalculated? When this is true ResetPathFinding() is called...
void ResetPathFinding(cChunk &a_Chunk)
Resets a pathfinding task, typically because m_FinalDestination has deviated too much from m_Deviatio...
ePathFinderStatus GetNextWayPoint(cChunk &a_Chunk, const Vector3d &a_Source, Vector3d *a_Destination, Vector3d *a_OutputWaypoint, bool a_DontCare=false)
Updates the PathFinder's internal state and returns a waypoint.
int m_NotFoundCooldown
When a path is not found, this cooldown prevents any recalculations for several ticks.
cChunk * GetNeighborChunk(int a_BlockX, int a_BlockZ)
Returns the chunk into which the specified block belongs, by walking the neighbors.
Vector3d m_Source
Coordinates for where the mob is currently at.
std::unique_ptr< cPath > m_Path
The current cPath instance we have.
std::enable_if< std::is_arithmetic< T >::value, C >::type FloorC(T a_Value)
Floors a value, then casts it to C (an int by default)
cPathFinder(double a_MobWidth, double a_MobHeight)
Creates a cPathFinder instance.
#define UNREACHABLE(x)
Use to mark code that should be impossible to reach.