1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
|
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* Additional copyright for this file:
* Copyright (C) 1995-1997 Presto Studios, Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include "pegasus/energymonitor.h"
#include "pegasus/gamestate.h"
#include "pegasus/pegasus.h"
#include "pegasus/ai/ai_area.h"
#include "pegasus/items/inventory/airmask.h"
#include "pegasus/neighborhood/norad/norad.h"
#include "pegasus/neighborhood/norad/noradelevator.h"
#include "pegasus/neighborhood/norad/pressuredoor.h"
#include "pegasus/neighborhood/norad/subcontrolroom.h"
#include "pegasus/neighborhood/norad/subplatform.h"
namespace Pegasus {
const tNotificationFlags kDoneWithPressureDoorNotification = 1;
const tNotificationFlags kNoradNotificationFlags = kDoneWithPressureDoorNotification;
// This class handles everything that Norad Alpha and Delta have in common, such as
// oxygen mask usage, the elevator and the pressure doors.
Norad::Norad(InputHandler *nextHandler, PegasusEngine *vm, const Common::String &resName, tNeighborhoodID id) :
Neighborhood(nextHandler, vm, resName, id), _noradNotification(kNoradNotificationID, vm) {
_elevatorUpSpotID = kNoHotSpotID;
_elevatorDownSpotID = kNoHotSpotID;
_elevatorUpRoomID = kNoHotSpotID;
_elevatorDownRoomID = kNoHotSpotID;
_subRoomEntryRoom1 = kNoRoomID;
_subRoomEntryDir1 = kNoDirection;
_subRoomEntryRoom2 = kNoRoomID;
_subRoomEntryDir2 = kNoDirection;
_upperPressureDoorRoom = kNoRoomID;
_lowerPressureDoorRoom = kNoRoomID;
_upperPressureDoorUpSpotID = kNoHotSpotID;
_upperPressureDoorDownSpotID = kNoHotSpotID;
_upperPressureDoorAbortSpotID = kNoHotSpotID;
_lowerPressureDoorUpSpotID = kNoHotSpotID;
_lowerPressureDoorDownSpotID = kNoHotSpotID;
_lowerPressureDoorAbortSpotID = kNoHotSpotID;
_pressureSoundIn = 0xffffffff;
_pressureSoundOut = 0xffffffff;
_equalizeSoundIn = 0xffffffff;
_equalizeSoundOut = 0xffffffff;
_accessDeniedIn = 0xffffffff;
_accessDeniedOut = 0xffffffff;
_platformRoom = kNoRoomID;
_subControlRoom = kNoRoomID;
_doneWithPressureDoor = false;
_noradNotification.notifyMe(this, kNoradNotificationFlags, kNoradNotificationFlags);
}
GameInteraction *Norad::makeInteraction(const tInteractionID interactionID) {
PressureDoor *pressureDoor;
SubControlRoom *subControl;
switch (interactionID) {
case kNoradElevatorInteractionID:
return new NoradElevator(this, _elevatorUpRoomID, _elevatorDownRoomID, _elevatorUpSpotID, _elevatorDownSpotID);
case kNoradPressureDoorInteractionID:
if (GameState.getCurrentRoom() == _upperPressureDoorRoom)
pressureDoor = new PressureDoor(this, true, _upperPressureDoorUpSpotID, _upperPressureDoorDownSpotID,
_upperPressureDoorAbortSpotID, _pressureSoundIn, _pressureSoundOut, _equalizeSoundIn, _equalizeSoundOut);
else
pressureDoor = new PressureDoor(this, false, _lowerPressureDoorUpSpotID, _lowerPressureDoorDownSpotID,
_lowerPressureDoorAbortSpotID, _pressureSoundIn, _pressureSoundOut, _equalizeSoundIn, _equalizeSoundOut);
if (GameState.getCurrentRoom() == kNorad59West && playingAgainstRobot())
pressureDoor->playAgainstRobot();
return pressureDoor;
case kNoradSubControlRoomInteractionID:
subControl = new SubControlRoom(this);
if (GameState.getCurrentRoom() == kNorad60West && playingAgainstRobot())
subControl->playAgainstRobot();
return subControl;
case kNoradSubPlatformInteractionID:
return new SubPlatform(this);
default:
return 0;
}
}
void Norad::flushGameState() {
g_energyMonitor->saveCurrentEnergyValue();
}
void Norad::start() {
setUpAirMask();
Neighborhood::start();
}
void Norad::activateHotspots() {
Neighborhood::activateHotspots();
tRoomID room = GameState.getCurrentRoom();
if (room == _elevatorUpRoomID)
_neighborhoodHotspots.activateOneHotspot(_elevatorDownSpotID);
else if (room == _elevatorDownRoomID)
_neighborhoodHotspots.activateOneHotspot(_elevatorUpSpotID);
}
void Norad::arriveAt(const tRoomID room, const tDirectionConstant direction) {
Neighborhood::arriveAt(room, direction);
if (GameState.getCurrentRoom() == _elevatorUpRoomID || GameState.getCurrentRoom() == _elevatorDownRoomID)
arriveAtNoradElevator();
else if (GameState.getCurrentRoom() == _upperPressureDoorRoom)
arriveAtUpperPressureDoorRoom();
else if (GameState.getCurrentRoom() == _lowerPressureDoorRoom)
arriveAtLowerPressureDoorRoom();
else if (GameState.getCurrentRoom() == _platformRoom)
arriveAtSubPlatformRoom();
else if (GameState.getCurrentRoom() == _subControlRoom)
arriveAtSubControlRoom();
if (_doneWithPressureDoor) {
_doneWithPressureDoor = false;
openDoor();
}
}
void Norad::arriveAtNoradElevator() {
if (_currentInteraction)
_currentInteraction->startOverInteraction();
else
newInteraction(kNoradElevatorInteractionID);
}
void Norad::arriveAtUpperPressureDoorRoom() {
newInteraction(kNoradPressureDoorInteractionID);
}
void Norad::arriveAtLowerPressureDoorRoom() {
newInteraction(kNoradPressureDoorInteractionID);
}
void Norad::arriveAtSubPlatformRoom() {
newInteraction(kNoradSubPlatformInteractionID);
}
void Norad::arriveAtSubControlRoom() {
newInteraction(kNoradSubControlRoomInteractionID);
}
int16 Norad::getStaticCompassAngle(const tRoomID room, const tDirectionConstant dir) {
int16 result = Neighborhood::getStaticCompassAngle(room, dir);
if (room == _elevatorUpRoomID || room == _elevatorDownRoomID)
result += kElevatorCompassAngle;
else if (room == _platformRoom)
result += kSubPlatformCompassAngle;
else if (room == _subControlRoom)
result += kSubControlCompassAngle;
return result;
}
tCanOpenDoorReason Norad::canOpenDoor(DoorTable::Entry &entry) {
if (((GameState.getCurrentRoom() == _subRoomEntryRoom1 && GameState.getCurrentDirection() == _subRoomEntryDir1) ||
(GameState.getCurrentRoom() == _subRoomEntryRoom2 && GameState.getCurrentDirection() == _subRoomEntryDir2)) &&
GameState.getNoradSubRoomPressure() != kNormalSubRoomPressure)
return kCantOpenBadPressure;
return Neighborhood::canOpenDoor(entry);
}
void Norad::cantOpenDoor(tCanOpenDoorReason reason) {
if (reason == kCantOpenBadPressure)
playSpotSoundSync(_pressureSoundIn, _pressureSoundOut);
else
playSpotSoundSync(_accessDeniedIn, _accessDeniedOut);
}
void Norad::startExitMovie(const ExitTable::Entry &exitEntry) {
if (GameState.getCurrentRoom() == _elevatorUpRoomID) {
if (exitEntry.exitRoom != _elevatorDownRoomID)
newInteraction(kNoInteractionID);
} else if (GameState.getCurrentRoom() == _elevatorDownRoomID) {
if (exitEntry.exitRoom != _elevatorUpRoomID)
newInteraction(kNoInteractionID);
} else {
newInteraction(kNoInteractionID);
}
Neighborhood::startExitMovie(exitEntry);
}
void Norad::startZoomMovie(const ZoomTable::Entry &zoomEntry) {
newInteraction(kNoInteractionID);
Neighborhood::startZoomMovie(zoomEntry);
}
void Norad::upButton(const Input &input) {
if (GameState.getCurrentRoom() != _elevatorUpRoomID && GameState.getCurrentRoom() != _elevatorDownRoomID)
Neighborhood::upButton(input);
}
void Norad::setUpAirMask() {
_airMaskCallBack.setNotification(&_neighborhoodNotification);
_airMaskCallBack.initCallBack(&_airMaskTimer, kCallBackAtExtremes);
_airMaskCallBack.setCallBackFlag(kAirTimerExpiredFlag);
_neighborhoodNotification.notifyMe(this, kAirTimerExpiredFlag, kAirTimerExpiredFlag);
_airMaskCallBack.scheduleCallBack(kTriggerAtStop, 0, 0);
_airMaskTimer.setScale(1);
_airMaskTimer.setSegment(0, kNoradAirMaskTimeLimit);
checkAirMask();
}
void Norad::checkAirMask() {
if (g_airMask && g_airMask->isAirFilterOn()) {
_airMaskTimer.stop();
} else if (GameState.getNoradGassed() && !_airMaskTimer.isRunning()) {
_airMaskTimer.setTime(0);
_airMaskTimer.start();
}
loadAmbientLoops();
}
void Norad::receiveNotification(Notification *notification, const tNotificationFlags flags) {
if (notification == &_neighborhoodNotification && (flags & kAirTimerExpiredFlag) != 0)
((PegasusEngine *)g_engine)->die(kDeathGassedInNorad);
Neighborhood::receiveNotification(notification, flags);
if (notification == &_noradNotification) {
// Must be kDoneWithPressureDoorNotification...
Input scratch;
_doneWithPressureDoor = true;
downButton(scratch);
}
}
uint16 Norad::getDateResID() const {
return kDate2112ID;
}
Common::String Norad::getBriefingMovie() {
return "Images/AI/Norad/XNO";
}
void Norad::pickedUpItem(Item *item) {
Neighborhood::pickedUpItem(item);
g_AIArea->checkMiddleArea();
}
void Norad::doneWithPressureDoor() {
_noradNotification.setNotificationFlags(kDoneWithPressureDoorNotification, kDoneWithPressureDoorNotification);
}
} // End of namespace Pegasus
|