MissileLauncherBuildingUpdate.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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: MissileLauncherBuildingUpdate.h /////////////////////////////////////////////////////////////////////////
  24. // Author: Matthew D. Campbell, April 2002
  25. // Desc: Update will change model state conditions based on special power state
  26. ///////////////////////////////////////////////////////////////////////////////////////////////////
  27. #pragma once
  28. #ifndef _MissileLauncherBuildingUpdate_H_
  29. #define _MissileLauncherBuildingUpdate_H_
  30. // INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
  31. #include "Common/AudioEventRTS.h"
  32. #include "Common/INI.h"
  33. #include "GameLogic/Module/SpecialPowerUpdateModule.h"
  34. class DamageInfo;
  35. class SpecialPowerTemplate;
  36. class SpecialPowerModule;
  37. class FXList;
  38. //-------------------------------------------------------------------------------------------------
  39. class MissileLauncherBuildingUpdateModuleData : public UpdateModuleData
  40. {
  41. public:
  42. SpecialPowerTemplate *m_specialPowerTemplate; ///< pointer to the special power template
  43. UnsignedInt m_doorOpenTime; ///< in frames, time we should take to open the door
  44. UnsignedInt m_doorWaitOpenTime; ///< in frames, time we should leave the door open after firing the superweapon
  45. UnsignedInt m_doorClosingTime; ///< in frames, time it takes to close the door
  46. const FXList *m_openingFX;
  47. const FXList *m_openFX;
  48. const FXList *m_waitingToCloseFX;
  49. const FXList *m_closingFX;
  50. const FXList *m_closedFX;
  51. AudioEventRTS m_openIdleAudio;
  52. MissileLauncherBuildingUpdateModuleData()
  53. {
  54. m_specialPowerTemplate = NULL;
  55. m_doorOpenTime = 0;
  56. m_doorWaitOpenTime = 0;
  57. m_doorClosingTime = 0;
  58. m_openingFX = m_openFX = m_waitingToCloseFX = m_closingFX = m_closedFX = NULL;
  59. }
  60. static void buildFieldParse(MultiIniFieldParse& p)
  61. {
  62. UpdateModuleData::buildFieldParse(p);
  63. static const FieldParse dataFieldParse[] =
  64. {
  65. { "SpecialPowerTemplate", INI::parseSpecialPowerTemplate, NULL, offsetof( MissileLauncherBuildingUpdateModuleData, m_specialPowerTemplate ) },
  66. { "DoorOpenTime", INI::parseDurationUnsignedInt, NULL, offsetof( MissileLauncherBuildingUpdateModuleData, m_doorOpenTime ) },
  67. { "DoorWaitOpenTime", INI::parseDurationUnsignedInt, NULL, offsetof( MissileLauncherBuildingUpdateModuleData, m_doorWaitOpenTime ) },
  68. { "DoorCloseTime", INI::parseDurationUnsignedInt, NULL, offsetof( MissileLauncherBuildingUpdateModuleData, m_doorClosingTime ) },
  69. { "DoorOpeningFX", INI::parseFXList, NULL, offsetof( MissileLauncherBuildingUpdateModuleData, m_openingFX ) },
  70. { "DoorOpenFX", INI::parseFXList, NULL, offsetof( MissileLauncherBuildingUpdateModuleData, m_openFX ) },
  71. { "DoorWaitingToCloseFX", INI::parseFXList, NULL, offsetof( MissileLauncherBuildingUpdateModuleData, m_waitingToCloseFX ) },
  72. { "DoorClosingFX", INI::parseFXList, NULL, offsetof( MissileLauncherBuildingUpdateModuleData, m_closingFX ) },
  73. { "DoorClosedFX", INI::parseFXList, NULL, offsetof( MissileLauncherBuildingUpdateModuleData, m_closedFX ) },
  74. { "DoorOpenIdleAudio", INI::parseAudioEventRTS, NULL, offsetof( MissileLauncherBuildingUpdateModuleData, m_openIdleAudio ) },
  75. { 0, 0, 0, 0 }
  76. };
  77. p.add(dataFieldParse);
  78. }
  79. };
  80. //-------------------------------------------------------------------------------------------------
  81. class MissileLauncherBuildingUpdate : public SpecialPowerUpdateModule
  82. {
  83. MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE( MissileLauncherBuildingUpdate, "MissileLauncherBuildingUpdate" )
  84. MAKE_STANDARD_MODULE_MACRO_WITH_MODULE_DATA( MissileLauncherBuildingUpdate, MissileLauncherBuildingUpdateModuleData )
  85. public:
  86. MissileLauncherBuildingUpdate( Thing *thing, const ModuleData* moduleData );
  87. // virtual destructor prototype provided by memory pool declaration
  88. //SpecialPowerUpdateInterface pure virtual implementations
  89. virtual Bool initiateIntentToDoSpecialPower(const SpecialPowerTemplate *specialPowerTemplate, const Object *targetObj, const Coord3D *targetPos, const Waypoint *way, UnsignedInt commandOptions );
  90. virtual Bool isSpecialAbility() const { return false; }
  91. virtual Bool isSpecialPower() const { return true; }
  92. virtual Bool isActive() const { return m_doorState != m_timeoutState; }
  93. SpecialPowerTemplate* getTemplate() const;
  94. virtual Bool doesSpecialPowerHaveOverridableDestinationActive() const { return false; } //Is it active now?
  95. virtual Bool doesSpecialPowerHaveOverridableDestination() const { return false; } //Does it have it, even if it's not active?
  96. virtual void setSpecialPowerOverridableDestination( const Coord3D *loc ) {}
  97. virtual SpecialPowerUpdateInterface* getSpecialPowerUpdateInterface() { return this; }
  98. virtual CommandOption getCommandOption() const { return (CommandOption)0; }
  99. virtual UpdateSleepTime update(); ///< Deciding whether or not to make new guys
  100. virtual Bool isPowerCurrentlyInUse( const CommandButton *command = NULL ) const;
  101. private:
  102. enum DoorStateType
  103. {
  104. DOOR_CLOSED,
  105. DOOR_OPENING,
  106. DOOR_OPEN,
  107. DOOR_WAITING_TO_CLOSE,
  108. DOOR_CLOSING,
  109. };
  110. void switchToState(DoorStateType dst);
  111. const SpecialPowerModuleInterface* m_specialPowerModule;
  112. DoorStateType m_doorState;
  113. DoorStateType m_timeoutState;
  114. UnsignedInt m_timeoutFrame;
  115. AudioEventRTS m_openIdleAudio;
  116. };
  117. #endif // _MissileLauncherBuildingUpdate_H_