4 #include "../BlockInfo.h"
13 m_Height(a_MobHeight),
63 switch (
m_Path->CalculationStep(a_Chunk))
119 if (
m_Path->NoMoreWayPoints())
183 if ((Chunk ==
nullptr) || !Chunk->
IsValid())
202 constexpr std::array<Vector3i, 8> Offsets =
217 bool InTheAir =
true;
218 for (
const auto & Offset : Offsets)
220 auto InspectPos = Below + Offset;
222 if ((Chunk ==
nullptr) || !Chunk->
IsValid())
230 BelowRel = InspectRel;
280 size_t acceptableDeviation =
m_Path->WayPointsLeft() / 2;
281 if (acceptableDeviation == 0)
283 acceptableDeviation = 1;
286 return (DeviationSqr > (acceptableDeviation * acceptableDeviation));
@ E_BLOCK_STATIONARY_WATER
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
unsigned char BLOCKTYPE
The datatype used by blockdata.
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).
static bool IsSolid(BLOCKTYPE Block)
Is this block solid (player cannot walk through)?
cChunk * GetNeighborChunk(int a_BlockX, int a_BlockZ)
Returns the chunk into which the specified block belongs, by walking the neighbors.
bool IsValid(void) const
Returns true iff the chunk block data is valid (loaded / generated)
void GetBlockTypeMeta(Vector3i a_RelPos, BLOCKTYPE &a_BlockType, NIBBLETYPE &a_BlockMeta) const
static bool IsValidHeight(Vector3i a_BlockPosition)
Validates a height-coordinate.
static void AbsoluteToRelative(int &a_X, int &a_Y, int &a_Z, int &a_ChunkX, int &a_ChunkZ)
Converts absolute block coords into relative (chunk + block) coords:
Vector3d m_DeviationOrigin
When FinalDestination is too far from this, we recalculate.
std::unique_ptr< cPath > m_Path
The current cPath instance we have.
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.
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.
int m_GiveUpCounter
If 0, will give up reaching the next m_WayPoint and will recalculate path.
float m_Height
The height of the Mob which owns this PathFinder.
bool m_NoPathToTarget
True if there's no path to target and we're walking to a nearby location instead.
Vector3d m_WayPoint
Coordinates of the next position that should be reached.
cPathFinder(float a_MobWidth, float a_MobHeight)
Creates a cPathFinder instance.
Vector3d m_Source
Coordinates for where the mob is currently at.
bool PathIsTooOld() const
Is the path too old and should be recalculated? When this is true ResetPathFinding() is called.
int m_NotFoundCooldown
When a path is not found, this cooldown prevents any recalculations for several ticks.
float m_Width
The width of the Mob which owns this PathFinder.
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.
void ResetPathFinding(cChunk &a_Chunk)
Resets a pathfinding task, typically because m_FinalDestination has deviated too much from m_Deviatio...
Vector3< T > addedY(T a_AddY) const
Returns a copy of this vector moved by the specified amount on the y axis.
Vector3< int > Floor(void) const
Returns a new Vector3i with coords set to std::floor() of this vector's coords.