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_STREAM_H 18 #define SOLARUS_STREAM_H 19 20 #include "solarus/core/Common.h" 21 #include "solarus/entities/Entity.h" 22 #include <string> 23 24 namespace Solarus { 25 26 /** 27 * \brief A special terrain where the hero is moved towards a specific 28 * direction. 29 * 30 * The hero may or may not resist to the movement of the stream, depending 31 * on its properties. 32 */ 33 class Stream: public Entity { 34 35 public: 36 37 static constexpr EntityType ThisType = EntityType::STREAM; 38 39 Stream( 40 const std::string& name, 41 int layer, 42 const Point& xy, 43 int direction, 44 const std::string& sprite_name 45 ); 46 47 virtual EntityType get_type() const override; 48 49 int get_speed() const; 50 void set_speed(int speed); 51 bool get_allow_movement() const; 52 void set_allow_movement(bool allow_movement); 53 bool get_allow_attack() const; 54 void set_allow_attack(bool allow_attack); 55 bool get_allow_item() const; 56 void set_allow_item(bool allow_item); 57 virtual void notify_direction_changed() override; 58 59 virtual bool is_obstacle_for(Entity& other) override; 60 virtual void notify_collision( 61 Entity& entity_overlapping, 62 CollisionMode collision_mode 63 ) override; 64 void activate(Entity& target); 65 66 private: 67 68 int speed; /**< Speed to apply in pixels per second. */ 69 bool allow_movement; /**< Whether the player can move the hero in this stream. */ 70 bool allow_attack; /**< Whether the player can use the sword in this stream. */ 71 bool allow_item; /**< Whether the player can use equipment items in this stream. */ 72 73 }; 74 75 } 76 77 #endif 78 79