damageablegameobj.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /*
  2. ** Command & Conquer Renegade(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. *** Confidential - Westwood Studios ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : Commando *
  23. * *
  24. * $Archive:: /Commando/Code/Combat/damageablegameobj.h $*
  25. * *
  26. * $Author:: Greg_h $*
  27. * *
  28. * $Modtime:: 2/19/02 1:45p $*
  29. * *
  30. * $Revision:: 21 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #if defined(_MSC_VER)
  36. #pragma once
  37. #endif
  38. #ifndef DAMAGEABLEGAMEOBJ_H
  39. #define DAMAGEABLEGAMEOBJ_H
  40. #include "always.h"
  41. #include "scriptablegameobj.h"
  42. #include "damage.h"
  43. #include "encyclopediamgr.h"
  44. /*
  45. ** DamageableGameObjDef - Defintion class for a DamageableGameObj
  46. */
  47. class DamageableGameObjDef : public ScriptableGameObjDef
  48. {
  49. public:
  50. DamageableGameObjDef( void );
  51. virtual bool Save( ChunkSaveClass &csave );
  52. virtual bool Load( ChunkLoadClass &cload );
  53. DECLARE_EDITABLE( DamageableGameObjDef, ScriptableGameObjDef );
  54. int Get_Name_ID (void) const { return TranslatedNameID; }
  55. //
  56. // Encyclopedia information
  57. //
  58. EncyclopediaMgrClass::TYPE Get_Encyclopedia_Type (void) const { return EncyclopediaType; }
  59. int Get_Encyclopedia_ID (void) const { return EncyclopediaID; }
  60. //
  61. // Icon information
  62. //
  63. const StringClass & Get_Icon_Filename (void) const { return InfoIconTextureFilename; }
  64. int Get_Translated_Name_ID (void) const { return TranslatedNameID; }
  65. const DefenseObjectDefClass & Get_DefenseObjectDef( void ) const { return DefenseObjectDef; }
  66. //
  67. // Accessors (added as needed)
  68. //
  69. int Get_Default_Player_Type(void) const { return DefaultPlayerType; }
  70. protected:
  71. DefenseObjectDefClass DefenseObjectDef;
  72. StringClass InfoIconTextureFilename;
  73. int TranslatedNameID;
  74. EncyclopediaMgrClass::TYPE EncyclopediaType;
  75. int EncyclopediaID;
  76. bool NotTargetable;
  77. int DefaultPlayerType;
  78. friend class DamageableGameObj;
  79. };
  80. /*
  81. **
  82. */
  83. class DamageableGameObj : public ScriptableGameObj
  84. {
  85. public:
  86. // Constructor and Destructor
  87. DamageableGameObj( void );
  88. virtual ~DamageableGameObj( void );
  89. // Definitions
  90. void Init( const DamageableGameObjDef & definition );
  91. void Copy_Settings( const DamageableGameObjDef & definition );
  92. void Re_Init( const DamageableGameObjDef & definition );
  93. const DamageableGameObjDef & Get_Definition( void ) const ;
  94. // Save / Load
  95. virtual bool Save( ChunkSaveClass & csave );
  96. virtual bool Load( ChunkLoadClass & cload );
  97. DefenseObjectClass * Get_Defense_Object( void ) { return &DefenseObject; }
  98. virtual void Apply_Damage( const OffenseObjectClass & damager, float scale = 1.0f, int alternate_skin = -1 );
  99. virtual void Completely_Damaged( const OffenseObjectClass & damager ) {};
  100. // Information settings
  101. const StringClass & Get_Info_Icon_Texture_Filename( void ) { return Get_Definition().InfoIconTextureFilename; }
  102. int Get_Translated_Name_ID( void ) const { return Get_Definition().TranslatedNameID; }
  103. virtual bool Is_Targetable( void ) const { return !Get_Definition().NotTargetable; }
  104. virtual bool Is_Health_Bar_Displayed( void ) const { return IsHealthBarDisplayed; }
  105. virtual void Set_Is_Health_Bar_Displayed( bool state ) { IsHealthBarDisplayed = state; }
  106. // Type identification
  107. virtual DamageableGameObj *As_DamageableGameObj( void ) { return this; }
  108. // Teams / Playertypes
  109. virtual int Get_Player_Type(void) const {return PlayerType;}
  110. virtual void Set_Player_Type(int type);
  111. bool Is_Team_Player(void);
  112. Vector3 Get_Team_Color(void);
  113. bool Is_Teammate(DamageableGameObj * p_obj);
  114. bool Is_Enemy(DamageableGameObj * p_obj);
  115. //
  116. // Network support
  117. //
  118. virtual void Import_Occasional( BitStreamClass &packet );
  119. virtual void Export_Occasional( BitStreamClass &packet );
  120. protected:
  121. DefenseObjectClass DefenseObject;
  122. int PlayerType;
  123. bool IsHealthBarDisplayed;
  124. };
  125. #endif // DAMAGEABLEGAMEOBJ_H