Index: /trunk/src/world_entities/space_ships/space_ship.cc
===================================================================
--- /trunk/src/world_entities/space_ships/space_ship.cc	(revision 6429)
+++ /trunk/src/world_entities/space_ships/space_ship.cc	(revision 6430)
@@ -132,4 +132,6 @@
   cycle = 0.0;
 
+  this->setMaxEnergy(100);
+  this->setEnergy(80);
 
   travelSpeed = 15.0;
@@ -212,4 +214,5 @@
   this->attachCamera();
 
+  this->setEnergyWidgetVisibilit(true);
 
 }
@@ -220,4 +223,5 @@
   this->detachCamera();
 
+  this->setEnergyWidgetVisibilit(false);
 
 }
@@ -315,11 +319,11 @@
 
   //readjust
-  
+
   /*
     In the game "Yager" the spaceship gets readjusted when the player moves the mouse.
     I (bknecht) go and check it out how they do it, we could probably use this also in Orxonox.
   */
-  //if (xMouse != 0 && yMouse != 0) 
-  
+  //if (xMouse != 0 && yMouse != 0)
+
   //if (this->getAbsDirZ().y > 0.1) this->shiftDir(Quaternion(time*0.3, Vector(1,0,0)));
   //else if (this->getAbsDirZ().y < -0.1) this->shiftDir(Quaternion(-time*0.3, Vector(1,0,0)));
Index: /trunk/src/world_entities/world_entity.cc
===================================================================
--- /trunk/src/world_entities/world_entity.cc	(revision 6429)
+++ /trunk/src/world_entities/world_entity.cc	(revision 6430)
@@ -27,4 +27,6 @@
 #include "obb_tree.h"
 
+#include "glgui_bar.h"
+
 #include "state.h"
 
@@ -32,6 +34,6 @@
 
 SHELL_COMMAND(model, WorldEntity, loadModel)
-    ->describe("sets the Model of the WorldEntity")
-    ->defaultValues(2, "models/ships/fighter.obj", 1.0);
+->describe("sets the Model of the WorldEntity")
+->defaultValues(2, "models/ships/fighter.obj", 1.0);
 
 SHELL_COMMAND(debugEntity, WorldEntity, debugWE);
@@ -43,15 +45,16 @@
  *              that can calls WorldEntities loadParams for itself.
  */
-WorldEntity::WorldEntity(const TiXmlElement* root)
-  : Synchronizeable()
+WorldEntity::WorldEntity()
+    : Synchronizeable()
 {
   this->setClassID(CL_WORLD_ENTITY, "WorldEntity");
 
   this->obbTree = NULL;
+  this->energyWidget = NULL;
+  this->energyMax = 1.0f;
+  this->energy = 1.0f;
 
   this->md2TextureFileName = NULL;
 
-  if (root != NULL)
-    this->loadParams(root);
 
   this->setVisibiliy(true);
@@ -72,4 +75,7 @@
     delete this->obbTree;
 
+  if (this->energyWidget != NULL)
+    delete this->energyWidget;
+
   // Delete the model (unregister it with the ResourceManager)
   for (unsigned int i = 0; i < this->models.size(); i++)
@@ -89,11 +95,19 @@
 
   LoadParam(root, "md2texture", this, WorldEntity, loadMD2Texture)
-      .describe("the fileName of the texture, that should be loaded onto this world-entity. (must be relative to the data-dir)")
-      .defaultValues(1, NULL);
+  .describe("the fileName of the texture, that should be loaded onto this world-entity. (must be relative to the data-dir)")
+  .defaultValues(1, NULL);
 
   // Model Loading
   LoadParam(root, "model", this, WorldEntity, loadModel)
-      .describe("the fileName of the model, that should be loaded onto this world-entity. (must be relative to the data-dir)")
-      .defaultValues(3, NULL, 1.0f, 0);
+  .describe("the fileName of the model, that should be loaded onto this world-entity. (must be relative to the data-dir)")
+  .defaultValues(3, NULL, 1.0f, 0);
+
+  LoadParam(root, "maxEnergy", this, WorldEntity, setMaxEnergy)
+  .describe("The Maximum energy that can be loaded onto this entity")
+  .defaultValues(1, 1.0f);
+
+  LoadParam(root, "energy", this, WorldEntity, setEnergy)
+  .describe("The Energy the WorldEntity has at this moment")
+  .defaultValues(1, 1.0f);
 }
 
@@ -111,5 +125,5 @@
   if ( fileName != NULL && strcmp(fileName, "") )
   {
-   // search for the special character # in the LoadParam
+    // search for the special character # in the LoadParam
     if (strchr(fileName, '#') != NULL)
     {
@@ -147,5 +161,5 @@
       PRINTF(4)("fetching MD2 file: %s\n", fileName);
       Model* m = new MD2Model(fileName, this->md2TextureFileName);
-        //this->setModel((Model*)ResourceManager::getInstance()->load(fileName, MD2, RP_CAMPAIGN), 0);
+      //this->setModel((Model*)ResourceManager::getInstance()->load(fileName, MD2, RP_CAMPAIGN), 0);
       this->setModel(m, 0);
     }
@@ -170,5 +184,5 @@
   {
     Resource* resource = ResourceManager::getInstance()->locateResourceByPointer(this->models[modelNumber]);
-//     if (resource != NULL)
+    //     if (resource != NULL)
     ResourceManager::getInstance()->unload(resource, RP_LEVEL);
   }
@@ -179,6 +193,6 @@
 
 
-//   if (this->model != NULL)
-//     this->buildObbTree(4);
+  //   if (this->model != NULL)
+  //     this->buildObbTree(4);
 }
 
@@ -251,5 +265,5 @@
    * You can always define a default Action.... don't be affraid just test it :)
    */
-//  PRINTF(3)("collision %s vs %s @ (%f,%f,%f)\n", this->getClassName(), entity->getClassName(), location.x, location.y, location.z);
+  //  PRINTF(3)("collision %s vs %s @ (%f,%f,%f)\n", this->getClassName(), entity->getClassName(), location.x, location.y, location.z);
 }
 
@@ -260,6 +274,5 @@
  */
 void WorldEntity::postSpawn ()
-{
-}
+{}
 
 
@@ -273,6 +286,5 @@
  */
 void WorldEntity::leftWorld ()
-{
-}
+{}
 
 
@@ -284,6 +296,5 @@
 */
 void WorldEntity::tick(float time)
-{
-}
+{}
 
 
@@ -296,5 +307,5 @@
 void WorldEntity::draw() const
 {
-    //PRINTF(0)("(%s::%s)\n", this->getClassName(), this->getName());
+  //PRINTF(0)("(%s::%s)\n", this->getClassName(), this->getName());
   //  assert(!unlikely(this->models.empty()));
   {
@@ -325,4 +336,96 @@
     }
     glPopMatrix();
+  }
+}
+
+/**
+ * @param energy the Energy to add.
+ * @returns the energy left (this->energyMax - energy+this->energy)
+ */
+float WorldEntity::addEnergy(float energy)
+{
+  this->energy += energy;
+  if (this->energy > this->energyMax)
+  {
+    float retEnergy = this->energyMax - this->energy;
+    this->energy = this->energyMax;
+    this->updateEnergyWidget();
+    return retEnergy;
+  }
+  this->updateEnergyWidget();
+  return 0.0;
+}
+
+/**
+ * @param energy the Energy to be removed
+ * @returns 0.0 or the rest, that was not substracted (bellow 0.0)
+ */
+float WorldEntity::removeEnergy(float energy)
+{
+  this->energy -= energy;
+
+  if (this->energy < 0)
+  {
+    float retEnergy = -this->energy;
+    this->energy = 0.0f;
+    this->updateEnergyWidget();
+    return retEnergy;
+  }
+  this->updateEnergyWidget();
+  return 0.0;
+
+}
+
+/**
+ * @param maxEnergy the maximal energy that can be loaded onto the entity.
+ */
+void WorldEntity::setMaxEnergy(float maxEnergy)
+{
+  this->energyMax = maxEnergy;
+  if (this->energy > this->energyMax)
+  {
+    PRINTF(3)("new maxEnergy is bigger as the old energy. Did you really intend to do this for (%s::%s)\n", this->getClassName(), this->getName());
+    this->energy = this->energyMax;
+  }
+  this->updateEnergyWidget();
+}
+
+void WorldEntity::createEnergyWidget()
+{
+  if (this->energyWidget == NULL)
+  {
+    this->energyWidget = new GLGuiBar();
+    this->energyWidget->setSize2D(30,400);
+    this->energyWidget->setAbsCoor2D(5,100);
+
+    this->updateEnergyWidget();
+  }
+  else
+    PRINTF(3)("Allready created the EnergyWidget for %s::%s\n", this->getClassName(), this->getName());
+}
+
+void WorldEntity::setEnergyWidgetVisibilit(bool visibility)
+{
+    if (visibility)
+    {
+      if (this->energyWidget != NULL)
+        this->energyWidget->show();
+      else
+      {
+        this->createEnergyWidget();
+        this->updateEnergyWidget();
+        this->energyWidget->show();
+      }
+    }
+    else if (this->energyWidget != NULL)
+      this->energyWidget->hide();
+}
+
+void WorldEntity::updateEnergyWidget()
+{
+  if (this->energyWidget != NULL)
+  {
+    this->energyWidget->setMaximum(this->energyMax);
+    this->energyWidget->setValue(this->energy);
   }
 }
Index: /trunk/src/world_entities/world_entity.h
===================================================================
--- /trunk/src/world_entities/world_entity.h	(revision 6429)
+++ /trunk/src/world_entities/world_entity.h	(revision 6430)
@@ -20,4 +20,5 @@
 class BVTree;
 class Model;
+class GLGuiBar;
 
 //class CharacterAttributes;
@@ -27,6 +28,6 @@
 class WorldEntity : public PNode, public Synchronizeable
 {
- public:
-  WorldEntity(const TiXmlElement* root = NULL);
+public:
+  WorldEntity();
   virtual ~WorldEntity ();
 
@@ -35,5 +36,5 @@
   void loadModel(const char* fileName, float scaling = 1.0f, unsigned int modelNumber = 0);
   void setModel(Model* model, unsigned int modelNumber = 0);
-  Model* getModel(unsigned int modelNumber = 0) const { return (this->models.size() > modelNumber)? this->models[modelNumber] : NULL; };
+Model* getModel(unsigned int modelNumber = 0) const { return (this->models.size() > modelNumber)? this->models[modelNumber] : NULL; };
 
   inline void loadMD2Texture(const char* fileName) { this->md2TextureFileName = fileName; }
@@ -61,5 +62,6 @@
 
 
-  void debugWE() { this->debugEntity(); };  ///FIXME
+  void debugWE() { this->debugEntity(); }
+  ;  ///FIXME
   void debugEntity() const;
 
@@ -82,9 +84,27 @@
   int       readState(byte* data, int maxLength );
 
- protected:
-  //  CharacterAttributes*    charAttr;         //!< the character attributes of a world_entity
+  /** @returns the Energy of the entity */
+  float getEnergy() const { return this->energy; };
+  /** @returns the Maximum energy this entity can be charged with */
+  float getMaxEnergy() const { return this->energyMax; }
+  float addEnergy(float energy);
+  float removeEnergy(float energy);
+  void setMaxEnergy(float maxEnergy);
 
 
- private:
+protected:
+  void setEnergy(float energy) { this->energy = energy; };
+  void setEnergyWidgetVisibilit(bool visibility);
+  void createEnergyWidget();
+  //  CharacterAttributes*    charAttr;         //!< the character attributes of a world_entity
+private:
+  void updateEnergyWidget();
+
+private:
+  /// TODO maybe we will move the following three entries and the corresponding functions to Playable AND NPC
+  float                   energy;             //!< The Energy of this Entity, if the Entity has any energy at all.
+  float                   energyMax;          //!< The Maximal energy this entity can take.
+  GLGuiBar*               energyWidget;       //!< The Slider (if wanted).
+
   std::vector<Model*>     models;             //!< The model that should be loaded for this entity.
   const char*             md2TextureFileName; //!< the file name of the md2 model texture, only if this
