Building Game Engines
PathFinderComponent Class Reference

#include <PathFinderComponent.hpp>

Inheritance diagram for PathFinderComponent:
Inheritance graph
Collaboration diagram for PathFinderComponent:
Collaboration graph

Public Member Functions

 PathFinderComponent (int *newTileMap)
 construct the pathfinder component with the given tilemap (reference) More...
 
 ~PathFinderComponent ()
 
void check_neighbor_bound (int *m_Tiles, std::vector< Move_n_cost > &neighbors, int TILE_MAP_ROW, int TILE_MAP_COL, Position local, Position neighbor, bool diagonal)
 check if going to a neighbor is valid and record the move cost More...
 
std::vector< Move_n_costget_neighbors (int *m_Tiles, Position local, int data_height, int data_width)
 get all valid neighbors of a given tile More...
 
void find_path (int *m_Tiles, std::unordered_map< Position, Position > &came_from, Position start, Position end)
 plan the path between start and end, and stores the moves into a vector More...
 
void reconstruct_path (int *m_Tiles, std::unordered_map< Position, Position > &came_from, Position start, Position end)
 write down the path lines to a vector More...
 
void PrintMap (int *PathMap)
 debugger for viewing map More...
 
void DrawDebugPath (SDL_Renderer *ren, int enemyCamX, int enemyCamY)
 a visual debugger that draw red squres on the path More...
 
void PlanPath (Position start, Position end)
 trigger the functions that generate paths More...
 
bool arriveTarget (Position currPos)
 determines if the target is arrived at More...
 
Position GetNewDirection (Position curr_grid, Position curr_coord)
 get the moving direction in order to move the object on the path More...
 
Position SeeNextTarget ()
 get the next target for distance checking More...
 
- Public Member Functions inherited from Component
 Component ()
 
 ~Component ()
 

Constructor & Destructor Documentation

◆ PathFinderComponent()

PathFinderComponent::PathFinderComponent ( int *  newTileMap)
inline

construct the pathfinder component with the given tilemap (reference)

◆ ~PathFinderComponent()

PathFinderComponent::~PathFinderComponent ( )
inline

Member Function Documentation

◆ arriveTarget()

bool PathFinderComponent::arriveTarget ( Position  currPos)

determines if the target is arrived at

◆ check_neighbor_bound()

void PathFinderComponent::check_neighbor_bound ( int *  m_Tiles,
std::vector< Move_n_cost > &  neighbors,
int  TILE_MAP_ROW,
int  TILE_MAP_COL,
Position  local,
Position  neighbor,
bool  diagonal 
)

check if going to a neighbor is valid and record the move cost

◆ DrawDebugPath()

void PathFinderComponent::DrawDebugPath ( SDL_Renderer *  ren,
int  enemyCamX,
int  enemyCamY 
)

a visual debugger that draw red squres on the path

◆ find_path()

void PathFinderComponent::find_path ( int *  m_Tiles,
std::unordered_map< Position, Position > &  came_from,
Position  start,
Position  end 
)

plan the path between start and end, and stores the moves into a vector

◆ get_neighbors()

std::vector< Move_n_cost > PathFinderComponent::get_neighbors ( int *  m_Tiles,
Position  local,
int  data_height,
int  data_width 
)

get all valid neighbors of a given tile

◆ GetNewDirection()

Position PathFinderComponent::GetNewDirection ( Position  curr_grid,
Position  curr_coord 
)

get the moving direction in order to move the object on the path

◆ PlanPath()

void PathFinderComponent::PlanPath ( Position  start,
Position  end 
)

trigger the functions that generate paths

◆ PrintMap()

void PathFinderComponent::PrintMap ( int *  PathMap)

debugger for viewing map

◆ reconstruct_path()

void PathFinderComponent::reconstruct_path ( int *  m_Tiles,
std::unordered_map< Position, Position > &  came_from,
Position  start,
Position  end 
)

write down the path lines to a vector

◆ SeeNextTarget()

Position PathFinderComponent::SeeNextTarget ( )

get the next target for distance checking