RailedTransportDockUpdate.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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: RailedTransportDockUpdate.h //////////////////////////////////////////////////////////////
  24. // Author: Colin Day, August 2002
  25. // Desc: Railed transport dock update
  26. ///////////////////////////////////////////////////////////////////////////////////////////////////
  27. #ifndef __RAILED_TRANSPORT_DOCK_UPDATE_H_
  28. #define __RAILED_TRANSPORT_DOCK_UPDATE_H_
  29. // INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
  30. #include "GameLogic/Module/DockUpdate.h"
  31. // ------------------------------------------------------------------------------------------------
  32. // ------------------------------------------------------------------------------------------------
  33. class RailedTransportDockUpdateModuleData : public DockUpdateModuleData
  34. {
  35. public:
  36. RailedTransportDockUpdateModuleData( void );
  37. static void buildFieldParse( MultiIniFieldParse &p );
  38. UnsignedInt m_pullInsideDurationInFrames; /**< how long it takes to pull object inside
  39. once they're at the dock action point */
  40. UnsignedInt m_pushOutsideDurationInFrames; /**< how long it takes to push object outside
  41. when we're unloading */
  42. Real m_toleranceDistance; ///< The maximum distance the docking unit must be within in order to cheat and dock.
  43. };
  44. // ------------------------------------------------------------------------------------------------
  45. // ------------------------------------------------------------------------------------------------
  46. class RailedTransportDockUpdateInterface
  47. {
  48. public:
  49. virtual Bool isLoadingOrUnloading( void ) = 0;
  50. virtual void unloadAll( void ) = 0;
  51. virtual void unloadSingleObject( Object *obj ) = 0;
  52. };
  53. // ------------------------------------------------------------------------------------------------
  54. // ------------------------------------------------------------------------------------------------
  55. class RailedTransportDockUpdate : public DockUpdate,
  56. public RailedTransportDockUpdateInterface
  57. {
  58. MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE( RailedTransportDockUpdate, "RailedTransportDockUpdate" )
  59. MAKE_STANDARD_MODULE_MACRO_WITH_MODULE_DATA( RailedTransportDockUpdate, RailedTransportDockUpdateModuleData )
  60. public:
  61. RailedTransportDockUpdate( Thing *thing, const ModuleData *moduleData );
  62. // virtual destructor prototype provided by memory pool declaration
  63. // module interfaces
  64. virtual RailedTransportDockUpdateInterface *getRailedTransportDockUpdateInterface( void ) { return this; }
  65. // update module methods
  66. virtual UpdateSleepTime update( void );
  67. // dock methods
  68. virtual DockUpdateInterface* getDockUpdateInterface() { return this; }
  69. virtual Bool action( Object* docker, Object *drone = NULL );
  70. virtual Bool isClearToEnter( Object const* docker ) const;
  71. // our own methods
  72. virtual Bool isLoadingOrUnloading( void );
  73. virtual void unloadAll( void );
  74. virtual void unloadSingleObject( Object *obj );
  75. protected:
  76. void doPullInDocking( void ); ///< pull docking objects into us
  77. void doPushOutDocking( void ); ///< push unloading objects out of us
  78. void unloadNext( void ); ///< start the "next" object we have inside us coming out
  79. ObjectID m_dockingObjectID; ///< object docking with us
  80. Real m_pullInsideDistancePerFrame; ///< when docking, pull object inside this much each frame
  81. ObjectID m_unloadingObjectID; ///< object that is currently unloading
  82. Real m_pushOutsideDistancePerFrame; ///< when unloading, push object outside this much frame
  83. Int m_unloadCount; ///< count used to govern unloading 1 or all objects
  84. };
  85. #endif // end __RAILED_TRANSPORT_DOCK_UPDATE_H_