Horizon Official Technical Documentation
Horizon::Zone::MapComponent Class Reference

#include <MapComponent.hpp>

+ Inheritance diagram for Horizon::Zone::MapComponent:
+ Collaboration diagram for Horizon::Zone::MapComponent:

Public Member Functions

 MapComponent ()
 
 MapComponent (std::shared_ptr< GameLogicProcess > container)
 
 ~MapComponent ()
 
void sync_definitions (std::shared_ptr< sol::state > state)
 
void sync_data_types (std::shared_ptr< sol::state > state)
 
void sync_functions (std::shared_ptr< sol::state > state)
 
- Public Member Functions inherited from Horizon::Zone::LUAComponent
 LUAComponent ()
 
 LUAComponent (std::shared_ptr< GameLogicProcess > container)
 
 ~LUAComponent ()
 
virtual void sync_definitions (std::shared_ptr< sol::state > state)=0
 
virtual void sync_data_types (std::shared_ptr< sol::state > state)=0
 
virtual void sync_functions (std::shared_ptr< sol::state > state)=0
 
std::shared_ptr< GameLogicProcessget_container ()
 

Constructor & Destructor Documentation

◆ MapComponent() [1/2]

Horizon::Zone::MapComponent::MapComponent ( )
inline
42{ }

◆ MapComponent() [2/2]

Horizon::Zone::MapComponent::MapComponent ( std::shared_ptr< GameLogicProcess container)
inline
43: LUAComponent(container) { }
LUAComponent()
Definition: LUAComponent.hpp:42

◆ ~MapComponent()

Horizon::Zone::MapComponent::~MapComponent ( )
inline
44{ }

Member Function Documentation

◆ sync_data_types()

void MapComponent::sync_data_types ( std::shared_ptr< sol::state >  state)
virtual

Implements Horizon::Zone::LUAComponent.

44{
45 sol::usertype<GridCoords> config_1 = state->new_usertype<GridCoords>("GridCoords", sol::constructors<GridCoords(uint16_t, uint16_t)>());
46 config_1["x"] = &GridCoords::x;
47 config_1["y"] = &GridCoords::y;
48 config_1["move_cost"] = &GridCoords::move_cost;
49 config_1["set_move_cost"] = &GridCoords::set_move_cost;
50
51
52 sol::usertype<MapCoords> config_2 = state->new_usertype<MapCoords>("MapCoords",
53 sol::constructors<MapCoords(uint16_t, uint16_t)>());
54 config_2["x"] = &MapCoords::x;
55 config_2["y"] = &MapCoords::y;
56 config_2["move_cost"] = &MapCoords::move_cost;
57 config_2["set_move_cost"] = &MapCoords::set_move_cost;
58
59 sol::usertype<Map> config_3 = state->new_usertype<Map>("Map");
60 config_3["name"] = sol::readonly_property(&Map::get_name);
61 config_3["width"] = sol::readonly_property(&Map::get_width);
62 config_3["height"] = sol::readonly_property(&Map::get_height);
63 config_3["has_obstruction_at"] = &Map::has_obstruction_at;
64 config_3["get_random_coordinates_in_walkable_range"] = &Map::get_random_coordinates_in_walkable_range;
65 config_3["get_random_coordinates_in_walkable_area"] = &Map::get_random_coordinates_in_walkable_area;
66 config_3["add_new_item_drop"] = sol::resolve<void(int, MapCoords, int, int)>(&Map::add_item_drop);
67 config_3["add_unique_item_drop"] = sol::resolve<void(std::shared_ptr<item_entry_data>, int32_t, MapCoords)>(&Map::add_item_drop);
68}
int16_t y() const
Definition: Coordinates.hpp:120
int16_t move_cost() const
Definition: Coordinates.hpp:121
int16_t x() const
Definition: Coordinates.hpp:119
void set_move_cost(int16_t move_cost)
Definition: Coordinates.hpp:122
The class Map is the representation of a map in the game. It contains all the cells and the grid hold...
Definition: Map.hpp:62
void add_item_drop(int item_id, MapCoords map_coords, int amount, int identified)
Definition: Map.cpp:95
std::string const & get_name()
Definition: Map.hpp:69
uint16_t get_width()
Definition: Map.hpp:73
bool has_obstruction_at(int16_t x, int16_t y)
Definition: Map.cpp:67
MapCoords get_random_coordinates_in_walkable_area(uint16_t x, uint16_t y, int16_t xs, int16_t ys)
Definition: Map.hpp:130
uint16_t get_height()
Definition: Map.hpp:74
MapCoords get_random_coordinates_in_walkable_range(uint16_t x, uint16_t y, int16_t min, int16_t max)
Definition: Map.hpp:109

References Horizon::Zone::Map::add_item_drop(), Horizon::Zone::Map::get_height(), Horizon::Zone::Map::get_name(), Horizon::Zone::Map::get_random_coordinates_in_walkable_area(), Horizon::Zone::Map::get_random_coordinates_in_walkable_range(), Horizon::Zone::Map::get_width(), Horizon::Zone::Map::has_obstruction_at(), Coordinates< MAX_GRIDS_PER_MAP >::move_cost(), Coordinates< MAX_CELLS_PER_MAP >::move_cost(), Coordinates< MAX_CELLS_PER_MAP >::set_move_cost(), Coordinates< MAX_GRIDS_PER_MAP >::set_move_cost(), Coordinates< MAX_GRIDS_PER_MAP >::x(), Coordinates< MAX_CELLS_PER_MAP >::x(), Coordinates< MAX_CELLS_PER_MAP >::y(), and Coordinates< MAX_GRIDS_PER_MAP >::y().

+ Here is the call graph for this function:

◆ sync_definitions()

void MapComponent::sync_definitions ( std::shared_ptr< sol::state >  state)
virtual

Implements Horizon::Zone::LUAComponent.

40{
41}

◆ sync_functions()

void MapComponent::sync_functions ( std::shared_ptr< sol::state >  state)
virtual

Implements Horizon::Zone::LUAComponent.

71{
72 // @TODO
73 state->set_function("get_map_by_name",
74 [] (std::string const &name)
75 {
76 int segment_number = sZone->get_segment_number_for_resource<Horizon::Zone::GameLogicProcess, RESOURCE_PRIORITY_PRIMARY, std::string, std::shared_ptr<Map>>(Horizon::System::RUNTIME_GAMELOGIC, name, nullptr);
77
78 if (segment_number == 0)
79 return std::shared_ptr<Map>(nullptr);
80
81 auto resource_manager = sZone->get_component_of_type<GameLogicProcess>(Horizon::System::RUNTIME_GAMELOGIC, segment_number)->get_resource_manager();
82 return resource_manager.template get_resource<RESOURCE_PRIORITY_PRIMARY, std::string, std::shared_ptr<Map>>(name, nullptr);
83 });
84}
@ RESOURCE_PRIORITY_PRIMARY
Definition: Server.hpp:79
#define sZone
Definition: Zone.hpp:247
Definition: GameLogicProcess.hpp:48
@ RUNTIME_GAMELOGIC
Definition: System.hpp:86

References RESOURCE_PRIORITY_PRIMARY, Horizon::System::RUNTIME_GAMELOGIC, and sZone.


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