TunnelContain.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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: TunnelContain.h ////////////////////////////////////////////////////////////////////////////
  24. // Author: Graham Smallwood, March 2002
  25. // Desc: A version of OpenContain that overrides where the passengers are stored: the Owning Player's
  26. // TunnelTracker. All queries about capacity and contents are also redirected.
  27. ///////////////////////////////////////////////////////////////////////////////////////////////////
  28. #pragma once
  29. #ifndef __TUNNEL_CONTAIN_H_
  30. #define __TUNNEL_CONTAIN_H_
  31. // INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
  32. #include "GameLogic/Module/OpenContain.h"
  33. #include "GameLogic/Module/HealContain.h"
  34. #include "GameLogic/Module/DieModule.h"
  35. #include "GameLogic/Module/CreateModule.h"
  36. #include "Common/GameMemory.h"
  37. class Team;
  38. //-------------------------------------------------------------------------------------------------
  39. class TunnelContainModuleData : public OpenContainModuleData
  40. {
  41. public:
  42. Real m_framesForFullHeal; ///< time (in frames) something becomes fully healed
  43. TunnelContainModuleData()
  44. {
  45. // by default, takes no time to heal ppl
  46. m_framesForFullHeal = 1.0f;
  47. //
  48. // by default we say that transports can have infantry inside them, this will be totally
  49. // overwritten by any data provided from the INI entry tho
  50. //
  51. m_allowInsideKindOf = MAKE_KINDOF_MASK(KINDOF_INFANTRY);
  52. }
  53. static void buildFieldParse(MultiIniFieldParse& p)
  54. {
  55. OpenContainModuleData::buildFieldParse(p);
  56. static const FieldParse dataFieldParse[] =
  57. {
  58. { "TimeForFullHeal", INI::parseDurationReal, NULL, offsetof( TunnelContainModuleData, m_framesForFullHeal ) },
  59. { 0, 0, 0, 0 }
  60. };
  61. p.add(dataFieldParse);
  62. }
  63. };
  64. class TunnelContain : public OpenContain, public CreateModuleInterface
  65. {
  66. MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE( TunnelContain, "TunnelContain" )
  67. MAKE_STANDARD_MODULE_MACRO_WITH_MODULE_DATA( TunnelContain, TunnelContainModuleData )
  68. public:
  69. TunnelContain( Thing *thing, const ModuleData* moduleData );
  70. // virtual destructor prototype provided by memory pool declaration
  71. virtual CreateModuleInterface* getCreate() { return this; }
  72. static Int getInterfaceMask() { return OpenContain::getInterfaceMask() | (MODULEINTERFACE_CREATE); }
  73. virtual OpenContain *asOpenContain() { return this; } ///< treat as open container
  74. virtual Bool isGarrisonable() const { return false; } ///< can this unit be Garrisoned? (ick)
  75. virtual Bool isBustable() const { return TRUE; } ///< can this container get busted by a bunkerbuster
  76. virtual Bool isHealContain() const { return false; } ///< true when container only contains units while healing (not a transport!)
  77. virtual Bool isTunnelContain() const { return TRUE; }
  78. virtual Bool isImmuneToClearBuildingAttacks() const { return true; }
  79. virtual Bool isSpecialOverlordStyleContainer() const {return FALSE;}
  80. virtual void onContaining( Object *obj, Bool wasSelected ); ///< object now contains 'obj'
  81. virtual void onRemoving( Object *obj ); ///< object no longer contains 'obj'
  82. virtual void onSelling();///< Container is being sold. Tunnel responds by kicking people out if this is the last tunnel.
  83. virtual void onCapture( Player *oldOwner, Player *newOwner ); // Need to change who we are registered with.
  84. virtual Bool isValidContainerFor(const Object* obj, Bool checkCapacity) const;
  85. 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)
  86. virtual void removeFromContain( Object *obj, Bool exposeStealthUnits = FALSE ); ///< remove 'obj' from contain list
  87. virtual void removeAllContained( Bool exposeStealthUnits = FALSE ); ///< remove all objects on contain list
  88. virtual void harmAndForceExitAllContained( DamageInfo *info );
  89. virtual void killAllContained( void ); ///< kill all objects on contain list
  90. // contain list access
  91. virtual void iterateContained( ContainIterateFunc func, void *userData, Bool reverse );
  92. virtual UnsignedInt getContainCount() const;
  93. virtual Int getContainMax( void ) const;
  94. virtual const ContainedItemsList* getContainedItemsList() const;
  95. virtual Bool isDisplayedOnControlBar() const { return TRUE; } ///< Does this container display its contents on the ControlBar?
  96. virtual Bool isKickOutOnCapture(){ return FALSE; }///< Caves and Tunnels don't kick out on capture.
  97. // override the onDie we inherit from OpenContain
  98. virtual void onDie( const DamageInfo *damageInfo ); ///< the die callback
  99. virtual void onDelete( void );
  100. virtual void onCreate( void );
  101. virtual void onObjectCreated();
  102. virtual void onBuildComplete();
  103. virtual Bool shouldDoOnBuildComplete() const { return m_needToRunOnBuildComplete; }
  104. // so that the ppl within the tunnel network can get healed
  105. virtual UpdateSleepTime update(); ///< called once per frame
  106. protected:
  107. void scatterToNearbyPosition(Object* obj);
  108. Bool m_needToRunOnBuildComplete;
  109. Bool m_isCurrentlyRegistered; ///< Keeps track if this is registered with the player, so we don't double remove and mess up
  110. };
  111. #endif // end __TUNNEL_CONTAIN_H_