ScummVM API documentation
area.h
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 modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (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, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 // Based on Phantasma code by Thomas Harte (2013),
23 // available at https://github.com/TomHarte/Phantasma/ (MIT)
24 
25 #ifndef FREESCAPE_AREA_H
26 #define FREESCAPE_AREA_H
27 
28 #include "math/ray.h"
29 #include "math/vector3d.h"
30 
31 #include "freescape/language/instruction.h"
32 #include "freescape/objects/object.h"
33 #include "freescape/objects/group.h"
34 
35 
36 namespace Freescape {
37 
38 typedef Common::HashMap<uint16, Object *> ObjectMap;
39 typedef Common::Array<Object *> ObjectArray;
40 class Area {
41 public:
42  Area(uint16 areaID, uint16 areaFlags, ObjectMap *objectsByID, ObjectMap *entrancesByID);
43  virtual ~Area();
44 
45  Common::String _name;
46  Object *objectWithID(uint16 objectID);
47  Object *entranceWithID(uint16 objectID);
48  void changeObjectID(uint16 objectID, uint16 newObjectID);
49  ObjectArray getSensors();
50  uint16 getAreaID();
51  uint16 getAreaFlags();
52  uint8 getScale();
53  void remapColor(int index, int color);
54  void unremapColor(int index);
55  void draw(Renderer *gfx, uint32 animationTicks, Math::Vector3d camera, Math::Vector3d direction);
56  void drawGroup(Renderer *gfx, Group *group, bool runAnimation);
57  void show();
58 
59  Object *checkCollisionRay(const Math::Ray &ray, int raySize);
60  bool checkInSight(const Math::Ray &ray, float maxDistance);
61  Math::Vector3d separateFromWall(const Math::Vector3d &position);
62  ObjectArray checkCollisions(const Math::AABB &boundingBox);
63  bool checkIfPlayerWasCrushed(const Math::AABB &boundingBox);
64  Math::Vector3d resolveCollisions(Math::Vector3d const &lastPosition, Math::Vector3d const &newPosition, int playerHeight);
65  void addObjectFromArea(int16 id, Area *global);
66  void addGroupFromArea(int16 id, Area *global);
67  void addObject(Object *obj);
68  void addFloor();
69  void addStructure(Area *global);
70  void removeObject(int16 id);
71  void resetArea();
72  void resetAreaGroups();
73  bool isOutside();
74  bool hasActiveGroups();
75 
76  Common::Array<Common::String> _conditionSources;
78 
79  // Serialization
80  void saveObjects(Common::WriteStream *stream);
81  void loadObjects(Common::SeekableReadStream *stream, Area *global);
82 
83  // Driller specific
84  Common::Point _gasPocketPosition;
85  uint32 _gasPocketRadius;
86 
87  uint8 _scale;
88  uint8 _skyColor;
89  uint8 _groundColor;
90  uint8 _usualBackgroundColor;
91  uint8 _underFireBackgroundColor;
92  uint8 _inkColor;
93  uint8 _paperColor;
94  uint8 _extraColor[4];
95  ColorReMap _colorRemaps;
96 
97  uint32 _lastTick;
98 
99 private:
100  uint16 _areaID;
101  uint16 _areaFlags;
102  ObjectMap *_objectsByID;
103  ObjectMap *_entrancesByID;
104  ObjectArray _drawableObjects;
105  ObjectMap _addedObjects;
106  Object *objectWithIDFromMap(ObjectMap *map, uint16 objectID);
107 };
108 
109 } // End of namespace Freescape
110 
111 #endif // FREESCAPE_AREA_H
Definition: group.h:40
Definition: str.h:59
Definition: stream.h:77
Definition: area.h:36
Definition: area.h:40
Definition: stream.h:745
Definition: gfx.h:60
Definition: rect.h:45
Definition: object.h:56