summaryrefslogtreecommitdiffstats
path: root/src/Mobs/Path.h
diff options
context:
space:
mode:
authorSafwat Halaby <SafwatHalaby@users.noreply.github.com>2015-12-16 17:39:23 +0100
committerSafwat Halaby <SafwatHalaby@users.noreply.github.com>2015-12-16 17:39:23 +0100
commit3c1f9e8a3a0c70d82f2145f1e03ba846ad2a6399 (patch)
tree2d9f76057167d166516658f7be4dc3aab82e001d /src/Mobs/Path.h
parentMerge pull request #2754 from Gargaj/horsefix (diff)
parentChanged cPath to have a reset method. (diff)
downloadcuberite-3c1f9e8a3a0c70d82f2145f1e03ba846ad2a6399.tar
cuberite-3c1f9e8a3a0c70d82f2145f1e03ba846ad2a6399.tar.gz
cuberite-3c1f9e8a3a0c70d82f2145f1e03ba846ad2a6399.tar.bz2
cuberite-3c1f9e8a3a0c70d82f2145f1e03ba846ad2a6399.tar.lz
cuberite-3c1f9e8a3a0c70d82f2145f1e03ba846ad2a6399.tar.xz
cuberite-3c1f9e8a3a0c70d82f2145f1e03ba846ad2a6399.tar.zst
cuberite-3c1f9e8a3a0c70d82f2145f1e03ba846ad2a6399.zip
Diffstat (limited to 'src/Mobs/Path.h')
-rw-r--r--src/Mobs/Path.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/Mobs/Path.h b/src/Mobs/Path.h
index 410d6fec5..d133c3669 100644
--- a/src/Mobs/Path.h
+++ b/src/Mobs/Path.h
@@ -76,6 +76,14 @@ public:
/** Creates a dummy path which does nothing except returning false when isValid is called. */
cPath();
+ /** delete default constructors */
+ cPath(const cPath & a_other) = delete;
+ cPath(cPath && a_other) = delete;
+
+ /** delete default assignment operators */
+ cPath & operator=(const cPath & a_other) = delete;
+ cPath & operator=(cPath && a_other) = delete;
+
/** Performs part of the path calculation and returns the appropriate status.
If NEARBY_FOUND is returned, it means that the destination is not reachable, but a nearby destination
is reachable. If the user likes the alternative destination, they can call AcceptNearbyPath to treat the path as found,
@@ -129,6 +137,31 @@ public:
return m_PathPoints.size() - m_CurrentPoint;
}
+ /** Recreates a pathfinder instance. A Mob will probably need a single pathfinder instance for its entire life.
+
+ Note that if you have a man-sized mob (1x1x2, zombies, etc), you are advised to call this function without parameters
+ because the declaration might change in later version of the pathFinder, and a parameter-less call always assumes a man-sized mob.
+
+ If your mob is not man-sized, you are advised to use cPath(width, height), this would be compatible with future versions,
+ but please be aware that as of now those parameters will be ignored and your mob will be assumed to be man sized.
+
+ @param a_BoundingBoxWidth the character's boundingbox width in blocks. Currently the parameter is ignored and 1 is assumed.
+ @param a_BoundingBoxHeight the character's boundingbox width in blocks. Currently the parameter is ignored and 2 is assumed.
+ @param a_MaxUp the character's max jump height in blocks. Currently the parameter is ignored and 1 is assumed.
+ @param a_MaxDown How far is the character willing to fall? Currently the parameter is ignored and 1 is assumed. */
+ /** Attempts to find a path starting from source to destination.
+ After calling this, you are expected to call Step() once per tick or once per several ticks until it returns true. You should then call getPath() to obtain the path.
+ Calling this before a path is found resets the current path and starts another search.
+ @param a_StartingPoint The function expects this position to be the lowest block the mob is in, a rule of thumb: "The block where the Zombie's knees are at".
+ @param a_EndingPoint "The block where the Zombie's knees want to be".
+ @param a_MaxSteps The maximum steps before giving up. */
+ void Reset(
+ cChunk & a_Chunk,
+ const Vector3d & a_StartingPoint, const Vector3d & a_EndingPoint, int a_MaxSteps,
+ double a_BoundingBoxWidth, double a_BoundingBoxHeight,
+ int a_MaxUp = 1, int a_MaxDown = 1
+ );
+
@@ -141,6 +174,11 @@ private:
void FinishCalculation(ePathFinderStatus a_NewStatus); // Clears the memory used for calculating the path and changes the status.
void AttemptToFindAlternative();
void BuildPath();
+ /** Handles all logic associated with reseting the path to a clean state */
+ void ResetImpl(
+ const Vector3d & a_StartingPoint, const Vector3d & a_EndingPoint,
+ double a_BoundingBoxWidth, double a_BoundingBoxHeight
+ );
/* Openlist and closedlist management */
void OpenListAdd(cPathCell * a_Cell);