]> icculus.org git repositories - icculus/iodoom3.git/blob - neo/d3xp/Item.h
Various Mac OS X tweaks to get this to build. Probably breaking things.
[icculus/iodoom3.git] / neo / d3xp / Item.h
1 /*
2 ===========================================================================
3
4 Doom 3 GPL Source Code
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company. 
6
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).  
8
9 Doom 3 Source Code is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13
14 Doom 3 Source Code is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with Doom 3 Source Code.  If not, see <http://www.gnu.org/licenses/>.
21
22 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.
23
24 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.
25
26 ===========================================================================
27 */
28
29 #ifndef __GAME_ITEM_H__
30 #define __GAME_ITEM_H__
31
32
33 /*
34 ===============================================================================
35
36   Items the player can pick up or use.
37
38 ===============================================================================
39 */
40
41 class idItem : public idEntity {
42 public:
43         CLASS_PROTOTYPE( idItem );
44
45                                                         idItem();
46         virtual                                 ~idItem();
47
48         void                                    Save( idSaveGame *savefile ) const;
49         void                                    Restore( idRestoreGame *savefile );
50
51         void                                    Spawn( void );
52         void                                    GetAttributes( idDict &attributes );
53         virtual bool                    GiveToPlayer( idPlayer *player );
54         virtual bool                    Pickup( idPlayer *player );
55         virtual void                    Think( void );
56         virtual void                    Present();
57
58         enum {
59                 EVENT_PICKUP = idEntity::EVENT_MAXEVENTS,
60                 EVENT_RESPAWN,
61                 EVENT_RESPAWNFX,
62 #ifdef CTF
63         EVENT_TAKEFLAG,
64         EVENT_DROPFLAG,
65         EVENT_FLAGRETURN,
66                 EVENT_FLAGCAPTURE,
67 #endif
68                 EVENT_MAXEVENTS
69         };
70
71         virtual void                    ClientPredictionThink( void );
72         virtual bool                    ClientReceiveEvent( int event, int time, const idBitMsg &msg );
73
74         // networking
75         virtual void                    WriteToSnapshot( idBitMsgDelta &msg ) const;
76         virtual void                    ReadFromSnapshot( const idBitMsgDelta &msg );
77
78 private:
79         idVec3                                  orgOrigin;
80         bool                                    spin;
81         bool                                    pulse;
82         bool                                    canPickUp;
83
84         // for item pulse effect
85         int                                             itemShellHandle;
86         const idMaterial *              shellMaterial;
87
88         // used to update the item pulse effect
89         mutable bool                    inView;
90         mutable int                             inViewTime;
91         mutable int                             lastCycle;
92         mutable int                             lastRenderViewTime;
93
94         bool                                    UpdateRenderEntity( renderEntity_s *renderEntity, const renderView_t *renderView ) const;
95         static bool                             ModelCallback( renderEntity_s *renderEntity, const renderView_t *renderView );
96
97         void                                    Event_DropToFloor( void );
98         void                                    Event_Touch( idEntity *other, trace_t *trace );
99         void                                    Event_Trigger( idEntity *activator );
100         void                                    Event_Respawn( void );
101         void                                    Event_RespawnFx( void );
102 };
103
104 class idItemPowerup : public idItem {
105 public:
106         CLASS_PROTOTYPE( idItemPowerup );
107
108                                                         idItemPowerup();
109
110         void                                    Save( idSaveGame *savefile ) const;
111         void                                    Restore( idRestoreGame *savefile );
112
113         void                                    Spawn();
114         virtual bool                    GiveToPlayer( idPlayer *player );
115
116 private:
117         int                                             time;
118         int                                             type;
119 };
120
121 class idObjective : public idItem {
122 public:
123         CLASS_PROTOTYPE( idObjective );
124
125                                                         idObjective();
126
127         void                                    Save( idSaveGame *savefile ) const;
128         void                                    Restore( idRestoreGame *savefile );
129
130         void                                    Spawn();
131
132 private:
133         idVec3                                  playerPos;
134
135         void                                    Event_Trigger( idEntity *activator );
136         void                                    Event_HideObjective( idEntity *e );
137         void                                    Event_GetPlayerPos();
138         void                                    Event_CamShot();
139 };
140
141 class idVideoCDItem : public idItem {
142 public:
143         CLASS_PROTOTYPE( idVideoCDItem );
144
145         void                                    Spawn();
146         virtual bool                    GiveToPlayer( idPlayer *player );
147 };
148
149 class idPDAItem : public idItem {
150 public:
151         CLASS_PROTOTYPE( idPDAItem );
152
153         virtual bool                    GiveToPlayer( idPlayer *player );
154 };
155
156 class idMoveableItem : public idItem {
157 public:
158         CLASS_PROTOTYPE( idMoveableItem );
159
160                                                         idMoveableItem();
161         virtual                                 ~idMoveableItem();
162
163         void                                    Save( idSaveGame *savefile ) const;
164         void                                    Restore( idRestoreGame *savefile );
165
166         void                                    Spawn( void );
167         virtual void                    Think( void );
168 #ifdef _D3XP
169         virtual bool                    Collide( const trace_t &collision, const idVec3 &velocity );
170 #endif
171         virtual bool                    Pickup( idPlayer *player );
172
173         static void                             DropItems( idAnimatedEntity *ent, const char *type, idList<idEntity *> *list );
174         static idEntity *               DropItem( const char *classname, const idVec3 &origin, const idMat3 &axis, const idVec3 &velocity, int activateDelay, int removeDelay );
175
176         virtual void                    WriteToSnapshot( idBitMsgDelta &msg ) const;
177         virtual void                    ReadFromSnapshot( const idBitMsgDelta &msg );
178
179 #ifdef CTF    
180 protected:
181 #else
182 private:
183 #endif
184         idPhysics_RigidBody             physicsObj;
185         idClipModel *                   trigger;
186         const idDeclParticle *  smoke;
187         int                                             smokeTime;
188
189 #ifdef _D3XP
190         int                                             nextSoundTime;
191 #endif
192 #ifdef CTF
193         bool                                    repeatSmoke;    // never stop updating the particles
194 #endif
195
196         void                                    Gib( const idVec3 &dir, const char *damageDefName );
197
198         void                                    Event_DropToFloor( void );
199         void                                    Event_Gib( const char *damageDefName );
200 };
201
202 #ifdef CTF
203
204 class idItemTeam : public idMoveableItem {
205 public:
206     CLASS_PROTOTYPE( idItemTeam );
207
208                             idItemTeam();
209         virtual                                 ~idItemTeam();
210
211     void                    Spawn();
212         virtual bool                    Pickup( idPlayer *player );
213         virtual bool                    ClientReceiveEvent( int event, int time, const idBitMsg &msg );    
214         virtual void                    Think(void );
215
216         void                                    Drop( bool death = false );     // was the drop caused by death of carrier?
217         void                                    Return( idPlayer * player = NULL );
218         void                                    Capture( void );
219
220         virtual void                    FreeLightDef( void );
221         virtual void                    Present( void );
222
223         // networking
224         virtual void                    WriteToSnapshot( idBitMsgDelta &msg ) const;
225         virtual void                    ReadFromSnapshot( const idBitMsgDelta &msg );
226
227 public:
228     int                     team;
229         // TODO : turn this into a state : 
230         bool                                    carried;                        // is it beeing carried by a player?
231         bool                                    dropped;                        // was it dropped?
232
233 private:
234         idVec3                                  returnOrigin;
235         idMat3                                  returnAxis;
236         int                                             lastDrop;
237
238         const idDeclSkin *              skinDefault;
239         const idDeclSkin *              skinCarried;
240
241         const function_t *              scriptTaken;
242         const function_t *              scriptDropped;
243         const function_t *              scriptReturned;
244         const function_t *              scriptCaptured;
245
246     renderLight_t           itemGlow;           // Used by flags when they are picked up
247     int                     itemGlowHandle;
248
249         int                                             lastNuggetDrop;
250         const char *                    nuggetName;
251
252 private:
253
254         void                                    Event_TakeFlag( idPlayer * player );
255     void                                        Event_DropFlag( bool death );
256         void                                    Event_FlagReturn( idPlayer * player = NULL );
257         void                                    Event_FlagCapture( void );
258
259         void                                    PrivateReturn( void );
260         function_t *                    LoadScript( char * script );
261
262         void                                    SpawnNugget( idVec3 pos );
263     void                    UpdateGuis( void );
264 };
265
266 #endif
267
268
269 class idMoveablePDAItem : public idMoveableItem {
270 public:
271         CLASS_PROTOTYPE( idMoveablePDAItem );
272
273         virtual bool                    GiveToPlayer( idPlayer *player );
274 };
275
276 /*
277 ===============================================================================
278
279   Item removers.
280
281 ===============================================================================
282 */
283
284 class idItemRemover : public idEntity {
285 public:
286         CLASS_PROTOTYPE( idItemRemover );
287
288         void                                    Spawn();
289         void                                    RemoveItem( idPlayer *player );
290
291 private:
292         void                                    Event_Trigger( idEntity *activator );
293 };
294
295 class idObjectiveComplete : public idItemRemover {
296 public:
297         CLASS_PROTOTYPE( idObjectiveComplete );
298
299                                                         idObjectiveComplete();
300
301         void                                    Save( idSaveGame *savefile ) const;
302         void                                    Restore( idRestoreGame *savefile );
303
304         void                                    Spawn();
305
306 private:
307         idVec3                                  playerPos;
308
309         void                                    Event_Trigger( idEntity *activator );
310         void                                    Event_HideObjective( idEntity *e );
311         void                                    Event_GetPlayerPos();
312 };
313
314 #endif /* !__GAME_ITEM_H__ */