The Battle for Wesnoth  1.15.1+dev
Public Member Functions | Static Public Attributes | Private Attributes | List of all members
game_events::entity_location Struct Reference

#include <entity_location.hpp>

Inheritance diagram for game_events::entity_location:
Inheritance graph

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_locationfilter_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 vconfig &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 &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_locationvector_sum_assign (const map_location &a)
 
map_locationvector_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
 
std::pair< int, int > get_in_basis_N_NE () const
 
map_location rotate_right_around_center (const map_location &center, 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  DIRECTION {
  NORTH =0, NORTH_EAST =1, SOUTH_EAST =2, SOUTH =3,
  SOUTH_WEST =4, NORTH_WEST =5, NDIRECTIONS =6
}
 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 const std::vector< DIRECTION > & default_dirs ()
 Default list of directions. More...
 
static DIRECTION rotate_right (DIRECTION d, unsigned int k=1u)
 
static DIRECTION rotate_right (DIRECTION d, signed int k)
 
static DIRECTION get_opposite_dir (DIRECTION d)
 
static DIRECTION parse_direction (const std::string &str)
 
static std::vector< DIRECTIONparse_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_locationZERO ()
 
static const map_locationnull_location ()
 
- Public Attributes inherited from map_location
int x
 
int y
 

Detailed Description

Definition at line 31 of file entity_location.hpp.

Constructor & Destructor Documentation

◆ entity_location() [1/4]

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.

◆ entity_location() [2/4]

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.

◆ entity_location() [3/4]

game_events::entity_location::entity_location ( const unit u)
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.

◆ entity_location() [4/4]

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.

Member Function Documentation

◆ filter_loc()

const map_location& game_events::entity_location::filter_loc ( ) const
inline

◆ get_unit()

unit_const_ptr game_events::entity_location::get_unit ( ) const

◆ matches_unit()

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 game_events::wml_event_pump::filter_event(), filter_loc(), and matches_unit_filter().

◆ matches_unit_filter()

bool game_events::entity_location::matches_unit_filter ( const unit_map::const_iterator un_it,
const vconfig 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 vconfig::empty(), filter_loc_, unit_filter::matches(), matches_unit(), and unit_map::iterator_base< iter_types >::valid().

Referenced by game_events::wml_event_pump::filter_event(), and filter_loc().

Member Data Documentation

◆ filter_loc_

map_location game_events::entity_location::filter_loc_
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 54 of file entity_location.hpp.

Referenced by filter_loc(), and matches_unit_filter().

◆ id_

std::size_t game_events::entity_location::id_
private

The underlying ID of the unit associated with this.

Set to 0 if there is no associated unit.

Definition at line 49 of file entity_location.hpp.

Referenced by get_unit(), and matches_unit().

◆ null_entity

const entity_location game_events::entity_location::null_entity
static

Definition at line 44 of file entity_location.hpp.


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