ScummVM API documentation
room.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 DARKSEED_ROOM_H
23 #define DARKSEED_ROOM_H
24 
25 #include "common/rect.h"
26 #include "darkseed/nsp.h"
27 #include "darkseed/pal.h"
28 #include "darkseed/pic.h"
29 #include "sound.h"
30 
31 namespace Darkseed {
32 
33 struct RoomExit {
34  uint16 x = 0;
35  uint16 y = 0;
36  uint16 width = 0;
37  uint16 height = 0;
38  uint16 roomNumber = 0;
39  uint8 direction = 0;
40 };
41 
42 struct RoomStruct2 {
43  uint8 strip[40];
44 };
45 
47  uint16 type = 0;
48  uint16 objNum = 0;
49  uint16 xOffset = 0;
50  uint16 yOffset = 0;
51  uint16 width = 0;
52  uint16 height = 0;
53  uint8 depth = 0;
54  uint8 spriteNum = 0;
55 };
56 
57 class Room {
58  bool _palLoaded = false;
59 
60 public:
61  static constexpr int MAX_CONNECTORS = 12;
62  uint8 _roomNumber;
63  Pic _pic;
64  Pal _pal;
65  Nsp _locationSprites;
66  Common::Array<int16> _locObjFrame;
67  Common::Array<int16> _locObjFrameTimer;
68 
70  Common::Array<RoomStruct2> _walkableLocationsMap;
72  Common::Array<Common::Point> _connectors;
73 
74  uint16 _selectedObjIndex = 0;
75  int16 _collisionType = 0;
76 
77  explicit Room(int roomNumber);
78 
79  void initRoom();
80  void draw();
81 
82  void update();
83 
84  int checkCursorAndMoveableObjects();
85  int checkCursorAndStaticObjects(int x, int y);
86  int CheckCursorAndMovedObjects();
87  int getRoomExitAtCursor();
88  void getWalkTargetForObjectType_maybe(int objId);
89  int getObjectUnderCursor();
90  uint16 getDoorTargetRoom(int objId);
91  int getExitRoomNumberAtPoint(int x, int y);
92  bool exitRoom();
93  Common::String getRoomFilenameBase(int roomNumber);
94  bool canWalkAtLocation(int x, int y);
95  bool canWalkInLineToTarget(int x, int y, int targetX, int targetY);
96  void printRoomDescriptionText() const;
97  void calculateScaledSpriteDimensions(int width, int height, int curYPosition);
98  bool isOutside() const;
99  bool isGiger();
100  void runRoomObjects();
101  void removeObjectFromRoom(int16 objNum);
102  void updateRoomObj(int16 objNum, int16 x, int16 width, int16 y, int16 height);
103  bool advanceFrame(int animIdx);
104  void mikeStickThrowAnim();
105  void loadRoom61AWalkableLocations();
106  void restorePalette();
107  void darkenSky();
108  void loadLocationSprites(const Common::Path &path);
109  Common::Point getExitPointForRoom(uint8 roomNumber);
110  static MusicId getMusicIdForRoom(uint8 roomNumber);
111  void loadRoomMusic();
112 
113 private:
114  bool load();
115  static Common::String stripSpaces(const Common::String &source);
116  void drawTrunk();
117  void advanceLocAnimFrame(int roomObjIdx);
118 };
119 
120 } // namespace Darkseed
121 
122 #endif // DARKSEED_ROOM_H
Definition: str.h:59
Definition: path.h:52
Definition: room.h:57
Definition: room.h:42
Definition: pal.h:33
Definition: nsp.h:61
Definition: rect.h:45
Definition: room.h:33
Definition: pic.h:31
Definition: adlib_worx.h:27
Definition: room.h:46