Contains a number of free functions which display units. More...
Classes | |
class | unit_mover |
A class to encapsulate the steps of drawing a unit's move. More... | |
Functions | |
void | move_unit (const std::vector< map_location > &path, unit_ptr u, bool animate, map_location::DIRECTION dir, bool force_scroll) |
Display a unit moving along a given path. More... | |
void | reset_helpers (const unit *attacker, const unit *defender) |
void | unit_draw_weapon (const map_location &loc, unit &u, const attack_type *attack=nullptr, const attack_type *secondary_attack=nullptr, const map_location &defender_loc=map_location::null_location(), unit *defender=nullptr) |
Play a pre-fight animation First unit is the attacker, second unit the defender. More... | |
void | unit_sheath_weapon (const map_location &loc, unit *u=nullptr, const attack_type *attack=nullptr, const attack_type *secondary_attack=nullptr, const map_location &defender_loc=map_location::null_location(), unit *defender=nullptr) |
Play a post-fight animation Both unit can be set to null, only valid units will play their animation. More... | |
void | unit_die (const map_location &loc, unit &u, const attack_type *attack=nullptr, const attack_type *secondary_attack=nullptr, const map_location &winner_loc=map_location::null_location(), unit *winner=nullptr) |
Show a unit fading out. More... | |
void | unit_attack (display *disp, game_board &board,const map_location &a, const map_location &b, int damage, const attack_type &attack, const attack_type *secondary_attack, int swing, std::string hit_text, int drain_amount, std::string att_text, const std::vector< std::string > *extra_hit_sounds=nullptr) |
Make the unit on tile 'a' attack the unit on tile 'b'. More... | |
void | unit_recruited (const map_location &loc, const map_location &leader_loc) |
void | unit_healing (unit &healed, const std::vector< unit * > &healers, int healing, const std::string &extra_text="") |
This will use a poisoning anim if healing<0. More... | |
void | wml_animation_internal (unit_animator &animator, const vconfig &cfg, const map_location &default_location=map_location::null_location()) |
void | wml_animation (const vconfig &cfg, const map_location &default_location=map_location::null_location()) |
Parse a standard WML for animations and play the corresponding animation. More... | |
Contains a number of free functions which display units.
performing various on-screen actions - moving, attacking, and dying.
void unit_display::move_unit | ( | const std::vector< map_location > & | path, |
unit_ptr | u, | ||
bool | animate, | ||
map_location::DIRECTION | dir, | ||
bool | force_scroll | ||
) |
Display a unit moving along a given path.
path | The path to traverse. |
u | The unit to show being moved. Its facing will be updated, but not its position. |
animate | If set to false, only side-effects of move are applied (correct unit facing, path hexes redrawing). |
dir | Unit will be set facing this direction after move. If nothing passed, direction will be set based on path. |
Definition at line 486 of file udisplay.cpp.
References unit_display::unit_mover::finish(), unit_display::unit_mover::proceed_to(), and unit_display::unit_mover::start().
Referenced by wb::manager::create_temp_move(), game_lua_kernel::intf_teleport(), wb::move::move(), actions::undo::move_action::redo(), ai::simulated_move(), actions::undo::move_action::undo(), and game_events::WML_HANDLER_FUNCTION().
Definition at line 680 of file udisplay.cpp.
References unit_map::end(), unit_map::find(), unit::get_abilities(), display::get_singleton(), display::get_units(), and resources::units.
Referenced by unit_attack(), unit_die(), and unit_sheath_weapon().
void unit_display::unit_attack | ( | display * | disp, |
game_board & | board, | ||
const map_location & | a, | ||
const map_location & | b, | ||
int | damage, | ||
const attack_type & | attack, | ||
const attack_type * | secondary_attack, | ||
int | swing, | ||
std::string | hit_text, | ||
int | drain_amount, | ||
std::string | att_text, | ||
const std::vector< std::string > * | extra_hit_sounds = nullptr |
||
) |
Make the unit on tile 'a' attack the unit on tile 'b'.
The 'damage' will be subtracted from the unit's hitpoints, and a die effect will be displayed if the unit dies.
true | if the defending unit is dead, should be removed from the playing field. |
Definition at line 572 of file udisplay.cpp.
References unit_animator::add_animation(), CVideo::faked(), unit_map::find(), game_board::find_unit(), display::fogged(), unit_animator::get_animation_time(), unit_animator::get_animation_time_potential(), unit_animator::get_end_time(), map_location::get_relative_dir(), unit_animation::HIT, unit_animation::KILL, log_scope, unit_animation::MISS, map_location::null_location(), number_and_text(), display::ONSCREEN, sound::play_sound(), reset_helpers(), display::rgb(), display::scroll_to_tiles(), display::select_hex(), preferences::show_combat(), unit_animator::start_animations(), game_board::units(), CVideo::update_locked(), unit_map::iterator_base< iter_types >::valid(), display::video(), unit_animator::wait_for_end(), unit_animator::wait_until(), and unit_animator::would_end().
void unit_display::unit_die | ( | const map_location & | loc, |
unit & | u, | ||
const attack_type * | attack = nullptr , |
||
const attack_type * | secondary_attack = nullptr , |
||
const map_location & | winner_loc = map_location::null_location() , |
||
unit * | winner = nullptr |
||
) |
Show a unit fading out.
Note: this only shows the effect, it doesn't actually kill the unit.
Definition at line 548 of file udisplay.cpp.
References unit_animator::add_animation(), CVideo::faked(), display::fogged(), events::mouse_handler::get_singleton(), display::get_singleton(), events::mouse_handler::invalidate_reachmap(), unit_animation::KILL, reset_helpers(), preferences::show_combat(), unit_animator::start_animations(), CVideo::update_locked(), display::video(), and unit_animator::wait_for_end().
Referenced by game_lua_kernel::intf_kill(), and events::menu_handler::kill_unit().
void unit_display::unit_draw_weapon | ( | const map_location & | loc, |
unit & | attacker, | ||
const attack_type * | attack, | ||
const attack_type * | secondary_attack, | ||
const map_location & | defender_loc, | ||
unit * | defender | ||
) |
Play a pre-fight animation First unit is the attacker, second unit the defender.
Definition at line 500 of file udisplay.cpp.
References unit_animator::add_animation(), CVideo::faked(), display::fogged(), map_location::get_relative_dir(), display::get_singleton(), unit_animation::HIT, unit_animation::MISS, unit::set_facing(), preferences::show_combat(), unit_animator::start_animations(), CVideo::update_locked(), display::video(), and unit_animator::wait_for_end().
void unit_display::unit_healing | ( | unit & | healed, |
const std::vector< unit * > & | healers, | ||
int | healing, | ||
const std::string & | extra_text | ||
) |
This will use a poisoning anim if healing<0.
Definition at line 731 of file udisplay.cpp.
References unit_animator::add_animation(), game_display::display_unit_hex(), CVideo::faked(), display::fogged(), unit::get_location(), game_display::get_singleton(), map_location::null_location(), number_and_text(), display::ONSCREEN, display::rgb(), display::scroll_to_tile(), unit_animator::set_all_standing(), unit_animator::start_animations(), CVideo::update_locked(), display::video(), and unit_animator::wait_for_end().
Referenced by game_lua_kernel::intf_heal_unit().
void unit_display::unit_recruited | ( | const map_location & | loc, |
const map_location & | leader_loc | ||
) |
Definition at line 703 of file udisplay.cpp.
References unit_animator::add_animation(), display::draw(), unit_map::end(), CVideo::faked(), unit_map::find(), display::fogged(), map_location::get_relative_dir(), game_display::get_singleton(), display::get_units(), game_display::invalidate_unit(), display::mouseover_hex(), map_location::null_location(), display::ONSCREEN, display::scroll_to_tile(), display::scroll_to_tiles(), unit_animator::set_all_standing(), unit_animator::start_animations(), CVideo::update_locked(), display::video(), and unit_animator::wait_for_end().
Referenced by actions::place_recruit(), unit_creator::post_create(), and SYNCED_COMMAND_HANDLER_FUNCTION().
void unit_display::unit_sheath_weapon | ( | const map_location & | primary_loc, |
unit * | primary_unit, | ||
const attack_type * | primary_attack, | ||
const attack_type * | secondary_attack, | ||
const map_location & | secondary_loc, | ||
unit * | secondary_unit | ||
) |
Play a post-fight animation Both unit can be set to null, only valid units will play their animation.
Definition at line 518 of file udisplay.cpp.
References unit_animator::add_animation(), unit::anim_comp(), CVideo::faked(), display::fogged(), display::get_singleton(), unit_animation::INVALID, reset_helpers(), unit_animation_component::set_standing(), preferences::show_combat(), unit_animator::start_animations(), CVideo::update_locked(), display::video(), and unit_animator::wait_for_end().
void unit_display::wml_animation | ( | const vconfig & | cfg, |
const map_location & | default_location = map_location::null_location() |
||
) |
Parse a standard WML for animations and play the corresponding animation.
Returns once animation is played.
This is used for the animate_unit action, but can easily be generalized if other wml-described animations are needed.
Definition at line 771 of file udisplay.cpp.
References CVideo::faked(), resources::screen, unit_animator::set_all_standing(), unit_animator::start_animations(), CVideo::update_locked(), display::video(), unit_animator::wait_for_end(), and wml_animation_internal().
Referenced by game_lua_kernel::intf_animate_unit().
void unit_display::wml_animation_internal | ( | unit_animator & | animator, |
const vconfig & | cfg, | ||
const map_location & | default_location = map_location::null_location() |
||
) |
Definition at line 782 of file udisplay.cpp.
References unit_animator::add_animation(), config::attribute_value::blank(), vconfig::child(), vconfig::empty(), unit_race::FEMALE, resources::filter_con, unit_map::find(), unit_filter::first_match_on_map(), vconfig::get_children(), vconfig::get_config(), terrain_filter::get_locations(), vconfig::get_parsed_config(), unit_map::iterator_base< iter_types >::get_shared_ptr(), unit_animation::HIT, unit_animation::INVALID, itor, unit_animation::KILL, unit_animation::MISS, vconfig::null(), map_location::null_location(), display::ONSCREEN, display::rgb(), resources::screen, display::scroll_to_tile(), config::attribute_value::str(), resources::units, and unit_map::iterator_base< iter_types >::valid().
Referenced by wml_animation().