Capycore Engine  0.1.0
A simple and lightweight game engine written in C++ based on the Unity API architecture.
Loading...
Searching...
No Matches
NavigationNode Class Reference

Component representing a navigation node in a navigation graph. More...

#include <navigation_node.h>

Inheritance diagram for NavigationNode:
[legend]

Public Member Functions

 NavigationNode ()
 
void update (float dt) override
 Update is left empty as navigation nodes do not require per-frame updates.
 
NavigationNodeadd_edge (NavigationNode &neighbor, float cost)
 Adds a neighboring node with the specified movement cost.
 
const std::vector< Edge > & get_edges () const
 Retrieves the edges (connections) to neighboring nodes.
 
std::optional< std::reference_wrapper< Edge > > get_edge_to (const NavigationNode &neighbor) const
 Retrieves the edge to a specific neighboring node, if it exists.
 
GraphPosition position () const noexcept
 Gets the graph position of this navigation node.
 
NavigationNodeposition (const GraphPosition &position)
 Sets the graph position of this navigation node.
 
std::string type_name () const override
 Provides a consistent type name for the component.
 
- Public Member Functions inherited from Renderable
 Renderable ()
 
 Renderable (int layer)
 
 ~Renderable () override=default
 
Renderableorder_in_layer (int layer)
 
int order_in_layer () const
 
void set_render_strategy (Component &component)
 
virtual IRenderingStrategyrender_strategy () const
 
std::string type_name () const override
 Provides a consistent type name for the component.
 
Renderabledisable_draw () noexcept
 
Renderableenable_draw () noexcept
 
bool should_draw () const noexcept
 
- Public Member Functions inherited from Component
 Component ()
 
virtual ~Component ()=default
 
bool active () const noexcept
 Checks if the component is active.
 
Componentactive (bool value) noexcept
 
bool marked_for_deletion () const noexcept
 Activates the component.
 
Componentmark_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.
 
Componentparent (GameObject &parent)
 
Componentparent (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)
 

Additional Inherited Members

- Protected Attributes inherited from Renderable
std::unique_ptr< IRenderingStrategyrender_strategy_
 
int ordering_layer_ = 0
 
bool draw {true}
 

Detailed Description

Component representing a navigation node in a navigation graph.

This component holds references to neighboring nodes and associated movement costs. It is used in AI pathfinding to navigate through a graph of nodes.

Usage:

  • Create NavigationNode components and attach them to GameObjects.
  • Use add_edge() to connect nodes and define movement costs.
  • Retrieve edges and positions for pathfinding algorithms.
    Note
    NavigationNode components are typically used in conjunction with the the NavigationGraph.

Constructor & Destructor Documentation

◆ NavigationNode()

NavigationNode::NavigationNode ( )

Member Function Documentation

◆ add_edge()

NavigationNode & NavigationNode::add_edge ( NavigationNode neighbor,
float  cost 
)

Adds a neighboring node with the specified movement cost.

Parameters
neighborReference to the neighboring NavigationNode.
costThe cost associated with moving to the neighbor.
Returns
Reference to the NavigationNode instance for method chaining.

◆ get_edge_to()

std::optional< std::reference_wrapper< Edge > > NavigationNode::get_edge_to ( const NavigationNode neighbor) const

Retrieves the edge to a specific neighboring node, if it exists.

Parameters
neighborReference to the neighboring NavigationNode.
Returns
An optional reference to the Edge if the edge exists, std::nullopt otherwise.

◆ get_edges()

const std::vector< Edge > & NavigationNode::get_edges ( ) const

Retrieves the edges (connections) to neighboring nodes.

Returns
A constant reference to the vector of Edge representing the edges.

◆ position() [1/2]

GraphPosition NavigationNode::position ( ) const
noexcept

Gets the graph position of this navigation node.

Returns
The GraphPosition of the navigation node.

◆ position() [2/2]

NavigationNode & NavigationNode::position ( const GraphPosition position)

Sets the graph position of this navigation node.

Parameters
positionThe GraphPosition to set.
Returns
Reference to the NavigationNode instance for method chaining.

◆ type_name()

std::string NavigationNode::type_name ( ) const
overridevirtual

Provides a consistent type name for the component.

Returns
A string representing the type name of the component. @CAUTION: All derived components must implement this method to ensure consistent serialization across different compilers and platforms.

Implements Component.

◆ update()

void NavigationNode::update ( float  dt)
inlineoverridevirtual

Update is left empty as navigation nodes do not require per-frame updates.

Implements Component.


The documentation for this class was generated from the following file: