Capycore Engine  0.1.0
A simple and lightweight game engine written in C++ based on the Unity API architecture.
Loading...
Searching...
No Matches
pathfinding.h
Go to the documentation of this file.
1#pragma once
2
7
26class Pathfinding : public Component {
27 public:
29
32 void update(float dt) override{};
33
45
56
67
75 std::vector<std::reference_wrapper<GameObject>>& get_path();
76
85 std::optional<GraphPosition> find_closest_node(
86 const Vector3& world_position) const;
87
89 std::optional<Vector3> get_origin() const;
91
93 std::optional<Vector3> get_target() const;
95
97 std::optional<std::reference_wrapper<GameObject>> get_target_game_object()
98 const;
100
101 std::string type_name() const override;
102
103 private:
104 std::vector<std::reference_wrapper<GameObject>> path_;
105 std::optional<Vector3> origin_;
106 std::optional<Vector3> target_;
107 std::optional<std::reference_wrapper<GameObject>> target_game_object_;
108
109 std::reference_wrapper<NavigationGraph> get_navigation_graph_component()
110 const;
111 void generate_path_a_star(GraphPosition origin, GraphPosition target);
112};
Base class for all components that can be attached to GameObjects.
Definition component.h:24
Concept to constrain types to be derived from Component.
Definition gameObject.h:33
Component responsible for AI pathfinding using a navigation graph.
Definition pathfinding.h:26
std::optional< Vector3 > get_origin() const
Getters and Setters for origin (positions)
void update(float dt) override
Update is left empty as the pathfinding component does not require per-frame updates.
Definition pathfinding.h:32
Pathfinding & generate_path_to_target()
Pathfinding & set_origin(Vector3 origin)
std::vector< std::reference_wrapper< GameObject > > & get_path()
Retrieves the current path of the AI agent.
std::string type_name() const override
Provides a consistent type name for the component.
Pathfinding & generate_path_to_position()
std::optional< GraphPosition > find_closest_node(const Vector3 &world_position) const
Finds the closest navigation node to the specified world position.
Pathfinding & set_target_game_object(GameObject &target)
Pathfinding & generate_path_to_position(Vector3 origin, Vector3 target)
Generates a path to the specified target GameObject.
std::optional< std::reference_wrapper< GameObject > > get_target_game_object() const
Getters and Setters for target (GameObject)
Pathfinding & generate_path_to_target_game_object()
Generates a path to the current target GameObject using the A* algorithm.
Pathfinding & set_target(Vector3 target)
Pathfinding & generate_path_to_target(Vector3 origin)
Generates a path to the target GameObject using the A* algorithm.
std::optional< Vector3 > get_target() const
Getters and Setters for target (positions)
Represents a 3D vector with x, y, and z components. This class provides basic vector operations such ...
Definition vector3.h:8
Structure representing a position in the navigation graph.
Definition graph.h:29