OverlordContain.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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: OverlordContain.h ////////////////////////////////////////////////////////////////////////
  24. // Author: Graham Smallwood, September, 2002
  25. // Desc: Contain module that acts as transport normally, but when full it redirects queries to the first passenger
  26. ///////////////////////////////////////////////////////////////////////////////////////////////////
  27. #pragma once
  28. #ifndef __OVERLORD_CONTAIN_H_
  29. #define __OVERLORD_CONTAIN_H_
  30. // USER INCLUDES //////////////////////////////////////////////////////////////////////////////////
  31. #include "GameLogic/Module/TransportContain.h"
  32. #include "GameLOgic/GameLogic.h"
  33. typedef std::vector<AsciiString> TemplateNameList;
  34. typedef std::vector<AsciiString>::const_iterator TemplateNameIterator;
  35. //-------------------------------------------------------------------------------------------------
  36. class OverlordContainModuleData : public TransportContainModuleData
  37. {
  38. public:
  39. OverlordContainModuleData();
  40. TemplateNameList m_payloadTemplateNameData;
  41. Bool m_experienceSinkForRider;
  42. static void buildFieldParse(MultiIniFieldParse& p);
  43. static void parseInitialPayload( INI* ini, void *instance, void *store, const void* /*userData*/ );
  44. };
  45. //-------------------------------------------------------------------------------------------------
  46. class OverlordContain : public TransportContain
  47. {
  48. MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE( OverlordContain, "OverlordContain" )
  49. MAKE_STANDARD_MODULE_MACRO_WITH_MODULE_DATA( OverlordContain, OverlordContainModuleData )
  50. virtual void onBodyDamageStateChange( const DamageInfo* damageInfo,
  51. BodyDamageType oldState,
  52. BodyDamageType newState); ///< state change callback
  53. public:
  54. OverlordContain( Thing *thing, const ModuleData* moduleData );
  55. // virtual destructor prototype provided by memory pool declaration
  56. virtual OpenContain *asOpenContain() { return this; } ///< treat as open container
  57. virtual Bool isGarrisonable() const; ///< can this unit be Garrisoned? (ick)
  58. virtual Bool isBustable() { return false;}; ///< can this container get busted by bunkerbuster? (ick)
  59. virtual Bool isHealContain() const { return false; } ///< true when container only contains units while healing (not a transport!)
  60. virtual Bool isTunnelContain() const { return FALSE; }
  61. virtual Bool isImmuneToClearBuildingAttacks() const { return true; }
  62. virtual Bool isSpecialOverlordStyleContainer() const {return TRUE;}
  63. virtual Bool isPassengerAllowedToFire( ObjectID id = INVALID_ID ) const; ///< Hey, can I shoot out of this container?
  64. virtual void onDie( const DamageInfo *damageInfo ); ///< the die callback
  65. virtual void onDelete( void ); ///< Last possible moment cleanup
  66. virtual void onCapture( Player *oldOwner, Player *newOwner ); // Our main guy goes with us, but our redirected contain needs to do his thing too
  67. virtual void onObjectCreated();
  68. // Contain stuff we need to override to redirect on a condition
  69. virtual void onContaining( Object *obj, Bool wasSelected ); ///< object now contains 'obj'
  70. virtual void onRemoving( Object *obj ); ///< object no longer contains 'obj'
  71. virtual Bool isValidContainerFor(const Object* obj, Bool checkCapacity) const;
  72. virtual void addToContain( Object *obj ); ///< add 'obj' to contain list
  73. virtual void addToContainList( Object *obj ); ///< The part of AddToContain that inheritors can override (Can't do whole thing because of all the private stuff involved)
  74. virtual void removeFromContain( Object *obj, Bool exposeStealthUnits = FALSE ); ///< remove 'obj' from contain list
  75. virtual void removeAllContained( Bool exposeStealthUnits = FALSE ); ///< remove all objects on contain list
  76. virtual Bool isEnclosingContainerFor( const Object *obj ) const; ///< Does this type of Contain Visibly enclose its contents?
  77. virtual Bool isDisplayedOnControlBar() const ;///< Does this container display its contents on the ControlBar?
  78. virtual Bool isKickOutOnCapture();// The bunker may want to, but we certainly don't
  79. virtual void killAllContained( void ); ///< kill all objects inside. For us, this does not mean our rider
  80. // contain list access
  81. virtual void iterateContained( ContainIterateFunc func, void *userData, Bool reverse );
  82. virtual UnsignedInt getContainCount() const;
  83. virtual Int getContainMax( void ) const;
  84. virtual const ContainedItemsList* getContainedItemsList() const;
  85. // Friend for our Draw module only.
  86. virtual const Object *friend_getRider() const; ///< Damn. The draw order dependency bug for riders means that our draw module needs to cheat to get around it.
  87. ///< if my object gets selected, then my visible passengers should, too
  88. ///< this gets called from
  89. virtual void clientVisibleContainedFlashAsSelected();
  90. virtual Bool getContainerPipsToShow(Int& numTotal, Int& numFull);
  91. virtual void createPayload();
  92. private:
  93. /**< An empty overlord is a conatiner, but a full one redirects calls to its passengers. If this returns NULL,
  94. we are either empty or carrying a non container.
  95. */
  96. ContainModuleInterface *getRedirectedContain() const; ///< And this gets what are redirecting to.
  97. void activateRedirectedContain();///< I need to shut this off since I can talk directly to my bunker, but he can never directly see me
  98. void deactivateRedirectedContain();
  99. void parseInitialPayload( INI* ini, void *instance, void *store, const void* /*userData*/ );
  100. Bool m_redirectionActivated;
  101. };
  102. #endif