2
0

elevator.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. /*
  2. ** Command & Conquer Renegade(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /***********************************************************************************************
  19. *** Confidential - Westwood Studios ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : Commando *
  23. * *
  24. * $Archive:: /Commando/Code/Combat/elevator.h $*
  25. * *
  26. * $Author:: Byon_g $*
  27. * *
  28. * $Modtime:: 9/13/01 11:42a $*
  29. * *
  30. * $Revision:: 16 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #ifndef ELEVATOR_H
  36. #define ELEVATOR_H
  37. #ifndef ALWAYS_H
  38. #include "always.h"
  39. #endif
  40. #ifndef __ACCESSIBLE_PHYS_H
  41. #include "accessiblephys.h"
  42. #endif
  43. #include "gameobjref.h"
  44. class AudibleSoundClass;
  45. class SmartGameObj;
  46. /*
  47. ** Call zone IDs
  48. */
  49. typedef enum
  50. {
  51. ZONE_LOWER_CALL = 0,
  52. ZONE_LOWER_INSIDE,
  53. ZONE_UPPER_CALL,
  54. ZONE_UPPER_INSIDE,
  55. ZONE_MAX
  56. } ELEVATOR_ZONE;
  57. /*
  58. ** ElevatorPhysDefClass
  59. */
  60. class ElevatorPhysDefClass : public AccessiblePhysDefClass
  61. {
  62. public:
  63. ElevatorPhysDefClass(void);
  64. virtual uint32 Get_Class_ID( void ) const;
  65. virtual const char * Get_Type_Name(void) { return "ElevatorPhysDef"; }
  66. virtual bool Is_Type(const char *);
  67. virtual PersistClass * Create( void ) const ;
  68. virtual bool Save( ChunkSaveClass &csave );
  69. virtual bool Load( ChunkLoadClass &cload );
  70. virtual const PersistFactoryClass & Get_Factory( void ) const;
  71. const OBBoxClass & Get_Zone (ELEVATOR_ZONE id) const { return CallZones[id]; }
  72. DECLARE_EDITABLE( ElevatorPhysDefClass, AccessiblePhysDefClass );
  73. protected:
  74. OBBoxClass CallZones[4];
  75. float CloseDelay;
  76. float DoorClosedTop_FrameNum;
  77. float DoorOpeningBottom_FrameNum;
  78. float ElevatorStartTop_FrameNum;
  79. float ElevatorStoppedBottom_FrameNum;
  80. int DoorOpenSoundDefID;
  81. int DoorCloseSoundDefID;
  82. int DoorUnlockSoundDefID;
  83. int DoorAccessDeniedSoundDefID;
  84. int ElevatorMovingSoundDefID;
  85. friend class ElevatorPhysClass;
  86. };
  87. /*
  88. ** ElevatorPhysClass
  89. */
  90. class ElevatorPhysClass : public AccessiblePhysClass
  91. {
  92. public:
  93. // Constructor and Destructor
  94. ElevatorPhysClass( void );
  95. virtual ~ElevatorPhysClass( void );
  96. // RTTI
  97. virtual ElevatorPhysClass * As_ElevatorPhysClass(void) { return this; }
  98. // Definitions
  99. void Init( const ElevatorPhysDefClass & definition );
  100. const ElevatorPhysDefClass * Get_ElevatorPhysDef( void ) const { WWASSERT( Definition ); return (ElevatorPhysDefClass *)Definition; }
  101. // Save / Load
  102. virtual bool Save( ChunkSaveClass & csave );
  103. virtual bool Load( ChunkLoadClass & cload );
  104. virtual const PersistFactoryClass & Get_Factory( void ) const;
  105. virtual void Save_State( ChunkSaveClass & csave );
  106. virtual void Load_State( ChunkLoadClass & cload );
  107. // Timestep
  108. virtual void Timestep( float dt );
  109. // State import/export
  110. static void Set_Precision(void);
  111. // AI support
  112. bool Can_Object_Enter (SmartGameObj *game_obj);
  113. bool Can_Object_Exit (SmartGameObj *game_obj);
  114. void Request_Elevator (SmartGameObj *game_obj);
  115. int Get_Floor (void);
  116. bool Is_Moving (void) const { return (State == STATE_MOVING_UP || State == STATE_MOVING_DOWN); }
  117. void Set_Current_Rider (ScriptableGameObj *rider) { CurrentAIRider = rider; }
  118. ScriptableGameObj * Get_Current_Rider (void) { return CurrentAIRider; }
  119. enum {
  120. STATE_DOWN = 0,
  121. STATE_MOVING_UP,
  122. STATE_UP,
  123. STATE_MOVING_DOWN,
  124. STATE_MAX
  125. };
  126. enum {
  127. DOOR_STATE_NORMAL = 0,
  128. DOOR_STATE_UNLOCKED,
  129. DOOR_STATE_ACCESS_DENIED,
  130. DOOR_STATE_MAX
  131. };
  132. protected:
  133. void Get_Door_Transform( bool is_top, Matrix3D &tm );
  134. void Update_Sound_Effects( void );
  135. void Play_Effect( int effect_id, bool is_top );
  136. void Update_State(void);
  137. void Set_State( int new_state );
  138. void Set_Door_State( int new_state, int door_id );
  139. enum {
  140. TOP = 0,
  141. BOTTOM = 1
  142. };
  143. int State;
  144. int DoorStates[2];
  145. float CheckTimer;
  146. AudibleSoundClass * MovingSoundObj;
  147. float PrevFrame;
  148. bool IsCallTimerSet;
  149. float CallTimer;
  150. int TriggerRequest;
  151. GameObjReference CurrentAIRider;
  152. bool Triggered( int zone_id );
  153. friend class ElevatorNetworkObjectClass;
  154. };
  155. #endif // ELEVATOR_H