Index: code/branches/modularships/src/orxonox/worldentities/pawns/ModularSpaceShip.cc
===================================================================
--- code/branches/modularships/src/orxonox/worldentities/pawns/ModularSpaceShip.cc	(revision 10054)
+++ code/branches/modularships/src/orxonox/worldentities/pawns/ModularSpaceShip.cc	(revision 10055)
@@ -37,4 +37,5 @@
 #include "util/Math.h"
 #include "gametypes/Gametype.h"
+#include "core/command/ConsoleCommand.h"
 
 #include "items/ShipPart.h"
@@ -48,6 +49,10 @@
 namespace orxonox
 {
+    SetConsoleCommand("ModularSpaceShip", "killshippart", &ModularSpaceShip::killShipPart);
+
     RegisterClass(ModularSpaceShip);
 
+    std::map<StaticEntity*, ShipPart*>* ModularSpaceShip::partMap_s = 0;
+
     ModularSpaceShip::ModularSpaceShip(Context* context) : SpaceShip(context)
     {
@@ -55,4 +60,6 @@
 
         this->registerVariables();
+
+        ModularSpaceShip::partMap_s = &(this->partMap_);
 
     }
@@ -77,4 +84,8 @@
     }
 
+    /**
+    @brief
+        Searches for ShipParts matching to StaticEntities.
+    */
     void ModularSpaceShip::updatePartAssignment()
     {
@@ -115,4 +126,12 @@
     }
 
+    /**
+    @brief
+        Creates a new assignment for the given StaticEntity and ShipPart in the partMap_
+    @param entity
+        A pointer to the StaticEntity
+    @param part
+        A pointer to the ShipPart.
+    */
     void ModularSpaceShip::addPartEntityAssignment(StaticEntity* entity, ShipPart* part)
     {
@@ -150,69 +169,33 @@
     }
 
-    //FIXME: (noep) finish
-    // void ModularSpaceShip::attach
-
+    /**
+    @brief
+        If the damage occurred on an attached StaticEntity, the damage is given to the corresponding ShipPart to handle.
+    */
     void ModularSpaceShip::damage(float damage, float healthdamage, float shielddamage, Pawn* originator, const btCollisionShape* cs)
     {
-        /*orxout() << "Mdamage(): Collision detected on " << this->getRadarName() << ", btCS*: " << cs << endl;
-        orxout() << "UserPtr of said collisionShape: " << cs->getUserPointer() << endl;
-
-
-            // Print all attached objects & parts
-        /*
-        orxout() << "  " << this->getName() << " has the following Objects attached:" << endl;
-
-        for (int i=0; i<50; i++)
-        {
-            if (this->getAttachedObject(i)==NULL)
-                break;
-            orxout() << " " << i << ": " << this->getAttachedObject(i) << " (" << this->getAttachedObject(i)->getName() << ")";
-            orxout() << endl;
-        }
-
-        orxout() << "  Attached ShipParts:" << endl;
-        for(unsigned int i=0; i < this->partList_.size(); i++)
-        {
-            orxout() << "  " << i << ": " << this->partList_[i] << " (" << this->partList_[i]->getName() << ")" << endl;
-        }*/
-
-
-        //int collisionShapeIndex = this->isMyCollisionShape(cs);
-        //orxout() << collisionShapeIndex << endl;
-
-        //orxout() << "ShipPart of Entity " << cs->getUserPointer() << ": " << this->getPartOfEntity((StaticEntity*)(cs->getUserPointer())) << endl;
-
         if (this->getPartOfEntity((StaticEntity*)(cs->getUserPointer())) != NULL)
             this->getPartOfEntity((StaticEntity*)(cs->getUserPointer()))->handleHit(damage, healthdamage, shielddamage, originator);
         else
             SpaceShip::damage(damage, healthdamage, shielddamage, originator, cs);
-
-        /*
-        // Applies multiplier given by the DamageBoost Pickup.
-        if (originator)
-            damage *= originator->getDamageMultiplier();
-
-        if (this->getGametype() && this->getGametype()->allowPawnDamage(this, originator))
-        {
-            if (shielddamage >= this->getShieldHealth())
-            {
-                this->setShieldHealth(0);
-                this->setHealth(this->health_ - (healthdamage + damage));
-            }
-            else
-            {
-                this->setShieldHealth(this->shieldHealth_ - shielddamage);
-
-                // remove remaining shieldAbsorpton-Part of damage from shield
-                shielddamage = damage * this->shieldAbsorption_;
-                shielddamage = std::min(this->getShieldHealth(),shielddamage);
-                this->setShieldHealth(this->shieldHealth_ - shielddamage);
-
-                // set remaining damage to health
-                this->setHealth(this->health_ - (damage - shielddamage) - healthdamage);
-            }
-
-            this->lastHitOriginator_ = originator;
-        }*/
+    }
+
+    /**
+    @brief
+        Kills the ShipPart with the given name. Used from the console-command "ModularSpaceShip killshippart [string]".
+    @param name
+        The name of the part to be killed.
+    */
+    void ModularSpaceShip::killShipPart(std::string name)
+    {
+        for (std::map<StaticEntity*, ShipPart*>::const_iterator it = ModularSpaceShip::partMap_s->begin(); it != ModularSpaceShip::partMap_s->end(); ++it)
+        {
+            if (it->second->getName() == name)
+            {
+                it->second->death();
+                return;
+            }
+        }
+        orxout(internal_warning) << "Could not apply damage to ShipPart \"" << name << "\". Part not found." << endl;
     }
 
@@ -261,4 +244,11 @@
     }
 
+
+    /**
+    @brief
+        Removes a ShipPart from the SpaceShip, destroying the corresponding StaticEntity
+    @param part
+        The ShipPart to be removed.
+    */
     void ModularSpaceShip::removeShipPart(ShipPart* part)
     {
@@ -309,5 +299,5 @@
         orxout() << "MSS: detach()" << endl;
 
-        this->printBtChildShapes((btCompoundShape*)(this->getWorldEntityCollisionShape()->getCollisionShape()), 2, 0);
+        //this->printBtChildShapes((btCompoundShape*)(this->getWorldEntityCollisionShape()->getCollisionShape()), 2, 0);
         this->detachCollisionShape(object->collisionShape_);  // after succeeding, causes a crash in the collision handling
         //this->printBtChildShapes((btCompoundShape*)(this->getWorldEntityCollisionShape()->getCollisionShape()), 2, 0);
