WaveGuideUpdate.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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: WaveGuideUpdate.h ////////////////////////////////////////////////////////////////////////
  24. // Author: Colin Day, April 2002
  25. // Desc: Update module for the waver wave objects to create flooding
  26. ///////////////////////////////////////////////////////////////////////////////////////////////////
  27. #pragma once
  28. #ifndef __WATERWAVE_H_
  29. #define __WATERWAVE_H_
  30. // INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
  31. #include "GameLogic/Module/UpdateModule.h"
  32. // FORWARD REFERENCES /////////////////////////////////////////////////////////////////////////////
  33. struct FieldParse;
  34. // ------------------------------------------------------------------------------------------------
  35. // ------------------------------------------------------------------------------------------------
  36. class WaveGuideUpdateModuleData : public UpdateModuleData
  37. {
  38. public:
  39. WaveGuideUpdateModuleData( void );
  40. static void buildFieldParse(MultiIniFieldParse& p);
  41. Real m_waveDelay; ///< delay in frames to start the wave from when we become enabled
  42. Real m_ySize; ///< size of object in Y
  43. Real m_linearWaveSpacing; ///< linear waves get created at this resolution across the object
  44. Real m_waveBendMagnitude; ///< for curved waveshape, larger # = more straight
  45. Real m_waterVelocity; ///< (in distance per frame)this amount of force is applied to the water
  46. Real m_preferredHeight; ///< this is our preferred water height after the wave passes
  47. Real m_shorelineEffectDistance; ///< this far behind the wave we "hit" the shore
  48. Real m_damageRadius; ///< damage distance from sample points to do damage
  49. Real m_damageAmount; ///< amount of damage to do
  50. Real m_toppleForce; ///< force strength we topple things with
  51. AudioEventRTS m_randomSplashSound; ///< random splash sound to play sometimes during the wave
  52. Int m_randomSplashSoundFrequency; ///< number from 1-100 that must be above to play
  53. const ParticleSystemTemplate *m_bridgeParticle; ///< particle system to play when the wave hits a bridge
  54. Real m_bridgeParticleAngleFudge; ///< angle to offset the bridge particle system
  55. AudioEventRTS m_loopingSound; ///< Sound that plays once wave guide is triggered.
  56. };
  57. // ------------------------------------------------------------------------------------------------
  58. // ------------------------------------------------------------------------------------------------
  59. class WaveGuideUpdate : public UpdateModule
  60. {
  61. MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE( WaveGuideUpdate, "WaveGuideUpdate" )
  62. MAKE_STANDARD_MODULE_MACRO_WITH_MODULE_DATA( WaveGuideUpdate, WaveGuideUpdateModuleData )
  63. public:
  64. WaveGuideUpdate( Thing *thing, const ModuleData *moduleData );
  65. // virtual destructor prototype provided by MemoryPoolObject
  66. virtual UpdateSleepTime update( void ); ///< the update implementation
  67. protected:
  68. Bool initWaveGuide( void ); ///< initialize the waveguide on motion start
  69. Bool startMoving( void ); ///< start the waveguide moving
  70. void computeWaveShapePoints( void ); ///< compute the wave shape points
  71. void transformWaveShape( void ); ///< build an array we can re-use of the wave shape points
  72. void doShapeEffects( void ); ///< maintenance for the wave shape effects
  73. void doWaterMotion( void ); ///< do the push up water motion
  74. void doShoreEffects( void ); ///< do any effects on the shorelines
  75. void doDamage( void ); ///< do damage to things that have crossed our path
  76. UnsignedInt m_activeFrame; ///< frame we became active on
  77. Bool m_needDisable;
  78. Bool m_initialized; ///< set to TRUE after we're enabled and in motion
  79. enum { MAX_WAVEGUIDE_SHAPE_POINTS = 64 };
  80. Coord3D m_shapePoints[ MAX_WAVEGUIDE_SHAPE_POINTS ]; ///< array that will be our "shape" of sample points to affect the water
  81. Coord3D m_transformedShapePoints[ MAX_WAVEGUIDE_SHAPE_POINTS ]; ///< m_shapePoints transformed into current world coords
  82. enum { MAX_SHAPE_EFFECTS = 3 };
  83. ParticleSystemID m_shapeEffects[ MAX_WAVEGUIDE_SHAPE_POINTS ][ MAX_SHAPE_EFFECTS ]; ///< particle effects on the wavefront
  84. Int m_shapePointCount; ///< number of points in m_shape
  85. UnsignedInt m_splashSoundFrame; ///< frame we last tried to play a splash sound on
  86. Coord3D m_finalDestination; ///< the final destination of the waveguide path
  87. };
  88. #endif // end __WATERWAVE_H_