ScummVM API documentation
scene_objects.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 #ifndef BLADERUNNER_SCENE_OBJECTS_H
23 #define BLADERUNNER_SCENE_OBJECTS_H
24 
25 #include "bladerunner/boundingbox.h"
26 
27 #include "common/rect.h"
28 
29 namespace BladeRunner {
30 
31 class BladeRunnerEngine;
32 class SaveFileReadStream;
33 class SaveFileWriteStream;
34 class View;
35 
36 enum SceneObjectType {
37  kSceneObjectTypeUnknown = -1,
38  kSceneObjectTypeActor = 0,
39  kSceneObjectTypeObject = 1,
40  kSceneObjectTypeItem = 2
41 };
42 
43 class SceneObjects {
44  friend class Debugger;
45 
46  static const int kSceneObjectCount = 115;
47 
48  struct SceneObject {
49  int id;
50  SceneObjectType type;
51  BoundingBox boundingBox;
52  Common::Rect screenRectangle;
53  float distanceToCamera;
54  bool isPresent;
55  bool isClickable;
56  bool isObstacle;
57  int unknown1;
58  bool isTarget;
59  bool isMoving;
60  bool isRetired;
61  };
62 
63  BladeRunnerEngine *_vm;
64 
65  View *_view;
66  int _count;
67  SceneObject _sceneObjects[kSceneObjectCount];
68  int _sceneObjectsSortedByDistance[kSceneObjectCount];
69 
70 public:
72  ~SceneObjects();
73 
74  bool addActor(int sceneObjectId, const BoundingBox &boundingBox, const Common::Rect &screenRectangle, bool isClickable, bool isMoving, bool isTarget, bool isRetired);
75  bool addObject(int sceneObjectId, const BoundingBox &boundingBox, bool isClickable, bool isObstacle, uint8 unknown1, bool isTarget);
76  bool addItem(int sceneObjectId, const BoundingBox &boundingBox, const Common::Rect &screenRectangle, bool isTarget, bool isObstacle);
77  bool remove(int sceneObjectId);
78  void clear();
79  int findByXYZ(bool *isClickable, bool *isObstacle, bool *isTarget, Vector3 &position, bool findClickables, bool findObstacles, bool findTargets) const;
80  bool existsOnXZ(int exceptSceneObjectId, float x, float z, bool movingActorIsObstacle, bool standingActorIsObstacle) const;
81  void setMoving(int sceneObjectId, bool isMoving);
82  void setRetired(int sceneObjectId, bool isRetired);
83  bool isBetween(float sourceX, float sourceZ, float targetX, float targetZ, int sceneObjectId) const;
84  bool isObstacleBetween(const Vector3 &source, const Vector3 &target, int exceptSceneObjectId) const;
85  void setIsClickable(int sceneObjectId, bool isClickable);
86  void setIsObstacle(int sceneObjectId, bool isObstacle);
87  void setIsTarget(int sceneObjectId, bool isTarget);
88  void updateObstacles();
89  int getCount() { return _count; }
90 
91  int findById(int sceneObjectId) const;
92  bool isEmptyScreenRectangle(int sceneObjectId);
93  int compareScreenRectangle(int sceneObjectId, const Common::Rect &rectangle);
94  void resetScreenRectangleAndBbox(int sceneObjectId);
95  void synchScreenRectangle(int sceneObjectId, const Common::Rect &targetScreenRect);
96 
97  void save(SaveFileWriteStream &f);
98  void load(SaveFileReadStream &f);
99 
100 private:
101  bool addSceneObject(int sceneObjectId, SceneObjectType sceneObjectType, const BoundingBox &boundingBox, const Common::Rect &screenRectangle, bool isClickable, bool isObstacle, uint8 unknown1, bool isTarget, bool isMoving, bool isRetired);
102  int findEmpty() const;
103 };
104 
105 } // End of namespace BladeRunner
106 
107 #endif
Definition: savefile.h:88
Definition: view.h:33
Definition: actor.h:31
Definition: savefile.h:113
Definition: rect.h:144
Definition: scene_objects.h:43
Definition: boundingbox.h:31
Definition: debugger.h:56
Definition: vector.h:47
Definition: bladerunner.h:113