CrateCollide.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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: CrateCollide.h /////////////////////////////////////////////////////////////////////////
  24. // Author: Graham Smallwood, March 2002
  25. // Desc: Abstract base Class Crate Collide
  26. ///////////////////////////////////////////////////////////////////////////////////////////////////
  27. #pragma once
  28. #ifndef CRATE_COLLIDE_H_
  29. #define CRATE_COLLIDE_H_
  30. // INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
  31. #include "GameLogic/Module/CollideModule.h"
  32. // FORWARD REFERENCES /////////////////////////////////////////////////////////////////////////////
  33. class Thing;
  34. class Anim2DTemplate;
  35. class FXList;
  36. enum ScienceType;
  37. //-------------------------------------------------------------------------------------------------
  38. class CrateCollideModuleData : public CollideModuleData
  39. {
  40. public:
  41. KindOfMaskType m_kindof; ///< the kind(s) of units that can be collided with
  42. KindOfMaskType m_kindofnot; ///< the kind(s) of units that CANNOT be collided with
  43. Bool m_isForbidOwnerPlayer; ///< This crate cannot be picked up by the player of the dead thing that made it.
  44. Bool m_isBuildingPickup; ///< This crate can be picked up by a Building (bypassing AI requirement)
  45. Bool m_isHumanOnlyPickup; ///< Can this crate only be picked up by a human player? (Mission thing)
  46. ScienceType m_pickupScience; ///< Can only be picked up by a unit whose player has this science
  47. FXList *m_executeFX; ///< FXList to play when activated
  48. AsciiString m_executionAnimationTemplate; ///< Anim2D to play at crate location
  49. Real m_executeAnimationDisplayTimeInSeconds; ///< time to play animation for
  50. Real m_executeAnimationZRisePerSecond; ///< rise animation up while playing
  51. Bool m_executeAnimationFades; ///< animation fades out
  52. CrateCollideModuleData();
  53. static void buildFieldParse(MultiIniFieldParse& p);
  54. };
  55. //-------------------------------------------------------------------------------------------------
  56. class CrateCollide : public CollideModule
  57. {
  58. MEMORY_POOL_GLUE_ABC( CrateCollide )
  59. MAKE_STANDARD_MODULE_MACRO_ABC( CrateCollide )
  60. MAKE_STANDARD_MODULE_DATA_MACRO_ABC( CrateCollide, CrateCollideModuleData )
  61. public:
  62. enum SabotageVictimType
  63. {
  64. SAB_VICTIM_GENERIC = 0,
  65. SAB_VICTIM_COMMAND_CENTER,
  66. SAB_VICTIM_FAKE_BUILDING,
  67. SAB_VICTIM_INTERNET_CENTER,
  68. SAB_VICTIM_MILITARY_FACTORY,
  69. SAB_VICTIM_POWER_PLANT,
  70. SAB_VICTIM_SUPERWEAPON,
  71. SAB_VICTIM_SUPPLY_CENTER,
  72. SAB_VICTIM_DROP_ZONE,
  73. };
  74. CrateCollide( Thing *thing, const ModuleData* moduleData );
  75. // virtual destructor prototype provided by memory pool declaration
  76. /// This collide method gets called when collision occur
  77. virtual void onCollide( Object *other, const Coord3D *loc, const Coord3D *normal );
  78. virtual Bool wouldLikeToCollideWith(const Object* other) const { return isValidToExecute(other); }
  79. virtual Bool isRailroad() const { return FALSE;};
  80. virtual Bool isCarBombCrateCollide() const { return FALSE; }
  81. virtual Bool isHijackedVehicleCrateCollide() const { return FALSE; }
  82. virtual Bool isSabotageBuildingCrateCollide() const { return FALSE; }
  83. void doSabotageFeedbackFX( const Object *other, SabotageVictimType type = SAB_VICTIM_GENERIC );
  84. protected:
  85. /// This is the game logic execution function that all real CrateCollides will implement
  86. virtual Bool executeCrateBehavior( Object *other ) = 0;
  87. /// This allows specific vetoes to certain types of crates and their data
  88. virtual Bool isValidToExecute( const Object *other ) const;
  89. };
  90. #endif