W3DOverlordTruckDraw.cpp 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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. // FIEL: W3DOverlordTruckDraw.cpp ////////////////////////////////////////////////////////////////////////////
  24. // Author: Graham Smallwood, October 2002
  25. // Desc: The Overlord has a super specific special need. He needs his rider to draw explicitly after him,
  26. // and he needs direct access to get that rider when everyone else can't see it because of the OverlordContain.
  27. ///////////////////////////////////////////////////////////////////////////////////////////////////
  28. // INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
  29. #include "Common/Xfer.h"
  30. #include "GameClient/Drawable.h"
  31. #include "GameLogic/Object.h"
  32. #include "GameLogic/Module/ContainModule.h"
  33. #include "W3DDevice/GameClient/Module/W3DOverlordTruckDraw.h"
  34. //-------------------------------------------------------------------------------------------------
  35. W3DOverlordTruckDrawModuleData::W3DOverlordTruckDrawModuleData()
  36. {
  37. }
  38. //-------------------------------------------------------------------------------------------------
  39. W3DOverlordTruckDrawModuleData::~W3DOverlordTruckDrawModuleData()
  40. {
  41. }
  42. //-------------------------------------------------------------------------------------------------
  43. void W3DOverlordTruckDrawModuleData::buildFieldParse(MultiIniFieldParse& p)
  44. {
  45. W3DTruckDrawModuleData::buildFieldParse(p);
  46. static const FieldParse dataFieldParse[] =
  47. {
  48. { 0, 0, 0, 0 }
  49. };
  50. p.add(dataFieldParse);
  51. }
  52. //-------------------------------------------------------------------------------------------------
  53. //-------------------------------------------------------------------------------------------------
  54. W3DOverlordTruckDraw::W3DOverlordTruckDraw( Thing *thing, const ModuleData* moduleData )
  55. : W3DTruckDraw( thing, moduleData )
  56. {
  57. }
  58. //-------------------------------------------------------------------------------------------------
  59. //-------------------------------------------------------------------------------------------------
  60. W3DOverlordTruckDraw::~W3DOverlordTruckDraw()
  61. {
  62. }
  63. //-------------------------------------------------------------------------------------------------
  64. void W3DOverlordTruckDraw::doDrawModule(const Matrix3D* transformMtx)
  65. {
  66. W3DTruckDraw::doDrawModule(transformMtx);
  67. // Our big thing is that we get our specific passenger (the turret thing) and then wake it up and make it draw
  68. // It depends on us because our renderObject is only made correct in the act of drawing.
  69. Object *me = getDrawable()->getObject();
  70. if( me
  71. && me->getContain()
  72. && me->getContain()->friend_getRider()
  73. && me->getContain()->friend_getRider()->getDrawable()
  74. )
  75. {
  76. Drawable *riderDraw = me->getContain()->friend_getRider()->getDrawable();
  77. riderDraw->setColorTintEnvelope( *getDrawable()->getColorTintEnvelope() );
  78. riderDraw->notifyDrawableDependencyCleared();
  79. riderDraw->draw( NULL );// What the hell? This param isn't used for anything
  80. }
  81. }
  82. //-------------------------------------------------------------------------------------------------
  83. void W3DOverlordTruckDraw::setHidden(Bool h)
  84. {
  85. W3DTruckDraw::setHidden(h);
  86. // We need to hide our rider, since he won't realize he's being contained in a contained container
  87. Object *me = getDrawable()->getObject();
  88. if( me
  89. && me->getContain()
  90. && me->getContain()->friend_getRider()
  91. && me->getContain()->friend_getRider()->getDrawable()
  92. )
  93. {
  94. me->getContain()->friend_getRider()->getDrawable()->setDrawableHidden(h);
  95. }
  96. }
  97. //-------------------------------------------------------------------------------------------------
  98. // ------------------------------------------------------------------------------------------------
  99. /** CRC */
  100. // ------------------------------------------------------------------------------------------------
  101. void W3DOverlordTruckDraw::crc( Xfer *xfer )
  102. {
  103. // extend base class
  104. W3DTruckDraw::crc( xfer );
  105. } // end crc
  106. // ------------------------------------------------------------------------------------------------
  107. /** Xfer method
  108. * Version Info:
  109. * 1: Initial version */
  110. // ------------------------------------------------------------------------------------------------
  111. void W3DOverlordTruckDraw::xfer( Xfer *xfer )
  112. {
  113. // version
  114. XferVersion currentVersion = 1;
  115. XferVersion version = currentVersion;
  116. xfer->xferVersion( &version, currentVersion );
  117. // extend base class
  118. W3DTruckDraw::xfer( xfer );
  119. } // end xfer
  120. // ------------------------------------------------------------------------------------------------
  121. /** Load post process */
  122. // ------------------------------------------------------------------------------------------------
  123. void W3DOverlordTruckDraw::loadPostProcess( void )
  124. {
  125. // extend base class
  126. W3DTruckDraw::loadPostProcess();
  127. } // end loadPostProcess