Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/world_entities/npcs/generic_npc.h @ 9003

Last change on this file since 9003 was 9003, checked in by bensch, 18 years ago

orxonox/trunk: merged the single_player_map branche back
merged with command:
svn merge -r8896:HEAD https://svn.orxonox.net/orxonox/branches/single_player_map .
no conflicts

File size: 2.7 KB
Line 
1
2/*!
3 * @file generic_npc.h
4 * generic npc object
5 */
6
7#ifndef _GENERIC_ENTITY_H
8#define _GENERIC_ENTITY_H
9
10#include "npc.h"
11
12
13#include "sound_source.h"
14
15namespace OrxSound{ class SoundSource; }
16namespace OrxSound{ class SoundBuffer; }
17
18class TiXmlElement;
19class Animation3D;
20
21
22class GenericNPC : public NPC
23{
24
25
26 public:
27  GenericNPC(const TiXmlElement* root = NULL);
28  virtual ~GenericNPC ();
29
30  virtual void loadParams(const TiXmlElement* root);
31
32  /** sets the sound volume to @param vol: volume of the sound */
33  inline void setVolume(float vol) { this->soundVolume = vol; }
34
35
36
37  bool finalGoalReached() { return this->behaviourList.empty(); };
38
39  /* npc controlling functions to be Queued */
40  /* walking functions */
41  void walkTo(const Vector& coordinate);
42  void walkTo(float x, float y, float z);
43
44  /* running functions */
45  void runTo(const Vector& coordinate);
46  void runTo(float x, float y, float z);
47
48  /* couching functinos */
49  void crouchTo(const Vector& coordinate);
50  void crouchTo(float x, float y, float z);
51
52  /* stopping the movement */
53  void stop();
54  void nextStep();
55
56  /* some oriantation functions */
57  void lookAt(WorldEntity* worldEntity);
58  void turnTo(float qu, float qx, float qy, float qz);
59  void turnTo(float degreeInY);
60
61  /* talking funcitons*/
62  void talkTo(WorldEntity* worldEntity, int dialogNr);
63
64  /* shooting functions */
65  void shootAt(WorldEntity* entity);
66
67
68  /* some generic control funtions */
69  void playAnimation(int animationIndex, int animPlaybackMode);
70  void playSound(std::string filename);
71  void playSound(int i);
72
73  virtual void tick (float time);
74
75
76  void destroy();
77
78  private:
79    void init();
80
81    void setAnimation(int animationIndex, int animPlaybackMode);
82    int getAnimation();
83    bool isAnimationFinished();
84    void setAnimationSpeed(float speed);
85
86    void initNPC();
87
88
89 private:
90
91   typedef enum {
92    Walk,
93    Run,
94    Crouch,
95    Jump,
96    TurnTo,
97    LookAt,
98    TalkTo,
99
100    Shoot,
101
102
103   } AnimType;
104
105   typedef struct Anim
106   {
107     Vector        v;
108     Quaternion    q;
109
110
111     WorldEntity*  entity;
112     float         speed;
113
114
115     AnimType      type;
116   };
117   typedef std::list<GenericNPC::Anim>     genNPCAnimList;
118
119
120
121   OrxSound::SoundSource                   soundSource;
122   OrxSound::SoundBuffer*                  soundBuffer;
123   float                                   soundVolume;
124
125   std::list<GenericNPC::Anim>             behaviourList;
126   Vector                                  destCoor;
127   Quaternion                              destDir;
128
129   Animation3D*                            currentAnim;
130   float                                   time;          //!< Duration of the action
131   float                                   fallVelocity;
132};
133
134#endif /* _GENERIC_ENTITY_H */
Note: See TracBrowser for help on using the repository browser.