ScummVM API documentation
object.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/*
23 * This code is based on original Hugo Trilogy source code
24 *
25 * Copyright (c) 1989-1995 David P. Gray
26 *
27 */
28
29#ifndef HUGO_OBJECT_H
30#define HUGO_OBJECT_H
31
32#include "common/file.h"
33
34namespace Hugo {
35
36struct Target { // Secondary target for action
37 uint16 _nounIndex; // Secondary object
38 uint16 _verbIndex; // Action on secondary object
39};
40
41struct Uses { // Define uses of certain objects
42 int16 _objId; // Primary object
43 uint16 _dataIndex; // String if no secondary object matches
44 Target *_targets; // List of secondary targets
45};
46
48public:
50 virtual ~ObjectHandler();
51
52 Overlay _objBound;
53 Overlay _boundary; // Boundary overlay file
54 Overlay _overlay; // First overlay file
55 Overlay _ovlBase; // First overlay base file
56
57 Object *_objects;
58 uint16 _numObj;
59
60 byte getBoundaryOverlay(uint16 index) const;
61 byte getObjectBoundary(uint16 index) const;
62 byte getBaseBoundary(uint16 index) const;
63 byte getFirstOverlay(uint16 index) const;
64
65 int deltaX(const int x1, const int x2, const int vx, int y) const;
66 int deltaY(const int x1, const int x2, const int vy, const int y) const;
67 void boundaryCollision(Object *obj);
68 void clearBoundary(const int x1, const int x2, const int y);
69 void clearScreenBoundary(const int x1, const int x2, const int y);
70 void storeBoundary(const int x1, const int x2, const int y);
71
72 virtual void homeIn(const int objIndex1, const int objIndex2, const int8 objDx, const int8 objDy) = 0;
73 virtual void moveObjects() = 0;
74 virtual void updateImages() = 0;
75 virtual void swapImages(int objIndex1, int objIndex2, bool restoring) = 0;
76
77 bool isCarrying(uint16 wordIndex);
78 bool findObjectSpace(Object *obj, int16 *destx, int16 *desty);
79
80 int calcMaxScore();
81 int16 findObject(uint16 x, uint16 y);
82 void freeObjects();
83 void loadObjectArr(Common::ReadStream &in);
84 void loadObjectUses(Common::ReadStream &in);
85 void loadNumObj(Common::ReadStream &in);
86 void lookObject(Object *obj);
87 void readObjectImages();
88 void readObject(Common::ReadStream &in, Object &curObject);
89 void readUse(Common::ReadStream &in, Uses &curUse);
90 void restoreAllSeq();
91 void restoreObjects(Common::SeekableReadStream *in);
92 void saveObjects(Common::WriteStream *out);
93 void saveSeq(Object *obj);
94 void setCarriedScreen(int screenNum);
95 void showTakeables();
96 void useObject(int16 objId);
97
98 static int y2comp(const void *a, const void *b);
99
100 bool isCarried(int objIndex) const;
101 void setCarry(int objIndex, bool val);
102 void setVelocity(int objIndex, int8 vx, int8 vy);
103 void setPath(int objIndex, Path pathType, int16 vxPath, int16 vyPath);
104
105protected:
106 HugoEngine *_vm;
107
108 static const int kEdge = 10; // Closest object can get to edge of screen
109 static const int kEdge2 = kEdge * 2; // Push object further back on edge collision
110 static const int kMaxObjNumb = 128; // Used in Update_images()
111
112 uint16 _objCount;
113 Uses *_uses;
114 uint16 _usesSize;
115
116 void restoreSeq(Object *obj);
117
118 inline bool checkBoundary(int16 x, int16 y);
119 static inline int sign(int a) { return (a < 0) ? -1 : 1; }
120};
121
123public:
125 ~ObjectHandler_v1d() override;
126
127 void homeIn(const int objIndex1, const int objIndex2, const int8 objDx, const int8 objDy) override;
128 void moveObjects() override;
129 void updateImages() override;
130 void swapImages(int objIndex1, int objIndex2, bool restoring) override;
131};
132
134public:
136 ~ObjectHandler_v2d() override;
137
138 void moveObjects() override;
139 void updateImages() override;
140
141 void homeIn(const int objIndex1, const int objIndex2, const int8 objDx, const int8 objDy) override;
142};
143
145public:
147 ~ObjectHandler_v3d() override;
148
149 void moveObjects() override;
150 void swapImages(int objIndex1, int objIndex2, bool restoring) override;
151};
152
154public:
156 ~ObjectHandler_v1w() override;
157
158 void moveObjects() override;
159 void updateImages() override;
160 void swapImages(int objIndex1, int objIndex2, bool restoring) override;
161};
162
163} // End of namespace Hugo
164#endif //HUGO_OBJECT_H
Definition: stream.h:385
Definition: stream.h:745
Definition: stream.h:77
Definition: hugo.h:219
Definition: object.h:122
Definition: object.h:153
Definition: object.h:133
Definition: object.h:144
Definition: object.h:47
Definition: default_display_client.h:68
Definition: console.h:27
Path
Definition: game.h:76
Definition: game.h:143
Definition: object.h:36
Definition: object.h:41