CollideModule.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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: CollideModule.h /////////////////////////////////////////////////////////////////////////////////
  24. // Author: Colin Day, September 2001
  25. // Desc:
  26. ///////////////////////////////////////////////////////////////////////////////////////////////////
  27. #pragma once
  28. #ifndef __CollideModule_H_
  29. #define __CollideModule_H_
  30. #include "Common/Module.h"
  31. #include "GameLogic/Module/BehaviorModule.h"
  32. //-------------------------------------------------------------------------------------------------
  33. /** OBJECT COLLIDE MODULE
  34. - Called when two objects collide (or when object collides with ground)
  35. - Note in the 'collide' method that 'other' can be NULL, this indicates a
  36. collision with the ground
  37. - Also note the 'collide' method is the response for the object that THIS module
  38. belongs to, we do not need to worry about the collision moudle of 'other',
  39. it will have its own collide action called separately */
  40. //-------------------------------------------------------------------------------------------------
  41. class CollideModuleInterface
  42. {
  43. public:
  44. virtual void onCollide( Object *other, const Coord3D *loc, const Coord3D *normal ) = 0;
  45. virtual Bool wouldLikeToCollideWith(const Object* other) const = 0;
  46. virtual Bool isHijackedVehicleCrateCollide() const = 0;
  47. virtual Bool isSabotageBuildingCrateCollide() const = 0;
  48. virtual Bool isCarBombCrateCollide() const = 0;
  49. virtual Bool isRailroad() const = 0;
  50. virtual Bool isSalvageCrateCollide() const = 0;
  51. };
  52. //-------------------------------------------------------------------------------------------------
  53. class CollideModuleData : public BehaviorModuleData
  54. {
  55. public:
  56. static void buildFieldParse(MultiIniFieldParse& p)
  57. {
  58. BehaviorModuleData::buildFieldParse(p);
  59. }
  60. };
  61. //-------------------------------------------------------------------------------------------------
  62. class CollideModule : public BehaviorModule,
  63. public CollideModuleInterface
  64. {
  65. MEMORY_POOL_GLUE_ABC( CollideModule )
  66. MAKE_STANDARD_MODULE_MACRO_ABC( CollideModule )
  67. MAKE_STANDARD_MODULE_DATA_MACRO_ABC(CollideModule, CollideModuleData)
  68. public:
  69. CollideModule( Thing *thing, const ModuleData* moduleData );
  70. // virtual destructor prototype defined by MemoryPoolObject
  71. static Int getInterfaceMask() { return MODULEINTERFACE_COLLIDE; }
  72. // BehaviorModule
  73. virtual CollideModuleInterface* getCollide() { return this; }
  74. virtual void onCollide( Object *other, const Coord3D *loc, const Coord3D *normal ) = 0;
  75. /// this is used for things like pilots, to determine if they can "enter" something
  76. virtual Bool wouldLikeToCollideWith(const Object* other) const { return false; }
  77. virtual Bool isHijackedVehicleCrateCollide() const { return false; }
  78. virtual Bool isSabotageBuildingCrateCollide() const { return false; }
  79. virtual Bool isCarBombCrateCollide() const { return false; }
  80. virtual Bool isRailroad() const { return false;}
  81. virtual Bool isSalvageCrateCollide() const { return false; }
  82. };
  83. inline CollideModule::CollideModule( Thing *thing, const ModuleData* moduleData ) : BehaviorModule( thing, moduleData ) { }
  84. inline CollideModule::~CollideModule() { }
  85. //-------------------------------------------------------------------------------------------------
  86. #endif