The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
entity_location.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2016 by David White <[email protected]>
3  Part of the Battle for Wesnoth Project http://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 /**
16  * @file
17  * Define locations as used by the game's events mechanism.
18  */
19 
20 #ifndef GAME_EVENTS_ENTITY_LOCATION_H_INCLUDED
21 #define GAME_EVENTS_ENTITY_LOCATION_H_INCLUDED
22 
23 #include "map/location.hpp"
24 #include "units/map.hpp"
25 
26 class unit;
27 class vconfig;
28 
29 
30 namespace game_events
31 {
32  struct entity_location : public map_location {
33  entity_location(const map_location &loc, size_t id = 0);
34  entity_location(const map_location &loc, size_t id,
35  const map_location &filter_loc);
36  explicit entity_location(const unit &);
37  entity_location(const unit &u, const map_location &filter_loc);
38 
39  int filter_x() const { return filter_loc_.x; }
40  int filter_y() const { return filter_loc_.y; }
41  bool matches_unit(const unit_map::const_iterator & un_it) const;
43  const vconfig & filter) const;
44  unit_const_ptr get_unit() const;
45 
47 
48  private:
49  /// The underlying ID of the unit associated with this.
50  /// Set to 0 if there is no associated unit.
51  size_t id_;
52 
53  /// This map_location allows a unit to be filtered as if it were
54  /// somewhere other than where it is. (Use the parent struct if
55  /// you want to locate the unit.)
57  };
58 }
59 
60 #endif // GAME_EVENTS_ENTITY_LOCATION_H_INCLUDED
61 
unit_const_ptr get_unit() const
Definition: unit.hpp:95
entity_location(const map_location &loc, size_t id=0)
Constructor for when an event has a location but not necessarily a unit.
static const entity_location null_entity
bool matches_unit_filter(const unit_map::const_iterator &un_it, const vconfig &filter) const
Determines if un_it matches filter.
size_t id_
The underlying ID of the unit associated with this.
Encapsulates the map of the game.
Definition: location.hpp:38
Domain specific events.
Definition: action_wml.cpp:93
map_location filter_loc_
This map_location allows a unit to be filtered as if it were somewhere other than where it is...
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glew.h:3448
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 constructe...
A variable-expanding proxy for the config class.
Definition: variable.hpp:36