The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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, size_t id=0)
 Constructor for when an event has a location but not necessarily a unit. More...
 
 entity_location (const map_location &loc, 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...
 
int filter_x () const
 
int filter_y () 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 (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
 Inline vector ops. More...
 
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 d, unsigned int n=1u) const
 
map_location get_direction (DIRECTION d, signed int n) const
 Get Direction function. More...
 
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, intget_in_basis_N_NE () const
 
map_location rotate_right_around_center (const map_location &center, int k) const
 

Static Public Attributes

static const entity_location null_entity
 

Private Attributes

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)
 Inlined bodies. More...
 
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 ()
 Old implementation: More...
 
static const map_locationnull_location ()
 
- Public Attributes inherited from map_location
int x
 
int y
 

Detailed Description

Definition at line 32 of file entity_location.hpp.

Constructor & Destructor Documentation

game_events::entity_location::entity_location ( const map_location loc,
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,
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.

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.

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

int game_events::entity_location::filter_x ( ) const
inline
int game_events::entity_location::filter_y ( ) const
inline
unit_const_ptr game_events::entity_location::get_unit ( ) const
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::t_pump::filter_event(), game_lua_kernel::intf_kill(), and 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(), resources::filter_con, filter_loc_, unit_filter::matches(), matches_unit(), and unit_map::iterator_base< iter_types >::valid().

Referenced by game_events::t_pump::filter_event().

Member Data Documentation

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 56 of file entity_location.hpp.

Referenced by filter_x(), filter_y(), and matches_unit_filter().

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 51 of file entity_location.hpp.

Referenced by get_unit(), and matches_unit().

const entity_location game_events::entity_location::null_entity
static

Definition at line 46 of file entity_location.hpp.


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