|
Capycore Engine
0.1.0
A simple and lightweight game engine written in C++ based on the Unity API architecture.
|
Component responsible for AI pathfinding using a navigation graph. More...
#include <pathfinding.h>
Public Member Functions | |
| Pathfinding () | |
| void | update (float dt) override |
| Update is left empty as the pathfinding component does not require per-frame updates. | |
| Pathfinding & | generate_path_to_position (Vector3 origin, Vector3 target) |
| Generates a path to the specified target GameObject. | |
| Pathfinding & | generate_path_to_position () |
| Pathfinding & | generate_path_to_target (Vector3 origin) |
| Generates a path to the target GameObject using the A* algorithm. | |
| Pathfinding & | generate_path_to_target () |
| Pathfinding & | generate_path_to_target_game_object () |
| Generates a path to the current target GameObject using the A* algorithm. | |
| std::vector< std::reference_wrapper< GameObject > > & | get_path () |
| Retrieves the current path of the AI agent. | |
| std::optional< GraphPosition > | find_closest_node (const Vector3 &world_position) const |
| Finds the closest navigation node to the specified world position. | |
| std::optional< Vector3 > | get_origin () const |
| Getters and Setters for origin (positions) | |
| Pathfinding & | set_origin (Vector3 origin) |
| std::optional< Vector3 > | get_target () const |
| Getters and Setters for target (positions) | |
| Pathfinding & | set_target (Vector3 target) |
| std::optional< std::reference_wrapper< GameObject > > | get_target_game_object () const |
| Getters and Setters for target (GameObject) | |
| Pathfinding & | set_target_game_object (GameObject &target) |
| std::string | type_name () const override |
| Provides a consistent type name for the component. | |
Public Member Functions inherited from Component | |
| Component () | |
| virtual | ~Component ()=default |
| bool | active () const noexcept |
| Checks if the component is active. | |
| Component & | active (bool value) noexcept |
| bool | marked_for_deletion () const noexcept |
| Activates the component. | |
| Component & | mark_for_deletion () noexcept |
| virtual void | on_attach () |
| Called when the component is attached to a GameObject. | |
| virtual void | on_detach () |
| Called when the component is detached from a GameObject. | |
| virtual void | on_serialize (std::vector< uint8_t > &) const |
| Serializes the component's state into a byte array. | |
| virtual void | on_deserialize (const std::vector< uint8_t > &, size_t &) |
| Deserializes the component's state from a byte array. | |
| const std::optional< std::reference_wrapper< GameObject > > & | parent () const noexcept |
| Gets the parent GameObject of this component. | |
| std::optional< std::reference_wrapper< GameObject > > & | parent () noexcept |
| Gets the parent GameObject of this component. | |
| Component & | parent (GameObject &parent) |
| Component & | parent (std::nullopt_t nullopt) |
| size_t | add_on_attach (const std::function< void(Component &)> &action) |
| Retrieves the type information of the component. | |
| void | remove_on_attach (size_t index) |
| size_t | add_on_detach (const std::function< void(Component &)> &action) |
| Adds an action to be performed when the component is attached. | |
| void | remove_on_detach (size_t index) |
Component responsible for AI pathfinding using a navigation graph.
This component generates paths for AI-controlled GameObjects to navigate through the environment based on a NavigationGraph.
NOTE: This component requires a NavigationGraph component to be present on the same GameObject to function correctly.
Usage:
| Pathfinding::Pathfinding | ( | ) |
| std::optional< GraphPosition > Pathfinding::find_closest_node | ( | const Vector3 & | world_position | ) | const |
Finds the closest navigation node to the specified world position.
| world_position | The world position to find the closest navigation node to. |
| Pathfinding & Pathfinding::generate_path_to_position | ( | ) |
| Pathfinding & Pathfinding::generate_path_to_position | ( | Vector3 | origin, |
| Vector3 | target | ||
| ) |
Generates a path to the specified target GameObject.
| target | The target GameObject to generate a path to. |
| Pathfinding & Pathfinding::generate_path_to_target | ( | ) |
| Pathfinding & Pathfinding::generate_path_to_target | ( | Vector3 | origin | ) |
Generates a path to the target GameObject using the A* algorithm.
| Pathfinding & Pathfinding::generate_path_to_target_game_object | ( | ) |
Generates a path to the current target GameObject using the A* algorithm.
| std::optional< Vector3 > Pathfinding::get_origin | ( | ) | const |
Getters and Setters for origin (positions)
| std::vector< std::reference_wrapper< GameObject > > & Pathfinding::get_path | ( | ) |
Retrieves the current path of the AI agent.
| std::optional< Vector3 > Pathfinding::get_target | ( | ) | const |
Getters and Setters for target (positions)
| std::optional< std::reference_wrapper< GameObject > > Pathfinding::get_target_game_object | ( | ) | const |
Getters and Setters for target (GameObject)
| Pathfinding & Pathfinding::set_origin | ( | Vector3 | origin | ) |
| Pathfinding & Pathfinding::set_target | ( | Vector3 | target | ) |
| Pathfinding & Pathfinding::set_target_game_object | ( | GameObject & | target | ) |
|
overridevirtual |
Provides a consistent type name for the component.
Implements Component.
|
inlineoverridevirtual |
Update is left empty as the pathfinding component does not require per-frame updates.
Implements Component.