The Battle for Wesnoth  1.13.10+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 - 2017 by David White <dave@whitevine.net>
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 #pragma once
21 
22 #include "map/location.hpp"
23 #include "units/map.hpp"
24 
25 class unit;
26 class vconfig;
27 
28 
29 namespace game_events
30 {
31  struct entity_location : public map_location {
32  entity_location(const map_location &loc, size_t id = 0);
33  entity_location(const map_location &loc, size_t id,
34  const map_location &filter_loc);
35  explicit entity_location(const unit &);
36  entity_location(const unit &u, const map_location &filter_loc);
37 
38  const map_location& filter_loc() const { return filter_loc_; }
39  bool matches_unit(const unit_map::const_iterator & un_it) const;
41  const vconfig & filter) const;
42  unit_const_ptr get_unit() const;
43 
45 
46  private:
47  /// The underlying ID of the unit associated with this.
48  /// Set to 0 if there is no associated unit.
49  size_t id_;
50 
51  /// This map_location allows a unit to be filtered as if it were
52  /// somewhere other than where it is. (Use the parent struct if
53  /// you want to locate the unit.)
55  };
56 }
boost::intrusive_ptr< const unit > unit_const_ptr
Definition: ptr.hpp:30
unit_const_ptr get_unit() const
This class represents a single unit of a specific type.
Definition: unit.hpp:101
entity_location(const map_location &loc, size_t id=0)
Constructor for when an event has a location but not necessarily a unit.
const map_location & filter_loc() const
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:40
Domain specific events.
Definition: action_wml.cpp:88
map_location filter_loc_
This map_location allows a unit to be filtered as if it were somewhere other than where it is...
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:42