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
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
|
/* 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
static const NeighborhoodID kCaldoriaID = 0;
static const NeighborhoodID kFullTSAID = 1;
static const NeighborhoodID kFinalTSAID = 2;
static const NeighborhoodID kTinyTSAID = 3;
static const NeighborhoodID kPrehistoricID = 4;
static const NeighborhoodID kMarsID = 5;
static const NeighborhoodID kWSCID = 6;
static const NeighborhoodID kNoradAlphaID = 7;
static const NeighborhoodID 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.
static const NeighborhoodID kNoradSubChaseID = 1000;
static const TimeScale kDefaultLoopFadeScale = kThirtyTicksPerSecond;
static const TimeValue kDefaultLoopFadeOut = kHalfSecondPerThirtyTicks;
static const TimeValue kDefaultLoopFadeIn = kHalfSecondPerThirtyTicks;
enum QueueRequestType {
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 QueueRequest {
QueueRequestType requestType;
ExtraID extra;
TimeValue start, stop;
InputBits interruptionFilter;
bool playing;
NotificationFlags flags;
Notification *notification;
};
bool operator==(const QueueRequest &arg1, const QueueRequest &arg2);
bool operator!=(const QueueRequest &arg1, const QueueRequest &arg2);
class CaldoriaBomb;
class GameInteraction;
class Item;
class Neighborhood;
class StriderCallBack : public TimeBaseCallBack {
public:
StriderCallBack(Neighborhood *);
virtual ~StriderCallBack() {}
protected:
virtual void callBack();
Neighborhood *_neighborhood;
};
typedef Common::Queue<QueueRequest> NeighborhoodActionQueue;
class Neighborhood : public IDObject, public NotificationReceiver, public InputHandler, public Idler {
friend class CaldoriaBomb;
friend class StriderCallBack;
public:
Neighborhood(InputHandler *nextHandler, PegasusEngine *vm, const Common::String &resName, NeighborhoodID id);
virtual ~Neighborhood();
virtual void init();
virtual void start();
virtual void moveNavTo(const CoordType, const CoordType);
virtual void checkContinuePoint(const RoomID, const DirectionConstant) = 0;
void makeContinuePoint();
virtual void activateHotspots();
virtual void clickInHotspot(const Input &, const Hotspot *);
virtual CanMoveForwardReason canMoveForward(ExitTable::Entry &entry);
virtual CanTurnReason canTurn(TurnDirection turn, DirectionConstant &nextDir);
virtual CanOpenDoorReason canOpenDoor(DoorTable::Entry &entry);
virtual void cantMoveThatWay(CanMoveForwardReason);
virtual void cantTurnThatWay(CanTurnReason) {}
virtual void cantOpenDoor(CanOpenDoorReason);
virtual void arriveAt(const RoomID room, const DirectionConstant direction);
virtual void turnTo(const DirectionConstant);
virtual void spotCompleted();
virtual void doorOpened();
virtual void closeDoorOffScreen(const RoomID, const DirectionConstant) {}
virtual void moveForward();
virtual void turn(const TurnDirection);
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 ExtraID, const NotificationFlags, const InputBits interruptionFilter);
void requestSpotSound(const TimeValue, const TimeValue, const InputBits interruptionFilter, const NotificationFlags);
void playSpotSoundSync(const TimeValue in, const TimeValue out);
void requestDelay(const TimeValue, const TimeScale, const InputBits interruptionFilter, const NotificationFlags);
Notification *getNeighborhoodNotification() { return &_neighborhoodNotification; }
virtual void getExtraEntry(const uint32 id, ExtraTable::Entry &extraEntry);
virtual void startSpotLoop(TimeValue, TimeValue, NotificationFlags = 0);
virtual bool actionQueueEmpty() { return _actionQueue.empty(); }
virtual void showViewFrame(TimeValue);
virtual void findSpotEntry(const RoomID room, const DirectionConstant direction, SpotFlags flags, SpotTable::Entry &spotEntry);
virtual void startExtraSequence(const ExtraID, const NotificationFlags, const InputBits interruptionFilter);
bool startExtraSequenceSync(const ExtraID, const InputBits);
virtual void loopExtraSequence(const uint32, NotificationFlags = 0);
int32 getLastExtra() const { return _lastExtra; }
virtual void scheduleNavCallBack(NotificationFlags);
Movie *getNavMovie() { return &_navMovie; }
bool navMoviePlaying();
void setCurrentAlternate(const AlternateID alt) { _currentAlternate = alt; }
AlternateID getCurrentAlternate() const { return _currentAlternate; }
void setCurrentActivation(const HotSpotActivationID a) { _currentActivation = a; }
HotSpotActivationID getCurrentActivation() { return _currentActivation; }
virtual void playDeathExtra(ExtraID, DeathReason);
virtual void die(const DeathReason);
virtual void setSoundFXLevel(const uint16);
virtual void setAmbienceLevel(const uint16);
void forceStridingStop(const RoomID, const DirectionConstant, const AlternateID);
void restoreStriding(const RoomID, const DirectionConstant, const AlternateID);
HotspotInfoTable::Entry *findHotspotEntry(const HotSpotID);
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 AirQuality getAirQuality(const RoomID);
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);
bool loop1Loaded(const Common::String &soundName) { return _loop1SoundString == soundName; }
bool loop2Loaded(const Common::String &soundName) { return _loop2SoundString == soundName; }
void startLoop1Fader(const FaderMoveSpec &);
void startLoop2Fader(const FaderMoveSpec &);
virtual void takeItemFromRoom(Item *);
virtual void dropItemIntoRoom(Item *, Hotspot *);
virtual Hotspot *getItemScreenSpot(Item *, DisplayElement *) { return 0; }
virtual GameInteraction *makeInteraction(const InteractionID);
virtual void requestDeleteCurrentInteraction() { _doneWithInteraction = true; }
virtual uint16 getDateResID() const = 0;
virtual void showExtraView(uint32);
virtual void startExtraLongSequence(const uint32, const uint32, NotificationFlags, const InputBits interruptionFilter);
void openCroppedMovie(const Common::String &, CoordType, CoordType);
void loopCroppedMovie(const Common::String &, CoordType, CoordType);
void closeCroppedMovie();
void playCroppedMovieOnce(const Common::String &, CoordType, CoordType, const InputBits interruptionFilter = kFilterNoInput);
void playMovieSegment(Movie *, TimeValue = 0, TimeValue = 0xffffffff);
virtual void recallToTSASuccess();
virtual void recallToTSAFailure();
virtual void pickedUpItem(Item *) {}
virtual void handleInput(const Input &, const Hotspot *);
protected:
PegasusEngine *_vm;
Common::String _resName;
virtual Common::String getSoundSpotsName() = 0;
virtual Common::String getNavMovieName() = 0;
// Notification function.
virtual void receiveNotification(Notification *, const NotificationFlags);
// Map info functions.
virtual void getExitEntry(const RoomID room, const DirectionConstant direction, ExitTable::Entry &entry);
virtual TimeValue getViewTime(const RoomID room, const DirectionConstant direction);
virtual void getDoorEntry(const RoomID room, const DirectionConstant direction, DoorTable::Entry &doorEntry);
virtual DirectionConstant getTurnEntry(const RoomID room, const DirectionConstant direction, const TurnDirection turn);
virtual void getZoomEntry(const HotSpotID id, ZoomTable::Entry &zoomEntry);
virtual void getHotspotEntry(const HotSpotID 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, NotificationFlags flags);
virtual void startZoomMovie(const ZoomTable::Entry &);
virtual void startDoorOpenMovie(const TimeValue, const TimeValue);
virtual void startTurnPush(const TurnDirection, const TimeValue, const DirectionConstant);
virtual void playExtraMovie(const ExtraTable::Entry &, const NotificationFlags, const InputBits interruptionFilter);
virtual void activateCurrentView(const RoomID, const DirectionConstant, SpotFlags);
virtual void activateOneHotspot(HotspotInfoTable::Entry &, Hotspot *);
virtual void startSpotOnceOnly(TimeValue, TimeValue);
virtual void startMovieSequence(const TimeValue, const TimeValue, NotificationFlags,
bool loopSequence, const InputBits 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 QueueRequestType, const ExtraID, const TimeValue, const TimeValue, const InputBits, const NotificationFlags);
virtual bool prepareExtraSync(const ExtraID);
virtual bool waitMovieFinish(Movie *, const InputBits);
virtual InputBits getInputFilter();
// Misc.
virtual int16 getStaticCompassAngle(const RoomID, const DirectionConstant 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 setHotspotFlags(const HotSpotID, const HotSpotFlags);
virtual void setIsItemTaken(const ItemID);
virtual void upButton(const Input &);
virtual void leftButton(const Input &);
virtual void rightButton(const Input &);
virtual void downButton(const Input &);
void initOnePicture(Picture *, const Common::String &, DisplayOrder, CoordType, CoordType, bool);
void initOneMovie(Movie *, const Common::String &, DisplayOrder, CoordType, CoordType, bool);
void reinstateMonocleInterface();
virtual void newInteraction(const InteractionID);
virtual void useIdleTime();
virtual void bumpIntoWall();
virtual void zoomUpOrBump();
void scheduleEvent(const TimeValue, const TimeScale, const uint32);
void cancelEvent();
virtual void timerExpired(const uint32) {}
bool isEventTimerRunning() { return _eventTimer.isFuseLit(); }
uint32 getTimerEvent() { return _timerEvent; }
void timerFunction();
void pauseTimer();
void resumeTimer();
bool timerPaused();
// Navigation Data
DoorTable _doorTable;
ExitTable _exitTable;
ExtraTable _extraTable;
HotspotInfoTable _hotspotInfoTable;
SpotTable _spotTable;
TurnTable _turnTable;
ViewTable _viewTable;
ZoomTable _zoomTable;
AlternateID _currentAlternate;
HotSpotActivationID _currentActivation;
int32 _lastExtra;
DeathReason _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
SoundTimeBase _spotSounds;
// Action queue
NeighborhoodActionQueue _actionQueue;
TimeBase _delayTimer;
// Interruptibility...
InputBits _interruptionFilter;
// Nav hiding (for info support...)
bool _isRunning;
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
|