doors.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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/doors.h $*
  25. * *
  26. * $Author:: Patrick $*
  27. * *
  28. * $Modtime:: 1/17/02 10:37a $*
  29. * *
  30. * $Revision:: 23 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #ifndef DOORS_H
  36. #define DOORS_H
  37. #ifndef ALWAYS_H
  38. #include "always.h"
  39. #endif
  40. #ifndef __ACCESSIBLE_PHYS_H
  41. #include "accessiblephys.h"
  42. #endif
  43. class SoldierGameObj;
  44. /*
  45. ** Door States
  46. */
  47. enum
  48. {
  49. STATE_CLOSED_DOOR = 0,
  50. STATE_OPENED_DOOR,
  51. STATE_OPENING_DOOR,
  52. STATE_CLOSING_DOOR,
  53. STATE_ACCESS_DENIED,
  54. STATE_MAX
  55. };
  56. /*
  57. ** DoorPhysDefClass
  58. */
  59. class DoorPhysDefClass : public AccessiblePhysDefClass
  60. {
  61. public:
  62. DoorPhysDefClass(void);
  63. virtual uint32 Get_Class_ID( void ) const;
  64. virtual const char * Get_Type_Name(void) { return "DoorPhysDef"; }
  65. virtual bool Is_Type(const char *);
  66. virtual PersistClass * Create( void ) const ;
  67. virtual bool Save( ChunkSaveClass &csave );
  68. virtual bool Load( ChunkLoadClass &cload );
  69. virtual const PersistFactoryClass & Get_Factory( void ) const;
  70. DECLARE_EDITABLE( DoorPhysDefClass, AccessiblePhysDefClass );
  71. const OBBoxClass & Get_Trigger_Zone1 (void) const { return TriggerZone1; }
  72. const OBBoxClass & Get_Trigger_Zone2 (void) const { return TriggerZone2; }
  73. bool Is_Vehicle_Door (void) const { return DoorOpensForVehicles; }
  74. protected:
  75. OBBoxClass TriggerZone1;
  76. OBBoxClass TriggerZone2;
  77. float CloseDelay;
  78. int OpenSoundDefID;
  79. int CloseSoundDefID;
  80. int UnlockSoundDefID;
  81. int AccessDeniedSoundDefID;
  82. bool DoorOpensForVehicles;
  83. friend class DoorPhysClass;
  84. };
  85. /*
  86. ** DoorPhysClass
  87. */
  88. class DoorPhysClass : public AccessiblePhysClass
  89. {
  90. public:
  91. // Constructor and Destructor
  92. DoorPhysClass( void );
  93. virtual ~DoorPhysClass( void );
  94. // RTTI
  95. virtual DoorPhysClass * As_DoorPhysClass(void) { return this; }
  96. // Definitions
  97. void Init( const DoorPhysDefClass & definition );
  98. const DoorPhysDefClass * Get_DoorPhysDef( void ) const { WWASSERT( Definition ); return (DoorPhysDefClass *)Definition; }
  99. // State import/export
  100. static void Set_Precision(void);
  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 access
  110. bool Is_Door_Open( void ) const;
  111. void Request_Door_Open( void ) { OpenRequestPending = true; }
  112. void Lock_Door_Open( bool onoff );
  113. bool Is_State_Locked( void ) { return LockState; }
  114. bool Can_Unlock_Me( SoldierGameObj * soldier ) const;
  115. protected:
  116. // State determination
  117. virtual void Update_State( float dt );
  118. virtual int Can_Open_Door( void );
  119. virtual int Check_Door_Trigger( const OBBoxClass &trigger_zone );
  120. virtual bool Set_State( int new_state );
  121. float Timer;
  122. float CheckTimer;
  123. int State;
  124. bool OpenRequestPending;
  125. bool LockState;
  126. // Friends
  127. friend class DoorNetworkObjectClass;
  128. };
  129. #endif // DOORS_H