Squad.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. ** Command & Conquer Generals(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: Sqaud.h
  24. /*---------------------------------------------------------------------------*/
  25. /* EA Pacific */
  26. /* Confidential Information */
  27. /* Copyright (C) 2001 - All Rights Reserved */
  28. /* DO NOT DISTRIBUTE */
  29. /*---------------------------------------------------------------------------*/
  30. /* Project: RTS3 */
  31. /* File name: Sqaud.h */
  32. /* Created: John K. McDonald, Jr., 4/19/2002 */
  33. /* Desc: // @todo */
  34. /* Revision History: */
  35. /* 4/19/2002 : Initial creation */
  36. /*---------------------------------------------------------------------------*/
  37. #pragma once
  38. #ifndef _H_SQAUD_
  39. #define _H_SQAUD_
  40. // INCLUDES ///////////////////////////////////////////////////////////////////
  41. #include "Common/Snapshot.h"
  42. #include "Common/GameMemory.h"
  43. // DEFINES ////////////////////////////////////////////////////////////////////
  44. // FORWARD DECLARATIONS ///////////////////////////////////////////////////////
  45. class AIGroup;
  46. class Object;
  47. class Team;
  48. // TYPE DEFINES ///////////////////////////////////////////////////////////////
  49. typedef std::vector<ObjectID> VecObjectID;
  50. typedef VecObjectID::iterator VecObjectIDIt;
  51. typedef std::vector<Object*> VecObjectPtr;
  52. typedef VecObjectPtr::iterator VecObjectPtrIt;
  53. class Squad : public MemoryPoolObject, public Snapshot
  54. {
  55. MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(Squad, "Squad")
  56. protected:
  57. // snapshot methods
  58. virtual void crc( Xfer *xfer );
  59. virtual void xfer( Xfer *xfer );
  60. virtual void loadPostProcess( void );
  61. VecObjectID m_objectIDs;
  62. // this one is the last requested object stuff. Its used so that we can return a
  63. // const& rather than making a copy and placing it on the stack.
  64. VecObjectPtr m_objectsCached;
  65. public:
  66. void addObject(Object *objectToAdd); // add an object
  67. void addObjectID(ObjectID objectID); // add an object ID
  68. void removeObject(Object *objectToRemove); // remove an object
  69. void clearSquad(); // remove all objects from this squad.
  70. const VecObjectPtr& getAllObjects(void); // get all objects on the list that haven't been deleted
  71. const VecObjectPtr& getLiveObjects(void); // get all objects that pass "isEffectivelyDead" test
  72. Int getSizeOfGroup(void) const; // get the current number of objects, including dead objects
  73. Bool isOnSquad(const Object *objToTest) const; // returns true if the object is on this squad, otherwise false
  74. // convenience function to fill this squad with members of a team
  75. // There SHOULD NOT be a TeamFromSquad Function. See comments in Squad.cpp for details
  76. void squadFromTeam(const Team* fromTeam, Bool clearSquadFirst);
  77. // convenience function to create a squad from an AIGroup, and an AIGroup from a team.
  78. // When creating the AIGroup from the Squad, the old AIGroup affiliations are broken.
  79. void squadFromAIGroup(const AIGroup* fromAIGroup, Bool clearSquadFirst);
  80. void aiGroupFromSquad(AIGroup* aiGroupToFill);
  81. };
  82. EMPTY_DTOR(Squad)
  83. #endif /* _H_SQAUD_ */