ObjectWeaponStatusHelper.h 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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: ObjectWeaponStatusHelper.h ///////////////////////////////////////////////////////////////
  24. // Author: Steven Johnson, Colin Day - September 202
  25. // Desc: Object helpder - WeaponStatus
  26. ///////////////////////////////////////////////////////////////////////////////////////////////////
  27. #pragma once
  28. #ifndef __OBJECT_WEAPON_STATUS_HELPER_H_
  29. #define __OBJECT_WEAPON_STATUS_HELPER_H_
  30. // INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
  31. #include "Common/ThingTemplate.h"
  32. #include "GameLogic/Object.h"
  33. #include "GameLogic/Module/ObjectHelper.h"
  34. // ------------------------------------------------------------------------------------------------
  35. // ------------------------------------------------------------------------------------------------
  36. class ObjectWeaponStatusHelperModuleData : public ModuleData
  37. {
  38. };
  39. // ------------------------------------------------------------------------------------------------
  40. // ------------------------------------------------------------------------------------------------
  41. class ObjectWeaponStatusHelper : public ObjectHelper
  42. {
  43. MAKE_STANDARD_MODULE_MACRO_WITH_MODULE_DATA( ObjectWeaponStatusHelper, ObjectWeaponStatusHelperModuleData )
  44. MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(ObjectWeaponStatusHelper, "ObjectWeaponStatusHelperPool" )
  45. protected:
  46. /*
  47. The ObjectWeaponStatusHelper needs to have its update run after all "normal"
  48. user update modules, so it redefines this. Please don't redefine this
  49. for other modules without very careful deliberation. (srj)
  50. */
  51. virtual SleepyUpdatePhase getUpdatePhase() const
  52. {
  53. return PHASE_FINAL;
  54. }
  55. public:
  56. ObjectWeaponStatusHelper( Thing *thing, const ModuleData *modData ) :
  57. ObjectHelper( thing, modData )
  58. {
  59. // unlike other helpers, this one needs to start active.
  60. DEBUG_ASSERTCRASH(getObject()->getTemplate()->canPossiblyHaveAnyWeapon(), ("should not be instantiated if we have no weapon"));
  61. setWakeFrame(getObject(), UPDATE_SLEEP_NONE);
  62. }
  63. // virtual destructor prototype provided by memory pool object
  64. virtual UpdateSleepTime update()
  65. {
  66. getObject()->adjustModelConditionForWeaponStatus();
  67. // unlike other helpers, this one must run every frame.
  68. return UPDATE_SLEEP_NONE;
  69. }
  70. };
  71. #endif // end __OBJECT_DEFECTION_HELPER_H_