BridgeScaffoldBehavior.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. ** Command & Conquer Generals Zero Hour(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. // //
  20. // (c) 2001-2003 Electronic Arts Inc. //
  21. // //
  22. ////////////////////////////////////////////////////////////////////////////////
  23. // FILE: BridgeScaffoldBehavior.h /////////////////////////////////////////////////////////////////
  24. // Author: Colin Day, September 2002
  25. // Desc: Bridge scaffold
  26. ///////////////////////////////////////////////////////////////////////////////////////////////////
  27. #pragma once
  28. #ifndef __BRIDGE_SCAFFOLD_BEHAVIOR_H_
  29. #define __BRIDGE_SCAFFOLD_BEHAVIOR_H_
  30. // INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
  31. #include "GameLogic/Module/BehaviorModule.h"
  32. #include "GameLogic/Module/UpdateModule.h"
  33. // ------------------------------------------------------------------------------------------------
  34. // ------------------------------------------------------------------------------------------------
  35. enum ScaffoldTargetMotion
  36. {
  37. STM_STILL,
  38. STM_RISE,
  39. STM_BUILD_ACROSS,
  40. STM_TEAR_DOWN_ACROSS,
  41. STM_SINK,
  42. };
  43. // ------------------------------------------------------------------------------------------------
  44. // ------------------------------------------------------------------------------------------------
  45. class BridgeScaffoldBehaviorInterface
  46. {
  47. public:
  48. virtual void setPositions( const Coord3D *createPos,
  49. const Coord3D *riseToPos,
  50. const Coord3D *buildPos ) = 0;
  51. virtual void setMotion( ScaffoldTargetMotion targetMotion ) = 0;
  52. virtual ScaffoldTargetMotion getCurrentMotion( void ) = 0;
  53. virtual void reverseMotion( void ) = 0;
  54. virtual void setLateralSpeed( Real lateralSpeed ) = 0;
  55. virtual void setVerticalSpeed( Real verticalSpeed ) = 0;
  56. };
  57. // ------------------------------------------------------------------------------------------------
  58. // ------------------------------------------------------------------------------------------------
  59. class BridgeScaffoldBehavior : public UpdateModule,
  60. public BridgeScaffoldBehaviorInterface
  61. {
  62. MAKE_STANDARD_MODULE_MACRO( BridgeScaffoldBehavior );
  63. MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE( BridgeScaffoldBehavior, "BridgeScaffoldBehavior" )
  64. public:
  65. BridgeScaffoldBehavior( Thing *thing, const ModuleData* moduleData );
  66. // virtual destructor prototype provided by memory pool declaration
  67. // behavior module methods
  68. virtual BridgeScaffoldBehaviorInterface* getBridgeScaffoldBehaviorInterface() { return this; }
  69. // update methods
  70. virtual UpdateSleepTime update( void );
  71. // bridge scaffold interface methods
  72. virtual void setPositions( const Coord3D *createPos,
  73. const Coord3D *riseToPos,
  74. const Coord3D *buildPos );
  75. virtual void setMotion( ScaffoldTargetMotion targetMotion );
  76. virtual ScaffoldTargetMotion getCurrentMotion( void ) { return m_targetMotion; }
  77. virtual void reverseMotion( void );
  78. virtual void setLateralSpeed( Real lateralSpeed ) { m_lateralSpeed = lateralSpeed; }
  79. virtual void setVerticalSpeed( Real verticalSpeed ) { m_verticalSpeed = verticalSpeed; }
  80. // public interface acquisition
  81. static BridgeScaffoldBehaviorInterface *getBridgeScaffoldBehaviorInterfaceFromObject( Object *obj );
  82. protected:
  83. void doVerticalMotion( void ); ///< do rise/sink vertical motion
  84. void doLateralmotion( void ); ///< do lateral motion
  85. ScaffoldTargetMotion m_targetMotion; ///< which way our motion should be going (build up, still, tear down etc)
  86. Coord3D m_createPos; ///< initial position of object creation (in ground)
  87. Coord3D m_riseToPos; ///< position we "rise to" out of the ground
  88. Coord3D m_buildPos; ///< position we move to and stop at on the bridge surface
  89. Real m_lateralSpeed; ///< speed for lateral motions
  90. Real m_verticalSpeed; ///< speed for vertical motions
  91. Coord3D m_targetPos; ///< current target position for our motion type
  92. };
  93. #endif // end __BRIDGE_SCAFFOLD_BEHAVIOR_H_