SpawnPointProductionExitUpdate.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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: SpawnPointProductionExitUpdate.h /////////////////////////////////////////////////////////////////////////
  24. // Author: Graham Smallwood, April, 2002
  25. // Desc: Hand off produced Units to me so I can Exit them into the world with my specific style
  26. // This instance puts guys at named bones.
  27. ///////////////////////////////////////////////////////////////////////////////////////////////////
  28. #pragma once
  29. #ifndef _SPAWN_POINT_PRODUCTION_EXIT_UPDATE_H
  30. #define _SPAWN_POINT_PRODUCTION_EXIT_UPDATE_H
  31. #include "GameLogic/Module/UpdateModule.h"
  32. #include "Common/INI.h"
  33. #include "Lib/BaseType.h"
  34. class Object;
  35. enum
  36. {
  37. MAX_SPAWN_POINTS = 10 ///< Size the array that holds the bone positions
  38. };
  39. //-------------------------------------------------------------------------------------------------
  40. class SpawnPointProductionExitUpdateModuleData : public UpdateModuleData
  41. {
  42. public:
  43. AsciiString m_spawnPointBoneNameData;
  44. static void buildFieldParse(MultiIniFieldParse& p)
  45. {
  46. UpdateModuleData::buildFieldParse(p);
  47. static const FieldParse dataFieldParse[] =
  48. {
  49. { "SpawnPointBoneName", INI::parseAsciiString, NULL, offsetof( SpawnPointProductionExitUpdateModuleData, m_spawnPointBoneNameData ) },
  50. { 0, 0, 0, 0 }
  51. };
  52. p.add(dataFieldParse);
  53. }
  54. };
  55. //-------------------------------------------------------------------------------------------------
  56. class SpawnPointProductionExitUpdate : public UpdateModule, public ExitInterface
  57. {
  58. MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE( SpawnPointProductionExitUpdate, "SpawnPointProductionExitUpdate" )
  59. MAKE_STANDARD_MODULE_MACRO_WITH_MODULE_DATA( SpawnPointProductionExitUpdate, SpawnPointProductionExitUpdateModuleData )
  60. public:
  61. virtual ExitInterface* getUpdateExitInterface() { return this; }
  62. SpawnPointProductionExitUpdate( Thing *thing, const ModuleData* moduleData );
  63. // virtual destructor prototype provided by memory pool declaration
  64. // Required funcs to fufill interface requirements
  65. 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.
  66. virtual ExitDoorType reserveDoorForExit( const ThingTemplate* objType, Object *specificObject );
  67. virtual void exitObjectViaDoor( Object *newObj, ExitDoorType exitDoor );
  68. virtual void unreserveDoorForExit( ExitDoorType exitDoor );
  69. virtual void setRallyPoint( const Coord3D * ){}
  70. virtual const Coord3D *getRallyPoint() const { return NULL; }
  71. virtual void exitObjectByBudding( Object *newObj, Object *budHost ) { return; }
  72. virtual UpdateSleepTime update() { return UPDATE_SLEEP_FOREVER; }
  73. protected:
  74. Bool m_bonesInitialized; ///< To prevent creation bugs, only init the World coords when first asked for one
  75. Int m_spawnPointCount; ///< How many in the array are actually live and valid
  76. Coord3D m_worldCoordSpawnPoints[MAX_SPAWN_POINTS];///< Where my little friends will be created
  77. Real m_worldAngleSpawnPoints[MAX_SPAWN_POINTS]; ///< And what direction they should face
  78. ObjectID m_spawnPointOccupier[MAX_SPAWN_POINTS]; ///< Who I think is in each spot. I can validate their existance to see if I am free to exit something.
  79. // Required func to fufill Module requirement
  80. private:
  81. void initializeBonePositions(); ///< Look up the bone positions and store them in world space coords
  82. void revalidateOccupiers(); ///< Do a lookup on all our ID's and clear the dead ones.
  83. };
  84. #endif