RadiusDecalUpdate.cpp 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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: RadiusDecalUpdate.cpp ///////////////////////////////////////////////////////////////////////
  24. ///////////////////////////////////////////////////////////////////////////////////////////////////
  25. // INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
  26. #include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine
  27. #include "Common/RandomValue.h"
  28. #include "Common/Xfer.h"
  29. #include "GameLogic/GameLogic.h"
  30. #include "GameLogic/Module/RadiusDecalUpdate.h"
  31. #include "GameLogic/Object.h"
  32. //-------------------------------------------------------------------------------------------------
  33. //-------------------------------------------------------------------------------------------------
  34. RadiusDecalUpdate::RadiusDecalUpdate( Thing *thing, const ModuleData* moduleData ) : UpdateModule( thing, moduleData )
  35. {
  36. m_deliveryDecal.clear();
  37. m_killWhenNoLongerAttacking = false;
  38. setWakeFrame(getObject(), UPDATE_SLEEP_FOREVER);
  39. }
  40. //-------------------------------------------------------------------------------------------------
  41. //-------------------------------------------------------------------------------------------------
  42. RadiusDecalUpdate::~RadiusDecalUpdate( void )
  43. {
  44. m_deliveryDecal.clear();
  45. }
  46. //-------------------------------------------------------------------------------------------------
  47. //-------------------------------------------------------------------------------------------------
  48. void RadiusDecalUpdate::createRadiusDecal( const RadiusDecalTemplate& tmpl, Real radius, const Coord3D& pos )
  49. {
  50. m_deliveryDecal.clear();
  51. tmpl.createRadiusDecal(pos, radius, getObject()->getControllingPlayer(), m_deliveryDecal);
  52. setWakeFrame(getObject(), m_deliveryDecal.isEmpty() ? UPDATE_SLEEP_FOREVER : UPDATE_SLEEP_NONE);
  53. }
  54. //-------------------------------------------------------------------------------------------------
  55. //-------------------------------------------------------------------------------------------------
  56. void RadiusDecalUpdate::killRadiusDecal()
  57. {
  58. m_deliveryDecal.clear();
  59. setWakeFrame(getObject(), UPDATE_SLEEP_FOREVER);
  60. }
  61. //-------------------------------------------------------------------------------------------------
  62. //-------------------------------------------------------------------------------------------------
  63. UpdateSleepTime RadiusDecalUpdate::update( void )
  64. {
  65. if (m_killWhenNoLongerAttacking && !getObject()->testStatus( OBJECT_STATUS_IS_ATTACKING ))
  66. {
  67. m_deliveryDecal.clear();
  68. return UPDATE_SLEEP_FOREVER;
  69. }
  70. m_deliveryDecal.update();
  71. return UPDATE_SLEEP_NONE;
  72. }
  73. // ------------------------------------------------------------------------------------------------
  74. /** CRC */
  75. // ------------------------------------------------------------------------------------------------
  76. void RadiusDecalUpdate::crc( Xfer *xfer )
  77. {
  78. // extend base class
  79. UpdateModule::crc( xfer );
  80. } // end crc
  81. // ------------------------------------------------------------------------------------------------
  82. /** Xfer method
  83. * Version Info:
  84. * 1: Initial version */
  85. // ------------------------------------------------------------------------------------------------
  86. void RadiusDecalUpdate::xfer( Xfer *xfer )
  87. {
  88. // version
  89. XferVersion currentVersion = 1;
  90. XferVersion version = currentVersion;
  91. xfer->xferVersion( &version, currentVersion );
  92. // extend base class
  93. UpdateModule::xfer( xfer );
  94. // decal, if any
  95. m_deliveryDecal.xferRadiusDecal(xfer);
  96. xfer->xferBool(&m_killWhenNoLongerAttacking);
  97. } // end xfer
  98. // ------------------------------------------------------------------------------------------------
  99. /** Load post process */
  100. // ------------------------------------------------------------------------------------------------
  101. void RadiusDecalUpdate::loadPostProcess( void )
  102. {
  103. // extend base class
  104. UpdateModule::loadPostProcess();
  105. } // end loadPostProcess