Index: trunk/src/world_entities/world_entity.cc
===================================================================
--- trunk/src/world_entities/world_entity.cc	(revision 10618)
+++ trunk/src/world_entities/world_entity.cc	(revision 10698)
@@ -75,4 +75,6 @@
   this->aabbNode = NULL;
   this->healthWidget = NULL;
+  this->electronicWidget = NULL;
+  this->shieldWidget = NULL;
   this->healthMax = 1.0f;
   this->health = 1.0f;
@@ -128,9 +130,15 @@
 
   // Delete the obbTree
-  if( this->obbTree != NULL)
+  if( this->obbTree)
     delete this->obbTree;
 
-  if (this->healthWidget != NULL)
+  if (this->healthWidget)
     delete this->healthWidget;
+
+  if(this->shieldWidget)
+    delete this->shieldWidget;
+
+  if( this->electronicWidget)
+    delete this->electronicWidget;
 
   this->unsubscribeReactions();
@@ -776,6 +784,6 @@
   this->updateHealthWidget();
   return 0.0;
-
-}
+}
+
 
 /**
@@ -792,4 +800,46 @@
   this->updateHealthWidget();
 }
+
+
+
+/**
+ * @param shiled the Shieldstength to add.
+ * @returns the shield left (this->shieldMax - shiled + this->shield)
+ */
+float WorldEntity::increaseShield(float shiled)
+{
+  this->shield += shield;
+  if (this->shield > this->shieldTH * this->shieldMax) { this->bShieldActive = true; }
+  if (this->shield > this->shieldMax)
+  {
+    float retShield = this->shieldMax - this->shield;
+    this->shield = this->shieldMax;
+//     this->updateShieldWidget();
+    return retShield;
+  }
+//   this->updateShieldWidget();
+  return 0.0;
+}
+
+/**
+ * @param shield the Shieldstrength to be removed
+ * @returns 0.0 or the rest, if the shield drops belew 0.0
+ */
+float WorldEntity::decreaseShield(float shield)
+{
+  this->shield -= shield;
+
+  if (this->shield <= 0)
+  {
+    float retShield = -this->shield;
+//     this->updateShieldWidget();
+    this->bShieldActive = false;
+    return retShield;
+  }
+//   this->updateShieldWidget();
+  return 0.0;
+}
+
+
 
 /**
@@ -813,4 +863,51 @@
 }
 
+
+/**
+ * @brief creates the ImplantWidget
+ *
+ * since not all entities need an ImpantWidget, it is only created on request.
+ */
+void WorldEntity::createImplantWidget()
+{
+  if (this->implantWidget == NULL)
+  {
+    this->implantWidget = new OrxGui::GLGuiEnergyWidgetVertical();
+    //this->impantWidget->setDisplayedName("Implant");
+    //this->impantWidget->setSize2D(100,20);
+    //this->impantWidget->setAbsCoor2D(100,200);
+
+    //this->updateImplantWidget();
+  }
+  else
+    PRINTF(3)("Allready created the ImlpantWidget for %s::%s\n", this->getClassCName(), this->getCName());
+}
+
+
+
+void WorldEntity::createShieldWidget()
+{
+  if (this->shieldWidget == NULL)
+  {
+    this->shieldWidget = new OrxGui::GLGuiEnergyWidgetVertical();
+    this->updateShieldWidget();
+  }
+  else
+    PRINTF(3)("Allready created the ShieldWidget for %s::%s\n", this->getClassCName(), this->getCName());
+}
+
+void WorldEntity::createElectronicWidget()
+{
+  if (this->electronicWidget == NULL)
+  {
+    this->electronicWidget = new OrxGui::GLGuiEnergyWidgetVertical();
+    this->updateElectronicWidget();
+  }
+  else
+    PRINTF(3)("Allready created the ElectronicWidget for %s::%s\n", this->getClassCName(), this->getCName());
+}
+
+
+
 void WorldEntity::increaseHealthMax(float increaseHealth)
 {
@@ -822,7 +919,36 @@
 OrxGui::GLGuiWidget* WorldEntity::getHealthWidget()
 {
-  this->createHealthWidget();
+  if ( this->healthWidget == NULL)
+    this->createHealthWidget();
   return this->healthWidget;
 }
+
+
+
+OrxGui::GLGuiWidget* WorldEntity::getImplantWidget()
+{
+  this->createImplantWidget();
+  return this->implantWidget;
+}
+
+
+
+OrxGui::GLGuiWidget* WorldEntity::getShieldWidget()
+{
+  if ( this->shieldWidget == NULL)
+    this->createShieldWidget();
+  return this->shieldWidget;
+}
+
+
+OrxGui::GLGuiWidget* WorldEntity::getElectronicWidget()
+{
+  if ( this->electronicWidget == NULL)
+    this->createElectronicWidget();
+  return this->electronicWidget;
+}
+
+
+
 
 /**
@@ -830,5 +956,5 @@
  * (creates the widget if needed)
  */
-void WorldEntity::setHealthWidgetVisibilit(bool visibility)
+void WorldEntity::setHealthWidgetVisibility(bool visibility)
 {
   if (visibility)
@@ -890,4 +1016,52 @@
   }
 }
+
+/**
+ * @brief updates the Electronic Widget
+ */
+//!< xferred from spaceship
+void WorldEntity::updateElectronicWidget(){
+  if (this->electronicWidget != NULL)
+  { //if it exists already: update it
+     this->electronicWidget->setMaximum(this->electronicMax);
+     this->electronicWidget->setValue(this->electronic);
+  }
+  else
+  { //create the widget
+    this->electronicWidget = new OrxGui::GLGuiEnergyWidgetVertical();
+    this->electronicWidget->getBarWidget()->setChangedValueColor(Color(1,0,0,1));
+    //this->electronicWidget->setDisplayedName("Electronics:");
+    //this->electronicWidget->setSize2D(100,20);
+    //this->electronicWidget->setAbsCoor2D(150,200);
+    this->updateElectronicWidget();
+//     if ( dynamic_cast<SpaceShip*>(this)->hasPlayer() )
+//       State::getPlayer()->hud().setEnergyWidget(this->electronicWidget);
+  }
+}
+
+/**
+ * @brief updates the ShieldWidget
+ */
+//!< xferred from spaceship
+void WorldEntity::updateShieldWidget()
+{
+  if (this->shieldWidget != NULL)
+  {
+    this->shieldWidget->setMaximum(this->shieldMax);
+    this->shieldWidget->setValue(this->shield);;
+  }
+  else
+  {
+    this->shieldWidget = new OrxGui::GLGuiEnergyWidgetVertical();
+    this->shieldWidget->getBarWidget()->setChangedValueColor(Color(1,0,0,1));
+    //this->shieldWidget->setDisplayedName("Shield:");
+    //his->shieldWidget->setSize2D(100,20);
+    //this->shieldWidget->setAbsCoor2D(200,200);
+    this->updateShieldWidget();
+//     if (dynamic_cast<SpaceShip*>(this)->hasPlayer())
+//       State::getPlayer()->hud().setShieldWidget(this->shieldWidget);
+  }
+}
+
 
 
@@ -985,2 +1159,23 @@
 }
 
+
+void WorldEntity::regen(float time){
+  static float tmp;
+  increaseHealth(time * this->healthRegen);
+  increaseShield(time * this->shieldRegen);
+//   updateHealthWidget();
+//   updateShieldWidget();
+
+  //this->setHealth( this->shieldCur);      // FIXME currently just to test share system
+
+  if (this->electronic != this->electronicMax || this->electronicRegen != 0){
+    tmp = this->electronic + this->electronicRegen * time;
+    if ( tmp > electronicMax)
+      this->electronic = this->electronicMax;
+    else
+      this->electronic = tmp;
+
+    updateElectronicWidget();
+  }
+
+}
