Index: code/branches/pickup2/src/orxonox/pickup/DroppedItem.cc
===================================================================
--- code/branches/pickup2/src/orxonox/pickup/DroppedItem.cc	(revision 6412)
+++ code/branches/pickup2/src/orxonox/pickup/DroppedItem.cc	(revision 6412)
@@ -0,0 +1,123 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Daniel 'Huty' Haggenmueller
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "DroppedItem.h"
+
+#include "util/Math.h"
+#include "core/CoreIncludes.h"
+#include "core/Executor.h"
+#include "BaseItem.h"
+#include "graphics/Billboard.h"
+#include "graphics/Model.h"
+#include "worldentities/pawns/Pawn.h"
+
+namespace orxonox
+{
+    CreateFactory(DroppedItem);
+
+    DroppedItem::DroppedItem(BaseObject* creator) : StaticEntity(creator)
+    {
+        RegisterObject(DroppedItem);
+
+        this->triggerDistance_ = 20.0f;
+        this->timeToLive_ = 0;
+        this->item_ = 0;
+    }
+    DroppedItem::~DroppedItem()
+    {
+    }
+    void DroppedItem::tick(float dt)
+    {
+        if (this->item_)
+        {
+            for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); ++it)
+            {
+                Vector3 distance = it->getWorldPosition() - this->getWorldPosition();
+                if (distance.length() < this->triggerDistance_)
+                    this->trigger(*it);
+            }
+        }
+    }
+    void DroppedItem::trigger(Pawn* pawn)
+    {
+        if (this->item_->pickedUp(pawn))
+        {
+            COUT(3) << "DroppedItem '" << this->item_->getPickupIdentifier() << "' picked up." << std::endl;
+            this->destroy();
+        }
+    }
+    void DroppedItem::createTimer()
+    {
+        if (this->timeToLive_ > 0)
+        {
+            this->timer_.setTimer(this->timeToLive_, false, createExecutor(createFunctor(&DroppedItem::timerCallback, this)), false);
+        }
+    }
+    void DroppedItem::timerCallback()
+    {
+        if (this->item_)
+        {
+            COUT(3) << "Delete DroppedItem with '" << this->item_->getPickupIdentifier() << '\'' << std::endl;
+            this->item_->destroy();
+        }
+
+        this->destroy();
+    }
+
+    DroppedItem* DroppedItem::createDefaultDrop(BaseItem* item, const Vector3& position, const ColourValue& flareColour, float timeToLive)
+    {
+        DroppedItem* drop = new DroppedItem(item);
+        Model* model = new Model(item);
+        Billboard* billboard = new Billboard(item);
+
+        model->setMeshSource("sphere.mesh");
+        model->setScale(3.0f);
+
+        billboard->setMaterial("Examples/Flare");
+        billboard->setColour(flareColour);
+        billboard->setScale(0.5f);
+
+        drop->setPosition(position);
+        drop->attach(model);
+        drop->attach(billboard);
+
+        drop->setItem(item);
+
+        drop->setTimeToLive(timeToLive);
+        drop->createTimer();
+
+        COUT(3) << "Created DroppedItem for '" << item->getPickupIdentifier() << "' at (" << position.x << ',' << position.y << ',' << position.z << ")." << std::endl;
+
+        return drop;
+    }
+    DroppedItem* DroppedItem::createDefaultDrop(BaseItem* item, Pawn* pawn, const ColourValue& flareColour, float timeToLive)
+    {
+        Vector3 after = pawn->getPosition() + pawn->getOrientation() * Vector3(0.0f, 0.0f, 50.0f);
+        return DroppedItem::createDefaultDrop(item, after, flareColour, timeToLive);
+    }
+}
Index: code/branches/pickup2/src/orxonox/pickup/ModifierPickup.cc
===================================================================
--- code/branches/pickup2/src/orxonox/pickup/ModifierPickup.cc	(revision 6405)
+++ code/branches/pickup2/src/orxonox/pickup/ModifierPickup.cc	(revision 6412)
@@ -106,10 +106,10 @@
             for (it = this->additiveModifiers_.begin(); it != this->additiveModifiers_.end(); it++)
             {
-                pawn->getPickups().addAdditiveModifier((*it).first, (*it).second);
+                pawn->getPickups().addAdditiveModifier(it->first, it->second);
             }
 
             for (it = this->multiplicativeModifiers_.begin(); it != this->multiplicativeModifiers_.end(); it++)
             {
-                pawn->getPickups().addMultiplicativeModifier((*it).first, (*it).second);
+                pawn->getPickups().addMultiplicativeModifier(it->first, it->second);
             }
 
@@ -146,10 +146,10 @@
             for (it = this->additiveModifiers_.begin(); it != this->additiveModifiers_.end(); it++)
             {
-                pawn->getPickups().removeAdditiveModifier((*it).first, (*it).second);
+                pawn->getPickups().removeAdditiveModifier(it->first, it->second);
             }
 
             for (it = this->multiplicativeModifiers_.begin(); it != this->multiplicativeModifiers_.end(); it++)
             {
-                pawn->getPickups().removeMultiplicativeModifier((*it).first, (*it).second);
+                pawn->getPickups().removeMultiplicativeModifier(it->first, it->second);
             }
 
@@ -186,5 +186,5 @@
         std::map<ModifierType::Value, float>::const_iterator it = this->additiveModifiers_.find(type);
         if (it != this->additiveModifiers_.end())
-            return (*it).second;
+            return it->second;
         else
             return 0.0f;
@@ -203,5 +203,5 @@
         std::map<ModifierType::Value, float>::const_iterator it = this->multiplicativeModifiers_.find(type);
         if (it != this->multiplicativeModifiers_.end())
-            return (*it).second;
+            return it->second;
         else
             return 1.0f;
Index: code/branches/pickup2/src/orxonox/pickup/PickupCollection.cc
===================================================================
--- code/branches/pickup2/src/orxonox/pickup/PickupCollection.cc	(revision 6405)
+++ code/branches/pickup2/src/orxonox/pickup/PickupCollection.cc	(revision 6412)
@@ -102,6 +102,6 @@
         for (std::multimap<std::string, BaseItem*>::iterator it = this->items_.begin(); it != this->items_.end(); it++)
         {
-            if((*it).second && (*it).second->getOwner())
-                (*it).second->dropped((*it).second->getOwner());
+            if(it->second && it->second->getOwner())
+                it->second->dropped(it->second->getOwner());
         }
         this->currentUsable_ = NULL;
@@ -126,5 +126,5 @@
             for (std::multimap<std::string, BaseItem*>::iterator it = bounds.first; it != bounds.second && it != this->items_.end(); it++)
             {
-                if ((*it).second == item)
+                if (it->second == item)
                 {
                     return true;
@@ -178,5 +178,5 @@
             for (std::multimap<std::string, BaseItem*>::iterator it = bounds.first; it != bounds.second && it != this->items_.end(); it++)
             {
-                if ((*it).second == item)
+                if (it->second == item)
                 {
                     this->items_.erase(it);
@@ -219,5 +219,5 @@
         for (std::multimap<ModifierType::Value, float>::iterator it = range.first; it != range.second && it != this->additiveModifiers_.end(); it++)
         {
-            v += (*it).second;
+            v += it->second;
         }
 
@@ -234,5 +234,5 @@
         for (std::multimap<ModifierType::Value, float>::iterator it = range.first; it != range.second && it != this->additiveModifiers_.end(); it++)
         {
-            if ((*it).second == value)
+            if (it->second == value)
             {
                 this->additiveModifiers_.erase(it);
@@ -262,5 +262,5 @@
         for (std::multimap<ModifierType::Value, float>::iterator it = range.first; it != range.second && it != this->multiplicativeModifiers_.end(); it++)
         {
-            v *= (*it).second;
+            v *= it->second;
         }
 
@@ -277,5 +277,5 @@
         for (std::multimap<ModifierType::Value, float>::iterator it = range.first; it != range.second && it != this->multiplicativeModifiers_.end(); it++)
         {
-            if ((*it).second == value)
+            if (it->second == value)
             {
                 this->multiplicativeModifiers_.erase(it);
@@ -337,6 +337,6 @@
         for (std::multimap<std::string, BaseItem*>::iterator it = this->items_.begin(); it != this->items_.end(); it++)
         {
-            if ((*it).second->isA(ident))
-                ret.push_back(orxonox_cast<EquipmentItem*>((*it).second));
+            if (it->second->isA(ident))
+                ret.push_back(orxonox_cast<EquipmentItem*>(it->second));
         }
 
@@ -354,6 +354,6 @@
         for (std::multimap<std::string, BaseItem*>::iterator it = this->items_.begin(); it != this->items_.end(); it++)
         {
-            if ((*it).second->isA(ident))
-                ret.push_back(orxonox_cast<PassiveItem*>((*it).second));
+            if (it->second->isA(ident))
+                ret.push_back(orxonox_cast<PassiveItem*>(it->second));
         }
 
@@ -371,6 +371,6 @@
         for (std::multimap<std::string, BaseItem*>::iterator it = this->items_.begin(); it != this->items_.end(); it++)
         {
-            if ((*it).second->isA(ident))
-                ret.push_back(orxonox_cast<UsableItem*>((*it).second));
+            if (it->second->isA(ident))
+                ret.push_back(orxonox_cast<UsableItem*>(it->second));
         }
 
Index: code/branches/pickup2/src/orxonox/pickup/PickupInventory.cc
===================================================================
--- code/branches/pickup2/src/orxonox/pickup/PickupInventory.cc	(revision 6405)
+++ code/branches/pickup2/src/orxonox/pickup/PickupInventory.cc	(revision 6412)
@@ -110,13 +110,9 @@
     {
         if(PickupInventory::getSingleton()->isVisible()) {
-            GUIManager::getInstance().executeCode("hideGUI(\"PickupInventory\")");
-            GUIManager::getInstance().executeCode("hideCursor()");
-            InputManager::getInstance().leaveState("guiMouseOnly");
-        }
-        else
-        {
-            GUIManager::getInstance().showGUI("PickupInventory");
-            GUIManager::getInstance().executeCode("showCursor()");
-            InputManager::getInstance().enterState("guiMouseOnly");
+            GUIManager::hideGUI("PickupInventory");
+        }
+        else
+        {
+            GUIManager::showGUI("PickupInventory");
         }
         PickupInventory::getSingleton()->setVisible(!PickupInventory::getSingleton()->isVisible());
@@ -235,5 +231,5 @@
             return "";
 
-        std::string name = "pickup_" + item->getGUIImage();
+        const std::string& name = "pickup_" + item->getGUIImage();
 
         if(!CEGUI::ImagesetManager::getSingletonPtr()->isImagesetPresent(name))
@@ -242,5 +238,5 @@
         }
 
-        return "set:" + name + " image:full_image";
+        return ("set:" + name + " image:full_image");
     }
 
@@ -374,7 +370,7 @@
         txt->setVisible(true);
         txt->setProperty("Text", item->getGUIText());
-        txt->setProperty("TextColours", "tl:" + textColour + " tr:" + textColour + " bl:" + textColour + " br:" + textColour + "");
-
-        std::string image = PickupInventory::getImageForItem(item);
+        txt->setProperty("TextColours", "tl:" + textColour + " tr:" + textColour + " bl:" + textColour + " br:" + textColour);
+
+        const std::string& image = PickupInventory::getImageForItem(item);
         btn->setVisible(true);
         btn->setProperty("NormalImage", image);
Index: code/branches/pickup2/src/orxonox/pickup/PickupSpawner.cc
===================================================================
--- code/branches/pickup2/src/orxonox/pickup/PickupSpawner.cc	(revision 6412)
+++ code/branches/pickup2/src/orxonox/pickup/PickupSpawner.cc	(revision 6412)
@@ -0,0 +1,270 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Daniel 'Huty' Haggenmueller
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file
+    @brief Implementation of PickupSpawner.
+*/
+
+#include "PickupSpawner.h"
+
+#include "BaseItem.h"
+
+#include "core/CoreIncludes.h"
+#include "core/GUIManager.h"     // HACK; see below
+#include "core/Template.h"
+#include "core/XMLPort.h"
+#include "worldentities/pawns/Pawn.h"
+#include "PickupInventory.h"    // HACK; Only for hack, remove later
+
+
+namespace orxonox
+{
+
+    const float PickupSpawner::bounceSpeed_s = 6.0f;
+    const float PickupSpawner::rotationSpeed_s = 1.0f;
+    const float PickupSpawner::bounceDistance_s = 4.0f;
+
+    CreateFactory(PickupSpawner);
+
+    /**
+    @brief
+        Constructor. Registers the PickupSpawner.
+    @param creator
+        Pointer to the object which created this item.
+    */
+    PickupSpawner::PickupSpawner(BaseObject* creator) : StaticEntity(creator)
+    {
+        this->initialize();
+    }
+
+    PickupSpawner::PickupSpawner(BaseObject* creator, BaseItem* item, float triggerDistance, float respawnTime, int maxSpawnedItems) : StaticEntity(creator)
+    {
+        this->initialize();
+  
+        //TODO: Does this actually work?
+        this->itemTemplateName_ = item->getIdentifier()->getName();
+        this->itemTemplate_ = Template::getTemplate(this->itemTemplateName_);
+
+        this->triggerDistance_ = triggerDistance;
+        this->respawnTime_ = respawnTime;
+        this->setMaxSpawnedItems(maxSpawnedItems);
+    }
+
+    void PickupSpawner::initialize(void)
+    {
+        RegisterObject(PickupSpawner);
+
+        this->itemTemplate_ = NULL;
+        this->triggerDistance_ = 20;
+        this->respawnTime_ = 0.0f;
+        this->tickSum_ = 0.0f;
+        this->maxSpawnedItems_ = INF;
+        this->spawnsRemaining_ = INF;
+    }
+
+    /**
+    @brief
+        Destructor.
+    */
+    PickupSpawner::~PickupSpawner()
+    {
+        
+    }
+
+    /**
+    @brief
+        Method for creating a PickupSpawner through XML.
+    @param xmlelement
+        XML element which contains the PickupSpawner.
+    @param mode
+        XMLPort mode.
+    */
+    void PickupSpawner::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(PickupSpawner, XMLPort, xmlelement, mode);
+
+        XMLPortParam(PickupSpawner, "item", setItemTemplateName, getItemTemplateName, xmlelement, mode);
+        XMLPortParam(PickupSpawner, "triggerDistance", setTriggerDistance, getTriggerDistance, xmlelement, mode);
+        XMLPortParam(PickupSpawner, "respawnTime", setRespawnTime, getRespawnTime, xmlelement, mode);
+        XMLPortParam(PickupSpawner, "maxSpawnedItems", setMaxSpawnedItems, getMaxSpawnedItems, xmlelement, mode);
+
+        //TODO: Kill hack.
+        // HACKs
+        // Load the GUI image as soon as the PickupSpawner gets loaded
+        //  = less delays while running
+        BaseObject* newObject = this->itemTemplate_->getBaseclassIdentifier()->fabricate(this);
+        BaseItem* asItem = orxonox_cast<BaseItem*>(newObject);
+        if (asItem)
+        {
+            asItem->addTemplate(this->itemTemplate_);
+            PickupInventory::getImageForItem(asItem);
+            newObject->destroy();
+        }
+
+        //  & load the GUI itself too, along with some empty windows
+        //   = even less delays
+        GUIManager::showGUI("PickupInventory");
+        GUIManager::hideGUI("PickupInventory");
+        PickupInventory::getSingleton();
+    }
+
+    /**
+    @brief
+        Invoked when the activity has changed. Sets visibility of attached objects.
+    */
+    void PickupSpawner::changedActivity()
+    {
+        SUPER(PickupSpawner, changedActivity);
+
+        for (std::set<WorldEntity*>::const_iterator it = this->getAttachedObjects().begin(); it != this->getAttachedObjects().end(); it++)
+            (*it)->setVisible(this->isActive());
+    }
+
+    /**
+    @brief
+        Set the template name of the item to spawn, also loads the template.
+    @param name
+        Name of the new template.
+    */
+    void PickupSpawner::setItemTemplateName(const std::string& name)
+    {
+        this->itemTemplateName_ = name;
+        this->itemTemplate_ = Template::getTemplate(name);
+    }
+
+    void PickupSpawner::setMaxSpawnedItems(int items)
+    {
+        this->maxSpawnedItems_ = items;
+        this->spawnsRemaining_ = items;
+    }
+
+    /**
+    @brief
+        Tick, checks if any Pawn is close enough to trigger.
+    @param dt
+        Time since last tick.
+    */
+    //TODO: Replace this with a real DistanceTrigger.
+    void PickupSpawner::tick(float dt)
+    {
+        if (this->isActive())
+        {
+            //! Triggers as soon as a Pawn is in the specified distance.
+            for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); ++it)
+            {
+                Vector3 distance = it->getWorldPosition() - this->getWorldPosition();
+                if (distance.length() < this->triggerDistance_)
+                    this->trigger(*it);
+            }
+
+            //! Animation.
+            this->yaw(Radian(rotationSpeed_s*dt));
+            this->tickSum_ += bounceSpeed_s*dt;
+            this->translate(Vector3(0,bounceDistance_s*dt*sin(this->tickSum_),0));
+            if (this->tickSum_ > 2*Ogre::Math::PI)
+                this->tickSum_ -= 2*Ogre::Math::PI;
+        }
+    }
+
+    /**
+    @brief
+        Trigger the PickupSpawner.
+
+        Adds the pickup to the Pawn that triggered,
+        sets the timer to re-activate and deactives the PickupSpawner.
+
+    @param pawn
+        Pawn which triggered the PickupSpawner.
+    */
+    void PickupSpawner::trigger(Pawn* pawn)
+    {
+        if (this->isActive() && this->itemTemplate_ && this->itemTemplate_->getBaseclassIdentifier()) //!< Checks whether PickupItem is active, amongst other things.
+        {
+            BaseItem* item = this->getItem();
+            if (item != NULL) //!< If the conversion was successful.
+            {
+                item->setPickupIdentifier(this->itemTemplateName_); //TODO: Needed?
+                item->addTemplate(this->itemTemplate_); //TODO: Does what?
+
+                if(item->pickedUp(pawn))
+                {
+                    COUT(3) << this->itemTemplateName_ << " got picked up." << std::endl;
+
+
+                    if(this->spawnsRemaining_ != INF)
+                    {
+                        this->spawnsRemaining_--;
+                    }
+
+                    if (this->spawnsRemaining_ != 0 && this->respawnTime_ > 0.0f)
+                    {
+                        this->respawnTimer_.setTimer(this->respawnTime_, false, createExecutor(createFunctor(&PickupSpawner::respawnTimerCallback, this)));
+
+                        this->setActive(false);
+                        this->fireEvent();
+                    }
+                }
+                else
+                {
+                    item->destroy();
+                }
+            }
+        }
+
+        if(this->spawnsRemaining_ == 0)
+        {
+            COUT(3) << "PickupSpawner empty, selfdistruct initialized." << std::endl;
+            this->setActive(false);
+            this->destroy();
+        }
+    }
+
+    /**
+    @brief
+        Creates a BaseItem of the type specified by the PickupSpawner.
+    @return
+        The BaseItem created.
+    */    
+    BaseItem* PickupSpawner::getItem(void)
+    {
+        BaseObject* newItem = this->itemTemplate_->getBaseclassIdentifier()->fabricate(this); //!< Creates new object of specified item type.
+        return orxonox_cast<BaseItem*>(newItem);
+    }
+
+    /**
+    @brief
+        Invoked by the timer, re-activates the PickupSpawner.
+    */
+    void PickupSpawner::respawnTimerCallback()
+    {
+        COUT(3) << "PickupSpawner reactivated." << std::endl;
+
+        this->setActive(true);
+    }
+}
Index: code/branches/pickup2/src/orxonox/pickup/UsableItem.cc
===================================================================
--- code/branches/pickup2/src/orxonox/pickup/UsableItem.cc	(revision 6405)
+++ code/branches/pickup2/src/orxonox/pickup/UsableItem.cc	(revision 6412)
@@ -26,5 +26,5 @@
  *
  */
-        
+
 /**
     @file
@@ -41,5 +41,5 @@
     @param creator Pointer to the object which created this item.
     */
-    UsableItem::UsableItem(BaseObject* creator) : BaseItem(creator) 
+    UsableItem::UsableItem(BaseObject* creator) : BaseItem(creator)
     {
         RegisterObject(UsableItem);
