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