[8514] | 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 | |
---|
[8793] | 12 | |
---|
[8516] | 13 | #include "sound_source.h" |
---|
[8514] | 14 | |
---|
[8516] | 15 | namespace OrxSound{ class SoundSource; } |
---|
| 16 | namespace OrxSound{ class SoundBuffer; } |
---|
[8514] | 17 | |
---|
| 18 | class TiXmlElement; |
---|
[8802] | 19 | class Animation3D; |
---|
[8514] | 20 | |
---|
| 21 | |
---|
| 22 | class GenericNPC : public NPC |
---|
| 23 | { |
---|
[8908] | 24 | |
---|
| 25 | |
---|
[8514] | 26 | public: |
---|
[8908] | 27 | GenericNPC(const TiXmlElement* root = NULL); |
---|
[8514] | 28 | virtual ~GenericNPC (); |
---|
| 29 | |
---|
| 30 | virtual void loadParams(const TiXmlElement* root); |
---|
| 31 | |
---|
[8516] | 32 | /** sets the sound volume to @param vol: volume of the sound */ |
---|
| 33 | inline void setVolume(float vol) { this->soundVolume = vol; } |
---|
[8514] | 34 | |
---|
[8705] | 35 | |
---|
| 36 | |
---|
[8917] | 37 | bool finalGoalReached() { return this->behaviourList.empty(); }; |
---|
[8908] | 38 | |
---|
| 39 | /* npc controlling functions to be Queued */ |
---|
[8894] | 40 | /* walking functions */ |
---|
[8908] | 41 | void walkTo(const Vector& coordinate); |
---|
| 42 | void walkTo(float x, float y, float z); |
---|
[8514] | 43 | |
---|
[8894] | 44 | /* running functions */ |
---|
[8908] | 45 | void runTo(const Vector& coordinate); |
---|
| 46 | void runTo(float x, float y, float z); |
---|
[8783] | 47 | |
---|
[8894] | 48 | /* couching functinos */ |
---|
[8908] | 49 | void crouchTo(const Vector& coordinate); |
---|
| 50 | void crouchTo(float x, float y, float z); |
---|
[8783] | 51 | |
---|
[8894] | 52 | /* stopping the movement */ |
---|
| 53 | void stop(); |
---|
[8909] | 54 | void nextStep(); |
---|
[8894] | 55 | |
---|
| 56 | /* some oriantation functions */ |
---|
[8908] | 57 | void lookAt(WorldEntity* worldEntity); |
---|
| 58 | void turnTo(float qu, float qx, float qy, float qz); |
---|
| 59 | void turnTo(float degreeInY); |
---|
[8894] | 60 | |
---|
| 61 | /* talking funcitons*/ |
---|
[8908] | 62 | void talkTo(WorldEntity* worldEntity, int dialogNr); |
---|
[8783] | 63 | |
---|
[8894] | 64 | /* shooting functions */ |
---|
| 65 | void shootAt(WorldEntity* entity); |
---|
[8793] | 66 | |
---|
[8514] | 67 | |
---|
[8894] | 68 | /* some generic control funtions */ |
---|
| 69 | void playAnimation(int animationIndex, int animPlaybackMode); |
---|
| 70 | void playSound(std::string filename); |
---|
| 71 | void playSound(int i); |
---|
| 72 | |
---|
[8514] | 73 | virtual void tick (float time); |
---|
| 74 | |
---|
| 75 | |
---|
[8894] | 76 | void destroy(); |
---|
| 77 | |
---|
[8908] | 78 | private: |
---|
| 79 | void init(); |
---|
[8894] | 80 | |
---|
[8951] | 81 | void setAnimation(int animationIndex, int animPlaybackMode); |
---|
| 82 | int getAnimation(); |
---|
| 83 | bool isAnimationFinished(); |
---|
[8966] | 84 | void setAnimationSpeed(float speed); |
---|
[8908] | 85 | |
---|
[8957] | 86 | void initNPC(); |
---|
[8951] | 87 | |
---|
[8957] | 88 | |
---|
[8514] | 89 | private: |
---|
[8908] | 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 | |
---|
[8516] | 121 | OrxSound::SoundSource soundSource; |
---|
| 122 | OrxSound::SoundBuffer* soundBuffer; |
---|
| 123 | float soundVolume; |
---|
[8793] | 124 | |
---|
[8908] | 125 | std::list<GenericNPC::Anim> behaviourList; |
---|
[8793] | 126 | Vector destCoor; |
---|
| 127 | Quaternion destDir; |
---|
[8802] | 128 | |
---|
| 129 | Animation3D* currentAnim; |
---|
[8894] | 130 | float time; //!< Duration of the action |
---|
[8967] | 131 | float fallVelocity; |
---|
[8514] | 132 | }; |
---|
| 133 | |
---|
| 134 | #endif /* _GENERIC_ENTITY_H */ |
---|