Cuberite
A lightweight, fast and extensible game server for Minecraft
PathFinder.h
Go to the documentation of this file.
1 
2 #pragma once
3 #include "Path.h"
4 
5 #define WAYPOINT_RADIUS 0.5
6 
12 {
13 
14 public:
19  cPathFinder(float a_MobWidth, float a_MobHeight);
20 
39  ePathFinderStatus GetNextWayPoint(cChunk & a_Chunk, const Vector3d & a_Source, Vector3d * a_Destination, Vector3d * a_OutputWaypoint, bool a_DontCare = false);
40 
41 private:
42 
44  float m_Width;
45 
47  float m_Height;
48 
50  std::unique_ptr<cPath> m_Path;
51 
54 
57 
60 
63 
67 
68 
71 
74 
77 
82  bool EnsureProperPoint(Vector3d & a_Vector, cChunk & a_Chunk);
83 
85  void ResetPathFinding(cChunk &a_Chunk);
86 
88  bool IsWaterOrSolid(BLOCKTYPE a_BlockType);
89 
91  bool PathIsTooOld() const;
92 };
unsigned char BLOCKTYPE
The datatype used by blockdata.
Definition: ChunkDef.h:41
ePathFinderStatus
Definition: Path.h:26
Definition: Chunk.h:36
This class wraps cPath.
Definition: PathFinder.h:12
Vector3d m_DeviationOrigin
When FinalDestination is too far from this, we recalculate.
Definition: PathFinder.h:66
std::unique_ptr< cPath > m_Path
The current cPath instance we have.
Definition: PathFinder.h:50
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.
Definition: PathFinder.cpp:23
bool IsWaterOrSolid(BLOCKTYPE a_BlockType)
Return true the the blocktype is either water or solid.
Definition: PathFinder.cpp:269
Vector3d m_PathDestination
Coordinates for where we are practically going.
Definition: PathFinder.h:62
int m_GiveUpCounter
If 0, will give up reaching the next m_WayPoint and will recalculate path.
Definition: PathFinder.h:53
float m_Height
The height of the Mob which owns this PathFinder.
Definition: PathFinder.h:47
bool m_NoPathToTarget
True if there's no path to target and we're walking to a nearby location instead.
Definition: PathFinder.h:73
Vector3d m_WayPoint
Coordinates of the next position that should be reached.
Definition: PathFinder.h:56
cPathFinder(float a_MobWidth, float a_MobHeight)
Creates a cPathFinder instance.
Definition: PathFinder.cpp:11
Vector3d m_Source
Coordinates for where the mob is currently at.
Definition: PathFinder.h:70
bool PathIsTooOld() const
Is the path too old and should be recalculated? When this is true ResetPathFinding() is called.
Definition: PathFinder.cpp:278
int m_NotFoundCooldown
When a path is not found, this cooldown prevents any recalculations for several ticks.
Definition: PathFinder.h:76
float m_Width
The width of the Mob which owns this PathFinder.
Definition: PathFinder.h:44
Vector3d m_FinalDestination
Coordinates for where we should go.
Definition: PathFinder.h:59
bool EnsureProperPoint(Vector3d &a_Vector, cChunk &a_Chunk)
Ensures the location is not in the air or under water.
Definition: PathFinder.cpp:177
void ResetPathFinding(cChunk &a_Chunk)
Resets a pathfinding task, typically because m_FinalDestination has deviated too much from m_Deviatio...
Definition: PathFinder.cpp:164