The Battle for Wesnoth  1.19.5+dev
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
unit_animation Class Reference

#include <animation.hpp>

Classes

class  particle
 

Public Types

enum  variation_type { MATCH_FAIL = -10 , DEFAULT_ANIM = -9 }
 

Public Member Functions

 unit_animation ()=delete
 
 unit_animation (const config &cfg, const std::string &frame_string="")
 
int matches (const map_location &loc, const map_location &second_loc, unit_const_ptr my_unit, const std::string &event="", const int value=0, strike_result::type hit=strike_result::type::invalid, const_attack_ptr attack=nullptr, const_attack_ptr second_attack=nullptr, int value2=0) const
 
const unit_frameget_last_frame () const
 
void add_frame (const std::chrono::milliseconds &duration, const unit_frame &value, bool force_change=false)
 
std::vector< std::string > get_flags () const
 
bool need_update () const
 
bool need_minimal_update () const
 
bool animation_finished () const
 
bool animation_finished_potential () const
 
void update_last_draw_time ()
 
std::chrono::milliseconds get_begin_time () const
 
std::chrono::milliseconds get_end_time () const
 
auto time_to_tick (const std::chrono::milliseconds &animation_time) const
 
auto get_animation_time () const
 
void set_max_animation_time (const std::chrono::milliseconds &time)
 
auto get_animation_time_potential () const
 
void start_animation (const std::chrono::milliseconds &start_time, const map_location &src=map_location::null_location(), const map_location &dst=map_location::null_location(), const std::string &text="", const color_t text_color={0, 0, 0}, const bool accelerate=true)
 
void update_parameters (const map_location &src, const map_location &dst)
 
void pause_animation ()
 
void restart_animation ()
 
auto get_current_frame_begin_time () const
 
void redraw (frame_parameters &value, halo::manager &halo_man)
 
void clear_haloes ()
 
bool invalidate (frame_parameters &value)
 
std::string debug () const
 

Static Public Member Functions

static void fill_initial_animations (std::vector< unit_animation > &animations, const config &cfg)
 
static void add_anims (std::vector< unit_animation > &animations, const config &cfg)
 

Protected Member Functions

frame_parameters get_current_params (const frame_parameters &default_val=frame_parameters()) const
 

Private Member Functions

 unit_animation (const std::chrono::milliseconds &start_time, const unit_frame &frame, const std::string &event="", const int variation=DEFAULT_ANIM, const frame_builder &builder=frame_builder())
 

Private Attributes

t_translation::ter_list terrain_types_
 
std::vector< configunit_filter_
 
std::vector< configsecondary_unit_filter_
 
std::vector< map_location::directiondirections_
 
int frequency_
 
int base_score_
 
std::vector< std::string > event_
 
std::vector< int > value_
 
std::vector< configprimary_attack_filter_
 
std::vector< configsecondary_attack_filter_
 
std::vector< strike_result::type > hits_
 
std::vector< int > value2_
 
std::map< std::string, particlesub_anims_
 
particle unit_anim_
 
map_location src_
 
map_location dst_
 
bool invalidated_
 
bool play_offscreen_
 
std::set< map_locationoverlaped_hex_
 

Friends

class unit
 
class unit_drawer
 
std::ostream & operator<< (std::ostream &outstream, const unit_animation &u_animation)
 

Detailed Description

Definition at line 26 of file animation.hpp.

Member Enumeration Documentation

◆ variation_type

Enumerator
MATCH_FAIL 
DEFAULT_ANIM 

Definition at line 32 of file animation.hpp.

Constructor & Destructor Documentation

◆ unit_animation() [1/3]

unit_animation::unit_animation ( )
delete

Referenced by fill_initial_animations().

◆ unit_animation() [2/3]

unit_animation::unit_animation ( const config cfg,
const std::string &  frame_string = "" 
)
explicit

◆ unit_animation() [3/3]

unit_animation::unit_animation ( const std::chrono::milliseconds &  start_time,
const unit_frame frame,
const std::string &  event = "",
const int  variation = DEFAULT_ANIM,
const frame_builder builder = frame_builder() 
)
explicitprivate

Definition at line 253 of file animation.cpp.

References add_frame(), unit_frame::does_not_change(), and unit_frame::duration().

Member Function Documentation

◆ add_anims()

void unit_animation::add_anims ( std::vector< unit_animation > &  animations,
const config cfg 
)
static

◆ add_frame()

void unit_animation::add_frame ( const std::chrono::milliseconds &  duration,
const unit_frame value,
bool  force_change = false 
)
inline

Definition at line 46 of file animation.hpp.

References animated< T >::add_frame(), and unit_anim_.

Referenced by unit_animation().

◆ animation_finished()

bool unit_animation::animation_finished ( ) const

Definition at line 984 of file animation.cpp.

References animated< T >::animation_finished(), sub_anims_, and unit_anim_.

◆ animation_finished_potential()

bool unit_animation::animation_finished_potential ( ) const

◆ clear_haloes()

void unit_animation::clear_haloes ( )

Definition at line 1097 of file animation.cpp.

References unit_animation::particle::clear_halo(), sub_anims_, and unit_anim_.

◆ debug()

std::string unit_animation::debug ( ) const

Definition at line 1150 of file animation.cpp.

◆ fill_initial_animations()

void unit_animation::fill_initial_animations ( std::vector< unit_animation > &  animations,
const config cfg 
)
static

◆ get_animation_time()

auto unit_animation::get_animation_time ( ) const
inline

◆ get_animation_time_potential()

auto unit_animation::get_animation_time_potential ( ) const
inline

Definition at line 79 of file animation.hpp.

References animated< T >::get_animation_time_potential(), and unit_anim_.

◆ get_begin_time()

std::chrono::milliseconds unit_animation::get_begin_time ( ) const

◆ get_current_frame_begin_time()

auto unit_animation::get_current_frame_begin_time ( ) const
inline

◆ get_current_params()

frame_parameters unit_animation::get_current_params ( const frame_parameters default_val = frame_parameters()) const
inlineprotected

Definition at line 109 of file animation.hpp.

References unit_animation::particle::parameters(), and unit_anim_.

◆ get_end_time()

std::chrono::milliseconds unit_animation::get_end_time ( ) const

Definition at line 1013 of file animation.cpp.

References animated< T >::get_end_time(), sub_anims_, and unit_anim_.

◆ get_flags()

std::vector<std::string> unit_animation::get_flags ( ) const
inline

Definition at line 51 of file animation.hpp.

References event_.

◆ get_last_frame()

const unit_frame& unit_animation::get_last_frame ( ) const
inline

Definition at line 41 of file animation.hpp.

References animated< T >::get_last_frame(), and unit_anim_.

◆ invalidate()

bool unit_animation::invalidate ( frame_parameters value)

◆ matches()

int unit_animation::matches ( const map_location loc,
const map_location second_loc,
unit_const_ptr  my_unit,
const std::string &  event = "",
const int  value = 0,
strike_result::type  hit = strike_result::type::invalid,
const_attack_ptr  attack = nullptr,
const_attack_ptr  second_attack = nullptr,
int  value2 = 0 
) const

◆ need_minimal_update()

bool unit_animation::need_minimal_update ( ) const

◆ need_update()

bool unit_animation::need_update ( ) const

◆ pause_animation()

void unit_animation::pause_animation ( )

Definition at line 1065 of file animation.cpp.

References animated< T >::pause_animation(), sub_anims_, and unit_anim_.

◆ redraw()

void unit_animation::redraw ( frame_parameters value,
halo::manager halo_man 
)

◆ restart_animation()

void unit_animation::restart_animation ( )

Definition at line 1074 of file animation.cpp.

References animated< T >::restart_animation(), sub_anims_, and unit_anim_.

◆ set_max_animation_time()

void unit_animation::set_max_animation_time ( const std::chrono::milliseconds &  time)
inline

Definition at line 74 of file animation.hpp.

References animated< T >::set_max_animation_time(), and unit_anim_.

◆ start_animation()

void unit_animation::start_animation ( const std::chrono::milliseconds &  start_time,
const map_location src = map_location::null_location(),
const map_location dst = map_location::null_location(),
const std::string &  text = "",
const color_t  text_color = {0,0,0},
const bool  accelerate = true 
)

◆ time_to_tick()

auto unit_animation::time_to_tick ( const std::chrono::milliseconds &  animation_time) const
inline

Definition at line 64 of file animation.hpp.

References animated< T >::time_to_tick(), and unit_anim_.

◆ update_last_draw_time()

void unit_animation::update_last_draw_time ( )

◆ update_parameters()

void unit_animation::update_parameters ( const map_location src,
const map_location dst 
)

Definition at line 1059 of file animation.cpp.

References dst, dst_, src, and src_.

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  outstream,
const unit_animation u_animation 
)
friend

Definition at line 1157 of file animation.cpp.

◆ unit

friend class unit
friend

Definition at line 104 of file animation.hpp.

◆ unit_drawer

friend class unit_drawer
friend

Definition at line 105 of file animation.hpp.

Member Data Documentation

◆ base_score_

int unit_animation::base_score_
private

Definition at line 170 of file animation.hpp.

Referenced by matches().

◆ directions_

std::vector<map_location::direction> unit_animation::directions_
private

Definition at line 168 of file animation.hpp.

Referenced by matches(), and unit_animation().

◆ dst_

map_location unit_animation::dst_
private

Definition at line 181 of file animation.hpp.

Referenced by invalidate(), redraw(), start_animation(), and update_parameters().

◆ event_

std::vector<std::string> unit_animation::event_
private

Definition at line 171 of file animation.hpp.

Referenced by get_flags(), matches(), and unit_animation().

◆ frequency_

int unit_animation::frequency_
private

Definition at line 169 of file animation.hpp.

Referenced by matches().

◆ hits_

std::vector<strike_result::type> unit_animation::hits_
private

Definition at line 175 of file animation.hpp.

Referenced by matches(), and unit_animation().

◆ invalidated_

bool unit_animation::invalidated_
private

Definition at line 183 of file animation.hpp.

Referenced by invalidate(), and redraw().

◆ overlaped_hex_

std::set<map_location> unit_animation::overlaped_hex_
private

Definition at line 185 of file animation.hpp.

Referenced by invalidate(), and redraw().

◆ play_offscreen_

bool unit_animation::play_offscreen_
private

Definition at line 184 of file animation.hpp.

Referenced by need_minimal_update(), and unit_animation().

◆ primary_attack_filter_

std::vector<config> unit_animation::primary_attack_filter_
private

Definition at line 173 of file animation.hpp.

Referenced by matches(), and unit_animation().

◆ secondary_attack_filter_

std::vector<config> unit_animation::secondary_attack_filter_
private

Definition at line 174 of file animation.hpp.

Referenced by matches(), and unit_animation().

◆ secondary_unit_filter_

std::vector<config> unit_animation::secondary_unit_filter_
private

Definition at line 167 of file animation.hpp.

Referenced by matches(), and unit_animation().

◆ src_

map_location unit_animation::src_
private

Definition at line 180 of file animation.hpp.

Referenced by invalidate(), redraw(), start_animation(), and update_parameters().

◆ sub_anims_

std::map<std::string,particle> unit_animation::sub_anims_
private

◆ terrain_types_

t_translation::ter_list unit_animation::terrain_types_
private

Definition at line 165 of file animation.hpp.

Referenced by matches().

◆ unit_anim_

particle unit_animation::unit_anim_
private

◆ unit_filter_

std::vector<config> unit_animation::unit_filter_
private

Definition at line 166 of file animation.hpp.

Referenced by matches(), and unit_animation().

◆ value2_

std::vector<int> unit_animation::value2_
private

Definition at line 176 of file animation.hpp.

Referenced by matches(), and unit_animation().

◆ value_

std::vector<int> unit_animation::value_
private

Definition at line 172 of file animation.hpp.

Referenced by matches(), and unit_animation().


The documentation for this class was generated from the following files: