StructureCollapseUpdate.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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: StructureCollapseUpdate.h /////////////////////////////////////////////////////////////////////////
  24. // Author: Bryan Cleveland, March 2002
  25. // Desc: Update that will collapse a building.
  26. ///////////////////////////////////////////////////////////////////////////////////////////////////
  27. #pragma once
  28. #ifndef __StructureCollapseUpdate_H_
  29. #define __StructureCollapseUpdate_H_
  30. // INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
  31. #include "GameLogic/Module/BehaviorModule.h"
  32. #include "GameLogic/Module/DieModule.h"
  33. #include "GameLogic/Module/UpdateModule.h"
  34. #include "Common/RandomValue.h"
  35. class FXList;
  36. class ObjectCreationList;
  37. typedef std::vector<const ObjectCreationList*> OCLVec;
  38. typedef std::vector<const FXList*> FXVec;
  39. //-------------------------------------------------------------------------------------------------
  40. enum StructureCollapsePhaseType
  41. {
  42. SCPHASE_INITIAL = 0,
  43. SCPHASE_DELAY,
  44. SCPHASE_BURST,
  45. SCPHASE_FINAL,
  46. SC_PHASE_COUNT // keep last
  47. };
  48. //-------------------------------------------------------------------------------------------------
  49. class StructureCollapseUpdateModuleData : public UpdateModuleData
  50. {
  51. public:
  52. DieMuxData m_dieMuxData;
  53. Int m_minCollapseDelay;
  54. Int m_maxCollapseDelay;
  55. Int m_minBurstDelay;
  56. Int m_maxBurstDelay;
  57. Int m_bigBurstFrequency;
  58. Real m_collapseDamping;
  59. Real m_maxShudder;
  60. OCLVec m_ocls[SC_PHASE_COUNT];
  61. FXVec m_fxs[SC_PHASE_COUNT];
  62. UnsignedInt m_oclCount[SC_PHASE_COUNT];
  63. UnsignedInt m_fxCount[SC_PHASE_COUNT];
  64. StructureCollapseUpdateModuleData()
  65. {
  66. m_minCollapseDelay = 0;
  67. m_maxCollapseDelay = 0;
  68. m_minBurstDelay = 9999;
  69. //Removed by Sadullah Nader
  70. //Redundancy from above
  71. //m_minBurstDelay = 9999;
  72. m_maxShudder = 0;
  73. m_collapseDamping = 0.0;
  74. m_bigBurstFrequency = 0;
  75. for (int i = 0; i < SC_PHASE_COUNT; ++i)
  76. {
  77. // init to one, so that if these are omitted, we choose exactly one of each.
  78. m_oclCount[i] = 1;
  79. m_fxCount[i] = 1;
  80. }
  81. }
  82. static void buildFieldParse(MultiIniFieldParse& p);
  83. };
  84. //-------------------------------------------------------------------------------------------------
  85. //-------------------------------------------------------------------------------------------------
  86. class StructureCollapseUpdate : public UpdateModule,
  87. public DieModuleInterface
  88. {
  89. MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE( StructureCollapseUpdate, "StructureCollapseUpdate" )
  90. MAKE_STANDARD_MODULE_MACRO_WITH_MODULE_DATA( StructureCollapseUpdate, StructureCollapseUpdateModuleData )
  91. public:
  92. StructureCollapseUpdate( Thing *thing, const ModuleData* moduleData );
  93. // virtual destructor prototype provided by memory pool declaration
  94. static Int getInterfaceMask() { return UpdateModule::getInterfaceMask() | (MODULEINTERFACE_DIE); }
  95. // BehaviorModule
  96. virtual DieModuleInterface* getDie() { return this; }
  97. // UpdateModuleInterface
  98. virtual UpdateSleepTime update();
  99. // DieModuleInterface
  100. virtual void onDie( const DamageInfo *damageInfo );
  101. protected:
  102. void applyCrushingDamage(Real theta);
  103. void beginStructureCollapse( const DamageInfo *damageInfo );
  104. void doDamageLine(Object *building, const WeaponTemplate* wt, Real jcos, Real jsin, Real facingWidth, Real collapseAngle);
  105. void doCollapseStartFX(Object *building, const DamageInfo *damageInfo);
  106. void doCollapseDelayBurstFX();
  107. void doCollapseDoneStuff();
  108. void doPhaseStuff(StructureCollapsePhaseType scphase, const Coord3D *target);
  109. enum StructureCollapseStateType
  110. {
  111. COLLAPSESTATE_STANDING,
  112. COLLAPSESTATE_WAITINGFORCOLLAPSESTART,
  113. COLLAPSESTATE_COLLAPSING,
  114. COLLAPSESTATE_DONE
  115. };
  116. UnsignedInt m_collapseFrame;
  117. UnsignedInt m_burstFrame;
  118. StructureCollapseStateType m_collapseState;
  119. Real m_collapseVelocity;
  120. Real m_currentHeight;
  121. };
  122. #endif // __StructureCollapseUpdate_H_