Index: branches/powerups/src/world_entities/Makefile.am
===================================================================
--- branches/powerups/src/world_entities/Makefile.am	(revision 5874)
+++ branches/powerups/src/world_entities/Makefile.am	(revision 5955)
@@ -7,5 +7,6 @@
                   world_entity.cc \
                   camera.cc \
-                  player.cc \
+                  playable.cc \
+		  player.cc \
                   npc.cc \
                   npc2.cc \
@@ -17,4 +18,5 @@
                   character_attributes.cc \
                   test_entity.cc \
+		  space_ships/space_ship.cc \
                   weapons/weapon_manager.cc \
                   weapons/weapon.cc \
@@ -35,5 +37,6 @@
                  world_entity.h \
                  camera.h \
-                 player.h \
+                 playable.h \
+		 player.h \
                  npc.h \
                  npc2.h \
@@ -45,4 +48,5 @@
                  character_attributes.h \
                  test_entity.h \
+		 space_ships/space_ship.h \
                  weapons/weapon_manager.h \
                  weapons/weapon.h \
Index: branches/powerups/src/world_entities/playable.cc
===================================================================
--- branches/powerups/src/world_entities/playable.cc	(revision 5955)
+++ branches/powerups/src/world_entities/playable.cc	(revision 5955)
@@ -0,0 +1,127 @@
+/*
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2004 orx
+
+   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, or (at your option)
+   any later version.
+
+### File Specific:
+   main-programmer: Silvan Nellen
+   co-programmer: Benjamin Knecht
+*/
+
+
+#include "playable.h"
+
+#include "weapons/weapon_manager.h"
+#include "event_handler.h"
+#include "player.h"
+
+
+Playable::Playable()
+{
+  this->init();
+}
+
+Playable::~Playable()
+{
+  delete this->weaponMan;
+
+  if (this->currentPlayer)
+  {
+    PRINTF(2)("There is Still a Player subscribed to this Playable (%s::%s)\n", this->getClassName(), this->getName());
+
+  }
+}
+
+/**
+ * initializes this Playable
+ */
+void Playable::init()
+{
+  this->setClassID(CL_PLAYABLE, "Playable");
+  PRINTF(4)("PLAYABLE INIT\n");
+
+  this->weaponMan = new WeaponManager(this);
+
+  // the reference to the Current Player is NULL, because we dont have one at the beginning.
+  this->currentPlayer = NULL;
+}
+
+/**
+ * subscribe to all events the controllable needs
+ * @param player the player that shall controll this Playable
+ */
+bool Playable::subscribePlayer(Player* player)
+{
+  if (this->currentPlayer != NULL)
+  {
+    PRINTF(1)("Already registered Player:%s to this Playable (%s:%s)\n", this->currentPlayer->getName(), this->getClassName(), this->getName());
+    return false;
+  }
+  else
+  {
+    this->currentPlayer = player;
+    /*EventHandler*/
+    EventHandler* evh = EventHandler::getInstance();
+    std::list<int>::iterator ev;
+    for (ev = this->events.begin(); ev != events.end(); ev++)
+      evh->subscribe(player, ES_GAME, (*ev));
+
+    return true;
+  }
+}
+
+/**
+ * unsubscribe from all events the controllable needs
+ * @param player the Player, that controlled this Ship.
+ */
+bool Playable::unsubscribePlayer(Player* player)
+{
+  if (this->currentPlayer != player)
+  {
+    PRINTF(1)("not the right Player to unregister from this Playable (%s:%s)\n", this->currentPlayer->getName(), this->getClassName(), this->getName());
+    return false;
+  }
+
+  else
+  {
+    /*EventHandler*/
+    EventHandler* evh = EventHandler::getInstance();
+    std::list<int>::iterator ev;
+    for (ev = this->events.begin(); ev != events.end(); ev++)
+      evh->unsubscribe( ES_GAME, (*ev));
+
+    this->currentPlayer = NULL;
+    return true;
+  }
+}
+
+/**
+ * add an event to the event list of events this Playable can capture
+ * @param eventType the Type of event to add
+ */
+void Playable::registerEvent(int eventType)
+{
+  this->events.push_back(eventType);
+
+  if (this->currentPlayer != NULL)
+    EventHandler::getInstance()->subscribe(this->currentPlayer, ES_GAME, eventType);
+}
+
+/**
+ * remove an event to the event list this Playable can capture.
+ * @param event the event to unregister.
+ */
+void Playable::unregisterEvent(int eventType)
+{
+  this->events.remove(eventType);
+
+  if (this->currentPlayer != NULL)
+    EventHandler::getInstance()->unsubscribe(ES_GAME, eventType);
+}
+
+
Index: branches/powerups/src/world_entities/playable.h
===================================================================
--- branches/powerups/src/world_entities/playable.h	(revision 5955)
+++ branches/powerups/src/world_entities/playable.h	(revision 5955)
@@ -0,0 +1,56 @@
+
+/*!
+ * @file playable.h
+ * Interface for a basic controllable WorldEntity
+ */
+#ifndef _PLAYABLE_H
+#define _PLAYABLE_H
+
+#include "world_entity.h"
+#include "event.h"
+#include <list>
+
+class Weapon;
+class WeaponManager;
+class Player;
+
+//! Basic controllable WorldEntity
+/**
+ *
+ */
+class Playable : public WorldEntity
+{
+  public:
+    Playable();
+    virtual ~Playable();
+
+
+    virtual void addWeapon(Weapon* weapon )  {}//= 0;
+    virtual void removeWeapon(Weapon* weapon) {}//= 0;
+    inline WeaponManager* getWeaponManager() const { return this->weaponMan; };
+
+    bool subscribePlayer(Player* player);
+    bool unsubscribePlayer(Player* player);
+
+    virtual void process(const Event &event) = 0;
+
+
+    /** @return a List of Events in PEV_* sytle */
+    inline const std::list<int>& getEventList() { return this->events; };
+
+  protected:
+    void registerEvent(int eventType);
+    void unregisterEvent(int eventType);
+
+  private:
+    void init();
+
+  private:
+    WeaponManager*        weaponMan;          //!< the weapon manager: managing a list of weapon to wepaon-slot mapping
+    std::list<int>        events;             //!< A list of Events, that are captured for this playable
+
+    Player*               currentPlayer;      //!< The Player currently connected to this Playable (the one that has controll) otherwise NULL
+
+};
+
+#endif /* _PLAYABLE_H */
Index: branches/powerups/src/world_entities/player.cc
===================================================================
--- branches/powerups/src/world_entities/player.cc	(revision 5874)
+++ branches/powerups/src/world_entities/player.cc	(revision 5955)
@@ -10,37 +10,18 @@
 
    ### File Specific:
-   main-programmer: Patrick Boenzli
-   co-programmer: Christian Meyer
+   main-programmer: Silvan Nellen
+   co-programmer: Benjamin Knecht
 */
 
-#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY
-
-
-#include "executor/executor.h"
 #include "player.h"
-
-#include "track_manager.h"
-#include "objModel.h"
-#include "resource_manager.h"
-#include "factory.h"
-
-#include "weapons/weapon_manager.h"
-#include "weapons/test_gun.h"
-#include "weapons/turret.h"
-#include "weapons/cannon.h"
-
-#include "list.h"
+#include "playable.h"
 
 #include "event_handler.h"
 
-#include "event.h"
-
 using namespace std;
 
-CREATE_FACTORY(Player, CL_PLAYER);
 
 /**
  * creates a new Player
- * @param isFree if the player is free
 */
 Player::Player()
@@ -49,51 +30,4 @@
 }
 
-/**
- * loads a Players information from a specified file.
- * @param fileName the name of the File to load the player from (absolute path)
- */
-Player::Player(const char* fileName)
-{
-  this->init();
-  TiXmlDocument doc(fileName);
-
-  if(!doc.LoadFile())
-  {
-    PRINTF(2)("Loading file %s failed for player.\n", fileName);
-    return;
-  }
-
-  this->loadParams(doc.RootElement());
-}
-
-/**
- *  creates a new Player from Xml Data
- * @param root the xml element containing player data
-
-   @todo add more parameters to load
-*/
-Player::Player(const TiXmlElement* root)
-{
-  this->init();
-  if (root != NULL)
-    this->loadParams(root);
-
-  //weapons:
-  Weapon* wpRight = new TestGun(0);
-  wpRight->setName("testGun Right");
-  Weapon* wpLeft = new TestGun(1);
-  wpLeft->setName("testGun Left");
-  Weapon* cannon = dynamic_cast<Weapon*>(Factory::getFirst()->fabricate(CL_CANNON));
-
-  cannon->setName("BFG");
-
-  this->weaponMan->addWeapon(wpLeft, 1, 0);
-  this->weaponMan->addWeapon(wpRight,1 ,1);
-  this->weaponMan->addWeapon(cannon, 0, 6);
-
-  //this->weaponMan->addWeapon(turret, 3, 0);
-
-  this->weaponMan->changeWeaponConfig(1);
-}
 
 /**
@@ -102,12 +36,6 @@
 Player::~Player ()
 {
-  /* do not delete the weapons, they are contained in the pnode tree
-  and will be deleted there.
-  this only frees the memory allocated to save the list.
-  */
-  delete this->weaponMan;
 }
 
-//#include "glgui_pushbutton.h"
 
 /**
@@ -120,276 +48,37 @@
 
   PRINTF(4)("PLAYER INIT\n");
-  travelSpeed = 15.0;
-  bUp = bDown = bLeft = bRight = bAscend = bDescend = false;
-  bFire = false;
-  acceleration = 10.0;
 
-//   GLGuiButton* button = new GLGuiPushButton();
-//   button->show();
-//   button->setLabel("orxonox");
-//   button->setBindNode(this);
-
-  this->weaponMan = new WeaponManager(this);
-  this->weaponMan->setSlotCount(7);
-
-  this->weaponMan->setSlotPosition(0, Vector(-2.6, .1, -3.0));
-  this->weaponMan->setSlotCapability(0, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
-
-  this->weaponMan->setSlotPosition(1, Vector(-2.6, .1, 3.0));
-  this->weaponMan->setSlotCapability(1, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
-
-  this->weaponMan->setSlotPosition(2, Vector(-1.5, .5, -.5));
-  this->weaponMan->setSlotDirection(2, Quaternion(-M_PI_4*.5, Vector(1,0,0)));
-
-  this->weaponMan->setSlotPosition(3, Vector(-1.5, .5, .5));
-  this->weaponMan->setSlotDirection(3, Quaternion(M_PI_4*.5, Vector(1,0,0)));
-
-  this->weaponMan->setSlotPosition(4, Vector(-1.5, -.5, .5));
-  this->weaponMan->setSlotDirection(4, Quaternion(-M_PI_4*.5+M_PI, Vector(1,0,0)));
-
-  this->weaponMan->setSlotPosition(5, Vector(-1.5, -.5, -.5));
-  this->weaponMan->setSlotDirection(5, Quaternion(+M_PI_4*.5-M_PI, Vector(1,0,0)));
-//
-   this->weaponMan->setSlotPosition(6, Vector(-1, 0.0, 0));
-   this->weaponMan->setSlotCapability(6, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
-   //
-//   this->weaponMan->setSlotPosition(8, Vector(-2.5, -0.3, -2.0));
-//   this->weaponMan->setSlotDirection(8, Quaternion(-M_PI, Vector(1,0,0)));
-//
-//   this->weaponMan->setSlotPosition(9, Vector(-2.5, -0.3, 2.0));
-//   this->weaponMan->setSlotDirection(9, Quaternion(+M_PI, Vector(1,0,0)));:
-
+  this->controllable = NULL;
 }
 
 
-/**
- * loads the Settings of a Player from an XML-element.
- * @param root the XML-element to load the Player's properties from
- */
-void Player::loadParams(const TiXmlElement* root)
+bool Player::setControllable(Playable* controllable)
 {
-  static_cast<WorldEntity*>(this)->loadParams(root);
-
-
-
+  if(controllable != NULL && controllable->subscribePlayer(this))
+  {
+      this->controllable = controllable;
+      return true;
+  }
+  else
+    return false;
 }
 
-/**
- * adds a weapon to the weapon list of player
- * @param weapon to add
-*/
-void Player::addWeapon(Weapon* weapon)
-{
-  this->weaponMan->addWeapon(weapon);
-}
+bool Player::disconnectControllable()
+ {
+   if(this->controllable == NULL) return true;
 
+   if(this->controllable->unsubscribePlayer(this))
+   {
+     this->controllable = NULL;
+     return true;
+   }
+   else
+     return false;
+ }
 
-/**
- *  removes a weapon from the player
- * @param weapon to remove
-*/
-void Player::removeWeapon(Weapon* weapon)
-{
-  this->weaponMan->removeWeapon(weapon);
-}
+ void Player::process(const Event &event)
+ {
+   if (likely(this->controllable != NULL))
+     this->controllable->process(event);
+ }
 
-
-/**
- *  effect that occurs after the player is spawned
-*/
-void Player::postSpawn ()
-{
-  //setCollision(new CollisionCluster(1.0, Vector(0,0,0)));
-}
-
-
-/**
- *  the action occuring if the player left the game
-*/
-void Player::leftWorld ()
-{}
-
-
-WorldEntity* ref = NULL;
-/**
- *  this function is called, when two entities collide
- * @param entity: the world entity with whom it collides
- *
- * Implement behaviour like damage application or other miscellaneous collision stuff in this function
- */
-void Player::collidesWith(WorldEntity* entity, const Vector& location)
-{
-  if (entity->isA(CL_TURRET_POWER_UP) && entity != ref)
-  {
-    this->ADDWEAPON();
-    ref = entity;
-    }
-//  PRINTF(3)("collision %s vs %s @ (%f,%f,%f)\n", this->getClassName(), entity->getClassName(), location.x, location.y, location.z);
-}
-
-/**
- *  draws the player after transforming him.
-*/
-void Player::draw () const
-{
-  glMatrixMode(GL_MODELVIEW);
-  glPushMatrix();
-  /* translate */
-  glTranslatef (this->getAbsCoor ().x,
-                this->getAbsCoor ().y,
-                this->getAbsCoor ().z);
-  /* rotate */
-  Vector tmpRot = this->getAbsDir().getSpacialAxis();
-  glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
-  this->model->draw();
-  glPopMatrix();
-
-  this->weaponMan->draw();
-
-  //this->debug(0);
-}
-
-
-/**
- *  the function called for each passing timeSnap
- * @param time The timespan passed since last update
-*/
-void Player::tick (float time)
-{
-  // player controlled movement
-  this->move(time);
-
-  this->weaponMan->tick(time);
-  // weapon system manipulation
-  this->weaponAction();
-}
-
-
-/**
- *  action if player moves
- * @param time the timeslice since the last frame
-*/
-void Player::move (float time)
-{
-  Vector accel(0.0, 0.0, 0.0);
-  Vector rot(0.0, 0.0, 0.0);
-  float rotVal = 0.0;
-  /* FIXME: calculating the direction and orthDirection every timeSlice is redundant! save it somewhere */
-  /* calculate the direction in which the craft is heading  */
-  Vector direction (1.0, 0.0, 0.0);
-  //direction = this->absDirection.apply (direction);
-  Vector orthDirection (0.0, 0.0, 1.0);
-  //orthDirection = orthDirection.cross (direction);
-
-  if( this->bUp && this->getRelCoor().x < 20)
-    accel += direction;
-  if( this->bDown && this->getRelCoor().x > -5)
-    accel -= direction;
-
-  if( this->bLeft && TrackManager::getInstance()->getWidth() > -this->getRelCoor().z*2)
-  {
-    accel -=(orthDirection);
-    rot +=Vector(1,0,0);
-    rotVal -= .4;
-  }
-  if( this->bRight && TrackManager::getInstance()->getWidth() > this->getRelCoor().z*2)
-  {
-    accel += orthDirection;
-    rot += Vector(1,0,0);
-    rotVal += .4;
-  }
-  if (this->bAscend )
-  {
-    accel += Vector(0,1,0);
-    rot += Vector(0,0,1);
-    rotVal += .4;
-  }
-  if (this->bDescend )
-  {
-    accel -= Vector(0,1,0);
-    rot += Vector(0,0,1);
-    rotVal -= .4;
-  }
-
-  Vector move = accel * time *acceleration;
-
-/*  if (accel.z < 0)
-    this->setRelDirSoft(Quaternion(-.4, accel), 5);
-  else if (accel.z > 0)
-    this->setRelDirSoft(Quaternion(.4, accel), 5);
-  else*/
-  rot.normalize();
-  this->setRelDirSoft(Quaternion(rotVal, rot), 5);
-  this->shiftCoor (move);
-}
-
-
-/**
- * weapon manipulation by the player
-*/
-void Player::weaponAction()
-{
-  if( this->bFire)
-    {
-      this->weaponMan->fire();
-    }
-}
-
-/**
- * @todo switch statement ??
- */
-void Player::process(const Event &event)
-{
-  if( event.type == KeyMapper::PEV_UP)
-      this->bUp = event.bPressed;
-  else if( event.type == KeyMapper::PEV_DOWN)
-      this->bDown = event.bPressed;
-  else if( event.type == KeyMapper::PEV_RIGHT)
-      this->bRight= event.bPressed;
-  else if( event.type == KeyMapper::PEV_LEFT)
-      this->bLeft = event.bPressed;
-  else if( event.type == KeyMapper::PEV_FIRE1)
-      this->bFire = event.bPressed;
-  else if( event.type == KeyMapper::PEV_NEXT_WEAPON && event.bPressed)
-    this->weaponMan->nextWeaponConfig();//if( !event.bPressed) this->bWeaponChange = !this->bWeaponChange;
-  else if ( event.type == KeyMapper::PEV_PREVIOUS_WEAPON && event.bPressed)
-    this->weaponMan->previousWeaponConfig();
-
-  else if( event.type == SDLK_PAGEUP)
-    this->bAscend = event.bPressed; //this->shiftCoor(0,.1,0);
-  else if( event.type == SDLK_PAGEDOWN)
-    this->bDescend = event.bPressed; //this->shiftCoor(0,-.1,0);
-}
-
-#include "weapons/aiming_turret.h"
-// FIXME THIS MIGHT BE CONSIDERED EITHER A FEATURE, OR A BUG
-void Player::ADDWEAPON()
-{
-  Weapon* turret = NULL;
-
-  if ((float)rand()/RAND_MAX < .1)
-  {
-    //if (this->weaponMan->hasFreeSlot(2, WTYPE_TURRET))
-    {
-      turret = new Turret();
-      this->weaponMan->addWeapon(turret, 2);
-      this->weaponMan->changeWeaponConfig(2);
-    }
-  }
-  else
-  {
-    //if (this->weaponMan->hasFreeSlot(3))
-    {
-      turret = new AimingTurret();
-      this->weaponMan->addWeapon(turret, 3);
-
-      this->weaponMan->changeWeaponConfig(3);
-    }
-  }
-
-  if(turret != NULL)
-  {
-    turret->setName("Turret");
-    turret->setStateDuration(WS_SHOOTING, (float)rand()/RAND_MAX*.5+.1);
-  }
-}
Index: branches/powerups/src/world_entities/player.h
===================================================================
--- branches/powerups/src/world_entities/player.h	(revision 5874)
+++ branches/powerups/src/world_entities/player.h	(revision 5955)
@@ -7,13 +7,8 @@
 #define _PLAYER_H
 
-#include "world_entity.h"
-#include "physics_interface.h"
 #include "event_listener.h"
 
-template<class T> class tList;
-class Weapon;
-class WeaponManager;
-class Vector;
-class Event;
+/* Forward Declaration */
+class Playable;
 
 //! Basic controllable WorldEntity
@@ -23,51 +18,25 @@
      the player.cc for debug also
 */
-class Player : public WorldEntity, public EventListener
+class Player : public EventListener
 {
-  friend class World;
 
   public:
     Player();
-    Player(const char* fileName);
-    Player(const TiXmlElement* root);
     virtual ~Player();
 
-    void init();
-    void loadParams(const TiXmlElement* root);
+    bool              setControllable(Playable* controllalble);
+    inline Playable*  getControllable() { return this->controllable; };
 
-    void addWeapon(Weapon* weapon);
-    void removeWeapon(Weapon* weapon);
+    bool              disconnectControllable();
 
-    virtual void postSpawn();
-    virtual void leftWorld();
+    // eventListener extension.
+    virtual void      process(const Event &event);
 
-    virtual void collidesWith(WorldEntity* entity, const Vector& location);
-    virtual void tick(float time);
-    virtual void draw() const;
-
-    virtual void process(const Event &event);
+  private:
+    void              init();
 
 
   private:
-    void move(float time);
-    void weaponAction();
-
-    // !! temporary !!
-    void ADDWEAPON();
-
-  private:
-    bool                  bUp;                //!< up button pressed.
-    bool                  bDown;              //!< down button pressed.
-    bool                  bLeft;              //!< left button pressed.
-    bool                  bRight;             //!< right button pressed.
-    bool                  bAscend;            //!< ascend button pressed.
-    bool                  bDescend;           //!< descend button presses.
-    bool                  bFire;              //!< fire button pressed.
-
-    WeaponManager*        weaponMan;          //!< the weapon manager: managing a list of weapon to wepaon-slot mapping
-
-    Vector                velocity;           //!< the velocity of the player.
-    float                 travelSpeed;        //!< the current speed of the player (to make soft movement)
-    float                 acceleration;       //!< the acceleration of the player.
+    Playable*         controllable;                  //!< The one we controll or NULL if none
 };
 
Index: branches/powerups/src/world_entities/power_ups/laser_power_up.cc
===================================================================
--- branches/powerups/src/world_entities/power_ups/laser_power_up.cc	(revision 5874)
+++ branches/powerups/src/world_entities/power_ups/laser_power_up.cc	(revision 5955)
@@ -79,5 +79,5 @@
 {
  // PRINTF(3)("collision %s vs %s @ (%f,%f,%f)\n", this->getClassName(), entity->getClassName(), location.x, location.y, location.z);
- if (entity->isA(CL_PLAYER))
+ if (entity->isA(CL_PLAYABLE))
   State::getWorldEntityList()->remove(this);
 }
Index: branches/powerups/src/world_entities/power_ups/turret_power_up.cc
===================================================================
--- branches/powerups/src/world_entities/power_ups/turret_power_up.cc	(revision 5874)
+++ branches/powerups/src/world_entities/power_ups/turret_power_up.cc	(revision 5955)
@@ -79,5 +79,5 @@
 {
  // PRINTF(3)("collision %s vs %s @ (%f,%f,%f)\n", this->getClassName(), entity->getClassName(), location.x, location.y, location.z);
- if (entity->isA(CL_PLAYER))
+ if (entity->isA(CL_PLAYABLE))
   State::getWorldEntityList()->remove(this);
 }
Index: branches/powerups/src/world_entities/space_ships/space_ship.cc
===================================================================
--- branches/powerups/src/world_entities/space_ships/space_ship.cc	(revision 5955)
+++ branches/powerups/src/world_entities/space_ships/space_ship.cc	(revision 5955)
@@ -0,0 +1,401 @@
+/*
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2004 orx
+
+   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, or (at your option)
+   any later version.
+
+### File Specific:
+   main-programmer: Benjamin Knecht
+   co-programmer: ...
+
+*/
+
+#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY
+
+#include "executor/executor.h"
+#include "space_ship.h"
+
+#include "objModel.h"
+#include "resource_manager.h"
+
+#include "weapons/weapon_manager.h"
+#include "weapons/test_gun.h"
+#include "weapons/turret.h"
+#include "weapons/cannon.h"
+
+#include "factory.h"
+#include "key_mapper.h"
+
+using namespace std;
+
+CREATE_FACTORY(SpaceShip, CL_SPACE_SHIP);
+
+/**
+ *  creates the controlable Spaceship
+ */
+SpaceShip::SpaceShip()
+{
+  this->init();
+}
+
+/**
+ *  destructs the spaceship, deletes alocated memory
+ */
+SpaceShip::~SpaceShip ()
+{
+}
+
+/**
+ * loads a Spaceships information from a specified file.
+ * @param fileName the name of the File to load the spaceship from (absolute path)
+ */
+SpaceShip::SpaceShip(const char* fileName)
+{
+  this->init();
+  TiXmlDocument doc(fileName);
+
+  if(!doc.LoadFile())
+  {
+    PRINTF(2)("Loading file %s failed for spaceship.\n", fileName);
+    return;
+  }
+
+  this->loadParams(doc.RootElement());
+}
+
+/**
+ *  creates a new Spaceship from Xml Data
+ * @param root the xml element containing spaceship data
+
+   @todo add more parameters to load
+*/
+SpaceShip::SpaceShip(const TiXmlElement* root)
+{
+  this->init();
+  if (root != NULL)
+    this->loadParams(root);
+
+  //weapons:
+  Weapon* wpRight = new TestGun(0);
+  wpRight->setName("testGun Right");
+  Weapon* wpLeft = new TestGun(1);
+  wpLeft->setName("testGun Left");
+  Weapon* cannon = dynamic_cast<Weapon*>(Factory::getFirst()->fabricate(CL_CANNON));
+
+  cannon->setName("BFG");
+
+  this->getWeaponManager()->addWeapon(wpLeft, 1, 0);
+  this->getWeaponManager()->addWeapon(wpRight,1 ,1);
+  this->getWeaponManager()->addWeapon(cannon, 0, 6);
+
+  //this->getWeaponManager()->addWeapon(turret, 3, 0);
+
+  this->getWeaponManager()->changeWeaponConfig(1);
+}
+
+
+/**
+ * initializes a Spaceship
+ */
+void SpaceShip::init()
+{
+//  this->setRelDir(Quaternion(M_PI, Vector(1,0,0)));
+  this->setClassID(CL_SPACE_SHIP, "SpaceShip");
+
+  PRINTF(4)("SPACESHIP INIT\n");
+
+
+  bUp = bDown = bLeft = bRight = bAscend = bDescend = false;
+  bFire = false;
+
+  travelSpeed = 15.0;
+  this->velocity = Vector(0.0,0.0,0.0);
+  this->velocityDir = Vector(1.0,0.0,0.0);
+
+//   GLGuiButton* button = new GLGuiPushButton();
+//   button->show();
+//   button->setLabel("orxonox");
+//   button->setBindNode(this);
+
+  //add events to the eventlist
+  registerEvent(KeyMapper::PEV_UP);
+  registerEvent(KeyMapper::PEV_DOWN);
+  registerEvent(KeyMapper::PEV_LEFT);
+  registerEvent(KeyMapper::PEV_RIGHT);
+  registerEvent(KeyMapper::PEV_FIRE1);
+  registerEvent(KeyMapper::PEV_NEXT_WEAPON);
+  registerEvent(KeyMapper::PEV_PREVIOUS_WEAPON);
+  registerEvent(SDLK_PAGEUP);
+  registerEvent(SDLK_PAGEDOWN);
+
+  this->getWeaponManager()->setSlotCount(7);
+
+  this->getWeaponManager()->setSlotPosition(0, Vector(-2.6, .1, -3.0));
+  this->getWeaponManager()->setSlotCapability(0, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
+
+  this->getWeaponManager()->setSlotPosition(1, Vector(-2.6, .1, 3.0));
+  this->getWeaponManager()->setSlotCapability(1, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
+
+  this->getWeaponManager()->setSlotPosition(2, Vector(-1.5, .5, -.5));
+  this->getWeaponManager()->setSlotDirection(2, Quaternion(-M_PI_4*.5, Vector(1,0,0)));
+
+  this->getWeaponManager()->setSlotPosition(3, Vector(-1.5, .5, .5));
+  this->getWeaponManager()->setSlotDirection(3, Quaternion(M_PI_4*.5, Vector(1,0,0)));
+
+  this->getWeaponManager()->setSlotPosition(4, Vector(-1.5, -.5, .5));
+  this->getWeaponManager()->setSlotDirection(4, Quaternion(-M_PI_4*.5+M_PI, Vector(1,0,0)));
+
+  this->getWeaponManager()->setSlotPosition(5, Vector(-1.5, -.5, -.5));
+  this->getWeaponManager()->setSlotDirection(5, Quaternion(+M_PI_4*.5-M_PI, Vector(1,0,0)));
+//
+   this->getWeaponManager()->setSlotPosition(6, Vector(-1, 0.0, 0));
+   this->getWeaponManager()->setSlotCapability(6, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
+   //
+//   this->getWeaponManager()->setSlotPosition(8, Vector(-2.5, -0.3, -2.0));
+//   this->getWeaponManager()->setSlotDirection(8, Quaternion(-M_PI, Vector(1,0,0)));
+//
+//   this->getWeaponManager()->setSlotPosition(9, Vector(-2.5, -0.3, 2.0));
+//   this->getWeaponManager()->setSlotDirection(9, Quaternion(+M_PI, Vector(1,0,0)));:
+
+}
+
+/**
+ * loads the Settings of a SpaceShip from an XML-element.
+ * @param root the XML-element to load the Spaceship's properties from
+ */
+void SpaceShip::loadParams(const TiXmlElement* root)
+{
+  static_cast<WorldEntity*>(this)->loadParams(root);
+}
+
+
+/**
+ * adds a weapon to the weapon list of the spaceship
+ * @param weapon to add
+*/
+void SpaceShip::addWeapon(Weapon* weapon)
+{
+  this->getWeaponManager()->addWeapon(weapon);
+}
+
+
+/**
+ *  removes a weapon from the spaceship
+ * @param weapon to remove
+*/
+void SpaceShip::removeWeapon(Weapon* weapon)
+{
+  this->getWeaponManager()->removeWeapon(weapon);
+}
+
+/**
+ *  effect that occurs after the SpaceShip is spawned
+*/
+void SpaceShip::postSpawn ()
+{
+  //setCollision(new CollisionCluster(1.0, Vector(0,0,0)));
+}
+
+/**
+ *  the action occuring if the spaceship left the game
+*/
+void SpaceShip::leftWorld ()
+{}
+
+WorldEntity* ref = NULL;
+/**
+ *  this function is called, when two entities collide
+ * @param entity: the world entity with whom it collides
+ *
+ * Implement behaviour like damage application or other miscellaneous collision stuff in this function
+ */
+void SpaceShip::collidesWith(WorldEntity* entity, const Vector& location)
+{
+  if (entity->isA(CL_TURRET_POWER_UP) && entity != ref)
+  {
+    this->ADDWEAPON();
+    ref = entity;
+    }
+//  PRINTF(3)("collision %s vs %s @ (%f,%f,%f)\n", this->getClassName(), entity->getClassName(), location.x, location.y, location.z);
+}
+
+/**
+ *  draws the spaceship after transforming it.
+*/
+void SpaceShip::draw () const
+{
+  glMatrixMode(GL_MODELVIEW);
+  glPushMatrix();
+  /* translate */
+  glTranslatef (this->getAbsCoor ().x,
+                this->getAbsCoor ().y,
+                this->getAbsCoor ().z);
+  /* rotate */
+  Vector tmpRot = this->getAbsDir().getSpacialAxis();
+  glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
+  this->model->draw();
+  glPopMatrix();
+
+  this->getWeaponManager()->draw();
+
+  //this->debug(0);
+}
+
+/**
+ *  the function called for each passing timeSnap
+ * @param time The timespan passed since last update
+*/
+void SpaceShip::tick (float time)
+{
+  // spaceship controlled movement
+  this->calculateVelocity(time);
+
+  Vector move = (velocity)*time;
+
+  //orient the spaceship model in the direction of movement.
+
+  this->shiftCoor (move);
+
+  this->getWeaponManager()->tick(time);
+  // weapon system manipulation
+  this->weaponAction();
+}
+
+/**
+ *  calculate the velocity
+ * @param time the timeslice since the last frame
+*/
+void SpaceShip::calculateVelocity (float time)
+{
+  Vector accel(0.0, 0.0, 0.0);
+  //Vector rot(0.0, 0.0, 0.0);
+  //float rotVal = 0.0;
+  /* FIXME: calculating the direction and orthDirection every timeSlice is redundant! save it somewhere */
+  /* calculate the direction in which the craft is heading  */
+
+  if( this->bUp )
+   {
+     this->shiftCoor(this->getAbsDirX());
+      //if(travelSpeed <= 5000)  travelSpeed += 10;
+   }
+
+  if( this->bDown )
+   {
+     this->shiftCoor(Vector()-this->getAbsDirX());
+     //if(travelSpeed >= 10) travelSpeed -= 10;
+   }
+
+  if( this->bLeft /* > -this->getRelCoor().z*2*/)
+  {
+    this->shiftDir(Quaternion(time, Vector(0,1,0)));
+//    accel -= rightDirection;
+    //velocityDir.normalize();
+    //rot +=Vector(1,0,0);
+    //rotVal -= .4;
+  }
+  if( this->bRight /* > this->getRelCoor().z*2*/)
+  {
+    this->shiftDir(Quaternion(-time, Vector(0,1,0)));
+
+    //    accel += rightDirection;
+    //velocityDir.normalize();
+    //rot += Vector(1,0,0);
+    //rotVal += .4;
+  }
+  if (this->bAscend )
+  {
+    this->shiftDir(Quaternion(time, Vector(0,0,1)));
+
+//    accel += upDirection;
+    //velocityDir.normalize();
+    //rot += Vector(0,0,1);
+    //rotVal += .4;
+  }
+  if (this->bDescend )
+  {
+    this->shiftDir(Quaternion(-time, Vector(0,0,1)));
+
+    //    accel -= upDirection;
+    //velocityDir.normalize();
+    //rot += Vector(0,0,1);
+    //rotVal -= .4;
+  }
+
+  velocity += accel*(time);
+  //rot.normalize();
+  //this->setRelDirSoft(Quaternion(rotVal, rot), 5);
+}
+
+/**
+ * weapon manipulation by the player
+*/
+void SpaceShip::weaponAction()
+{
+  if( this->bFire)
+    {
+      this->getWeaponManager()->fire();
+    }
+}
+
+/**
+ * @todo switch statement ??
+ */
+void SpaceShip::process(const Event &event)
+{
+  if( event.type == KeyMapper::PEV_UP)
+      this->bUp = event.bPressed;
+  else if( event.type == KeyMapper::PEV_DOWN)
+      this->bDown = event.bPressed;
+  else if( event.type == KeyMapper::PEV_RIGHT)
+      this->bRight= event.bPressed;
+  else if( event.type == KeyMapper::PEV_LEFT)
+      this->bLeft = event.bPressed;
+  else if( event.type == KeyMapper::PEV_FIRE1)
+      this->bFire = event.bPressed;
+  else if( event.type == KeyMapper::PEV_NEXT_WEAPON && event.bPressed)
+    this->getWeaponManager()->nextWeaponConfig();//if( !event.bPressed) this->bWeaponChange = !this->bWeaponChange;
+  else if ( event.type == KeyMapper::PEV_PREVIOUS_WEAPON && event.bPressed)
+    this->getWeaponManager()->previousWeaponConfig();
+
+  else if( event.type == SDLK_PAGEUP)
+    this->bAscend = event.bPressed; //this->shiftCoor(0,.1,0);
+  else if( event.type == SDLK_PAGEDOWN)
+    this->bDescend = event.bPressed; //this->shiftCoor(0,-.1,0);
+}
+
+#include "weapons/aiming_turret.h"
+// FIXME THIS MIGHT BE CONSIDERED EITHER A FEATURE, OR A BUG
+void SpaceShip::ADDWEAPON()
+{
+  Weapon* turret = NULL;
+
+  if ((float)rand()/RAND_MAX < .1)
+  {
+    //if (this->getWeaponManager()->hasFreeSlot(2, WTYPE_TURRET))
+    {
+      turret = new Turret();
+      this->getWeaponManager()->addWeapon(turret, 2);
+      this->getWeaponManager()->changeWeaponConfig(2);
+    }
+  }
+  else
+  {
+    //if (this->getWeaponManager()->hasFreeSlot(3))
+    {
+      turret = new AimingTurret();
+      this->getWeaponManager()->addWeapon(turret, 3);
+
+      this->getWeaponManager()->changeWeaponConfig(3);
+    }
+  }
+
+  if(turret != NULL)
+  {
+    turret->setName("Turret");
+    turret->setStateDuration(WS_SHOOTING, (float)rand()/RAND_MAX*.5+.1);
+  }
+}
Index: branches/powerups/src/world_entities/space_ships/space_ship.h
===================================================================
--- branches/powerups/src/world_entities/space_ships/space_ship.h	(revision 5955)
+++ branches/powerups/src/world_entities/space_ships/space_ship.h	(revision 5955)
@@ -0,0 +1,65 @@
+/*!
+ * @file space_ship.h
+ * Implements the Control of a Spaceship
+ */
+
+#ifndef _SPACE_SHIP_H
+#define _SPACE_SHIP_H
+
+#include "playable.h"
+
+template<class T> class tList;
+class Vector;
+class Event;
+
+class SpaceShip : public Playable
+{
+
+  public:
+
+    SpaceShip();
+    SpaceShip(const char* fileName);
+    SpaceShip(const TiXmlElement* root);
+    virtual ~SpaceShip();
+
+    void init();
+    void loadParams(const TiXmlElement* root);
+
+    void addWeapon(Weapon* weapon );
+    void removeWeapon(Weapon* weapon);
+
+    virtual void postSpawn();
+    virtual void leftWorld();
+
+    virtual void collidesWith(WorldEntity* entity, const Vector& location);
+    virtual void tick(float time);
+    virtual void draw() const;
+
+    virtual void process(const Event &event);
+
+
+
+  private:
+
+    void calculateVelocity(float time);
+    void weaponAction();
+
+    // !! temporary !!
+    void ADDWEAPON();
+
+    bool                  bUp;                //!< up button pressed.
+    bool                  bDown;              //!< down button pressed.
+    bool                  bLeft;              //!< left button pressed.
+    bool                  bRight;             //!< right button pressed.
+    bool                  bAscend;            //!< ascend button pressed.
+    bool                  bDescend;           //!< descend button presses.
+    bool                  bFire;              //!< fire button pressed.
+
+    Vector                velocity;           //!< the velocity of the player.
+    Vector                velocityDir;        //!< the direction of the velocity of the spaceship
+    float                 travelSpeed;        //!< the current speed of the player (to make soft movement)
+    float                 acceleration;       //!< the acceleration of the player.
+
+};
+
+#endif /* _SPACE_SHIPS_H */
Index: branches/powerups/src/world_entities/weapons/aiming_turret.cc
===================================================================
--- branches/powerups/src/world_entities/weapons/aiming_turret.cc	(revision 5874)
+++ branches/powerups/src/world_entities/weapons/aiming_turret.cc	(revision 5955)
@@ -26,5 +26,4 @@
 
 #include "animation3d.h"
-#include "sound_engine.h"
 
 #include "factory.h"
@@ -93,5 +92,5 @@
 
   this->setCapability(WTYPE_ALLDIRS | WTYPE_TURRET);
-  this->setProjectileType(CL_ROCKET);
+  this->setProjectileType(CL_GUIDED_MISSILE);
 
 
@@ -142,7 +141,8 @@
     return;
 
-    pj->setVelocity(/*this->getVelocity()+*/(this->getAbsDir().apply(Vector(1,0,0))*250.0 + VECTOR_RAND(13)
+  pj->setVelocity(/*this->getVelocity()+*/(this->getAbsDir().apply(Vector(1,0,0))*250.0 + VECTOR_RAND(13)
             /*target->getAbsCoor() - this->getAbsCoor()*/)*.5);//this->getVelocity());
 
+  pj->setTarget(this->target->getParent());
   pj->setParent(NullParent::getInstance());
   pj->setAbsCoor(this->getEmissionPoint());
Index: branches/powerups/src/world_entities/weapons/cannon.cc
===================================================================
--- branches/powerups/src/world_entities/weapons/cannon.cc	(revision 5874)
+++ branches/powerups/src/world_entities/weapons/cannon.cc	(revision 5955)
@@ -32,5 +32,4 @@
 #include "list.h"
 #include "animation3d.h"
-#include "sound_engine.h"
 
 #include "null_parent.h"
Index: branches/powerups/src/world_entities/weapons/ground_turret.cc
===================================================================
--- branches/powerups/src/world_entities/weapons/ground_turret.cc	(revision 5874)
+++ branches/powerups/src/world_entities/weapons/ground_turret.cc	(revision 5955)
@@ -145,5 +145,6 @@
 void GroundTurret::collidesWith (WorldEntity* entity, const Vector& location)
 {
-
+  if (entity->isA(CL_PROJECTILE))
+    this->setAbsDirSoft(Quaternion(-90, Vector(0,0,1)), 90);
 }
 
Index: branches/powerups/src/world_entities/weapons/guided_missile.cc
===================================================================
--- branches/powerups/src/world_entities/weapons/guided_missile.cc	(revision 5874)
+++ branches/powerups/src/world_entities/weapons/guided_missile.cc	(revision 5955)
@@ -48,6 +48,6 @@
   this->energyMin = 1;
   this->energyMax = 10;
-  this->lifeSpan = 5;
-  this->agility = 5;
+  this->lifeSpan = 5.0;
+  this->agility = 5.0;
   this->maxVelocity = 100;
 
Index: branches/powerups/src/world_entities/weapons/test_gun.cc
===================================================================
--- branches/powerups/src/world_entities/weapons/test_gun.cc	(revision 5874)
+++ branches/powerups/src/world_entities/weapons/test_gun.cc	(revision 5955)
@@ -32,5 +32,4 @@
 #include "list.h"
 #include "animation3d.h"
-#include "sound_engine.h"
 
 #include "null_parent.h"
Index: branches/powerups/src/world_entities/weapons/turret.cc
===================================================================
--- branches/powerups/src/world_entities/weapons/turret.cc	(revision 5874)
+++ branches/powerups/src/world_entities/weapons/turret.cc	(revision 5955)
@@ -26,5 +26,4 @@
 #include "list.h"
 #include "animation3d.h"
-#include "sound_engine.h"
 
 #include "factory.h"
Index: branches/powerups/src/world_entities/weapons/weapon.cc
===================================================================
--- branches/powerups/src/world_entities/weapons/weapon.cc	(revision 5874)
+++ branches/powerups/src/world_entities/weapons/weapon.cc	(revision 5955)
@@ -28,7 +28,9 @@
 #include "load_param.h"
 #include "state.h"
-#include "sound_engine.h"
 #include "animation3d.h"
 #include "vector.h"
+
+#include "sound_source.h"
+#include "sound_buffer.h"
 
 ////////////////////
Index: branches/powerups/src/world_entities/weapons/weapon_manager.cc
===================================================================
--- branches/powerups/src/world_entities/weapons/weapon_manager.cc	(revision 5874)
+++ branches/powerups/src/world_entities/weapons/weapon_manager.cc	(revision 5955)
@@ -110,6 +110,4 @@
   this->crossHairSizeAnim->addKeyFrame(100, .05, ANIM_LINEAR);
   this->crossHairSizeAnim->addKeyFrame(50, .01, ANIM_LINEAR);
-
-  this->targetIterator = NULL;
 }
 
@@ -337,49 +335,4 @@
     }
   }
-}
-
-
-/**
- * Selects an Entity from the NPC-list, and returns the Target
- */
-PNode* WeaponManager::getSomeTarget()
-{
-   if (this->targetIterator == NULL)
-   {
-     std::list<BaseObject*>* npcList = ClassList::getList(CL_NPC);
-     if (npcList != NULL)
-     {
-       this->targetIterator = npcList->begin();
-     }
-     else
-       return NULL;
-   }
-
-   ///FIXME
-//   this->targetIterator++;
-   PNode* retNode = dynamic_cast<PNode*>((*targetIterator));
-//   if (retNode == NULL && this->targetIterator->getList()->getSize() > 0)
-//     retNode =  dynamic_cast<PNode*>(targetIterator->firstElement());
-
-   return retNode;
-}
-
-
-/**
- * Selects an Entity from the Entity-List, that is near of the carrier PNode.
- * @param carrier: The PNode from which the distance should be measured
- * @param distance: The Maximum Distance to Return.
- */
-PNode* WeaponManager::getDistanceTarget(const PNode* carrier, float distance)
-{
-  std::list<BaseObject*>* npcList = ClassList::getList(CL_NPC);
-  if (npcList != NULL)
-  {
-    list<BaseObject*>::iterator node;
-    for (node= npcList->begin(); node != npcList->end(); node++)
-      if ((carrier->getAbsCoor() - dynamic_cast<PNode*>(*node)->getAbsCoor()).len() < distance)
-        return dynamic_cast<PNode*>(*node);
-  }
-  return this->getFixedTarget();
 }
 
Index: branches/powerups/src/world_entities/weapons/weapon_manager.h
===================================================================
--- branches/powerups/src/world_entities/weapons/weapon_manager.h	(revision 5874)
+++ branches/powerups/src/world_entities/weapons/weapon_manager.h	(revision 5955)
@@ -80,6 +80,4 @@
     /** @returns a fixed target namely the Crosshair's 3D position */
     inline PNode* getFixedTarget() const { return this->crosshair; };
-    PNode* getSomeTarget();
-    PNode* getDistanceTarget(const PNode* carrier, float distance);
 
     void fire();
@@ -109,5 +107,3 @@
     Crosshair*              crosshair;                                //!< an aim.
     tAnimation<Crosshair>*  crossHairSizeAnim;                        //!< An animation for the crosshair (scaling)
-
-    std::list<BaseObject*>::iterator  targetIterator;                           //!< An iterator for traversion lists of enemies.
 };
