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_DYNAMIC_TILE_H 18 #define SOLARUS_DYNAMIC_TILE_H 19 20 #include "solarus/core/Common.h" 21 #include "solarus/entities/Entity.h" 22 #include <string> 23 24 namespace Solarus { 25 26 class TilePattern; 27 class Tileset; 28 29 /** 30 * \brief A special tile that can be enabled or disabled. 31 * 32 * A dynamic tile is a tile placed on the map 33 * that can be enabled or disabled by the script, 34 * contrary to the Tile instances that are totally static for performance reasons. 35 * An enabled dynamic tile behaves like a normal tile and may be an obstacle or any ground. 36 * A disabled dynamic tile is invisible and can be traversed. 37 */ 38 class DynamicTile: public Entity { 39 40 public: 41 42 static constexpr EntityType ThisType = EntityType::DYNAMIC_TILE; 43 44 DynamicTile( 45 const std::string& name, 46 int layer, 47 const Point& xy, 48 const Size& size, 49 const std::string& tile_pattern_id, 50 const std::shared_ptr<TilePattern>& tile_pattern, 51 const Tileset* tileset 52 ); 53 54 virtual EntityType get_type() const override; 55 56 const std::string& get_tile_pattern_id() const; 57 Ground get_modified_ground() const override; 58 const Tileset* get_tileset() const; 59 void set_tileset(const Tileset* tileset); 60 void set_tileset(const std::string& tileset_id); 61 bool is_drawn_at_its_position() const override; 62 void built_in_draw(Camera& camera) override; 63 void notify_tileset_changed() override; 64 65 private: 66 67 const std::string tile_pattern_id; /**< Id of the tile pattern. */ 68 std::shared_ptr<TilePattern> 69 tile_pattern; /**< Pattern of the tile, or nullptr if it does not exist. */ 70 const Tileset* tileset; /**< Tileset of the pattern (nullptr means the one of the map). */ 71 72 }; 73 74 } 75 76 #endif 77 78