/** * \brief Ends this state. * \param next_state the next state */ void Hero::LiftingState::stop(const State* next_state) { State::stop(next_state); if (lifted_item != NULL) { get_sprites().set_lifted_item(NULL); // the lifted item is still managed by this state switch (next_state->get_previous_carried_item_behavior()) { case CarriedItem::BEHAVIOR_THROW: throw_item(); break; case CarriedItem::BEHAVIOR_DESTROY: destroy_lifted_item(); break; case CarriedItem::BEHAVIOR_KEEP: // The next state is now the owner and has incremented the refcount. Debug::check_assertion(lifted_item->get_refcount() > 1, "Invalid carried item refcount"); RefCountable::unref(lifted_item); lifted_item = NULL; break; } get_keys_effect().set_action_key_effect(KeysEffect::ACTION_KEY_NONE); } }
/** * \brief Ends this state. * \param next_state the next state */ void Hero::LiftingState::stop(State* next_state) { State::stop(next_state); if (lifted_item != NULL) { get_sprites().set_lifted_item(NULL); // the lifted item is still managed by this state switch (next_state->get_previous_carried_item_behavior(*lifted_item)) { case CarriedItem::BEHAVIOR_THROW: throw_item(); break; case CarriedItem::BEHAVIOR_DESTROY: destroy_lifted_item(); break; case CarriedItem::BEHAVIOR_KEEP: lifted_item = NULL; break; } get_keys_effect().set_action_key_effect(KeysEffect::ACTION_KEY_NONE); } }
/** * \brief Destructor. */ Hero::LiftingState::~LiftingState() { destroy_lifted_item(); }