Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef TELEPORT_H_INCLUDED
00016 #define TELEPORT_H_INCLUDED
00017
00018 #include "map.hpp"
00019
00020 #include "config.hpp"
00021 #include "team.hpp"
00022 #include "terrain_filter.hpp"
00023 #include "savegame_config.hpp"
00024 #include "pathfind/pathfind.hpp"
00025
00026
00027 namespace pathfind {
00028
00029 typedef std::pair<std::set<map_location>, std::set<map_location> >
00030 teleport_pair;
00031
00032
00033
00034
00035 class teleport_group: public savegame::savegame_config {
00036 public:
00037
00038
00039
00040
00041 teleport_group(const config& cfg);
00042
00043
00044
00045
00046
00047
00048 teleport_group(const vconfig& cfg, bool way_back = false);
00049
00050
00051
00052
00053
00054
00055
00056 void get_teleport_pair(
00057 teleport_pair& loc_pair
00058 , const unit& u
00059 , const bool ignore_units) const;
00060
00061
00062
00063
00064
00065 const std::string& get_teleport_id() const;
00066
00067
00068
00069
00070
00071
00072 bool always_visible() const;
00073
00074
00075 config to_config() const;
00076
00077 private:
00078
00079 config cfg_;
00080 bool reversed_;
00081 std::string id_;
00082 };
00083
00084
00085 class teleport_map {
00086 public:
00087
00088
00089
00090
00091
00092
00093
00094 teleport_map(
00095 const std::vector<teleport_group>& teleport_groups
00096 , const unit& u
00097 , const team &viewing_team
00098 , const bool see_all
00099 , const bool ignore_units);
00100
00101
00102
00103
00104 teleport_map() :
00105 teleport_map_(), sources_(), targets_() {};
00106
00107
00108
00109
00110
00111 void get_adjacents(std::set<map_location>& adjacents, map_location loc) const;
00112
00113
00114
00115 void get_sources(std::set<map_location>& sources) const;
00116
00117
00118
00119 void get_targets(std::set<map_location>& targets) const;
00120
00121
00122
00123
00124 bool empty() const {
00125 return sources_.empty();
00126 }
00127
00128 private:
00129 std::map<map_location, std::set<std::string> > teleport_map_;
00130 std::map<std::string, std::set<map_location> > sources_;
00131 std::map<std::string, std::set<map_location> > targets_;
00132 };
00133
00134
00135
00136
00137
00138
00139
00140
00141 const teleport_map get_teleport_locations(const unit &u, const team &viewing_team,
00142 bool see_all = false, bool ignore_units = false);
00143
00144 class manager: public savegame::savegame_config {
00145 public:
00146 manager(const config &cfg);
00147
00148
00149
00150
00151 void add(const teleport_group &group);
00152
00153
00154
00155
00156 void remove(const std::string &id);
00157
00158
00159
00160
00161 const std::vector<teleport_group>& get() const;
00162
00163
00164 config to_config() const;
00165
00166
00167
00168
00169 std::string next_unique_id();
00170 private:
00171 std::vector<teleport_group> tunnels_;
00172 int id_;
00173 };
00174
00175 }
00176
00177 #endif