FlammableUpdate.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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: FlammableUpdate.h /////////////////////////////////////////////////////////////////////////
  24. // Author: Graham Smallwood, April 2002
  25. // Desc: Update that manages Aflame and Burned statuses and their effects
  26. ///////////////////////////////////////////////////////////////////////////////////////////////////
  27. #pragma once
  28. #ifndef __FLAMMABLE_UPDATE_H_
  29. #define __FLAMMABLE_UPDATE_H_
  30. // INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
  31. #include "Common/AudioEventRTS.h"
  32. #include "GameLogic/Module/DamageModule.h"
  33. #include "GameLogic/Module/UpdateModule.h"
  34. //-------------------------------------------------------------------------------------------------
  35. enum FlammabilityStatusType
  36. {
  37. // These show the state I last noticed my object was in.
  38. FS_NORMAL = 0,
  39. FS_AFLAME,
  40. FS_BURNED,
  41. FS_NORMAL_COUNT // keep last
  42. };
  43. //-------------------------------------------------------------------------------------------------
  44. class FlammableUpdateModuleData : public UpdateModuleData
  45. {
  46. public:
  47. UnsignedInt m_burnedDelay; ///< How long before I am ::Burned. 0 means never
  48. UnsignedInt m_aflameDuration; ///< How long I stay ::Aflame. Independent of Burned.
  49. // When aflame wears out is when I check to be normal or burned, So my model can
  50. // change to burned while I am still aflame.
  51. UnsignedInt m_aflameDamageDelay; ///< While ::Aflame, I take damage this often. If 0, never.
  52. Int m_aflameDamageAmount; ///< And this is how much I take.
  53. AsciiString m_burningSoundName; ///< Sound to loop-play while burning (Not an AudioEventRTS here, since that belongs to the module)
  54. Real m_flameDamageLimitData;
  55. UnsignedInt m_flameDamageExpirationDelay;
  56. FlammableUpdateModuleData();
  57. static void buildFieldParse(MultiIniFieldParse& p);
  58. private:
  59. };
  60. //-------------------------------------------------------------------------------------------------
  61. //-------------------------------------------------------------------------------------------------
  62. class FlammableUpdate : public UpdateModule, public DamageModuleInterface
  63. {
  64. MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE( FlammableUpdate, "FlammableUpdate" )
  65. MAKE_STANDARD_MODULE_MACRO_WITH_MODULE_DATA( FlammableUpdate, FlammableUpdateModuleData )
  66. public:
  67. FlammableUpdate( Thing *thing, const ModuleData* moduleData );
  68. // virtual destructor prototype provided by memory pool declaration
  69. static Int getInterfaceMask() { return UpdateModule::getInterfaceMask() | (MODULEINTERFACE_DAMAGE); }
  70. virtual DamageModuleInterface* getDamage() { return this; }
  71. void tryToIgnite(); ///< FlammabeDamage uses this. It is up to me to decide if I am burnable
  72. Bool wouldIgnite(); ///< Since we need to cheat sometimes and light something directly, ask if this would light
  73. //UpdateModuleInterface
  74. virtual UpdateSleepTime update();
  75. //DamageModuleInterface
  76. virtual void onDamage( DamageInfo *damageInfo );
  77. virtual void onHealing( DamageInfo *damageInfo ) { }
  78. virtual void onBodyDamageStateChange( const DamageInfo *damageInfo,
  79. BodyDamageType oldState,
  80. BodyDamageType newState ) { }
  81. protected:
  82. UpdateSleepTime calcSleepTime();
  83. void doAflameDamage();
  84. void startBurningSound();
  85. void stopBurningSound();
  86. FlammabilityStatusType m_status;
  87. UnsignedInt m_aflameEndFrame;
  88. UnsignedInt m_burnedEndFrame;
  89. UnsignedInt m_damageEndFrame;
  90. AudioHandle m_audioHandle;
  91. Real m_flameDamageLimit;
  92. UnsignedInt m_lastFlameDamageDealt;
  93. };
  94. #endif