ToppleUpdate.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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: ToppleUpdate.h /////////////////////////////////////////////////////////////////////////////
  24. // Author:
  25. // Desc:
  26. ///////////////////////////////////////////////////////////////////////////////////////////////////
  27. #pragma once
  28. #ifndef __TOPPLEUPDATE_H_
  29. #define __TOPPLEUPDATE_H_
  30. // INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
  31. #include "GameLogic/Module/BehaviorModule.h"
  32. #include "GameLogic/Module/CollideModule.h"
  33. #include "GameLogic/Module/UpdateModule.h"
  34. //-------------------------------------------------------------------------------------------------
  35. class FXList;
  36. // ------------------------------------------------------------------------------------------------
  37. /** Topple options */
  38. // ------------------------------------------------------------------------------------------------
  39. enum
  40. {
  41. TOPPLE_OPTIONS_NONE = 0x00000000,
  42. TOPPLE_OPTIONS_NO_BOUNCE = 0x00000001, ///< do not bounce when hit the ground
  43. TOPPLE_OPTIONS_NO_FX = 0x00000002, ///< do not play any FX when hit the ground
  44. };
  45. //-------------------------------------------------------------------------------------------------
  46. /** Topple update */
  47. //-------------------------------------------------------------------------------------------------
  48. class ToppleUpdateModuleData : public UpdateModuleData
  49. {
  50. public:
  51. const FXList* m_toppleFX;
  52. const FXList* m_bounceFX;
  53. AsciiString m_stumpName;
  54. Real m_initialVelocityPercent;
  55. Real m_initialAccelPercent;
  56. Real m_bounceVelocityPercent;
  57. Bool m_killWhenToppled;
  58. Bool m_killWhenStartToppled;
  59. Bool m_killStumpWhenToppled;
  60. Bool m_toppleLeftOrRightOnly; // constrained to topple to my left or right only
  61. Bool m_reorientToppledRubble;
  62. ToppleUpdateModuleData();
  63. static void buildFieldParse(MultiIniFieldParse& p);
  64. };
  65. //-------------------------------------------------------------------------------------------------
  66. class ToppleUpdate : public UpdateModule,
  67. public CollideModuleInterface
  68. {
  69. MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE( ToppleUpdate, "ToppleUpdate" )
  70. MAKE_STANDARD_MODULE_MACRO_WITH_MODULE_DATA( ToppleUpdate, ToppleUpdateModuleData )
  71. public:
  72. ToppleUpdate( Thing *thing, const ModuleData* moduleData );
  73. // virtual destructor prototype provided by memory pool declaration
  74. static Int getInterfaceMask() { return UpdateModule::getInterfaceMask() | (MODULEINTERFACE_COLLIDE); }
  75. // BehaviorModule
  76. virtual CollideModuleInterface* getCollide() { return this; }
  77. void applyTopplingForce( const Coord3D* toppleDirection, Real toppleSpeed, UnsignedInt options);
  78. Bool isAbleToBeToppled() const;
  79. // UpdateModuleInterface
  80. virtual UpdateSleepTime update();
  81. // CollideModuleInterface
  82. virtual void onCollide( Object *other, const Coord3D *loc, const Coord3D *normal );
  83. /// this is used for things like pilots, to determine if they can "enter" something
  84. virtual Bool wouldLikeToCollideWith(const Object* other) const { return false; }
  85. virtual Bool isHijackedVehicleCrateCollide() const { return false; }
  86. virtual Bool isCarBombCrateCollide() const { return false; }
  87. virtual Bool isRailroad() const { return false; }
  88. virtual Bool isSalvageCrateCollide() const { return false; }
  89. virtual Bool isSabotageBuildingCrateCollide() const { return FALSE; }
  90. protected:
  91. enum ToppleState
  92. {
  93. TOPPLE_UPRIGHT = 0,
  94. TOPPLE_FALLING,
  95. TOPPLE_DOWN
  96. };
  97. Real m_angularVelocity; ///< Velocity in degrees per frame (or is it radians per frame?)
  98. Real m_angularAcceleration; ///< Acceleration angularVelocity is increasing
  99. Coord3D m_toppleDirection; ///< Z-less direction we are toppling
  100. ToppleState m_toppleState; ///< Stage this module is in.
  101. Real m_angularAccumulation; ///< How much have I rotated so I know when to bounce.
  102. Real m_angleDeltaX; ///< how much to modify x angle each frame
  103. Int m_numAngleDeltaX; ///< how many frames to tweak x angle
  104. Bool m_doBounceFX; ///< do the bounce FX if we do bounce
  105. UnsignedInt m_options; ///< topple options
  106. ObjectID m_stumpID; ///< stump generated, if any
  107. };
  108. #endif // end __TOPPLEUPDATE_H_