physicalgameobj.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  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/physicalgameobj.h $*
  25. * *
  26. * $Author:: Greg_h $*
  27. * *
  28. * $Modtime:: 1/08/02 6:39p $*
  29. * *
  30. * $Revision:: 126 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #ifndef PHYSICALGAMEOBJ_H
  36. #define PHYSICALGAMEOBJ_H
  37. #ifndef ALWAYS_H
  38. #include "always.h"
  39. #endif
  40. #ifndef DAMAGEABLEGAMEOBJ_H
  41. #include "damageablegameobj.h"
  42. #endif
  43. #ifndef COMBATPHYSOBSERVER_H
  44. #include "combatphysobserver.h"
  45. #endif
  46. #ifndef WWPACKET_H
  47. #include "wwpacket.h"
  48. #endif
  49. #ifndef PHYS_H
  50. #include "phys.h"
  51. #endif
  52. /*
  53. **
  54. */
  55. class SoldierGameObj;
  56. class VehicleGameObj;
  57. class PowerUpGameObj;
  58. class ArmedGameObj;
  59. class C4GameObj;
  60. class BeaconGameObj;
  61. class AnimControlClass;
  62. class CinematicGameObj;
  63. class SimpleGameObj;
  64. class ActiveConversationClass;
  65. /*
  66. ** PhysicalGameObjDef - Defintion class for a PhysicalGameObj
  67. */
  68. class PhysicalGameObjDef : public DamageableGameObjDef
  69. {
  70. public:
  71. PhysicalGameObjDef( void );
  72. virtual bool Save( ChunkSaveClass &csave );
  73. virtual bool Load( ChunkLoadClass &cload );
  74. virtual bool Is_Valid_Config (StringClass &message);
  75. int Get_Phys_Def_ID( void ) const { return PhysDefID; }
  76. int Get_Orator_Type( void ) const { return OratorType; }
  77. DECLARE_EDITABLE( PhysicalGameObjDef, DamageableGameObjDef );
  78. protected:
  79. int Type;
  80. int RadarBlipType;
  81. float BullseyeOffsetZ;
  82. StringClass Animation;
  83. int PhysDefID;
  84. int KilledExplosion;
  85. bool DefaultHibernationEnable;
  86. bool AllowInnateConversations;
  87. int OratorType;
  88. bool UseCreationEffect;
  89. friend class PhysicalGameObj;
  90. };
  91. /*
  92. **
  93. */
  94. class PhysicalGameObj : public DamageableGameObj, public CombatPhysObserverClass {
  95. public:
  96. // Constructor and Destructor
  97. PhysicalGameObj( void );
  98. virtual ~PhysicalGameObj( void );
  99. // Definitions
  100. void Init( const PhysicalGameObjDef & definition );
  101. void Copy_Settings( const PhysicalGameObjDef & definition );
  102. void Re_Init( const PhysicalGameObjDef & definition );
  103. const PhysicalGameObjDef & Get_Definition( void ) const ;
  104. // Save / Load
  105. virtual bool Save( ChunkSaveClass & csave );
  106. virtual bool Load( ChunkLoadClass & cload );
  107. virtual void On_Post_Load(void);
  108. virtual void Startup( void ) {}
  109. // Physics
  110. WWINLINE PhysClass * Peek_Physical_Object( void ) const { return PhysObj; }
  111. void Attach_To_Object_Bone( PhysicalGameObj * host, const char * bone_name );
  112. bool Is_Attached_To_An_Object( void ) { return (HostGameObj.Get_Ptr () != NULL); }
  113. void Teleport_To_Host_Bone( void );
  114. void Set_Transform(const Matrix3D & tm);
  115. const Matrix3D & Get_Transform(void) const;
  116. virtual void Get_Position(Vector3 * set_pos) const;
  117. void Set_Position(const Vector3 & pos);
  118. float Get_Facing(void) const;
  119. // Display
  120. WWINLINE RenderObjClass * Peek_Model( void ) { return Peek_Physical_Object()->Peek_Model(); }
  121. AnimControlClass* Get_Anim_Control( void );
  122. void Set_Anim_Control( AnimControlClass * anim_control );
  123. // Note: Set_Animation calls will force an AnimControl to be created, if needed
  124. virtual void Set_Animation( const char *animation_name, bool looping = true, float frame_offset = 0.0f );
  125. virtual void Set_Animation_Frame ( const char *animation_name, int frame );
  126. // Targeting
  127. float Get_Bullseye_Offset_Z( void ) const { return Get_Definition().BullseyeOffsetZ; }
  128. virtual Vector3 Get_Bullseye_Position( void );
  129. virtual void Get_Information( StringClass & string );
  130. // Damage
  131. virtual void Apply_Damage( const OffenseObjectClass & damager, float scale = 1.0f, int alternate_skin = -1 );
  132. virtual void Apply_Damage_Extended( const OffenseObjectClass & offense, float scale = 1.0f,
  133. const Vector3 & direction = Vector3( 0,0,0 ), const char * collision_box_name = NULL );
  134. virtual void Completely_Damaged( const OffenseObjectClass & damager );
  135. bool Is_Soft( void );
  136. virtual bool Takes_Explosion_Damage( void ) { return true; }
  137. // Game Object Type
  138. int Get_Type() const { return Get_Definition().Type; }
  139. // Thinking
  140. virtual void Post_Think();
  141. // Collision
  142. void Set_Collision_Group( int group );
  143. virtual ExpirationReactionType Object_Expired( PhysClass * observed_obj ) { Set_Delete_Pending(); return EXPIRATION_APPROVED; }
  144. // Type identification
  145. virtual PhysicalGameObj *As_PhysicalGameObj( void ) { return this; }
  146. virtual DamageableGameObj *As_DamageableGameObj( void ) { return this; } // Re-implement for CombatPhysObserverClass
  147. virtual SoldierGameObj *As_SoldierGameObj( void ) { return (SoldierGameObj *)NULL; }
  148. virtual PowerUpGameObj *As_PowerUpGameObj( void ) { return (PowerUpGameObj *)NULL; }
  149. virtual VehicleGameObj *As_VehicleGameObj( void ) { return (VehicleGameObj *)NULL; }
  150. virtual C4GameObj *As_C4GameObj( void ) { return (C4GameObj *)NULL; }
  151. virtual BeaconGameObj *As_BeaconGameObj (void) { return (BeaconGameObj *)NULL; }
  152. virtual ArmedGameObj *As_ArmedGameObj( void ) { return (ArmedGameObj *)NULL; }
  153. virtual CinematicGameObj *As_CinematicGameObj( void ) { return NULL; }
  154. virtual SimpleGameObj *As_SimpleGameObj( void ) { return NULL; }
  155. // Network diagnostics
  156. BYTE Get_Server_Skips(void) {return ServerUpdateSkips;}
  157. void Reset_Server_Skips(BYTE value);
  158. void Increment_Server_Skips(void);
  159. /*
  160. // Color Tinting
  161. void Set_Tint(Vector3 color);
  162. const Vector3 & Get_Tint(void) {return TintColor;}
  163. */
  164. // Hibernation
  165. virtual bool Is_Hibernating( void ) { return HibernationTimer <= 0; }
  166. void Enable_Hibernation( bool enable ) { HibernationEnable = enable; if ( Is_Hibernating() ) HibernationTimer = 1;}
  167. void Reset_Hibernating( void );
  168. void Do_Not_Hibernate( void ) { if ( HibernationTimer < 1 ) HibernationTimer = 1; }
  169. virtual void Begin_Hibernation( void );
  170. virtual void End_Hibernation( void );
  171. // Radar Blips
  172. int Get_Radar_Blip_Shape_Type( void ) { return RadarBlipShapeType; }
  173. void Set_Radar_Blip_Shape_Type( int type ) { RadarBlipShapeType = type; }
  174. void Reset_Radar_Blip_Shape_Type( void ) { RadarBlipShapeType = Get_Definition().RadarBlipType; }
  175. int Get_Radar_Blip_Color_Type( void ) { return RadarBlipColorType; }
  176. void Set_Radar_Blip_Color_Type( int type ) { RadarBlipColorType = type; }
  177. void Reset_Radar_Blip_Color_Type( void );
  178. float Get_Radar_Blip_Intensity( void ) { return RadarBlipIntensity; }
  179. void Set_Radar_Blip_Intensity( float value ) { RadarBlipIntensity = value; }
  180. // Network support
  181. virtual void Export_Creation( BitStreamClass &packet );
  182. virtual void Import_Creation( BitStreamClass &packet );
  183. virtual void Export_Rare( BitStreamClass &packet );
  184. virtual void Import_Rare( BitStreamClass &packet );
  185. virtual void Export_Frequent( BitStreamClass &packet );
  186. virtual void Import_Frequent( BitStreamClass &packet );
  187. virtual int Get_Vis_ID(void);
  188. virtual bool Get_World_Position (Vector3 &pos) const { Get_Position (&pos); return true; }
  189. //
  190. // Conversation support
  191. //
  192. bool Are_Innate_Conversations_Enabled( void ) { return Get_Definition().AllowInnateConversations && IsInnateConversationsEnabled; }
  193. void Enable_Innate_Conversations( bool enable ) { IsInnateConversationsEnabled = enable; }
  194. bool Is_In_Conversation( void ) const { return ActiveConversation != NULL; }
  195. void Set_Conversation( ActiveConversationClass *conversation );
  196. void Hide_Muzzle_Flashes( bool hide = true );
  197. void Enable_HUD_Pokable_Indicator( bool enable );
  198. bool Is_HUD_Pokable_Indicator_Enabled( void ) { return HUDPokableIndicatorEnabled; }
  199. virtual void Set_Player_Type(int type);
  200. //
  201. // Phys Observer support
  202. //
  203. virtual void Object_Shattered_Something(PhysClass * observed_obj, PhysClass * shattered_obj, int surface_type);
  204. protected:
  205. //
  206. // Conversation stuff
  207. //
  208. ActiveConversationClass *ActiveConversation;
  209. private:
  210. PhysClass * PhysObj;
  211. AnimControlClass * AnimControl;
  212. //
  213. // Networking bandwidth stuff
  214. //
  215. BYTE ServerUpdateSkips;
  216. //Vector3 TintColor;
  217. float HibernationTimer;
  218. bool HibernationEnable;
  219. GameObjReference HostGameObj;
  220. int HostGameObjBone;
  221. // Radar Blips
  222. int RadarBlipShapeType;
  223. int RadarBlipColorType;
  224. float RadarBlipIntensity;
  225. // Pending Host Obj
  226. int PendingHostObjID;
  227. bool HUDPokableIndicatorEnabled;
  228. bool IsInnateConversationsEnabled;
  229. };
  230. #endif // PHYSICALGAMEOBJ_H