POWTruckBehavior.cpp 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. /*
  2. ** Command & Conquer Generals(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: POWTruckBehavior.cpp /////////////////////////////////////////////////////////////////////
  24. // Author: Colin Day
  25. // Desc: POW Truck
  26. ///////////////////////////////////////////////////////////////////////////////////////////////////
  27. // INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
  28. #include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine
  29. #include "Common/ThingTemplate.h"
  30. #include "Common/Xfer.h"
  31. #include "GameClient/InGameUI.h"
  32. #include "GameLogic/Object.h"
  33. #include "GameLogic/Module/AIUpdate.h"
  34. #include "GameLogic/Module/POWTruckAIUpdate.h"
  35. #include "GameLogic/Module/POWTruckBehavior.h"
  36. #ifdef ALLOW_SURRENDER
  37. ///////////////////////////////////////////////////////////////////////////////////////////////////
  38. ///////////////////////////////////////////////////////////////////////////////////////////////////
  39. ///////////////////////////////////////////////////////////////////////////////////////////////////
  40. // ------------------------------------------------------------------------------------------------
  41. // ------------------------------------------------------------------------------------------------
  42. POWTruckBehaviorModuleData::POWTruckBehaviorModuleData( void )
  43. {
  44. } // end POWTruckBehaviorModuleData
  45. // ------------------------------------------------------------------------------------------------
  46. // ------------------------------------------------------------------------------------------------
  47. /*static*/ void POWTruckBehaviorModuleData::buildFieldParse( MultiIniFieldParse &p )
  48. {
  49. OpenContainModuleData::buildFieldParse( p );
  50. static const FieldParse dataFieldParse[] =
  51. {
  52. { 0, 0, 0, 0 }
  53. };
  54. p.add(dataFieldParse);
  55. } // end buildFieldParse
  56. ///////////////////////////////////////////////////////////////////////////////////////////////////
  57. ///////////////////////////////////////////////////////////////////////////////////////////////////
  58. ///////////////////////////////////////////////////////////////////////////////////////////////////
  59. //-------------------------------------------------------------------------------------------------
  60. //-------------------------------------------------------------------------------------------------
  61. POWTruckBehavior::POWTruckBehavior( Thing *thing, const ModuleData *moduleData )
  62. : OpenContain( thing, moduleData )
  63. {
  64. } // end POWTruckBehavior
  65. //-------------------------------------------------------------------------------------------------
  66. //-------------------------------------------------------------------------------------------------
  67. POWTruckBehavior::~POWTruckBehavior( void )
  68. {
  69. } // end ~POWTruckBehavior
  70. // ------------------------------------------------------------------------------------------------
  71. // ------------------------------------------------------------------------------------------------
  72. void POWTruckBehavior::onCollide( Object *other, const Coord3D *loc, const Coord3D *normal )
  73. {
  74. Object *us = getObject();
  75. // sanity
  76. if( other == NULL )
  77. return;
  78. // if other isn't slated to be picked up by us, ignore
  79. AIUpdateInterface *otherAi = other->getAIUpdateInterface();
  80. if( otherAi == NULL || otherAi->isSurrendered() == FALSE )
  81. return;
  82. // get our AI info
  83. AIUpdateInterface *ourAI = us->getAIUpdateInterface();
  84. DEBUG_ASSERTCRASH( ourAI, ("POWTruckBehavior::onCollide - '%s' has no AI\n",
  85. us->getTemplate()->getName().str()) );
  86. POWTruckAIUpdateInterface *powTruckAI = ourAI->getPOWTruckAIUpdateInterface();
  87. DEBUG_ASSERTCRASH( powTruckAI, ("POWTruckBehavior::onCollide - '%s' has no POWTruckAI\n",
  88. us->getTemplate()->getName().str()) );
  89. // pick up the prisoner
  90. powTruckAI->loadPrisoner( other );
  91. } // end onCollide
  92. // ------------------------------------------------------------------------------------------------
  93. /** CRC */
  94. // ------------------------------------------------------------------------------------------------
  95. void POWTruckBehavior::crc( Xfer *xfer )
  96. {
  97. // extend base class
  98. OpenContain::crc( xfer );
  99. } // end crc
  100. // ------------------------------------------------------------------------------------------------
  101. /** Xfer method
  102. * Version Info:
  103. * 1: Initial version */
  104. // ------------------------------------------------------------------------------------------------
  105. void POWTruckBehavior::xfer( Xfer *xfer )
  106. {
  107. // version
  108. XferVersion currentVersion = 1;
  109. XferVersion version = currentVersion;
  110. xfer->xferVersion( &version, currentVersion );
  111. // extend base class
  112. OpenContain::xfer( xfer );
  113. } // end xfer
  114. // ------------------------------------------------------------------------------------------------
  115. /** Load post process */
  116. // ------------------------------------------------------------------------------------------------
  117. void POWTruckBehavior::loadPostProcess( void )
  118. {
  119. // extend base class
  120. OpenContain::loadPostProcess();
  121. } // end loadPostProcess
  122. #endif