fix agentOnCamera to cope with the wrap
[openc2e.git] / Map.h
blobea5a035f495c3be62bbc7c33e1d677a9be12fe75
1 /*
2 * Map.h
3 * openc2e
5 * Created by Alyssa Milburn on Tue May 25 2004.
6 * Copyright (c) 2004 Alyssa Milburn. All rights reserved.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
20 #ifndef _OPENC2E_MAP_H
21 #define _OPENC2E_MAP_H
23 #include "physics.h"
24 #include "openc2e.h"
25 #include <vector>
27 class Room;
28 class MetaRoom;
30 class Map {
31 protected:
32 FRIEND_SERIALIZE(Map);
33 unsigned int width, height;
34 std::vector<MetaRoom *> metarooms;
35 std::vector<shared_ptr<Room> > rooms;
37 friend class MetaRoom;
39 public:
40 /* Get a room, any room.
42 * For those times when you really, really need a room.
44 MetaRoom *getFallbackMetaroom() {
45 return metarooms.size() == 0 ? NULL : metarooms[0];
48 unsigned int room_base, metaroom_base;
50 Map() { width = 0; height = 0; room_base = 0; metaroom_base = 0; }
52 void Reset();
53 void SetMapDimensions(unsigned int, unsigned int);
54 unsigned int getWidth() { return width; }
55 unsigned int getHeight() { return height; }
57 int addMetaRoom(MetaRoom *);
58 MetaRoom *getMetaRoom(unsigned int);
59 MetaRoom *getArrayMetaRoom(unsigned int i) { return metarooms[i]; } // TODO: hack!
61 unsigned int getMetaRoomCount();
62 shared_ptr<Room> getRoom(unsigned int);
63 unsigned int getRoomCount();
65 MetaRoom *metaRoomAt(unsigned int, unsigned int);
66 shared_ptr<Room> roomAt(float, float);
67 std::vector<shared_ptr<Room> > roomsAt(float, float);
69 bool collideLineWithRoomSystem(Point src, Point dest, shared_ptr<Room> &room, Point &where, Line &wall, unsigned int &walldir, int perm);
70 bool collideLineWithRoomBoundaries(Point src, Point dest, shared_ptr<Room> room, shared_ptr<Room> &newroom, Point &where, Line &wall, unsigned int &walldir, int perm);
72 void tick();
75 #endif
76 /* vim: set noet: */