28#define ERR_NG LOG_STREAM(err, log_engine)
30using namespace std::chrono_literals;
34std::chrono::steady_clock::time_point get_next_idle_tick()
37 return std::chrono::steady_clock::time_point::max();
40 const double rate = std::pow(2.0, -
prefs::get().idle_anim_rate() / 10.0);
51 std::vector<const unit_animation*> options;
54 int matching = anim.
matches(
loc,second_loc,
u_.shared_from_this(),event,
value,hit,attack,second_attack,swing_num);
56 options.push_back(&anim);
57 }
else if(matching > max_val) {
60 options.push_back(&anim);
85 anim_->pause_animation();
112 bool with_bars,
const std::string &text,
color_t text_color,
STATE state)
126 const auto real_start_time = start_time == std::chrono::milliseconds::max() ?
anim_->get_begin_time() : start_time;
128 text, text_color, accelerate);
177 params.
y -= height_adjust;
178 params.
halo_y -= height_adjust;
213 if(effect[
"id"].empty()) {
216 static std::map< std::string, std::vector<unit_animation>> animation_cache;
217 std::vector<unit_animation> &built = animation_cache[effect[
"id"]];
226 std::set<std::string> result;
228 const std::vector<std::string>& flags = anim.get_flags();
229 std::copy_if(flags.begin(), flags.end(), std::inserter(result, result.begin()), [](
const std::string& flag) {
230 return !(flag.empty() || (flag.front() ==
'_' && flag.back() ==
'_'));
233 return std::vector<std::string>(result.begin(), result.end());
std::chrono::steady_clock::time_point get_current_animation_tick(bool uses_acceleration)
Gets the current time point for animations.
static lg::log_domain log_engine("engine")
A config object defines a single node in a WML file, with access to child nodes.
virtual const gamemap & map() const =0
Sort-of-Singleton that many classes, both GUI and non-GUI, use to access the game data.
static double get_zoom_factor()
Returns the current zoom factor.
bool tile_nearly_on_screen(const map_location &loc) const
Checks if location loc or one of the adjacent tiles is visible on screen.
static display * get_singleton()
Returns the display object if a display object exists.
const display_context & context() const
Encapsulates the map of the game.
const terrain_type & get_terrain_info(const t_translation::terrain_code &terrain) const
static rng & default_instance()
int get_random_int(int min, int max)
int unit_height_adjust() const
void set_idling()
Sets the animation state to idling.
bool draw_bars_
bool indicating whether to draw bars with the unit
std::vector< halo::handle > abil_halos_
handle to the abilities halos of this unit
std::vector< unit_animation > animations_
List of registered animations for this unit.
void apply_new_animation_effect(const config &effect)
Adds an animation described by a config.
std::unique_ptr< unit_animation > anim_
The current animation.
halo::handle unit_halo_
handle to the halo of this unit
bool invalidate(const display &disp)
Invalidates an animation with respect to a display object, preparing it for redraw.
void set_ghosted(bool with_bars=true)
Sets the animation state to ghosted.
void refresh()
Intermittently activates the idling animations in place of the standing animations.
STATE state_
animation state
unit_animation * get_animation() const
Get a pointer to the current animation.
void reset_after_advance(const unit_type *newtype=nullptr)
Resets the animations list after the unit is advanced.
void reset_affect_adjacent(const unit_map &units)
Refresh map around unit if has ability with [affect_adjacent/distant] tag.
std::vector< std::string > get_flags()
Get the flags of all registered animations.
void set_standing(bool with_bars=true)
Sets the animation state to standing.
const unit & u_
A reference to the unit that owns this object.
std::vector< std::string > abil_halos_ref_
vector used to check that halo_abilities vector isn't modified between each read
STATE
States for animation.
@ STATE_FORGET
anim must fit in a hex
void set_selecting()
Sets the animation state to that when the unit is selected.
bool refreshing_
avoid infinite recursion.
void clear_haloes()
Clear the haloes associated to the unit.
void set_disabled_ghosted(bool with_bars=true)
Whiteboard related somehow.
std::chrono::milliseconds frame_begin_time_
time for the frame to begin
const unit_animation * choose_animation(const map_location &loc, const std::string &event, const map_location &second_loc=map_location::null_location(), const int damage=0, const strike_result::type hit_type=strike_result::type::invalid, const const_attack_ptr &attack=nullptr, const const_attack_ptr &second_attack=nullptr, int swing_num=0)
Chooses an appropriate animation from the list of known animations.
void start_animation(const std::chrono::milliseconds &start_time, const unit_animation *animation, bool with_bars, const std::string &text="", color_t text_color={}, STATE state=STATE_ANIM)
Begin an animation.
std::chrono::steady_clock::time_point next_idling_
time for next idle animation
bool invalidate(frame_parameters &value)
int matches(const map_location &loc, const map_location &second_loc, const unit_const_ptr &my_unit, const std::string &event="", const int value=0, strike_result::type hit=strike_result::type::invalid, const const_attack_ptr &attack=nullptr, const const_attack_ptr &second_attack=nullptr, int value2=0) const
static void add_anims(std::vector< unit_animation > &animations, const config &cfg)
Container associating units to locations.
A single unit type that the player may recruit.
const std::vector< unit_animation > & animations() const
This class represents a single unit of a specific type.
Definitions for the interface to Wesnoth Markup Language (WML).
map_location::direction facing_
bool incapacitated() const
Check if the unit has been petrified.
std::string TC_image_mods() const
Constructs a recolor (RC) IPF string for this unit's team color.
std::string image_mods() const
Gets an IPF string containing all IPF image mods.
std::string default_anim_image() const
The default image to use for animation frames with no defined image.
unit_animation_component & anim_comp() const
bool is_flying() const
Check if the unit is a flying unit.
std::size_t max_ability_radius_image() const
If this unit has abilities with [affect_adjacent] subtags and halo_image or overlay_image attributes,...
Standard logging facilities (interface).
std::shared_ptr< const attack_type > const_attack_ptr
std::unique_ptr< MIX_Audio, decltype(&MIX_DestroyAudio)> value
The basic class for representing 8-bit RGB or RGBA colour values.
All parameters from a frame at a given instant.
Encapsulates the map of the game.
map_location get_direction(direction dir, unsigned int n=1u) const