04-22-2015, 04:28 PM
(This post was last modified: 04-23-2015, 06:22 AM by LogicParrot.)
Still debugging. In the meanwhile, what do you think of this interface?
I recall you wanted a "dumb device" which receives coordinates are spits out a path. Ideally, this would have been a static class with a single function "getPath".
But I had to make instances because:
I'd love to hear if you have a better proposal.
interface usage example:
I recall you wanted a "dumb device" which receives coordinates are spits out a path. Ideally, this would have been a static class with a single function "getPath".
But I had to make instances because:
- MCserver is threaded, a static function seemed dangerous to me
- A mob might want to spread the load of calculating a path across several ticks, this is impossible with a single static function. A single static function would have to be blocking.
I'd love to hear if you have a better proposal.
cPathFinder(
double a_boundingBoxWidth, // The character's boundingBox Width. (Currently preset to 1, parameter will be ignored)
double a_boundingBoxHeight, // The character's boundingBox Height. (Currently preset to 2, parameter will be ignored)
int a_maxUp, // What is the highest wall this character can climb / jump? (Currently preset to 1, parameter will be ignored)
int a_maxDown // How far down is the character willing to fall? TODO more flexibility here. (Currently preset to 1, parameter will be ignored)
);
~cPathFinder();
void findPath(int a_maxSearch, const Vector3d &a_startingPoint, const Vector3d &a_endingPoint);
bool isCalculationFinished();
cPath* getPath();
interface usage example:
//When a zombie is born...
m_pathFinder=pathFinder(1,2,1,1); //The parameters do nothing because they are not implemented yet
...
//When a zombie wants to attack someone.
pathFinder.findPath(100,myLocation,theirLocation);
//Every tick...
if (pathFinder.isCalculationFinished())
{
myPath=pathFinder.getPath();
//now walk that path.
}

