Hid some implementations away from the interface.

This commit is contained in:
Guillaume Melquiond 2009-05-09 13:40:50 +00:00
parent 3eb2fa170a
commit af1007f984
2 changed files with 33 additions and 23 deletions

View File

@ -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;

View File

@ -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_;