1 /*
2  * Copyright (C) 2006-2019 Christopho, Solarus - http://www.solarus-games.org
3  *
4  * Solarus is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * Solarus is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 #ifndef SOLARUS_HERO_PULLING_STATE_H
18 #define SOLARUS_HERO_PULLING_STATE_H
19 
20 #include "solarus/core/Common.h"
21 #include "solarus/hero/HeroState.h"
22 #include <memory>
23 
24 namespace Solarus {
25 
26 class PathMovement;
27 
28 /**
29  * \brief The state "Pulling" of the hero.
30  */
31 class Hero::PullingState: public HeroState {
32 
33   public:
34 
35     explicit PullingState(Hero& hero);
36 
37     void start(const State* previous_state) override;
38     void stop(const State* next_state) override;
39     void update() override;
40     void notify_grabbed_entity_collision() override;
41     void notify_movement_finished() override;
42     void notify_position_changed() override;
43     void notify_obstacle_reached() override;
44     bool is_grabbing_or_pulling() const override;
45     bool is_moving_grabbed_entity() const override;
46     bool is_shallow_water_obstacle() const override;
47     bool is_deep_water_obstacle() const override;
48     bool is_hole_obstacle() const override;
49     bool is_lava_obstacle() const override;
50     bool is_prickle_obstacle() const override;
51     bool is_stream_obstacle(Stream& stream) override;
52     bool is_separator_obstacle(Separator& separator) override;
53 
54     bool get_can_be_hurt(Entity* attacker) override;
55     bool get_can_pick_treasure(EquipmentItem& item) const override;
56 
57   private:
58 
59     void stop_moving_pulled_entity();
60 
61     Entity* pulled_entity;             /**< The entity the hero is pulling (or nullptr). */
62     std::shared_ptr<PathMovement>
63         pulling_movement;              /**< The movement created by this state.
64                                         * The movement of the hero is also this object,
65                                         * unless a script decided to change it. */
66 
67 };
68 
69 }
70 
71 #endif
72 
73