34 std::vector<const unit_animation*>
options;
37 int matching = anim.matches(loc,second_loc,
u_.shared_from_this(),event,value,hit,attack,second_attack,swing_num);
39 options.push_back(&anim);
40 }
else if(matching > max_val) {
43 options.push_back(&anim);
68 anim_->pause_animation();
95 bool with_bars,
const std::string &text,
color_t text_color,
STATE state)
109 const int real_start_time = start_time == INT_MAX ?
anim_->get_begin_time() : start_time;
111 text, text_color, accelerate);
169 params.
y -= height_adjust;
170 params.
halo_y -= height_adjust;
193 if(effect[
"id"].empty()) {
196 static std::map< std::string, std::vector<unit_animation>> animation_cache;
197 std::vector<unit_animation> &built = animation_cache[effect[
"id"]];
206 std::set<std::string> result;
208 const std::vector<std::string>& flags = anim.get_flags();
209 std::copy_if(flags.begin(), flags.end(), std::inserter(result, result.begin()), [](
const std::string
flag) {
210 return !(flag.empty() || (flag.front() ==
'_' && flag.back() ==
'_'));
213 return std::vector<std::string>(result.begin(), result.end());
void start_animation(int start_time, const unit_animation *animation, bool with_bars, const std::string &text="", color_t text_color={}, STATE state=STATE_ANIM)
Begin an animation.
bool refreshing_
avoid infinite recursion.
All parameters from a frame at a given instant.
static display * get_singleton()
Returns the display object if a display object exists.
const unit & u_
A reference to the unit that owns this object.
void set_disabled_ghosted(bool with_bars=true)
Whiteboard related somehow.
bool is_flying() const
Check if the unit is a flying unit.
static double get_zoom_factor()
Returns the current zoom factor.
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_attack_ptr attack=nullptr, const_attack_ptr second_attack=nullptr, int swing_num=0)
Chooses an appropriate animation from the list of known animations.
std::unique_ptr< unit_animation > anim_
The current animation.
int get_current_animation_tick()
static void add_anims(std::vector< unit_animation > &animations, const config &cfg)
void set_selecting()
Sets the animation state to that when the unit is selected.
A terrain string which is converted to a terrain is a string with 1 or 2 layers the layers are separa...
const terrain_type & get_terrain_info(const t_translation::terrain_code &terrain) const
bool draw_bars_
bool indicating whether to draw bars with the unit
Definitions for the interface to Wesnoth Markup Language (WML).
void refresh()
Intermittently activates the idling animations in place of the standing animations.
unit_animation * get_animation() const
Get a pointer to the current animation.
int frame_begin_time_
time for the frame to begin
A single unit type that the player may recruit.
map_location get_direction(DIRECTION dir, unsigned int n=1u) const
void clear_haloes()
Clear the haloes associated to the unit.
int unit_height_adjust() const
const std::vector< unit_animation > & animations() const
terrain_code get_terrain(const map_location &loc) const
Looks up terrain at a particular location.
Encapsulates the map of the game.
The basic class for representing 8-bit RGB or RGBA colour values.
STATE state_
animation state
bool invalidate(const display &disp)
Invalidates an animation with respect to a display object, preparing it for redraw.
map_display and display: classes which take care of displaying the map and game-data on the screen...
std::string default_anim_image() const
The default image to use for animation frames with no defined image.
bool show_standing_animations()
STATE
States for animation.
Encapsulates the map of the game.
void set_idling()
Sets the animation state to idling.
std::vector< std::string > get_flags()
Get the flags of all registered animations.
bool tile_nearly_on_screen(const map_location &loc) const
Checks if location loc or one of the adjacent tiles is visible on screen.
int get_random_int(int min, int max)
This helper method provides a random int from the underlying generator, using results of next_random...
void apply_new_animation_effect(const config &effect)
Adds an animation described by a config.
std::vector< unit_animation > animations_
List of registered animations for this unit.
const gamemap & get_map() const
bool incapacitated() const
Check if the unit has been petrified.
halo::handle unit_halo_
handle to the halo of this unit
void set_standing(bool with_bars=true)
Sets the animation state to standing.
A config object defines a single node in a WML file, with access to child nodes.
std::shared_ptr< const attack_type > const_attack_ptr
std::string TC_image_mods() const
Constructs a recolor (RC) IPF string for this unit's team color.
static rng & default_instance()
void set_ghosted(bool with_bars=true)
Sets the animation state to ghosted.
std::string image_mods() const
Gets an IPF string containing all IPF image mods.
void reset_after_advance(const unit_type *newtype=nullptr)
Resets the animations list after the unit is advanced.
int next_idling_
time for next idle animation
bool invalidate(frame_parameters &value)
map_location::DIRECTION facing_