mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-05-26 22:42:57 +00:00
Inlines restrictCenter and leashRestrictionGoal as value members and stores Path nodes by value, removing per-mob and per-path malloc churn.
42 lines
936 B
C++
42 lines
936 B
C++
#pragma once
|
|
|
|
#include <format>
|
|
#include <memory>
|
|
#include <vector>
|
|
|
|
#include "minecraft/world/level/pathfinder/Node.h"
|
|
#include "minecraft/world/phys/Vec3.h"
|
|
|
|
class Entity;
|
|
|
|
class Path {
|
|
friend class PathFinder;
|
|
|
|
private:
|
|
// Nodes are stored by value. The vector is sized once in the constructor
|
|
// and never resized, so Node* returned by get()/last() remain valid for
|
|
// the lifetime of the Path.
|
|
std::vector<Node> nodes;
|
|
int index;
|
|
int length;
|
|
|
|
public:
|
|
Path(std::vector<Node*>& nodes);
|
|
~Path() = default;
|
|
|
|
void next();
|
|
bool isDone();
|
|
Node* last();
|
|
Node* get(int i);
|
|
int getSize();
|
|
void setSize(int length);
|
|
int getIndex();
|
|
void setIndex(int index);
|
|
Vec3 getPos(std::shared_ptr<Entity> e, int index);
|
|
Vec3 currentPos(std::shared_ptr<Entity> e);
|
|
Vec3 currentPos();
|
|
bool sameAs(Path* path);
|
|
bool endsIn(Vec3* pos);
|
|
bool endsInXZ(Vec3* pos);
|
|
};
|