1 /* GemRB - Infinity Engine Emulator 2 * Copyright (C) 2003 The GemRB Project 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 2 7 * of the License, or (at your option) any later version. 8 * 9 * This program 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 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 * 18 * 19 */ 20 21 #ifndef TILEMAP_H 22 #define TILEMAP_H 23 24 #include "exports.h" 25 26 #include "Scriptable/Door.h" 27 #include "TileOverlay.h" 28 29 namespace GemRB { 30 31 //special container types 32 #define IE_CONTAINER_PILE 4 33 34 class Container; 35 class InfoPoint; 36 class TileObject; 37 38 class GEM_EXPORT TileMap { 39 private: 40 std::vector< TileOverlay*> overlays; 41 std::vector< TileOverlay*> rain_overlays; 42 std::vector< Door*> doors; 43 std::vector< Container*> containers; 44 std::vector< InfoPoint*> infoPoints; 45 std::vector< TileObject*> tiles; 46 public: 47 TileMap(void); 48 ~TileMap(void); 49 50 Door* AddDoor(const char* ID, const char* Name, unsigned int Flags, 51 int ClosedIndex, unsigned short* indices, int count, DoorTrigger&& dt); 52 //gets door by active region (click target) 53 Door* GetDoor(const Point &position) const; 54 //gets door by activation position (spell target) 55 Door* GetDoorByPosition(const Point &position) const; 56 Door* GetDoor(size_t idx) const; 57 Door* GetDoor(const char* Name) const; GetDoorCount()58 size_t GetDoorCount() { return doors.size(); } 59 //update doors for a new overlay 60 void UpdateDoors(); 61 void AutoLockDoors() const; 62 63 /* type is an optional filter for container type*/ 64 void AddContainer(Container *c); 65 //gets container by active region (click target) 66 Container* GetContainer(const Point &position, int type=-1) const; 67 //gets container by activation position (spell target) 68 Container* GetContainerByPosition(const Point &position, int type=-1) const; 69 Container* GetContainer(const char* Name) const; 70 Container* GetContainer(unsigned int idx) const; 71 /* cleans up empty heaps, returns 1 if container removed*/ 72 int CleanupContainer(Container *container); GetContainerCount()73 size_t GetContainerCount() const { return containers.size(); } 74 75 InfoPoint* AddInfoPoint(const char* Name, unsigned short Type, std::shared_ptr<Gem_Polygon> outline); 76 InfoPoint* GetInfoPoint(const Point &position, bool detectable) const; 77 InfoPoint* GetInfoPoint(const char* Name) const; 78 InfoPoint* GetInfoPoint(unsigned int idx) const; 79 InfoPoint* GetTravelTo(const char* Destination) const; 80 InfoPoint* AdjustNearestTravel(Point &p); GetInfoPointCount()81 size_t GetInfoPointCount() const { return infoPoints.size(); } 82 83 TileObject* AddTile(const char* ID, const char* Name, unsigned int Flags, 84 unsigned short* openindices, int opencount,unsigned short* closeindices, int closecount); 85 TileObject* GetTile(unsigned int idx); 86 TileObject* GetTile(const char* Name); GetTileCount()87 size_t GetTileCount() { return tiles.size(); } 88 89 void ClearOverlays(); 90 void AddOverlay(TileOverlay* overlay); 91 void AddRainOverlay(TileOverlay* overlay); 92 void DrawOverlays(const Region& screen, bool rain, BlitFlags flags); 93 Size GetMapSize(); 94 public: 95 int XCellCount = 0, YCellCount = 0; 96 }; 97 98 } 99 100 #endif 101