1 /* ScummVM - Graphic Adventure Engine 2 * 3 * ScummVM is the legal property of its developers, whose names 4 * are too numerous to list here. Please refer to the COPYRIGHT 5 * file distributed with this source distribution. 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 */ 22 #ifndef SLUDGE_FLOOR_H 23 #define SLUDGE_FLOOR_H 24 25 #include "common/rect.h" 26 27 namespace Sludge { 28 29 class SludgeEngine; 30 struct OnScreenPerson; 31 32 struct FloorPolygon { 33 int numVertices; 34 int *vertexID; 35 }; 36 37 struct Floor { 38 int originalNum; 39 Common::Point *vertex; 40 int numPolygons; 41 FloorPolygon *polygon; 42 int **matrix; 43 }; 44 45 class FloorManager { 46 public: 47 FloorManager(SludgeEngine *vm); 48 ~FloorManager(); 49 50 bool init(); 51 void kill(); 52 53 void setFloorNull(); 54 bool setFloor(int fileNum); 55 void drawFloor(); 56 int inFloor(int x, int y); isFloorNoPolygon()57 bool isFloorNoPolygon() { return !_currentFloor || _currentFloor->numPolygons == 0; } 58 59 // For Person collision detection 60 bool handleClosestPoint(int &setX, int &setY, int &setPoly); 61 bool doBorderStuff(OnScreenPerson *moveMe); 62 63 // Save & load 64 void save(Common::WriteStream *stream); 65 bool load(Common::SeekableReadStream *stream); 66 67 private: 68 Floor *_currentFloor; 69 SludgeEngine *_vm; 70 71 bool getMatchingCorners(FloorPolygon &, FloorPolygon &, int &, int &); 72 bool closestPointOnLine(int &closestX, int &closestY, int x1, int y1, int x2, int y2, int xP, int yP); 73 bool pointInFloorPolygon(FloorPolygon &floorPoly, int x, int y); 74 bool polysShareSide(FloorPolygon &a, FloorPolygon &b); 75 }; 76 77 } // End of namespace Sludge 78 79 #endif 80