The Battle for Wesnoth  1.15.5+dev
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2018 by David White <>
3  Part of the Battle for Wesnoth Project
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,
12  See the COPYING file for more details.
13 */
15 /**
16  * @file
17  * Define locations as used by the game's events mechanism.
18  */
20 #pragma once
22 #include "map/location.hpp"
23 #include "units/map.hpp"
25 class unit;
26 class vconfig;
29 namespace game_events
30 {
31  struct entity_location : public map_location {
32  entity_location(const map_location &loc, std::size_t id = 0);
33  entity_location(const map_location &loc, std::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);
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;
46  private:
47  /// The underlying ID of the unit associated with this.
48  /// Set to 0 if there is no associated unit.
49  std::size_t id_;
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 }
std::size_t id_
The underlying ID of the unit associated with this.
bool matches_unit_filter(const unit_map::const_iterator &un_it, const vconfig &filter) const
Determines if un_it matches filter.
This class represents a single unit of a specific type.
Definition: unit.hpp:129
const map_location & filter_loc() const
std::shared_ptr< const unit > unit_const_ptr
Definition: ptr.hpp:29
unit_const_ptr get_unit() const
static const entity_location null_entity
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...
entity_location(const map_location &loc, std::size_t id=0)
Constructor for when an event has a location but not necessarily a unit.
Encapsulates the map of the game.
Definition: location.hpp:42
Domain specific events.
Definition: action_wml.cpp:89
map_location filter_loc_
This map_location allows a unit to be filtered as if it were somewhere other than where it is...
A variable-expanding proxy for the config class.
Definition: variable.hpp:44