QueueProductionExitUpdate.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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: QueueProductionExitUpdate.h /////////////////////////////////////////////////////////////////////////
  24. // Author: Graham Smallwood, January, 2002
  25. // Desc: Hand off produced Units to me so I can Exit them into the world with my specific style
  26. // This instance refuses to spit a second out until the first is clear
  27. ///////////////////////////////////////////////////////////////////////////////////////////////////
  28. #pragma once
  29. #ifndef _QUEUE_PRODUCTION_EXIT_UPDATE_H
  30. #define _QUEUE_PRODUCTION_EXIT_UPDATE_H
  31. #include "GameLogic/Module/UpdateModule.h"
  32. #include "Common/INI.h"
  33. #include "Lib/BaseType.h"
  34. class Object;
  35. //-------------------------------------------------------------------------------------------------
  36. class QueueProductionExitUpdateModuleData : public UpdateModuleData
  37. {
  38. public:
  39. Coord3D m_unitCreatePoint;
  40. Coord3D m_naturalRallyPoint;
  41. UnsignedInt m_exitDelayData;
  42. Bool m_allowAirborneCreationData;
  43. UnsignedInt m_initialBurst;
  44. QueueProductionExitUpdateModuleData()
  45. {
  46. m_unitCreatePoint.zero();
  47. m_naturalRallyPoint.zero();
  48. m_exitDelayData = 0;
  49. m_allowAirborneCreationData = FALSE;
  50. m_initialBurst = 0;
  51. }
  52. static void buildFieldParse(MultiIniFieldParse& p)
  53. {
  54. UpdateModuleData::buildFieldParse(p);
  55. static const FieldParse dataFieldParse[] =
  56. {
  57. { "UnitCreatePoint", INI::parseCoord3D, NULL, offsetof( QueueProductionExitUpdateModuleData, m_unitCreatePoint ) },
  58. { "NaturalRallyPoint", INI::parseCoord3D, NULL, offsetof( QueueProductionExitUpdateModuleData, m_naturalRallyPoint ) },
  59. { "ExitDelay", INI::parseDurationUnsignedInt, NULL, offsetof( QueueProductionExitUpdateModuleData, m_exitDelayData ) },
  60. { "AllowAirborneCreation", INI::parseBool, NULL, offsetof( QueueProductionExitUpdateModuleData, m_allowAirborneCreationData ) },
  61. { "InitialBurst", INI::parseUnsignedInt, NULL, offsetof( QueueProductionExitUpdateModuleData, m_initialBurst ) },
  62. { 0, 0, 0, 0 }
  63. };
  64. p.add(dataFieldParse);
  65. }
  66. };
  67. //-------------------------------------------------------------------------------------------------
  68. class QueueProductionExitUpdate : public UpdateModule, public ExitInterface
  69. {
  70. MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE( QueueProductionExitUpdate, "QueueProductionExitUpdate" )
  71. MAKE_STANDARD_MODULE_MACRO_WITH_MODULE_DATA( QueueProductionExitUpdate, QueueProductionExitUpdateModuleData )
  72. public:
  73. virtual ExitInterface* getUpdateExitInterface() { return this; }
  74. QueueProductionExitUpdate( Thing *thing, const ModuleData* moduleData );
  75. // virtual destructor prototype provided by memory pool declaration
  76. // Required funcs to fufill interface requirements
  77. virtual Bool isExitBusy() const {return FALSE;} ///< Contain style exiters are getting the ability to space out exits, so ask this before reserveDoor as a kind of no-commitment check.
  78. virtual ExitDoorType reserveDoorForExit( const ThingTemplate* objType, Object *specificObject );
  79. virtual void exitObjectViaDoor( Object *newObj, ExitDoorType exitDoor );
  80. virtual void exitObjectByBudding( Object *newObj, Object *budHost );
  81. virtual void unreserveDoorForExit( ExitDoorType exitDoor );
  82. virtual void setRallyPoint( const Coord3D *pos ); ///< define a "rally point" for units to move towards
  83. virtual const Coord3D *getRallyPoint( void ) const; ///< define a "rally point" for units to move towards
  84. virtual Bool getExitPosition( Coord3D& exitPosition ) const; ///< access to the "Door" position of the production object
  85. virtual Bool getNaturalRallyPoint( Coord3D& rallyPoint, Bool offset = TRUE ) const; ///< get the natural "rally point" for units to move towards
  86. virtual UpdateSleepTime update();
  87. protected:
  88. UnsignedInt m_currentDelay; ///< When this hits zero, I can exit again
  89. Coord3D m_rallyPoint; ///< Where units should move to after they have reached the "natural" rally point
  90. Bool m_rallyPointExists; ///< Only move to the rally point if this is true
  91. Real m_creationClearDistance; ///< I can think of myself as ready when the previous guy is this far away.
  92. UnsignedInt m_currentBurstCount; ///< how many times must I still override the delay timer
  93. Bool isFreeToExit() const;
  94. };
  95. inline void QueueProductionExitUpdate::setRallyPoint( const Coord3D *pos )
  96. {
  97. m_rallyPoint = *pos;
  98. m_rallyPointExists = true;
  99. }
  100. inline const Coord3D *QueueProductionExitUpdate::getRallyPoint( void ) const
  101. {
  102. if (m_rallyPointExists)
  103. return &m_rallyPoint;
  104. return NULL;
  105. }
  106. #endif