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 
40 class Area {
41 public:
42  Area(uint16 areaID, uint16 areaFlags, ObjectMap *objectsByID, ObjectMap *entrancesByID, bool isCastle);
43  virtual ~Area();
44 
45  Common::String _name;
46  Object *objectWithID(uint16 objectID);
47  Object *entranceWithID(uint16 objectID);
48  Common::List<int> getEntranceIds();
49 
50  void changeObjectID(uint16 objectID, uint16 newObjectID);
51  ObjectArray getSensors();
52  uint16 getAreaID();
53  Common::Array<Object *> &getSortedObjects() { return _sortedObjects; }
54  ObjectMap *getObjectsByID() { return _objectsByID; }
55  ObjectMap *getEntrancesByID() { return _entrancesByID; }
56  uint16 getAreaFlags();
57  uint8 getScale();
58  void remapColor(int index, int color);
59  void unremapColor(int index);
60  void draw(Renderer *gfx, uint32 animationTicks, Math::Vector3d camera, Math::Vector3d direction, bool insideWait);
61  void drawGroup(Renderer *gfx, Group *group, bool runAnimation);
62  void show();
63 
64  Object *checkCollisionRay(const Math::Ray &ray, int raySize);
65  bool checkInSight(const Math::Ray &ray, float maxDistance);
66  Math::Vector3d separateFromWall(const Math::Vector3d &position);
67  ObjectArray checkCollisions(const Math::AABB &boundingBox);
68  bool checkIfPlayerWasCrushed(const Math::AABB &boundingBox);
69  Math::Vector3d resolveCollisions(Math::Vector3d const &lastPosition, Math::Vector3d const &newPosition, int playerHeight);
70  void addObjectFromArea(int16 id, Area *global);
71  void addGroupFromArea(int16 id, Area *global);
72  void addObject(Object *obj);
73  void addFloor();
74  void addStructure(Area *global);
75  void removeObject(int16 id);
76  void resetArea();
77  void resetAreaGroups();
78  bool isOutside();
79  bool hasActiveGroups();
80 
81  Common::Array<Common::String> _conditionSources;
83 
84  // Serialization
85  void saveObjects(Common::WriteStream *stream);
86  void loadObjects(Common::SeekableReadStream *stream, Area *global);
87 
88  // Driller specific
89  Common::Point _gasPocketPosition;
90  uint32 _gasPocketRadius;
91 
92  // Castle Master specific
93  bool _isCastle;
94 
95  uint8 _scale;
96  uint8 _skyColor;
97  uint8 _groundColor;
98  uint8 _usualBackgroundColor;
99  uint8 _underFireBackgroundColor;
100  uint8 _inkColor;
101  uint8 _paperColor;
102  uint8 _extraColor[4];
103  bool _colorCycling; // Amiga/Atari: bit 14 of area header enables COLOR15 cycling
104  ColorReMap _colorRemaps;
105 
106  uint32 _lastTick;
107 
108 private:
109  Math::Vector3d _lastCameraPosition;
110  ObjectArray _sortedObjects;
111 
112  uint16 _areaID;
113  uint16 _areaFlags;
114  ObjectMap *_objectsByID;
115  ObjectMap *_entrancesByID;
116  ObjectArray _drawableObjects;
117  ObjectMap _addedObjects;
118  Object *objectWithIDFromMap(ObjectMap *map, uint16 objectID);
119 };
120 
121 } // End of namespace Freescape
122 
123 #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:63
Definition: rect.h:144
Definition: object.h:56