DeployStyleAIUpdate.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. // DeployStyleAIUpdate.h ////////////
  24. // Author: Kris Morness, August 2002
  25. // Desc: State machine that allows deploying/undeploying to control the AI.
  26. // When deployed, you can't move, when undeployed, you can't attack.
  27. #pragma once
  28. #ifndef __DEPLOY_STYLE_AI_UPDATE_H
  29. #define __DEPLOY_STYLE_AI_UPDATE_H
  30. #include "Common/StateMachine.h"
  31. #include "GameLogic/Module/AIUpdate.h"
  32. //-------------------------------------------------------------------------------------------------
  33. enum DeployStateTypes
  34. {
  35. READY_TO_MOVE, ///< Mobile, can't attack.
  36. DEPLOY, ///< Not mobile, can't attack, currently unpacking to attack
  37. READY_TO_ATTACK, ///< Not mobile, can attack
  38. UNDEPLOY, ///< Not mobile, can't attack, currently packing to move
  39. ALIGNING_TURRETS, ///< While deployed, we must wait for the turret to go back to natural position prior to undeploying.
  40. };
  41. //-------------------------------------------------------------------------------------------------
  42. class DeployStyleAIUpdateModuleData : public AIUpdateModuleData
  43. {
  44. public:
  45. UnsignedInt m_unpackTime;
  46. UnsignedInt m_packTime;
  47. Bool m_resetTurretBeforePacking;
  48. Bool m_turretsFunctionOnlyWhenDeployed;
  49. Bool m_turretsMustCenterBeforePacking;
  50. Bool m_manualDeployAnimations;
  51. DeployStyleAIUpdateModuleData()
  52. {
  53. m_unpackTime = 0;
  54. m_packTime = 0;
  55. m_resetTurretBeforePacking = false;
  56. m_turretsFunctionOnlyWhenDeployed = false;
  57. // Added By Sadullah Nader
  58. // Initialization necessary
  59. m_turretsMustCenterBeforePacking = FALSE;
  60. // End Add
  61. m_manualDeployAnimations = FALSE;
  62. }
  63. static void buildFieldParse(MultiIniFieldParse& p)
  64. {
  65. AIUpdateModuleData::buildFieldParse(p);
  66. static const FieldParse dataFieldParse[] =
  67. {
  68. { "UnpackTime", INI::parseDurationUnsignedInt, NULL, offsetof( DeployStyleAIUpdateModuleData, m_unpackTime ) },
  69. { "PackTime", INI::parseDurationUnsignedInt, NULL, offsetof( DeployStyleAIUpdateModuleData, m_packTime ) },
  70. { "ResetTurretBeforePacking", INI::parseBool, NULL, offsetof( DeployStyleAIUpdateModuleData, m_resetTurretBeforePacking ) },
  71. { "TurretsFunctionOnlyWhenDeployed", INI::parseBool, NULL, offsetof( DeployStyleAIUpdateModuleData, m_turretsFunctionOnlyWhenDeployed ) },
  72. { "TurretsMustCenterBeforePacking", INI::parseBool, NULL, offsetof( DeployStyleAIUpdateModuleData, m_turretsMustCenterBeforePacking ) },
  73. { "ManualDeployAnimations", INI::parseBool, NULL, offsetof( DeployStyleAIUpdateModuleData, m_manualDeployAnimations ) },
  74. { 0, 0, 0, 0 }
  75. };
  76. p.add(dataFieldParse);
  77. }
  78. };
  79. //-------------------------------------------------------------------------------------------------
  80. class DeployStyleAIUpdate : public AIUpdateInterface
  81. {
  82. MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE( DeployStyleAIUpdate, "DeployStyleAIUpdate" )
  83. MAKE_STANDARD_MODULE_MACRO_WITH_MODULE_DATA( DeployStyleAIUpdate, DeployStyleAIUpdateModuleData )
  84. private:
  85. public:
  86. DeployStyleAIUpdate( Thing *thing, const ModuleData* moduleData );
  87. // virtual destructor prototype provided by memory pool declaration
  88. virtual void aiDoCommand(const AICommandParms* parms);
  89. virtual Bool isIdle() const;
  90. virtual UpdateSleepTime update();
  91. UnsignedInt getUnpackTime() const { return getDeployStyleAIUpdateModuleData()->m_unpackTime; }
  92. UnsignedInt getPackTime() const { return getDeployStyleAIUpdateModuleData()->m_packTime; }
  93. Bool doTurretsFunctionOnlyWhenDeployed() const { return getDeployStyleAIUpdateModuleData()->m_turretsFunctionOnlyWhenDeployed; }
  94. Bool doTurretsHaveToCenterBeforePacking() const { return getDeployStyleAIUpdateModuleData()->m_turretsMustCenterBeforePacking; }
  95. void setMyState( DeployStateTypes StateID, Bool reverseDeploy = FALSE );
  96. protected:
  97. DeployStateTypes m_state;
  98. UnsignedInt m_frameToWaitForDeploy;
  99. };
  100. #endif