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();
266 void Event_SetGuiStates();
273 ===============================================================================
277 ===============================================================================
287 class idMover_Binary : public idEntity {
289 CLASS_PROTOTYPE( idMover_Binary );
296 void Save( idSaveGame *savefile ) const;
297 void Restore( idRestoreGame *savefile );
299 virtual void PreBind( void );
300 virtual void PostBind( void );
302 void Enable( bool b );
303 void InitSpeed( idVec3 &mpos1, idVec3 &mpos2, float mspeed, float maccelTime, float mdecelTime );
304 void InitTime( idVec3 &mpos1, idVec3 &mpos2, float mtime, float maccelTime, float mdecelTime );
305 void GotoPosition1( void );
306 void GotoPosition2( void );
307 void Use_BinaryMover( idEntity *activator );
308 void SetGuiStates( const char *state );
309 void UpdateBuddies( int val );
310 idMover_Binary * GetActivateChain( void ) const { return activateChain; }
311 idMover_Binary * GetMoveMaster( void ) const { return moveMaster; }
312 void BindTeam( idEntity *bindTo );
313 void SetBlocked( bool b );
314 bool IsBlocked( void );
315 idEntity * GetActivator( void ) const;
317 virtual void WriteToSnapshot( idBitMsgDelta &msg ) const;
318 virtual void ReadFromSnapshot( const idBitMsgDelta &msg );
320 void SetPortalState( bool open );
325 moverState_t moverState;
326 idMover_Binary * moveMaster;
327 idMover_Binary * activateChain;
338 idEntityPtr<idEntity> activatedBy;
343 int updateStatus; // 1 = lock behaviour, 2 = open close status
345 idPhysics_Parametric physicsObj;
346 qhandle_t areaPortal; // 0 = no portal
351 idList< idEntityPtr<idEntity> > guiTargets;
353 void MatchActivateTeam( moverState_t newstate, int time );
354 void JoinActivateTeam( idMover_Binary *master );
356 void UpdateMoverSound( moverState_t state );
357 void SetMoverState( moverState_t newstate, int time );
358 moverState_t GetMoverState( void ) const { return moverState; }
359 void FindGuiTargets( void );
360 void SetGuiState( const char *key, const char *val ) const;
362 void Event_SetCallback( void );
363 void Event_ReturnToPos1( void );
364 void Event_Use_BinaryMover( idEntity *activator );
365 void Event_Reached_BinaryMover( void );
366 void Event_MatchActivateTeam( moverState_t newstate, int time );
367 void Event_Enable( void );
368 void Event_Disable( void );
369 void Event_OpenPortal( void );
370 void Event_ClosePortal( void );
371 void Event_FindGuiTargets( void );
372 void Event_InitGuiTargets( void );
374 static void GetMovedir( float dir, idVec3 &movedir );
377 class idDoor : public idMover_Binary {
379 CLASS_PROTOTYPE( idDoor );
386 void Save( idSaveGame *savefile ) const;
387 void Restore( idRestoreGame *savefile );
389 virtual void Think( void );
390 virtual void PreBind( void );
391 virtual void PostBind( void );
392 virtual void Hide( void );
393 virtual void Show( void );
396 bool IsNoTouch( void );
398 bool AllowPlayerOnly( idEntity *ent );
400 int IsLocked( void );
402 void Use( idEntity *other, idEntity *activator );
405 void SetCompanion( idDoor *door );
411 bool aas_area_closed;
413 idClipModel * trigger;
414 idClipModel * sndTrigger;
415 int nextSndTriggerTime;
416 idVec3 localTriggerOrigin;
417 idMat3 localTriggerAxis;
421 int normalAxisIndex; // door faces X or Y for spectator teleports
422 idDoor * companionDoor;
424 void SetAASAreaState( bool closed );
426 void GetLocalTriggerPosition( const idClipModel *trigger );
427 void CalcTriggerBounds( float size, idBounds &bounds );
429 void Event_Reached_BinaryMover( void );
430 void Event_TeamBlocked( idEntity *blockedEntity, idEntity *blockingEntity );
431 void Event_PartBlocked( idEntity *blockingEntity );
432 void Event_Touch( idEntity *other, trace_t *trace );
433 void Event_Activate( idEntity *activator );
434 void Event_StartOpen( void );
435 void Event_SpawnDoorTrigger( void );
436 void Event_SpawnSoundTrigger( void );
437 void Event_Close( void );
438 void Event_Open( void );
439 void Event_Lock( int f );
440 void Event_IsOpen( void );
441 void Event_Locked( void );
442 void Event_SpectatorTouch( idEntity *other, trace_t *trace );
443 void Event_OpenPortal( void );
444 void Event_ClosePortal( void );
447 class idPlat : public idMover_Binary {
449 CLASS_PROTOTYPE( idPlat );
456 void Save( idSaveGame *savefile ) const;
457 void Restore( idRestoreGame *savefile );
459 virtual void Think( void );
460 virtual void PreBind( void );
461 virtual void PostBind( void );
464 idClipModel * trigger;
465 idVec3 localTriggerOrigin;
466 idMat3 localTriggerAxis;
468 void GetLocalTriggerPosition( const idClipModel *trigger );
469 void SpawnPlatTrigger( idVec3 &pos );
471 void Event_TeamBlocked( idEntity *blockedEntity, idEntity *blockingEntity );
472 void Event_PartBlocked( idEntity *blockingEntity );
473 void Event_Touch( idEntity *other, trace_t *trace );
478 ===============================================================================
480 Special periodic movers.
482 ===============================================================================
485 class idMover_Periodic : public idEntity {
487 CLASS_PROTOTYPE( idMover_Periodic );
489 idMover_Periodic( void );
493 void Save( idSaveGame *savefile ) const;
494 void Restore( idRestoreGame *savefile );
496 virtual void Think( void );
498 virtual void WriteToSnapshot( idBitMsgDelta &msg ) const;
499 virtual void ReadFromSnapshot( const idBitMsgDelta &msg );
502 idPhysics_Parametric physicsObj;
505 void Event_TeamBlocked( idEntity *blockedEntity, idEntity *blockingEntity );
506 void Event_PartBlocked( idEntity *blockingEntity );
509 class idRotater : public idMover_Periodic {
511 CLASS_PROTOTYPE( idRotater );
517 void Save( idSaveGame *savefile ) const;
518 void Restore( idRestoreGame *savefile );
521 idEntityPtr<idEntity> activatedBy;
523 void Event_Activate( idEntity *activator );
526 class idBobber : public idMover_Periodic {
528 CLASS_PROTOTYPE( idBobber );
537 class idPendulum : public idMover_Periodic {
539 CLASS_PROTOTYPE( idPendulum );
548 class idRiser : public idMover_Periodic {
550 CLASS_PROTOTYPE( idRiser );
557 void Event_Activate( idEntity *activator );
560 #endif /* !__GAME_MOVER_H__ */