FXListDie.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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: FXListDie.h /////////////////////////////////////////////////////////////////////////////
  24. // Author: Steven Johnson, Jan 2002
  25. // Desc: Simple die module
  26. ///////////////////////////////////////////////////////////////////////////////////////////////////
  27. #pragma once
  28. #ifndef __FXListDie_H_
  29. #define __FXListDie_H_
  30. // INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
  31. #include "Common/INI.h"
  32. #include "GameLogic/Module/DieModule.h"
  33. #include "GameLogic/Module/UpgradeModule.h"
  34. #include "GameLogic/Weapon.h"
  35. #include "GameLogic/Damage.h"
  36. // FORWARD REFERENCES /////////////////////////////////////////////////////////////////////////////
  37. class Thing;
  38. class FXList;
  39. //-------------------------------------------------------------------------------------------------
  40. class FXListDieModuleData : public DieModuleData
  41. {
  42. public:
  43. const FXList *m_defaultDeathFX; ///< default fx to make
  44. UpgradeMuxData m_upgradeMuxData;
  45. Bool m_orientToObject;
  46. Bool m_initiallyActive;
  47. FXListDieModuleData()
  48. {
  49. m_defaultDeathFX = NULL;
  50. m_orientToObject = TRUE;
  51. m_initiallyActive = TRUE; //Patch 1.02 -- Craptacular HACK -- should default to FALSE but only ONE case sets it false out of 847!
  52. }
  53. static void buildFieldParse(MultiIniFieldParse& p)
  54. {
  55. DieModuleData::buildFieldParse(p);
  56. static const FieldParse dataFieldParse[] =
  57. {
  58. { "StartsActive", INI::parseBool, NULL, offsetof( FXListDieModuleData, m_initiallyActive ) },
  59. { "DeathFX", INI::parseFXList, NULL, offsetof( FXListDieModuleData, m_defaultDeathFX ) },
  60. { "OrientToObject", INI::parseBool, NULL, offsetof( FXListDieModuleData, m_orientToObject ) },
  61. { 0, 0, 0, 0 }
  62. };
  63. p.add(dataFieldParse);
  64. p.add(UpgradeMuxData::getFieldParse(), offsetof( FXListDieModuleData, m_upgradeMuxData ));
  65. }
  66. };
  67. //-------------------------------------------------------------------------------------------------
  68. class FXListDie : public DieModule, public UpgradeMux
  69. {
  70. MAKE_STANDARD_MODULE_MACRO_WITH_MODULE_DATA( FXListDie, FXListDieModuleData );
  71. MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE( FXListDie, "FXListDie" )
  72. public:
  73. FXListDie( Thing *thing, const ModuleData* moduleData );
  74. // virtual destructor prototype provided by memory pool declaration
  75. // module methods
  76. static Int getInterfaceMask() { return BehaviorModule::getInterfaceMask() | (MODULEINTERFACE_UPGRADE) | (MODULEINTERFACE_DIE); }
  77. // BehaviorModule
  78. virtual UpgradeModuleInterface* getUpgrade() { return this; }
  79. virtual DieModuleInterface* getDie() { return this; }
  80. virtual void onDie( const DamageInfo *damageInfo );
  81. protected:
  82. virtual void upgradeImplementation()
  83. {
  84. // nothing!
  85. }
  86. virtual void getUpgradeActivationMasks(UpgradeMaskType& activation, UpgradeMaskType& conflicting) const
  87. {
  88. getFXListDieModuleData()->m_upgradeMuxData.getUpgradeActivationMasks(activation, conflicting);
  89. }
  90. virtual void performUpgradeFX()
  91. {
  92. getFXListDieModuleData()->m_upgradeMuxData.performUpgradeFX(getObject());
  93. }
  94. virtual void processUpgradeRemoval()
  95. {
  96. // I can't take it any more. Let the record show that I think the UpgradeMux multiple inheritence is CRAP.
  97. getFXListDieModuleData()->m_upgradeMuxData.muxDataProcessUpgradeRemoval(getObject());
  98. }
  99. virtual Bool requiresAllActivationUpgrades() const
  100. {
  101. return getFXListDieModuleData()->m_upgradeMuxData.m_requiresAllTriggers;
  102. }
  103. inline Bool isUpgradeActive() const { return isAlreadyUpgraded(); }
  104. virtual Bool isSubObjectsUpgrade() { return false; }
  105. };
  106. #endif // __FXListDie_H_