DamageModule.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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: DamageModule.h /////////////////////////////////////////////////////////////////////////////////
  24. // Author: Colin Day, September 2001
  25. // Desc:
  26. ///////////////////////////////////////////////////////////////////////////////////////////////////
  27. #pragma once
  28. #ifndef __DamageModule_H_
  29. #define __DamageModule_H_
  30. #include "Common/Module.h"
  31. #include "GameLogic/Damage.h"
  32. #include "GameLogic/Module/BehaviorModule.h"
  33. enum BodyDamageType;
  34. //-------------------------------------------------------------------------------------------------
  35. /** OBJECT DAMAGE MODULE base class */
  36. //-------------------------------------------------------------------------------------------------
  37. //-------------------------------------------------------------------------------------------------
  38. class DamageModuleInterface
  39. {
  40. public:
  41. virtual void onDamage( DamageInfo *damageInfo ) = 0; ///< damage callback
  42. virtual void onHealing( DamageInfo *damageInfo ) = 0; ///< healing callback
  43. virtual void onBodyDamageStateChange( const DamageInfo* damageInfo,
  44. BodyDamageType oldState,
  45. BodyDamageType newState) = 0; ///< state change callback
  46. };
  47. //-------------------------------------------------------------------------------------------------
  48. class DamageModuleData : public BehaviorModuleData
  49. {
  50. public:
  51. // DamageTypeFlags m_damageTypes;
  52. DamageModuleData()
  53. // : m_damageTypes(DAMAGE_TYPE_FLAGS_ALL)
  54. {
  55. }
  56. static void buildFieldParse(MultiIniFieldParse& p)
  57. {
  58. BehaviorModuleData::buildFieldParse(p);
  59. static const FieldParse dataFieldParse[] =
  60. {
  61. // { "DamageTypes", INI::parseDamageTypeFlags, NULL, offsetof( DamageModuleData, m_damageTypes ) },
  62. { 0, 0, 0, 0 }
  63. };
  64. p.add(dataFieldParse);
  65. }
  66. };
  67. //-------------------------------------------------------------------------------------------------
  68. class DamageModule : public BehaviorModule, public DamageModuleInterface
  69. {
  70. MEMORY_POOL_GLUE_ABC( DamageModule )
  71. MAKE_STANDARD_MODULE_MACRO_ABC( DamageModule )
  72. MAKE_STANDARD_MODULE_DATA_MACRO_ABC( DamageModule, DamageModuleData )
  73. public:
  74. DamageModule( Thing *thing, const ModuleData* moduleData );
  75. // virtual destructor prototype defined by MemoryPoolObject
  76. // module methods
  77. static Int getInterfaceMask() { return MODULEINTERFACE_DAMAGE; }
  78. // BehaviorModule
  79. virtual DamageModuleInterface* getDamage() { return this; }
  80. // damage module callbacks
  81. virtual void onDamage( DamageInfo *damageInfo ) = 0; ///< damage callback
  82. virtual void onHealing( DamageInfo *damageInfo ) = 0; ///< healing callback
  83. virtual void onBodyDamageStateChange( const DamageInfo* damageInfo,
  84. BodyDamageType oldState,
  85. BodyDamageType newState) = 0; ///< state change callback
  86. protected:
  87. };
  88. inline DamageModule::DamageModule( Thing *thing, const ModuleData* moduleData ) : BehaviorModule( thing, moduleData ) { }
  89. inline DamageModule::~DamageModule() { }
  90. //-------------------------------------------------------------------------------------------------
  91. #endif