Item.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. /*
  2. ===========================================================================
  3. Doom 3 GPL Source Code
  4. Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
  5. This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
  6. Doom 3 Source Code is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. Doom 3 Source Code 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. You should have received a copy of the GNU General Public License
  15. along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
  16. In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
  17. If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
  18. ===========================================================================
  19. */
  20. #ifndef __GAME_ITEM_H__
  21. #define __GAME_ITEM_H__
  22. /*
  23. ===============================================================================
  24. Items the player can pick up or use.
  25. ===============================================================================
  26. */
  27. class idItem : public idEntity {
  28. public:
  29. CLASS_PROTOTYPE( idItem );
  30. idItem();
  31. virtual ~idItem();
  32. void Save( idSaveGame *savefile ) const;
  33. void Restore( idRestoreGame *savefile );
  34. void Spawn( void );
  35. void GetAttributes( idDict &attributes );
  36. virtual bool GiveToPlayer( idPlayer *player );
  37. virtual bool Pickup( idPlayer *player );
  38. virtual void Think( void );
  39. virtual void Present();
  40. enum {
  41. EVENT_PICKUP = idEntity::EVENT_MAXEVENTS,
  42. EVENT_RESPAWN,
  43. EVENT_RESPAWNFX,
  44. EVENT_MAXEVENTS
  45. };
  46. virtual void ClientPredictionThink( void );
  47. virtual bool ClientReceiveEvent( int event, int time, const idBitMsg &msg );
  48. // networking
  49. virtual void WriteToSnapshot( idBitMsgDelta &msg ) const;
  50. virtual void ReadFromSnapshot( const idBitMsgDelta &msg );
  51. private:
  52. idVec3 orgOrigin;
  53. bool spin;
  54. bool pulse;
  55. bool canPickUp;
  56. // for item pulse effect
  57. int itemShellHandle;
  58. const idMaterial * shellMaterial;
  59. // used to update the item pulse effect
  60. mutable bool inView;
  61. mutable int inViewTime;
  62. mutable int lastCycle;
  63. mutable int lastRenderViewTime;
  64. bool UpdateRenderEntity( renderEntity_s *renderEntity, const renderView_t *renderView ) const;
  65. static bool ModelCallback( renderEntity_s *renderEntity, const renderView_t *renderView );
  66. void Event_DropToFloor( void );
  67. void Event_Touch( idEntity *other, trace_t *trace );
  68. void Event_Trigger( idEntity *activator );
  69. void Event_Respawn( void );
  70. void Event_RespawnFx( void );
  71. };
  72. class idItemPowerup : public idItem {
  73. public:
  74. CLASS_PROTOTYPE( idItemPowerup );
  75. idItemPowerup();
  76. void Save( idSaveGame *savefile ) const;
  77. void Restore( idRestoreGame *savefile );
  78. void Spawn();
  79. virtual bool GiveToPlayer( idPlayer *player );
  80. private:
  81. int time;
  82. int type;
  83. };
  84. class idObjective : public idItem {
  85. public:
  86. CLASS_PROTOTYPE( idObjective );
  87. idObjective();
  88. void Save( idSaveGame *savefile ) const;
  89. void Restore( idRestoreGame *savefile );
  90. void Spawn();
  91. private:
  92. idVec3 playerPos;
  93. void Event_Trigger( idEntity *activator );
  94. void Event_HideObjective( idEntity *e );
  95. void Event_GetPlayerPos();
  96. void Event_CamShot();
  97. };
  98. class idVideoCDItem : public idItem {
  99. public:
  100. CLASS_PROTOTYPE( idVideoCDItem );
  101. void Spawn();
  102. virtual bool GiveToPlayer( idPlayer *player );
  103. };
  104. class idPDAItem : public idItem {
  105. public:
  106. CLASS_PROTOTYPE( idPDAItem );
  107. virtual bool GiveToPlayer( idPlayer *player );
  108. };
  109. class idMoveableItem : public idItem {
  110. public:
  111. CLASS_PROTOTYPE( idMoveableItem );
  112. idMoveableItem();
  113. virtual ~idMoveableItem();
  114. void Save( idSaveGame *savefile ) const;
  115. void Restore( idRestoreGame *savefile );
  116. void Spawn( void );
  117. virtual void Think( void );
  118. virtual bool Pickup( idPlayer *player );
  119. static void DropItems( idAnimatedEntity *ent, const char *type, idList<idEntity *> *list );
  120. static idEntity * DropItem( const char *classname, const idVec3 &origin, const idMat3 &axis, const idVec3 &velocity, int activateDelay, int removeDelay );
  121. virtual void WriteToSnapshot( idBitMsgDelta &msg ) const;
  122. virtual void ReadFromSnapshot( const idBitMsgDelta &msg );
  123. private:
  124. idPhysics_RigidBody physicsObj;
  125. idClipModel * trigger;
  126. const idDeclParticle * smoke;
  127. int smokeTime;
  128. void Gib( const idVec3 &dir, const char *damageDefName );
  129. void Event_DropToFloor( void );
  130. void Event_Gib( const char *damageDefName );
  131. };
  132. class idMoveablePDAItem : public idMoveableItem {
  133. public:
  134. CLASS_PROTOTYPE( idMoveablePDAItem );
  135. virtual bool GiveToPlayer( idPlayer *player );
  136. };
  137. /*
  138. ===============================================================================
  139. Item removers.
  140. ===============================================================================
  141. */
  142. class idItemRemover : public idEntity {
  143. public:
  144. CLASS_PROTOTYPE( idItemRemover );
  145. void Spawn();
  146. void RemoveItem( idPlayer *player );
  147. private:
  148. void Event_Trigger( idEntity *activator );
  149. };
  150. class idObjectiveComplete : public idItemRemover {
  151. public:
  152. CLASS_PROTOTYPE( idObjectiveComplete );
  153. idObjectiveComplete();
  154. void Save( idSaveGame *savefile ) const;
  155. void Restore( idRestoreGame *savefile );
  156. void Spawn();
  157. private:
  158. idVec3 playerPos;
  159. void Event_Trigger( idEntity *activator );
  160. void Event_HideObjective( idEntity *e );
  161. void Event_GetPlayerPos();
  162. };
  163. #endif /* !__GAME_ITEM_H__ */