2 ===========================================================================
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
9 Doom 3 Source Code is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
14 Doom 3 Source Code is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
22 In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
26 ===========================================================================
29 #ifndef __GAME_MOVER_H__
30 #define __GAME_MOVER_H__
32 extern const idEventDef EV_TeamBlocked;
33 extern const idEventDef EV_PartBlocked;
34 extern const idEventDef EV_ReachedPos;
35 extern const idEventDef EV_ReachedAng;
38 ===============================================================================
42 ===============================================================================
45 class idMover : public idEntity {
47 CLASS_PROTOTYPE( idMover );
53 void Save( idSaveGame *savefile ) const;
54 void Restore( idRestoreGame *savefile );
56 virtual void Killed( idEntity *inflictor, idEntity *attacker, int damage, const idVec3 &dir, int location );
58 virtual void WriteToSnapshot( idBitMsgDelta &msg ) const;
59 virtual void ReadFromSnapshot( const idBitMsgDelta &msg );
61 virtual void Hide( void );
62 virtual void Show( void );
64 void SetPortalState( bool open );
82 // mover directions. make sure to change script/doom_defs.script if you add any, or change their order
95 DIR_REL_FORWARD = -11,
115 idPhysics_Parametric physicsObj;
117 void Event_OpenPortal( void );
118 void Event_ClosePortal( void );
119 void Event_PartBlocked( idEntity *blockingEntity );
121 void MoveToPos( const idVec3 &pos);
122 void UpdateMoveSound( moveStage_t stage );
123 void UpdateRotationSound( moveStage_t stage );
124 void SetGuiStates( const char *state );
125 void FindGuiTargets( void );
126 void SetGuiState( const char *key, const char *val ) const;
128 virtual void DoneMoving( void );
129 virtual void DoneRotating( void );
130 virtual void BeginMove( idThread *thread = NULL );
131 virtual void BeginRotation( idThread *thread, bool stopwhendone );
139 idAngles dest_angles;
140 idAngles angle_delta;
141 idVec3 dest_position;
148 bool useSplineAngles;
149 idEntityPtr<idEntity> splineEnt;
150 moverCommand_t lastCommand;
153 qhandle_t areaPortal; // 0 = no portal
155 idList< idEntityPtr<idEntity> > guiTargets;
157 void VectorForDir( float dir, idVec3 &vec );
158 idCurve_Spline<idVec3> *GetSpline( idEntity *splineEntity ) const;
160 void Event_SetCallback( void );
161 void Event_TeamBlocked( idEntity *blockedPart, idEntity *blockingEntity );
162 void Event_StopMoving( void );
163 void Event_StopRotating( void );
164 void Event_UpdateMove( void );
165 void Event_UpdateRotation( void );
166 void Event_SetMoveSpeed( float speed );
167 void Event_SetMoveTime( float time );
168 void Event_SetDecelerationTime( float time );
169 void Event_SetAccellerationTime( float time );
170 void Event_MoveTo( idEntity *ent );
171 void Event_MoveToPos( idVec3 &pos );
172 void Event_MoveDir( float angle, float distance );
173 void Event_MoveAccelerateTo( float speed, float time );
174 void Event_MoveDecelerateTo( float speed, float time );
175 void Event_RotateDownTo( int axis, float angle );
176 void Event_RotateUpTo( int axis, float angle );
177 void Event_RotateTo( idAngles &angles );
178 void Event_Rotate( idAngles &angles );
179 void Event_RotateOnce( idAngles &angles );
180 void Event_Bob( float speed, float phase, idVec3 &depth );
181 void Event_Sway( float speed, float phase, idAngles &depth );
182 void Event_SetAccelSound( const char *sound );
183 void Event_SetDecelSound( const char *sound );
184 void Event_SetMoveSound( const char *sound );
185 void Event_FindGuiTargets( void );
186 void Event_InitGuiTargets( void );
187 void Event_EnableSplineAngles( void );
188 void Event_DisableSplineAngles( void );
189 void Event_RemoveInitialSplineAngles( void );
190 void Event_StartSpline( idEntity *splineEntity );
191 void Event_StopSpline( void );
192 void Event_Activate( idEntity *activator );
193 void Event_PostRestore( int start, int total, int accel, int decel, int useSplineAng );
194 void Event_IsMoving( void );
195 void Event_IsRotating( void );
198 class idSplinePath : public idEntity {
200 CLASS_PROTOTYPE( idSplinePath );
214 class idElevator : public idMover {
216 CLASS_PROTOTYPE( idElevator );
222 void Save( idSaveGame *savefile ) const;
223 void Restore( idRestoreGame *savefile );
225 virtual bool HandleSingleGuiCommand( idEntity *entityGui, idLexer *src );
226 void Event_GotoFloor( int floor );
227 floorInfo_s * GetFloorInfo( int floor );
230 virtual void DoneMoving( void );
231 virtual void BeginMove( idThread *thread = NULL );
232 void SpawnTrigger( const idVec3 &pos );
233 void GetLocalTriggerPosition();
234 void Event_Touch( idEntity *other, trace_t *trace );
243 elevatorState_t state;
244 idList<floorInfo_s> floorInfo;
248 bool controlsDisabled;
253 class idDoor * GetDoor( const char *name );
255 void OpenInnerDoor( void );
256 void OpenFloorDoor( int floor );
257 void CloseAllDoors( void );
258 void DisableAllDoors( void );
259 void EnableProperDoors( void );
261 void Event_TeamBlocked( idEntity *blockedEntity, idEntity *blockingEntity );
262 void Event_Activate( idEntity *activator );
263 void Event_PostFloorArrival();
269 ===============================================================================
273 ===============================================================================
283 class idMover_Binary : public idEntity {
285 CLASS_PROTOTYPE( idMover_Binary );
292 void Save( idSaveGame *savefile ) const;
293 void Restore( idRestoreGame *savefile );
295 virtual void PreBind( void );
296 virtual void PostBind( void );
298 void Enable( bool b );
299 void InitSpeed( idVec3 &mpos1, idVec3 &mpos2, float mspeed, float maccelTime, float mdecelTime );
300 void InitTime( idVec3 &mpos1, idVec3 &mpos2, float mtime, float maccelTime, float mdecelTime );
301 void GotoPosition1( void );
302 void GotoPosition2( void );
303 void Use_BinaryMover( idEntity *activator );
304 void SetGuiStates( const char *state );
305 void UpdateBuddies( int val );
306 idMover_Binary * GetActivateChain( void ) const { return activateChain; }
307 idMover_Binary * GetMoveMaster( void ) const { return moveMaster; }
308 void BindTeam( idEntity *bindTo );
309 void SetBlocked( bool b );
310 bool IsBlocked( void );
311 idEntity * GetActivator( void ) const;
313 virtual void WriteToSnapshot( idBitMsgDelta &msg ) const;
314 virtual void ReadFromSnapshot( const idBitMsgDelta &msg );
316 void SetPortalState( bool open );
321 moverState_t moverState;
322 idMover_Binary * moveMaster;
323 idMover_Binary * activateChain;
334 idEntityPtr<idEntity> activatedBy;
339 int updateStatus; // 1 = lock behaviour, 2 = open close status
341 idPhysics_Parametric physicsObj;
342 qhandle_t areaPortal; // 0 = no portal
344 idList< idEntityPtr<idEntity> > guiTargets;
346 void MatchActivateTeam( moverState_t newstate, int time );
347 void JoinActivateTeam( idMover_Binary *master );
349 void UpdateMoverSound( moverState_t state );
350 void SetMoverState( moverState_t newstate, int time );
351 moverState_t GetMoverState( void ) const { return moverState; }
352 void FindGuiTargets( void );
353 void SetGuiState( const char *key, const char *val ) const;
355 void Event_SetCallback( void );
356 void Event_ReturnToPos1( void );
357 void Event_Use_BinaryMover( idEntity *activator );
358 void Event_Reached_BinaryMover( void );
359 void Event_MatchActivateTeam( moverState_t newstate, int time );
360 void Event_Enable( void );
361 void Event_Disable( void );
362 void Event_OpenPortal( void );
363 void Event_ClosePortal( void );
364 void Event_FindGuiTargets( void );
365 void Event_InitGuiTargets( void );
367 static void GetMovedir( float dir, idVec3 &movedir );
370 class idDoor : public idMover_Binary {
372 CLASS_PROTOTYPE( idDoor );
379 void Save( idSaveGame *savefile ) const;
380 void Restore( idRestoreGame *savefile );
382 virtual void Think( void );
383 virtual void PreBind( void );
384 virtual void PostBind( void );
385 virtual void Hide( void );
386 virtual void Show( void );
389 bool IsNoTouch( void );
390 int IsLocked( void );
392 void Use( idEntity *other, idEntity *activator );
395 void SetCompanion( idDoor *door );
401 bool aas_area_closed;
403 idClipModel * trigger;
404 idClipModel * sndTrigger;
405 int nextSndTriggerTime;
406 idVec3 localTriggerOrigin;
407 idMat3 localTriggerAxis;
411 int normalAxisIndex; // door faces X or Y for spectator teleports
412 idDoor * companionDoor;
414 void SetAASAreaState( bool closed );
416 void GetLocalTriggerPosition( const idClipModel *trigger );
417 void CalcTriggerBounds( float size, idBounds &bounds );
419 void Event_Reached_BinaryMover( void );
420 void Event_TeamBlocked( idEntity *blockedEntity, idEntity *blockingEntity );
421 void Event_PartBlocked( idEntity *blockingEntity );
422 void Event_Touch( idEntity *other, trace_t *trace );
423 void Event_Activate( idEntity *activator );
424 void Event_StartOpen( void );
425 void Event_SpawnDoorTrigger( void );
426 void Event_SpawnSoundTrigger( void );
427 void Event_Close( void );
428 void Event_Open( void );
429 void Event_Lock( int f );
430 void Event_IsOpen( void );
431 void Event_Locked( void );
432 void Event_SpectatorTouch( idEntity *other, trace_t *trace );
433 void Event_OpenPortal( void );
434 void Event_ClosePortal( void );
437 class idPlat : public idMover_Binary {
439 CLASS_PROTOTYPE( idPlat );
446 void Save( idSaveGame *savefile ) const;
447 void Restore( idRestoreGame *savefile );
449 virtual void Think( void );
450 virtual void PreBind( void );
451 virtual void PostBind( void );
454 idClipModel * trigger;
455 idVec3 localTriggerOrigin;
456 idMat3 localTriggerAxis;
458 void GetLocalTriggerPosition( const idClipModel *trigger );
459 void SpawnPlatTrigger( idVec3 &pos );
461 void Event_TeamBlocked( idEntity *blockedEntity, idEntity *blockingEntity );
462 void Event_PartBlocked( idEntity *blockingEntity );
463 void Event_Touch( idEntity *other, trace_t *trace );
468 ===============================================================================
470 Special periodic movers.
472 ===============================================================================
475 class idMover_Periodic : public idEntity {
477 CLASS_PROTOTYPE( idMover_Periodic );
479 idMover_Periodic( void );
483 void Save( idSaveGame *savefile ) const;
484 void Restore( idRestoreGame *savefile );
486 virtual void Think( void );
488 virtual void WriteToSnapshot( idBitMsgDelta &msg ) const;
489 virtual void ReadFromSnapshot( const idBitMsgDelta &msg );
492 idPhysics_Parametric physicsObj;
495 void Event_TeamBlocked( idEntity *blockedEntity, idEntity *blockingEntity );
496 void Event_PartBlocked( idEntity *blockingEntity );
499 class idRotater : public idMover_Periodic {
501 CLASS_PROTOTYPE( idRotater );
507 void Save( idSaveGame *savefile ) const;
508 void Restore( idRestoreGame *savefile );
511 idEntityPtr<idEntity> activatedBy;
513 void Event_Activate( idEntity *activator );
516 class idBobber : public idMover_Periodic {
518 CLASS_PROTOTYPE( idBobber );
527 class idPendulum : public idMover_Periodic {
529 CLASS_PROTOTYPE( idPendulum );
538 class idRiser : public idMover_Periodic {
540 CLASS_PROTOTYPE( idRiser );
547 void Event_Activate( idEntity *activator );
550 #endif /* !__GAME_MOVER_H__ */