RailedTransportContain.cpp 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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: RailedTransportContain.cpp ///////////////////////////////////////////////////////////////
  24. // Author: Colin Day, August 2002
  25. // Desc: Railed Transport Contain Module
  26. ///////////////////////////////////////////////////////////////////////////////////////////////////
  27. // INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
  28. #include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine
  29. #include "Common/Xfer.h"
  30. #include "GameLogic/Object.h"
  31. #include "GameLogic/Module/RailedTransportContain.h"
  32. #include "GameLogic/Module/RailedTransportDockUpdate.h"
  33. // ------------------------------------------------------------------------------------------------
  34. // ------------------------------------------------------------------------------------------------
  35. static RailedTransportDockUpdateInterface *getRailedTransportDockUpdateInterface( Object *obj )
  36. {
  37. // sanity
  38. if( obj == NULL )
  39. return NULL;
  40. // find us our dock interface
  41. RailedTransportDockUpdateInterface *rtdui = NULL;
  42. for( BehaviorModule **u = obj->getBehaviorModules(); *u; ++u )
  43. if( (rtdui = (*u)->getRailedTransportDockUpdateInterface()) != NULL )
  44. break;
  45. return rtdui;
  46. } // end getRailedTransportDockUpdateInterface
  47. // ------------------------------------------------------------------------------------------------
  48. // ------------------------------------------------------------------------------------------------
  49. RailedTransportContain::RailedTransportContain( Thing *thing, const ModuleData *moduleData )
  50. : TransportContain( thing, moduleData )
  51. {
  52. } // end RailedTransportContain
  53. // ------------------------------------------------------------------------------------------------
  54. // ------------------------------------------------------------------------------------------------
  55. RailedTransportContain::~RailedTransportContain( void )
  56. {
  57. } // end ~RailedTransportContain
  58. // ------------------------------------------------------------------------------------------------
  59. // ------------------------------------------------------------------------------------------------
  60. void RailedTransportContain::onRemoving( Object *obj )
  61. {
  62. // extend functionality
  63. TransportContain::onRemoving( obj );
  64. // once we have removed all our contents we are "open" for docking again for more transportation
  65. if( getContainCount() == 0 )
  66. {
  67. DockUpdateInterface *dui = getObject()->getDockUpdateInterface();
  68. if( dui )
  69. dui->setDockOpen( TRUE );
  70. } // end if
  71. } // end onRemoving
  72. // ------------------------------------------------------------------------------------------------
  73. // ------------------------------------------------------------------------------------------------
  74. Bool RailedTransportContain::isSpecificRiderFreeToExit( Object *obj )
  75. {
  76. Object *us = getObject();
  77. // if we are in transit we cannot exit, when we're in transit, the dock is closed
  78. DockUpdateInterface *dui = us->getDockUpdateInterface();
  79. if( dui && dui->isDockOpen() == FALSE )
  80. return FALSE;
  81. // we can now exit, note we're not extending the base class cause *we* handle it all
  82. return TRUE;
  83. } // end isSpecificRiderFreeToExit
  84. // ------------------------------------------------------------------------------------------------
  85. // ------------------------------------------------------------------------------------------------
  86. void RailedTransportContain::exitObjectViaDoor( Object *newObj, ExitDoorType exitDoor )
  87. {
  88. RailedTransportDockUpdateInterface *rtdui = getRailedTransportDockUpdateInterface();
  89. if( rtdui == NULL )
  90. return;
  91. // tell the railed dock to exit ONE object, this one
  92. rtdui->unloadSingleObject( newObj );
  93. } // end exitObjectViaDoor
  94. // ------------------------------------------------------------------------------------------------
  95. /** CRC */
  96. // ------------------------------------------------------------------------------------------------
  97. void RailedTransportContain::crc( Xfer *xfer )
  98. {
  99. // extend base class
  100. TransportContain::crc( xfer );
  101. } // end crc
  102. // ------------------------------------------------------------------------------------------------
  103. /** Xfer method
  104. * Version Info:
  105. * 1: Initial version */
  106. // ------------------------------------------------------------------------------------------------
  107. void RailedTransportContain::xfer( Xfer *xfer )
  108. {
  109. // version
  110. XferVersion currentVersion = 1;
  111. XferVersion version = currentVersion;
  112. xfer->xferVersion( &version, currentVersion );
  113. // extend base class
  114. TransportContain::xfer( xfer );
  115. } // end xfer
  116. // ------------------------------------------------------------------------------------------------
  117. /** Load post process */
  118. // ------------------------------------------------------------------------------------------------
  119. void RailedTransportContain::loadPostProcess( void )
  120. {
  121. // extend base class
  122. TransportContain::loadPostProcess();
  123. } // end loadPostProcess