HelixContain.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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. ///////////////////////////////////////////////////////////////////////////////////////////////////
  24. //
  25. // FILE: HelixContain.h ////////////////////////////////////////////////////////////////////////
  26. // Author: Mark Lorenzen, April, 2003
  27. //
  28. // Desc: Contain module that acts as transport normally, but
  29. //
  30. ///////////////////////////////////////////////////////////////////////////////////////////////////
  31. #pragma once
  32. #ifndef __HELIX_CONTAIN_H_
  33. #define __HELIX_CONTAIN_H_
  34. // USER INCLUDES //////////////////////////////////////////////////////////////////////////////////
  35. #include "GameLogic/Module/TransportContain.h"
  36. typedef std::vector<AsciiString> TemplateNameList;
  37. typedef std::vector<AsciiString>::const_iterator TemplateNameIterator;
  38. //-------------------------------------------------------------------------------------------------
  39. class HelixContainModuleData : public TransportContainModuleData
  40. {
  41. public:
  42. HelixContainModuleData();
  43. TemplateNameList m_payloadTemplateNameData;
  44. Bool m_drawPips;
  45. static void buildFieldParse(MultiIniFieldParse& p);
  46. static void parseInitialPayload( INI* ini, void *instance, void *store, const void* /*userData*/ );
  47. };
  48. //-------------------------------------------------------------------------------------------------
  49. class HelixContain : public TransportContain
  50. {
  51. MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE( HelixContain, "HelixContain" )
  52. MAKE_STANDARD_MODULE_MACRO_WITH_MODULE_DATA( HelixContain, HelixContainModuleData )
  53. virtual void onBodyDamageStateChange( const DamageInfo* damageInfo,
  54. BodyDamageType oldState,
  55. BodyDamageType newState); ///< state change callback
  56. public:
  57. HelixContain( Thing *thing, const ModuleData* moduleData );
  58. // virtual destructor prototype provided by memory pool declaration
  59. virtual OpenContain *asOpenContain() { return this; } ///< treat as open container
  60. virtual Bool isHealContain() const { return false; } ///< true when container only contains units while healing (not a transport!)
  61. virtual Bool isTunnelContain() const { return FALSE; }
  62. virtual Bool isImmuneToClearBuildingAttacks() const { return true; }
  63. virtual Bool isSpecialOverlordStyleContainer() const {return TRUE;}
  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 );
  67. virtual void onObjectCreated();
  68. virtual void onContaining( Object *obj, Bool wasSelected );
  69. virtual void onRemoving( Object *obj );
  70. virtual UpdateSleepTime update(); ///< called once per frame
  71. // virtual void onContaining( Object *obj, Bool wasSelected ); ///< object now contains 'obj'
  72. // virtual void onRemoving( Object *obj ); ///< object no longer contains 'obj'
  73. virtual Bool isValidContainerFor(const Object* obj, Bool checkCapacity) const;
  74. virtual void addToContain( Object *obj ); ///< add 'obj' to contain list
  75. 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)
  76. virtual void removeFromContain( Object *obj, Bool exposeStealthUnits = FALSE ); ///< remove 'obj' from contain list
  77. //virtual void removeAllContained( Bool exposeStealthUnits = FALSE ); ///< remove all objects on contain list
  78. virtual Bool isEnclosingContainerFor( const Object *obj ) const; ///< Does this type of Contain Visibly enclose its contents?
  79. virtual Bool isPassengerAllowedToFire( ObjectID id = INVALID_ID ) const; ///< Hey, can I shoot out of this container?
  80. // Friend for our Draw module only.
  81. 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.
  82. ///< if my object gets selected, then my visible passengers should, too
  83. ///< this gets called from
  84. virtual void clientVisibleContainedFlashAsSelected();
  85. virtual void redeployOccupants();
  86. virtual Bool getContainerPipsToShow(Int& numTotal, Int& numFull)
  87. {
  88. if ( getHelixContainModuleData()->m_drawPips == FALSE )
  89. {
  90. numTotal = 0;
  91. numFull = 0;
  92. return FALSE;
  93. }
  94. return ContainModuleInterface::getContainerPipsToShow( numTotal, numFull );
  95. }
  96. virtual void createPayload();
  97. private:
  98. void parseInitialPayload( INI* ini, void *instance, void *store, const void* /*userData*/ );
  99. Object *getPortableStructure( void );
  100. ObjectID m_portableStructureID;
  101. };
  102. #endif