#include <entity_location.hpp>
Public Member Functions | |
entity_location (const map_location &loc, std::size_t id=0) | |
Constructor for when an event has a location but not necessarily a unit. More... | |
entity_location (const map_location &loc, std::size_t id, const map_location &filter_loc) | |
Constructor for when an event has a unit that needs to be filtered as if it was in a different location. More... | |
entity_location (const unit &) | |
Convenience constructor for when an event has a unit, saving the caller the need to explicitly get the location and underlying ID. More... | |
entity_location (const unit &u, const map_location &filter_loc) | |
Convenience constructor for when an event has a unit that needs to be filtered as if it was in a different location, and the caller does not want to explicitly get the unit's location and underlying ID. More... | |
const map_location & | filter_loc () const |
bool | matches_unit (const unit_map::const_iterator &un_it) const |
Determines if un_it matches (using underlying ID) the unit that was supplied when this was constructed. More... | |
bool | matches_unit_filter (const unit_map::const_iterator &un_it, const unit_filter &filter) const |
Determines if un_it matches filter. More... | |
unit_const_ptr | get_unit () const |
Public Member Functions inherited from map_location | |
map_location () | |
map_location (int x, int y) | |
map_location (int x, int y, wml_loc) | |
map_location (const config_attribute_value &x, const config_attribute_value &y, wml_loc) | |
map_location (const config &cfg, const variable_set *variables=nullptr) | |
void | write (config &cfg) const |
bool | valid () const |
bool | valid (const int parWidth, const int parHeight) const |
bool | valid (const int parWidth, const int parHeight, const int border) const |
bool | matches_range (const std::string &xloc, const std::string &yloc) const |
bool | operator< (const map_location &a) const |
bool | operator== (const map_location &a) const |
bool | operator!= (const map_location &a) const |
int | do_compare (const map_location &a) const |
three-way comparator More... | |
map_location | vector_negation () const |
map_location | vector_sum (const map_location &a) const |
map_location & | vector_sum_assign (const map_location &a) |
map_location & | vector_difference_assign (const map_location &a) |
map_location | get_direction (direction dir, unsigned int n=1u) const |
map_location | get_direction (direction dir, signed int n) const |
direction | get_relative_dir (const map_location &loc, map_location::RELATIVE_DIR_MODE mode) const |
direction | get_relative_dir (const map_location &loc) const |
cubic_location | to_cubic () const |
map_location | rotate_right_around_center (const map_location ¢er, int k) const |
int | wml_x () const |
int | wml_y () const |
void | set_wml_x (int v) |
void | set_wml_y (int v) |
void | add (int x_diff, int y_diff) |
map_location | plus (int x_diff, int y_diff) const |
Static Public Attributes | |
static const entity_location | null_entity |
Private Attributes | |
std::size_t | id_ |
The underlying ID of the unit associated with this. More... | |
map_location | filter_loc_ |
This map_location allows a unit to be filtered as if it were somewhere other than where it is. More... | |
Additional Inherited Members | |
Public Types inherited from map_location | |
enum class | direction { north , north_east , south_east , south , south_west , north_west , indeterminate } |
Valid directions which can be moved in our hexagonal world. More... | |
enum | RELATIVE_DIR_MODE { DEFAULT , RADIAL_SYMMETRY } |
Static Public Member Functions inherited from map_location | |
static std::vector< direction > | all_directions () |
static constexpr direction | rotate_direction (direction d, int steps=1) |
Returns the direction one would face having taken steps clockwise around an undefined center. More... | |
static constexpr direction | get_opposite_direction (direction d) |
static direction | parse_direction (const std::string &str) |
static std::vector< direction > | parse_directions (const std::string &str) |
Parse_directions takes a comma-separated list, and filters out any invalid directions. More... | |
static std::string | write_direction (direction dir) |
static std::string | write_translated_direction (direction dir) |
static const map_location & | ZERO () |
static const map_location & | null_location () |
static map_location | from_cubic (cubic_location h) |
Public Attributes inherited from map_location | |
int | x |
int | y |
Definition at line 31 of file entity_location.hpp.
game_events::entity_location::entity_location | ( | const map_location & | loc, |
std::size_t | id = 0 |
||
) |
Constructor for when an event has a location but not necessarily a unit.
Can also be used if the event has a unit and the caller already has the unit's location and underlying ID.
Definition at line 39 of file entity_location.cpp.
game_events::entity_location::entity_location | ( | const map_location & | loc, |
std::size_t | id, | ||
const map_location & | filter_loc | ||
) |
Constructor for when an event has a unit that needs to be filtered as if it was in a different location.
Definition at line 47 of file entity_location.cpp.
|
explicit |
Convenience constructor for when an event has a unit, saving the caller the need to explicitly get the location and underlying ID.
Definition at line 56 of file entity_location.cpp.
game_events::entity_location::entity_location | ( | const unit & | u, |
const map_location & | filter_loc | ||
) |
Convenience constructor for when an event has a unit that needs to be filtered as if it was in a different location, and the caller does not want to explicitly get the unit's location and underlying ID.
Definition at line 67 of file entity_location.cpp.
|
inline |
Definition at line 38 of file entity_location.hpp.
References filter_loc_.
Referenced by game_events::wml_event_pump::operator()().
unit_const_ptr game_events::entity_location::get_unit | ( | ) | const |
Definition at line 106 of file entity_location.cpp.
References unit_map::find(), resources::gameboard, unit_map::iterator_base< iter_types >::get_shared_ptr(), id_, and game_board::units().
Referenced by wfl::event_callable::get_value(), and actions::undo_event::undo_event().
bool game_events::entity_location::matches_unit | ( | const unit_map::const_iterator & | un_it | ) | const |
Determines if un_it matches (using underlying ID) the unit that was supplied when this was constructed.
If no unit was supplied, then all units (including non-existent units) match.
Definition at line 80 of file entity_location.cpp.
References id_, and unit_map::iterator_base< iter_types >::valid().
Referenced by matches_unit_filter().
bool game_events::entity_location::matches_unit_filter | ( | const unit_map::const_iterator & | un_it, |
const unit_filter & | filter | ||
) | const |
Determines if un_it matches filter.
If the filter is not empty, the unit is required to additionally match the unit that was supplied when this was constructed.
Definition at line 91 of file entity_location.cpp.
References unit_filter::empty(), filter_loc_, unit_filter::matches(), matches_unit(), and unit_map::iterator_base< iter_types >::valid().
|
private |
This map_location allows a unit to be filtered as if it were somewhere other than where it is.
(Use the parent struct if you want to locate the unit.)
Definition at line 58 of file entity_location.hpp.
Referenced by filter_loc(), and matches_unit_filter().
|
private |
The underlying ID of the unit associated with this.
Set to 0 if there is no associated unit.
Definition at line 51 of file entity_location.hpp.
Referenced by get_unit(), and matches_unit().
|
static |
Definition at line 44 of file entity_location.hpp.