ScummVM API documentation
GameItem.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 /*
23  * Copyright (C) 2006-2010 - Frictional Games
24  *
25  * This file is part of Penumbra Overture.
26  */
27 
28 #ifndef GAME_GAME_ITEM_H
29 #define GAME_GAME_ITEM_H
30 
31 #include "hpl1/engine/engine.h"
32 #include "hpl1/penumbra-overture/GameEntity.h"
33 
34 using namespace hpl;
35 
36 //-----------------------------------------
37 
39  kSerializableClassInit(cGameItem_SaveData);
40 
41 public:
42  bool mbHasBeenFlashed;
43  float mfEnterFlashDist;
44  float mfExitFlashDist;
45 
46  iGameEntity *CreateEntity();
47 };
48 
49 //------------------------------------------
50 
52 public:
53  void SetUp(iPhysicsBody *apSkipBody);
54  bool OnIntersect(iPhysicsBody *pBody, cPhysicsRayParams *apParams);
55 
56  bool mbIntersected;
57  iPhysicsBody *mpSkipBody;
58 };
59 
60 //------------------------------------------
61 
62 class cGameItem : public iGameEntity {
63  typedef iGameEntity super;
64  friend class cEntityLoader_GameItem;
65 
66 public:
67  cGameItem(cInit *apInit, const tString &asName);
68  ~cGameItem(void);
69 
70  void OnWorldLoad();
71 
72  void OnPlayerPick();
73 
74  void OnPlayerInteract();
75 
76  void Update(float afTimeStep);
77 
78  void OnPostSceneDraw();
79 
80  float GetFlashAlpha() { return mfFlashAlpha; }
81 
82  const tString &GetImageFile() { return msImageFile; }
83  eGameItemType GetItemType() { return mItemType; }
84 
85  bool CanBeDropped() { return mbCanBeDropped; }
86 
87  bool HasCount() { return mbHasCount; }
88  int GetCount() { return mlCount; }
89 
90  tString GetHudModelFile() { return msHudModelFile; }
91  tString GetHudModelName() { return msHudModelName; }
92 
93  // SaveObject implementation
94  iGameEntity_SaveData *CreateSaveData();
95  void SaveToSaveData(iGameEntity_SaveData *apSaveData);
96  void LoadFromSaveData(iGameEntity_SaveData *apSaveData);
97 
98 private:
99  bool IsInView(float afMinDist);
100 
101  tString msImageFile;
102  eGameItemType mItemType;
103  bool mbCanBeDropped;
104  bool mbHasCount;
105  int mlCount;
106 
107  float mfCheckFlashCount;
108  float mfCheckFlashMax;
109  float mfStartFlashCount;
110  float mfFlashAlpha;
111  float mfFlashAlphaAdd;
112  bool mbHasBeenFlashed;
113  float mfEnterFlashDist;
114  float mfExitFlashDist;
115 
116  bool mbSkipRayCheck;
117 
118  cGameItem_InViewRay mRayCallback;
119 
120  tString msHudModelFile;
121  tString msHudModelName;
122 
123  tString msPickUpSound;
124 };
125 
126 //--------------------------------------
127 
129 
130 public:
131  cEntityLoader_GameItem(const tString &asName, cInit *apInit);
133 
134  static eGameItemType ToItemType(const char *apString);
135 
136 private:
137  void BeforeLoad(TiXmlElement *apRootElem, const cMatrixf &a_mtxTransform, cWorld3D *apWorld);
138  void AfterLoad(TiXmlElement *apRootElem, const cMatrixf &a_mtxTransform, cWorld3D *apWorld);
139 
140  cInit *mpInit;
141 };
142 
143 #endif // GAME_GAME_ITEM_H
Definition: AI.h:36
Definition: str.h:59
Definition: PhysicsWorld.h:92
Definition: GameItem.h:62
Definition: PhysicsWorld.h:100
Definition: GameEntity.h:76
Definition: GameItem.h:38
Definition: PhysicsBody.h:117
Definition: World3D.h:179
Definition: GameItem.h:51
Definition: EntityLoader_Object.h:52
Definition: tinyxml.h:864
Definition: GameItem.h:128
Definition: GameEntity.h:126
Definition: Init.h:70