FXListDie.cpp 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*
  2. ** Command & Conquer Generals(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: FXListDie.cpp ///////////////////////////////////////////////////////////////////////////
  24. // Author: Steven Johnson, Jan 2002
  25. // Desc: Simple Die module
  26. ///////////////////////////////////////////////////////////////////////////////////////////////////
  27. // INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
  28. #include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine
  29. #define DEFINE_DAMAGE_NAMES
  30. #include "Common/INI.h"
  31. #include "Common/ThingTemplate.h"
  32. #include "Common/Xfer.h"
  33. #include "GameClient/FXList.h"
  34. #include "GameLogic/Damage.h"
  35. #include "GameLogic/GameLogic.h"
  36. #include "GameLogic/Object.h"
  37. #include "GameLogic/Module/FXListDie.h"
  38. #include "GameLogic/Module/AIUpdate.h"
  39. //-------------------------------------------------------------------------------------------------
  40. //-------------------------------------------------------------------------------------------------
  41. FXListDie::FXListDie( Thing *thing, const ModuleData* moduleData ) : DieModule( thing, moduleData )
  42. {
  43. }
  44. //-------------------------------------------------------------------------------------------------
  45. //-------------------------------------------------------------------------------------------------
  46. FXListDie::~FXListDie( void )
  47. {
  48. }
  49. //-------------------------------------------------------------------------------------------------
  50. /** The die callback. */
  51. //-------------------------------------------------------------------------------------------------
  52. void FXListDie::onDie( const DamageInfo *damageInfo )
  53. {
  54. if (!isDieApplicable(damageInfo))
  55. return;
  56. const FXListDieModuleData* d = getFXListDieModuleData();
  57. if (d->m_defaultDeathFX)
  58. {
  59. // if the object has any ambient sound(s), kill 'em now.
  60. TheAudio->stopAllAmbientsBy(getObject());
  61. if (d->m_orientToObject)
  62. {
  63. Object *damageDealer = TheGameLogic->findObjectByID( damageInfo->in.m_sourceID );
  64. FXList::doFXObj(getFXListDieModuleData()->m_defaultDeathFX, getObject(), damageDealer);
  65. }
  66. else
  67. {
  68. FXList::doFXPos(getFXListDieModuleData()->m_defaultDeathFX, getObject()->getPosition());
  69. }
  70. }
  71. }
  72. // ------------------------------------------------------------------------------------------------
  73. /** CRC */
  74. // ------------------------------------------------------------------------------------------------
  75. void FXListDie::crc( Xfer *xfer )
  76. {
  77. // extend base class
  78. DieModule::crc( xfer );
  79. } // end crc
  80. // ------------------------------------------------------------------------------------------------
  81. /** Xfer method
  82. * Version Info:
  83. * 1: Initial version */
  84. // ------------------------------------------------------------------------------------------------
  85. void FXListDie::xfer( Xfer *xfer )
  86. {
  87. // version
  88. XferVersion currentVersion = 1;
  89. XferVersion version = currentVersion;
  90. xfer->xferVersion( &version, currentVersion );
  91. // extend base class
  92. DieModule::xfer( xfer );
  93. } // end xfer
  94. // ------------------------------------------------------------------------------------------------
  95. /** Load post process */
  96. // ------------------------------------------------------------------------------------------------
  97. void FXListDie::loadPostProcess( void )
  98. {
  99. // extend base class
  100. DieModule::loadPostProcess();
  101. } // end loadPostProcess