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
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
|
/* 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.
*
*/
#ifndef PEGASUS_NEIGHBORHOOD_H
#define PEGASUS_NEIGHBORHOOD_H
#include "common/queue.h"
#include "common/str.h"
#include "pegasus/fader.h"
#include "pegasus/hotspot.h"
#include "pegasus/input.h"
#include "pegasus/movie.h"
#include "pegasus/notification.h"
#include "pegasus/sound.h"
#include "pegasus/timers.h"
#include "pegasus/transition.h"
#include "pegasus/util.h"
#include "pegasus/neighborhood/door.h"
#include "pegasus/neighborhood/exit.h"
#include "pegasus/neighborhood/extra.h"
#include "pegasus/neighborhood/hotspotinfo.h"
#include "pegasus/neighborhood/spot.h"
#include "pegasus/neighborhood/turn.h"
#include "pegasus/neighborhood/view.h"
#include "pegasus/neighborhood/zoom.h"
namespace Pegasus {
class PegasusEngine;
// Pegasus Prime neighborhood id's
const tNeighborhoodID kCaldoriaID = 0;
const tNeighborhoodID kFullTSAID = 1;
const tNeighborhoodID kFinalTSAID = 2;
const tNeighborhoodID kTinyTSAID = 3;
const tNeighborhoodID kPrehistoricID = 4;
const tNeighborhoodID kMarsID = 5;
const tNeighborhoodID kWSCID = 6;
const tNeighborhoodID kNoradAlphaID = 7;
const tNeighborhoodID kNoradDeltaID = 8;
// The sub chase is not really a neighborhood, but we define a constant that is used
// to allow an easy transition out of Norad Alpha.
const tNeighborhoodID kNoradSubChaseID = 1000;
const TimeScale kDefaultLoopFadeScale = kThirtyTicksPerSecond;
const TimeValue kDefaultLoopFadeOut = kHalfSecondPerThirtyTicks;
const TimeValue kDefaultLoopFadeIn = kHalfSecondPerThirtyTicks;
enum tQueueRequestType {
kNavExtraRequest,
kSpotSoundRequest,
kDelayRequest
};
// For delay requests, start is interpreted as the total delay and stop is interpreted
// as the scale the delay is in.
// For extra requests, start and stop are not used.
struct tQueueRequest {
tQueueRequestType requestType;
tExtraID extra;
TimeValue start, stop;
tInputBits interruptionFilter;
bool playing;
tNotificationFlags flags;
Notification *notification;
};
bool operator==(const tQueueRequest &arg1, const tQueueRequest &arg2);
bool operator!=(const tQueueRequest &arg1, const tQueueRequest &arg2);
class Neighborhood;
class StriderCallBack : public TimeBaseCallBack {
public:
StriderCallBack(Neighborhood *);
virtual ~StriderCallBack() {}
protected:
virtual void callBack();
Neighborhood *_neighborhood;
};
typedef Common::Queue<tQueueRequest> NeighborhoodActionQueue;
class Neighborhood : public IDObject, public NotificationReceiver, public InputHandler, public Idler {
friend class StriderCallBack;
public:
Neighborhood(InputHandler *nextHandler, PegasusEngine *vm, const Common::String &resName, tNeighborhoodID id);
virtual ~Neighborhood();
virtual void init();
void start();
virtual void moveNavTo(const tCoordType, const tCoordType);
virtual void checkContinuePoint(const tRoomID, const tDirectionConstant) = 0;
virtual void activateHotspots();
virtual void clickInHotspot(const Input &, const Hotspot *);
tCanMoveForwardReason canMoveForward(ExitTable::Entry &entry);
tCanTurnReason canTurn(tTurnDirection turn, tDirectionConstant &nextDir);
tCanOpenDoorReason canOpenDoor(DoorTable::Entry &entry);
virtual void cantMoveThatWay(tCanMoveForwardReason);
virtual void cantTurnThatWay(tCanTurnReason) {}
virtual void cantOpenDoor(tCanOpenDoorReason);
virtual void arriveAt(tRoomID room, tDirectionConstant direction);
virtual void turnTo(const tDirectionConstant);
virtual void spotCompleted();
virtual void doorOpened();
virtual void closeDoorOffScreen(const tRoomID, const tDirectionConstant) {}
virtual void moveForward();
virtual void turn(const tTurnDirection);
virtual void turnLeft();
virtual void turnRight();
virtual void turnUp();
virtual void turnDown();
virtual void openDoor();
virtual void zoomTo(const Hotspot *);
virtual void updateViewFrame();
void requestExtraSequence(const tExtraID, const tNotificationFlags, const tInputBits interruptionFilter);
void requestSpotSound(const TimeValue, const TimeValue, const tInputBits interruptionFilter, const tNotificationFlags);
void playSpotSoundSync(const TimeValue in, const TimeValue out);
void requestDelay(const TimeValue, const TimeScale, const tInputBits interruptionFilter, const tNotificationFlags);
Notification *getNeighborhoodNotification() { return &_neighborhoodNotification; }
virtual void getExtraEntry(const uint32 id, ExtraTable::Entry &extraEntry);
virtual void startSpotLoop(TimeValue, TimeValue, tNotificationFlags = 0);
virtual bool actionQueueEmpty() { return _actionQueue.empty(); }
virtual void showViewFrame(TimeValue);
virtual void findSpotEntry(const tRoomID room, const tDirectionConstant direction, tSpotFlags flags, SpotTable::Entry &spotEntry);
virtual void startExtraSequence(const tExtraID, const tNotificationFlags, const tInputBits interruptionFilter);
bool startExtraSequenceSync(const tExtraID, const tInputBits);
virtual void loopExtraSequence(const uint32, tNotificationFlags = 0);
int32 getLastExtra() const { return _lastExtra; }
virtual void scheduleNavCallBack(tNotificationFlags);
Movie *getNavMovie() { return &_navMovie; }
bool navMoviePlaying();
void setCurrentAlternate(const tAlternateID alt) { _currentAlternate = alt; }
tAlternateID getCurrentAlternate() const { return _currentAlternate; }
void setCurrentActivation(const tHotSpotActivationID a) { _currentActivation = a; }
tHotSpotActivationID getCurrentActivation() { return _currentActivation; }
virtual void playDeathExtra(tExtraID, tDeathReason);
virtual void die(const tDeathReason);
virtual void setSoundFXLevel(const uint16);
virtual void setAmbienceLevel(const uint16);
void forceStridingStop(const tRoomID, const tDirectionConstant, const tAlternateID);
void restoreStriding(const tRoomID, const tDirectionConstant, const tAlternateID);
HotspotInfoTable::Entry *findHotspotEntry(const tHotSpotID);
Push *getTurnPush() { return &_turnPush; }
Picture *getTurnPushPicture() { return &_pushIn; }
void hideNav();
void showNav();
virtual void loadAmbientLoops() {}
virtual void flushGameState() {}
virtual Common::String getBriefingMovie();
virtual Common::String getEnvScanMovie();
virtual uint getNumHints();
virtual Common::String getHintMovie(uint);
virtual bool canSolve();
virtual void prepareForAIHint(const Common::String &) {}
virtual void cleanUpAfterAIHint(const Common::String &) {}
virtual void doSolve();
virtual bool okayToJump();
virtual tAirQuality getAirQuality(const tRoomID);
virtual void checkAirMask() {}
virtual void checkFlashlight() {}
virtual void shieldOn() {}
virtual void shieldOff() {}
virtual void loadLoopSound1(const Common::String &, const uint16 volume = 0x100,
const TimeValue fadeOut = kDefaultLoopFadeOut, const TimeValue fadeIn = kDefaultLoopFadeIn,
const TimeScale fadeScale = kDefaultLoopFadeScale);
virtual void loadLoopSound2(const Common::String &, const uint16 volume = 0x100,
const TimeValue fadeOut = kDefaultLoopFadeOut, const TimeValue fadeIn = kDefaultLoopFadeIn,
const TimeScale fadeScale = kDefaultLoopFadeScale);
virtual void takeItemFromRoom(Item *);
protected:
PegasusEngine *_vm;
Common::String _resName;
virtual void loadSoundSpots();
// Notification function.
virtual void receiveNotification(Notification *, const tNotificationFlags);
// Map info functions.
virtual void getExitEntry(const tRoomID room, const tDirectionConstant direction, ExitTable::Entry &entry);
virtual TimeValue getViewTime(const tRoomID room, const tDirectionConstant direction);
virtual void getDoorEntry(const tRoomID room, const tDirectionConstant direction, DoorTable::Entry &doorEntry);
virtual tDirectionConstant getTurnEntry(const tRoomID room, const tDirectionConstant direction, const tTurnDirection turn);
virtual void getZoomEntry(const tHotSpotID id, ZoomTable::Entry &zoomEntry);
virtual void getHotspotEntry(const tHotSpotID id, HotspotInfoTable::Entry &hotspotEntry);
// Nav movie sequences.
virtual void startExitMovie(const ExitTable::Entry &);
virtual void keepStriding(ExitTable::Entry &);
virtual void stopStriding();
virtual void checkStriding();
virtual bool stillMoveForward();
virtual void scheduleStridingCallBack(const TimeValue, tNotificationFlags flags);
virtual void startZoomMovie(const ZoomTable::Entry &);
virtual void startDoorOpenMovie(const TimeValue, const TimeValue);
virtual void startTurnPush(const tTurnDirection, const TimeValue, const tDirectionConstant);
virtual void playExtraMovie(const ExtraTable::Entry &, const tNotificationFlags, const tInputBits interruptionFilter);
virtual void activateCurrentView(const tRoomID, const tDirectionConstant, tSpotFlags);
virtual void activateOneHotspot(HotspotInfoTable::Entry &, Hotspot *);
virtual void startSpotOnceOnly(TimeValue, TimeValue);
virtual void startMovieSequence(const TimeValue, const TimeValue, tNotificationFlags,
bool loopSequence, const tInputBits interruptionFilter, const TimeValue strideStop = 0xffffffff);
virtual void createNeighborhoodSpots();
void resetLastExtra() { _lastExtra = -1; }
virtual void throwAwayInterface();
// Action queue stuff
void popActionQueue();
void serviceActionQueue();
void requestAction(const tQueueRequestType, const tExtraID, const TimeValue, const TimeValue, const tInputBits, const tNotificationFlags);
virtual bool prepareExtraSync(const tExtraID);
virtual bool waitMovieFinish(Movie *, const tInputBits);
virtual tInputBits getInputFilter();
// Misc.
virtual uint16 getStaticCompassAngle(const tRoomID, const tDirectionConstant dir);
virtual void getExitCompassMove(const ExitTable::Entry &, FaderMoveSpec &);
virtual void getZoomCompassMove(const ZoomTable::Entry &, FaderMoveSpec&);
virtual void getExtraCompassMove(const ExtraTable::Entry &, FaderMoveSpec&);
virtual void setUpAIRules();
virtual void newInteraction(const tInteractionID);
virtual void bumpIntoWall();
virtual void zoomUpOrBump();
// Navigation Data
DoorTable _doorTable;
ExitTable _exitTable;
ExtraTable _extraTable;
HotspotInfoTable _hotspotInfoTable;
SpotTable _spotTable;
TurnTable _turnTable;
ViewTable _viewTable;
ZoomTable _zoomTable;
tAlternateID _currentAlternate;
tHotSpotActivationID _currentActivation;
int32 _lastExtra;
tDeathReason _extraDeathReason;
// Graphics
Movie _navMovie;
Picture _pushIn;
Push _turnPush;
// Callbacks
Notification _neighborhoodNotification;
NotificationCallBack _navMovieCallBack;
StriderCallBack _stridingCallBack;
NotificationCallBack _turnPushCallBack;
NotificationCallBack _spotSoundCallBack;
NotificationCallBack _delayCallBack;
// Hotspots
HotspotList _neighborhoodHotspots;
// Sounds
Sound _spotSounds;
// Action queue
NeighborhoodActionQueue _actionQueue;
TimeBase _delayTimer;
// Interruptibility...
tInputBits _interruptionFilter;
// Nav hiding (for info support...)
bool _isRunning;
// TODO
//GameInteraction *_currentInteraction;
bool _doneWithInteraction;
Movie _croppedMovie;
Sound _soundLoop1;
Common::String _loop1SoundString;
SoundFader _loop1Fader;
Sound _soundLoop2;
Common::String _loop2SoundString;
SoundFader _loop2Fader;
// The event timer...
FuseFunction _eventTimer;
uint32 _timerEvent;
};
extern Neighborhood *g_neighborhood;
} // End of namespace Pegasus
#endif
|