ProductionPrerequisite.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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: ProductionPrerequisite.h //////////////////////////////////////////////////////
  24. //-----------------------------------------------------------------------------
  25. //
  26. // Westwood Studios Pacific.
  27. //
  28. // Confidential Information
  29. // Copyright (C) 2001 - All Rights Reserved
  30. //
  31. //-----------------------------------------------------------------------------
  32. //
  33. // Project: RTS3
  34. //
  35. // File name: ProductionPrerequisite.h
  36. //
  37. // Created: Steven Johnson, October 2001
  38. //
  39. //-----------------------------------------------------------------------------
  40. #pragma once
  41. #ifndef __ProductionPrerequisite_H_
  42. #define __ProductionPrerequisite_H_
  43. //-----------------------------------------------------------------------------
  44. // Includes
  45. //-----------------------------------------------------------------------------
  46. #include "Common/GameMemory.h"
  47. #include "Common/GameCommon.h"
  48. #include "Common/Science.h"
  49. //#include "GameClient/ControlBar.h"
  50. //-----------------------------------------------------------------------------
  51. class ThingTemplate;
  52. class Player;
  53. //-----------------------------------------------------------------------------
  54. class ProductionPrerequisite
  55. {
  56. public:
  57. ProductionPrerequisite();
  58. ~ProductionPrerequisite();
  59. /// init to safe default values.
  60. void init();
  61. void resetSciences( void ) { m_prereqSciences.clear(); }
  62. void addSciencePrereq( ScienceType science ) { m_prereqSciences.push_back(science); }
  63. void resetUnits( void ) { m_prereqUnits.clear(); }
  64. void addUnitPrereq( AsciiString units, Bool orUnitWithPrevious );
  65. void addUnitPrereq( const std::vector<AsciiString>& units );
  66. /// called after all ThingTemplates have been loaded.
  67. void resolveNames();
  68. /// returns an asciistring which is a list of all the prerequisites
  69. /// not satisfied yet
  70. UnicodeString getRequiresList(const Player *player) const;
  71. /// return true iff the player satisfies our set of prerequisites
  72. Bool isSatisfied(const Player *player) const;
  73. /**
  74. return the BuildFacilityTemplate, if any.
  75. if this template needs no build facility, null is returned.
  76. if the template needs a build facility but the given player doesn't have any in existence,
  77. null will be returned.
  78. you may not pass 'null' for player.
  79. */
  80. const ThingTemplate *getExistingBuildFacilityTemplate( const Player *player ) const;
  81. Int getAllPossibleBuildFacilityTemplates(const ThingTemplate* tmpls[], Int maxtmpls) const;
  82. private:
  83. enum
  84. {
  85. UNIT_OR_WITH_PREV = 0x01 // if set, unit is "or-ed" with prev unit, so that either one's presence satisfies
  86. };
  87. struct PrereqUnitRec
  88. {
  89. const ThingTemplate* unit;
  90. Int flags;
  91. AsciiString name;
  92. };
  93. enum { MAX_PREREQ = 32 };
  94. Int calcNumPrereqUnitsOwned(const Player *player, Int counts[MAX_PREREQ]) const;
  95. std::vector<PrereqUnitRec> m_prereqUnits;
  96. ScienceVec m_prereqSciences;
  97. };
  98. //-----------------------------------------------------------------------------
  99. #endif