Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef TOD_MANAGER_HPP_INCLUDED
00015 #define TOD_MANAGER_HPP_INCLUDED
00016
00017 #include "map_location.hpp"
00018 #include "config.hpp"
00019 #include "time_of_day.hpp"
00020 #include "savegame_config.hpp"
00021
00022 class game_state;
00023 class gamemap;
00024 class unit_map;
00025
00026
00027 class tod_manager : public savegame::savegame_config
00028 {
00029 public:
00030 explicit tod_manager(const config& scenario_cfg = config(), const int num_turns = -1);
00031 ~tod_manager() {}
00032 tod_manager& operator=(const tod_manager& manager);
00033
00034 config to_config() const;
00035
00036
00037
00038
00039
00040 const time_of_day& get_time_of_day(int for_turn = 0) const {
00041 return get_time_of_day_turn(times_, for_turn ? for_turn : turn_, currentTime_);
00042 }
00043
00044
00045
00046
00047
00048
00049 const time_of_day& get_time_of_day(const map_location& loc,
00050 int for_turn = 0) const;
00051
00052
00053
00054
00055
00056
00057 const time_of_day get_illuminated_time_of_day(const map_location& loc,
00058 int for_turn = 0) const;
00059
00060 const time_of_day& get_previous_time_of_day() const;
00061
00062 static bool is_start_ToD(const std::string&);
00063
00064
00065
00066
00067 void replace_schedule(const config& time_cfg);
00068
00069
00070
00071
00072
00073
00074
00075
00076 void add_time_area(const config& cfg);
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087 void add_time_area(const std::string& id, const std::set<map_location>& locs,
00088 const config& time_cfg);
00089
00090
00091
00092
00093
00094
00095
00096
00097 void remove_time_area(const std::string& id);
00098
00099 bool has_time_area() const {return !areas_.empty();};
00100
00101 const std::vector<time_of_day> times() const {return times_;}
00102
00103
00104 int turn() const { return turn_; }
00105 int number_of_turns() const {return num_turns_;}
00106 void modify_turns(const std::string& mod);
00107 void set_number_of_turns(int num);
00108
00109
00110 void set_turn(const int num, const bool increase_limit_if_needed = true);
00111
00112
00113
00114
00115
00116
00117 bool next_turn();
00118
00119
00120
00121
00122
00123
00124 bool is_time_left();
00125 private:
00126 int get_start_ToD(const config& level) const;
00127
00128
00129
00130
00131
00132
00133 const time_of_day& get_time_of_day_turn(const std::vector<time_of_day>& times, int nturn, const int current_time) const;
00134
00135
00136
00137
00138
00139
00140
00141 int calculate_current_time(
00142 const int number_of_times,
00143 const int for_turn_number,
00144 const int current_time,
00145 const bool only_to_allowed_range = false) const;
00146
00147
00148
00149
00150
00151 void set_new_current_times(const int new_current_turn_number);
00152
00153
00154 struct area_time_of_day {
00155 area_time_of_day() :
00156 xsrc(),
00157 ysrc(),
00158 id(),
00159 times(),
00160 hexes(),
00161 currentTime(0)
00162 {}
00163
00164 std::string xsrc, ysrc;
00165 std::string id;
00166 std::vector<time_of_day> times;
00167 std::set<map_location> hexes;
00168 int currentTime;
00169 };
00170
00171
00172 int currentTime_;
00173 std::vector<time_of_day> times_;
00174 std::vector<area_time_of_day> areas_;
00175
00176
00177 int turn_;
00178
00179 int num_turns_;
00180 };
00181 #endif