GrantStealthBehavior.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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: GrantStealthBehavior.h /////////////////////////////////////////////////////////////////////////
  24. // Author: Mark Lorenzen, June 2003
  25. // Desc: Update that grants permanent stealth to those whose stealth is permanently grantable
  26. //------------------------------------------
  27. #pragma once
  28. #ifndef __GrantStealthBehavior_H_
  29. #define __GrantStealthBehavior_H_
  30. // INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
  31. #include "GameClient/ParticleSys.h"
  32. #include "GameLogic/Module/BehaviorModule.h"
  33. #include "GameLogic/Module/UpgradeModule.h"
  34. #include "GameLogic/Module/UpdateModule.h"
  35. #include "GameLogic/Module/DamageModule.h"
  36. #include "Common/BitFlagsIO.h"
  37. class ParticleSystem;
  38. class ParticleSystemTemplate;
  39. //-------------------------------------------------------------------------------------------------
  40. class GrantStealthBehaviorModuleData : public UpdateModuleData
  41. {
  42. public:
  43. Bool m_initiallyActive;
  44. Bool m_singleBurst;
  45. Int m_healingAmount;
  46. Real m_startRadius;
  47. Real m_finalRadius;
  48. Real m_radiusGrowRate;
  49. KindOfMaskType m_kindOf; //Only these types can heal -- defaults to everything.
  50. const ParticleSystemTemplate* m_radiusParticleSystemTmpl; //Optional particle system meant to apply to entire effect for entire duration.
  51. GrantStealthBehaviorModuleData()
  52. {
  53. m_finalRadius = 200.0f;
  54. m_startRadius = 0.0f;
  55. m_radiusGrowRate = 10.0f;
  56. m_radiusParticleSystemTmpl = NULL;
  57. SET_ALL_KINDOFMASK_BITS( m_kindOf );
  58. }
  59. static void buildFieldParse( MultiIniFieldParse& p )
  60. {
  61. UpdateModuleData::buildFieldParse( p );
  62. static const FieldParse dataFieldParse[] =
  63. {
  64. { "StartRadius", INI::parseReal, NULL, offsetof( GrantStealthBehaviorModuleData, m_startRadius ) },
  65. { "FinalRadius", INI::parseReal, NULL, offsetof( GrantStealthBehaviorModuleData, m_finalRadius ) },
  66. { "RadiusGrowRate", INI::parseReal, NULL, offsetof( GrantStealthBehaviorModuleData, m_radiusGrowRate ) },
  67. { "KindOf", KindOfMaskType::parseFromINI, NULL, offsetof( GrantStealthBehaviorModuleData, m_kindOf ) },
  68. { "RadiusParticleSystemName", INI::parseParticleSystemTemplate, NULL, offsetof( GrantStealthBehaviorModuleData, m_radiusParticleSystemTmpl ) },
  69. { 0, 0, 0, 0 }
  70. };
  71. p.add(dataFieldParse);
  72. }
  73. };
  74. //-------------------------------------------------------------------------------------------------
  75. //-------------------------------------------------------------------------------------------------
  76. class GrantStealthBehavior : public UpdateModule
  77. {
  78. MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE( GrantStealthBehavior, "GrantStealthBehavior" )
  79. MAKE_STANDARD_MODULE_MACRO_WITH_MODULE_DATA( GrantStealthBehavior, GrantStealthBehaviorModuleData )
  80. public:
  81. GrantStealthBehavior( Thing *thing, const ModuleData* moduleData );
  82. // virtual destructor prototype provided by memory pool declaration
  83. virtual UpdateSleepTime update();
  84. private:
  85. void grantStealthToObject( Object *obj );
  86. ParticleSystemID m_radiusParticleSystemID;
  87. Real m_currentScanRadius;
  88. };
  89. #endif // __GrantStealthBehavior_H_