StickyBombUpdate.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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: StickyBombUpdate.h ////////////////////////////////////////////////////////////////////////
  24. // Author: Kris Morness, July 2002
  25. // Desc: Similar to ParachuteContain, this module is used essentially to attach a bomb to an object
  26. // moving around. The sticky bomb position simply updates to the specified bone until it explodes.
  27. ///////////////////////////////////////////////////////////////////////////////////////////////////
  28. #pragma once
  29. #ifndef __STICK_BOMB_UPDATE_H
  30. #define __STICK_BOMB_UPDATE_H
  31. #include "GameLogic/Module/UpdateModule.h"
  32. class WeaponTemplate;
  33. class FXList;
  34. //-------------------------------------------------------------------------------------------------
  35. class StickyBombUpdateModuleData : public UpdateModuleData
  36. {
  37. public:
  38. AsciiString m_attachToBone;
  39. Real m_offsetZ;
  40. WeaponTemplate* m_geometryBasedDamageWeaponTemplate;
  41. FXList* m_geometryBasedDamageFX;
  42. StickyBombUpdateModuleData()
  43. {
  44. m_offsetZ = 10.0f;
  45. m_geometryBasedDamageWeaponTemplate = NULL;
  46. m_geometryBasedDamageFX = NULL;
  47. }
  48. static void buildFieldParse(MultiIniFieldParse& p)
  49. {
  50. UpdateModuleData::buildFieldParse(p);
  51. static const FieldParse dataFieldParse[] =
  52. {
  53. { "AttachToTargetBone", INI::parseAsciiString, NULL, offsetof( StickyBombUpdateModuleData, m_attachToBone ) },
  54. { "OffsetZ", INI::parseReal, NULL, offsetof( StickyBombUpdateModuleData, m_offsetZ ) },
  55. { "GeometryBasedDamageWeapon",INI::parseWeaponTemplate, NULL, offsetof( StickyBombUpdateModuleData, m_geometryBasedDamageWeaponTemplate ) },
  56. { "GeometryBasedDamageFX", INI::parseFXList, NULL, offsetof( StickyBombUpdateModuleData, m_geometryBasedDamageFX ) },
  57. { 0, 0, 0, 0 }
  58. };
  59. p.add(dataFieldParse);
  60. }
  61. };
  62. //-------------------------------------------------------------------------------------------------
  63. class StickyBombUpdate : public UpdateModule
  64. {
  65. MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE( StickyBombUpdate, "StickyBombUpdate" )
  66. MAKE_STANDARD_MODULE_MACRO_WITH_MODULE_DATA( StickyBombUpdate, StickyBombUpdateModuleData )
  67. public:
  68. StickyBombUpdate( Thing *thing, const ModuleData* moduleData );
  69. // virtual destructor prototype provided by memory pool declaration
  70. virtual void onObjectCreated();
  71. virtual UpdateSleepTime update(); ///< called once per frame
  72. void initStickyBomb( Object *object, const Object *bomber, const Coord3D *specificPos = NULL );
  73. void detonate();
  74. Bool isTimedBomb() const { return m_dieFrame > 0; }
  75. UnsignedInt getDetonationFrame() const { return m_dieFrame; }
  76. Object* getTargetObject() const;
  77. void setTargetObject( Object *obj );
  78. private:
  79. ObjectID m_targetID;
  80. UnsignedInt m_dieFrame;
  81. UnsignedInt m_nextPingFrame;
  82. };
  83. #endif // __STICK_BOMB_UPDATE_H