HordeUpdate.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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: HordeUpdate.h //////////////////////////////////////////////////////////////////////////
  24. // Author: Steven Johnson, Feb 2002
  25. // Desc: Horde update module
  26. ///////////////////////////////////////////////////////////////////////////////////////////////////
  27. #pragma once
  28. #ifndef __HordeUpdate_H_
  29. #define __HordeUpdate_H_
  30. // INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
  31. #include "GameLogic/Module/UpdateModule.h"
  32. #include "Common/KindOf.h"
  33. class SimpleObjectIterator;
  34. class UpgradeTemplate;
  35. //-------------------------------------------------------------------------------------------------
  36. //-------------------------------------------------------------------------------------------------
  37. //-------------------------------------------------------------------------------------------------
  38. //-------------------------------------------------------------------------------------------------
  39. enum HordeActionType
  40. {
  41. HORDEACTION_HORDE = 0,
  42. HORDEACTION_COUNT
  43. };
  44. #ifdef DEFINE_HORDEACTION_NAMES
  45. static const char *TheHordeActionTypeNames[] =
  46. {
  47. "HORDE",
  48. NULL
  49. };
  50. #endif
  51. //-------------------------------------------------------------------------------------------------
  52. class HordeUpdateModuleData : public ModuleData
  53. {
  54. public:
  55. UnsignedInt m_updateRate; ///< how often to recheck our horde status
  56. KindOfMaskType m_kindof; ///< the kind(s) of units that count towards horde-ness
  57. Int m_minCount; ///< min count to get "horde" status
  58. Real m_minDist; ///< min dist to contribute to horde-ness
  59. Bool m_alliesOnly; ///< if true, only allied units count towards hordeness
  60. Bool m_exactMatch; ///< if true, only exact same type of units count towards hordeness
  61. Real m_rubOffRadius;///< If I am this close to another guy who is a true hordesman, it'll rub off on me
  62. HordeActionType m_action; ///< what to do if we get horde-ness
  63. Bool m_allowedNationalism; ///< Nationalism is hard ocded. Yeah! Add to the goodness with this flag instead of rewriting after Alpha.
  64. std::vector<AsciiString> m_flagSubObjNames; ///< name(s) of the flag subobj
  65. HordeUpdateModuleData();
  66. static void buildFieldParse(MultiIniFieldParse& p);
  67. private:
  68. };
  69. // ------------------------------------------------------------------------------------------------
  70. class HordeUpdateInterface
  71. {
  72. public:
  73. virtual Bool isInHorde() const = 0;
  74. virtual Bool hasFlag() const = 0;
  75. virtual Bool isTrueHordeMember() const = 0;
  76. virtual Bool isAllowedNationalism() const = 0;
  77. };
  78. //-------------------------------------------------------------------------------------------------
  79. class HordeUpdate : public UpdateModule, public HordeUpdateInterface
  80. {
  81. MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE( HordeUpdate, "HordeUpdate" )
  82. MAKE_STANDARD_MODULE_MACRO_WITH_MODULE_DATA( HordeUpdate, HordeUpdateModuleData )
  83. public:
  84. HordeUpdate( Thing *thing, const ModuleData* moduleData );
  85. // virtual destructor prototype provided by memory pool declaration
  86. HordeUpdateInterface *getHordeUpdateInterface() { return this; }
  87. virtual void onDrawableBoundToObject();
  88. virtual Bool isInHorde() const { return m_inHorde; }
  89. virtual Bool isTrueHordeMember() const { return m_trueHordeMember && m_inHorde; }
  90. virtual Bool isAllowedNationalism() const;
  91. virtual Bool hasFlag() const { return m_hasFlag; }
  92. virtual UpdateSleepTime update(); ///< update this object's AI
  93. protected:
  94. void showHideFlag(Bool show);
  95. void joinOrLeaveHorde(SimpleObjectIterator *iter, Bool join);
  96. private:
  97. UnsignedInt m_lastHordeRefreshFrame; //Just like it sounds
  98. Bool m_inHorde; //I amy be a trueMember, or I may merely inherit hordehood from a neighbor who is
  99. Bool m_trueHordeMember; //meaning, I have enough hordesman near me to qualify
  100. Bool m_hasFlag;
  101. };
  102. #endif // __HordeUpdate_H_