mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-28 18:49:28 +00:00
Hid some implementations away from the interface.
This commit is contained in:
parent
3eb2fa170a
commit
af1007f984
30
src/unit.cpp
30
src/unit.cpp
@ -2970,6 +2970,36 @@ unit& unit::clone(bool is_temporary)
|
||||
return *this;
|
||||
}
|
||||
|
||||
void unit::refresh(const game_display &disp,const map_location &loc)
|
||||
{
|
||||
if (state_ == STATE_FORGET && anim_ && anim_->animation_finished_potential()) {
|
||||
set_standing(loc);
|
||||
return;
|
||||
}
|
||||
if (state_ != STATE_STANDING || get_current_animation_tick() < next_idling_
|
||||
|| incapacitated())
|
||||
return;
|
||||
if (get_current_animation_tick() > next_idling_ + 1000) {
|
||||
// prevent all units animating at the same time
|
||||
set_standing(loc);
|
||||
} else {
|
||||
set_idling(disp, loc);
|
||||
}
|
||||
}
|
||||
|
||||
unit_movement_resetter::unit_movement_resetter(unit &u, bool operate) :
|
||||
u_(u), moves_(u.movement_)
|
||||
{
|
||||
if (operate) {
|
||||
u.movement_ = u.total_movement();
|
||||
}
|
||||
}
|
||||
|
||||
unit_movement_resetter::~unit_movement_resetter()
|
||||
{
|
||||
u_.movement_ = moves_;
|
||||
}
|
||||
|
||||
int team_units(const unit_map& units, unsigned int side)
|
||||
{
|
||||
int res = 0;
|
||||
|
26
src/unit.hpp
26
src/unit.hpp
@ -145,18 +145,7 @@ public:
|
||||
void end_turn();
|
||||
void new_scenario();
|
||||
/** Called on every draw */
|
||||
void refresh(const game_display& disp,const map_location& loc) {
|
||||
if (state_ == STATE_FORGET && anim_ && anim_->animation_finished_potential()) {
|
||||
set_standing( loc);
|
||||
return;
|
||||
}
|
||||
if (state_ != STATE_STANDING || (get_current_animation_tick() < next_idling_) || incapacitated()) return;
|
||||
if (get_current_animation_tick() > next_idling_ + 1000) { // prevent all units animating at the same
|
||||
set_standing(loc);
|
||||
} else {
|
||||
set_idling(disp, loc);
|
||||
}
|
||||
}
|
||||
void refresh(const game_display& disp,const map_location& loc);
|
||||
|
||||
bool take_hit(int damage) { hit_points_ -= damage; return hit_points_ <= 0; }
|
||||
void heal(int amount);
|
||||
@ -465,17 +454,8 @@ private:
|
||||
/** Object which temporarily resets a unit's movement */
|
||||
struct unit_movement_resetter
|
||||
{
|
||||
unit_movement_resetter(unit& u, bool operate=true) : u_(u), moves_(u.movement_)
|
||||
{
|
||||
if(operate) {
|
||||
u.movement_ = u.total_movement();
|
||||
}
|
||||
}
|
||||
|
||||
~unit_movement_resetter()
|
||||
{
|
||||
u_.movement_ = moves_;
|
||||
}
|
||||
unit_movement_resetter(unit& u, bool operate=true);
|
||||
~unit_movement_resetter();
|
||||
|
||||
private:
|
||||
unit& u_;
|
||||
|
Loading…
x
Reference in New Issue
Block a user