Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/world_entities/world_entity.h @ 6430

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

orxonox/trunk: Energy System on WorldEntity-level

File size: 4.3 KB
Line 
1/*!
2 * @file world_entity.h
3 * Definition of the basic WorldEntity
4*/
5
6#ifndef _WORLD_ENTITY_H
7#define _WORLD_ENTITY_H
8
9#include "p_node.h"
10#include "synchronizeable.h"
11#include "model.h"
12
13#include "object_manager.h"
14#include "glincl.h"
15#include <vector>
16
17// FORWARD DECLARATION
18class SoundBuffer;
19class SoundSource;
20class BVTree;
21class Model;
22class GLGuiBar;
23
24//class CharacterAttributes;
25
26
27//! Basis-class all interactive stuff in the world is derived from
28class WorldEntity : public PNode, public Synchronizeable
29{
30public:
31  WorldEntity();
32  virtual ~WorldEntity ();
33
34  void loadParams(const TiXmlElement* root);
35
36  void loadModel(const char* fileName, float scaling = 1.0f, unsigned int modelNumber = 0);
37  void setModel(Model* model, unsigned int modelNumber = 0);
38Model* getModel(unsigned int modelNumber = 0) const { return (this->models.size() > modelNumber)? this->models[modelNumber] : NULL; };
39
40  inline void loadMD2Texture(const char* fileName) { this->md2TextureFileName = fileName; }
41
42  bool buildObbTree(unsigned int depth);
43  /** @returns a reference to the obb tree of this worldentity */
44  BVTree* getOBBTree() const { return this->obbTree; };
45
46  /** @param visibility if the Entity should be visible (been draw) */
47  void setVisibiliy (bool visibility) { this->bVisible = visibility; };
48  /** @returns true if the entity is visible, false otherwise */
49  inline bool isVisible() const { return this->bVisible; };
50
51
52
53  virtual void postSpawn ();
54  virtual void leftWorld ();
55
56  virtual void tick (float time);
57
58  virtual void draw () const;
59
60  virtual void collidesWith (WorldEntity* entity, const Vector& location);
61  void drawBVTree(unsigned int depth, int drawMode) const;
62
63
64  void debugWE() { this->debugEntity(); }
65  ;  ///FIXME
66  void debugEntity() const;
67
68
69  /* @returns the Count of Faces on this WorldEntity */
70  //unsigned int getFaceCount () const { return (this->model != NULL)?this->model->getFaceCount():0; };
71  //  void addAbility(Ability* ability);
72  //  void removeAbility(Ability* ability);
73  //  void setCharacterAttributes(CharacterAttributes* charAttr);
74  //  CharacterAttributes* getCharacterAttributes();
75
76  void toList(OM_LIST list);
77
78  /** @returns a Reference to the objectListNumber to set. */
79  OM_LIST& getOMListNumber() { return this->objectListNumber; }
80  /** @returns a Reference to the Iterator */
81  std::list<WorldEntity*>::iterator& getEntityIterator() { return this->objectListIterator; }
82
83  int       writeState(const byte* data, int length, int sender);
84  int       readState(byte* data, int maxLength );
85
86  /** @returns the Energy of the entity */
87  float getEnergy() const { return this->energy; };
88  /** @returns the Maximum energy this entity can be charged with */
89  float getMaxEnergy() const { return this->energyMax; }
90  float addEnergy(float energy);
91  float removeEnergy(float energy);
92  void setMaxEnergy(float maxEnergy);
93
94
95protected:
96  void setEnergy(float energy) { this->energy = energy; };
97  void setEnergyWidgetVisibilit(bool visibility);
98  void createEnergyWidget();
99  //  CharacterAttributes*    charAttr;         //!< the character attributes of a world_entity
100private:
101  void updateEnergyWidget();
102
103private:
104  /// TODO maybe we will move the following three entries and the corresponding functions to Playable AND NPC
105  float                   energy;             //!< The Energy of this Entity, if the Entity has any energy at all.
106  float                   energyMax;          //!< The Maximal energy this entity can take.
107  GLGuiBar*               energyWidget;       //!< The Slider (if wanted).
108
109  std::vector<Model*>     models;             //!< The model that should be loaded for this entity.
110  const char*             md2TextureFileName; //!< the file name of the md2 model texture, only if this
111  BVTree*                 obbTree;            //!< this is the obb tree reference needed for collision detection
112
113  bool                    bCollide;           //!< If it should be considered for the collisiontest.
114  bool                    bVisible;           //!< If it should be visible.
115
116  OM_LIST                           objectListNumber;   //!< The ObjectList from ObjectManager this Entity is in.
117  std::list<WorldEntity*>::iterator objectListIterator; //!< The iterator position of this Entity in the given list of the ObjectManager.
118
119  float                   scaling;
120
121
122};
123
124#endif /* _WORLD_ENTITY_H */
Note: See TracBrowser for help on using the repository browser.