/** * \brief Constructor. * \param hero the hero controlled by this state * \param use_memorized_xy true to get back to the place previously memorized (if any), * false to get back to the last coordinates with solid ground * \param end_delay a delay to add at the end before returning control to the hero (default 0) * \param with_sound true to play a sound when returning to solid ground */ Hero::BackToSolidGroundState::BackToSolidGroundState(Hero& hero, bool use_memorized_xy, uint32_t end_delay, bool with_sound): BaseState(hero, "back to solid ground"), end_delay(end_delay), end_date(0), with_sound(with_sound) { if (use_memorized_xy && hero.get_target_solid_ground_coords().x != -1) { // go back to a target point specified earlier this->target_xy = hero.get_target_solid_ground_coords(); this->target_layer = hero.get_target_solid_ground_layer(); } else { // just go back to the last solid ground location this->target_xy = hero.get_last_solid_ground_coords(); this->target_layer = hero.get_last_solid_ground_layer(); } }