mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-19 23:41:14 +00:00
concentrated some time of day getting variants for a lua tod getter
This commit is contained in:
parent
c1ea8ac520
commit
398b6cf4bb
@ -95,9 +95,17 @@ config tod_manager::to_config() const
|
||||
return cfg;
|
||||
}
|
||||
|
||||
const time_of_day& tod_manager::get_time_of_day() const
|
||||
const time_of_day tod_manager::get_time_of_day(int for_turn, const map_location loc, const bool consider_illuminates) const
|
||||
{
|
||||
return times_[currentTime_];
|
||||
if(for_turn == 0) for_turn = turn_;
|
||||
if(consider_illuminates) {
|
||||
assert(resources::game_map->on_board(loc));
|
||||
return time_of_day_at(loc, for_turn);
|
||||
}
|
||||
if(!resources::game_map->on_board(loc)) {
|
||||
return get_time_of_day_turn(times_, for_turn, currentTime_);
|
||||
}
|
||||
return get_time_of_day(loc, for_turn);
|
||||
}
|
||||
|
||||
const time_of_day& tod_manager::get_previous_time_of_day() const
|
||||
@ -210,13 +218,13 @@ const time_of_day& tod_manager::get_time_of_day_turn(const std::vector<time_of_d
|
||||
return times[time];
|
||||
}
|
||||
|
||||
time_of_day tod_manager::time_of_day_at(const map_location& loc) const
|
||||
time_of_day tod_manager::time_of_day_at(const map_location& loc, const int for_turn) const
|
||||
{
|
||||
const gamemap& map = *resources::game_map;
|
||||
const unit_map& units = *resources::units;
|
||||
int light_modif = map.get_terrain_info(map.get_terrain(loc)).light_modification();
|
||||
|
||||
time_of_day tod = get_time_of_day(loc);
|
||||
time_of_day tod = get_time_of_day(loc, for_turn);
|
||||
|
||||
int light = tod.lawful_bonus + light_modif;
|
||||
int illum_light = light;
|
||||
|
@ -32,8 +32,14 @@ class tod_manager : public savegame::savegame_config
|
||||
|
||||
config to_config() const;
|
||||
|
||||
/** Returns time of day object for current turn. */
|
||||
const time_of_day& get_time_of_day() const;
|
||||
/**
|
||||
* Returns time of day object for the passed turn.
|
||||
* for_turn = 0 means current turn
|
||||
* if loc is on board then tod areas matter (else: scenario main time)
|
||||
* if consider_illuminates then tod modifying units matter in addition to time areas
|
||||
* loc must be on board if consider_illuminates
|
||||
*/
|
||||
const time_of_day get_time_of_day(int for_turn = 0, const map_location loc = map_location(), const bool consider_illuminates = false) const;
|
||||
const time_of_day& get_previous_time_of_day() const;
|
||||
|
||||
/**
|
||||
@ -84,7 +90,7 @@ class tod_manager : public savegame::savegame_config
|
||||
const std::vector<time_of_day> times() const {return times_;}
|
||||
|
||||
//consider tod modifying units (e.g. illuminates)
|
||||
time_of_day time_of_day_at(const map_location& loc) const;
|
||||
time_of_day time_of_day_at(const map_location& loc, const int for_turn = 0) const;
|
||||
|
||||
//turn functions
|
||||
int turn() const { return turn_; }
|
||||
|
Loading…
x
Reference in New Issue
Block a user