Index: code/branches/hud/src/asylum/orxonox/objects/weapon/AmmunitionDump.cc
===================================================================
--- code/branches/hud/src/asylum/orxonox/objects/weapon/AmmunitionDump.cc	(revision 1620)
+++ code/branches/hud/src/asylum/orxonox/objects/weapon/AmmunitionDump.cc	(revision 1620)
@@ -0,0 +1,127 @@
+/*
+ *   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:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "AmmunitionDump.h"
+
+#include "orxonox/Orxonox.h"
+#include "BulletManager.h"
+#include "tinyxml/tinyxml.h"
+#include "core/CoreIncludes.h"
+
+
+namespace orxonox {
+  CreateFactory(AmmunitionDump);
+
+  AmmunitionDump::AmmunitionDump()
+    : numberOfAmmos_(Orxonox::getSingleton()->getBulletMgr()->getNumberOfAmmos()),
+      stock_(new int[numberOfAmmos_]),
+      capacity_(new int[numberOfAmmos_])
+  {
+    RegisterObject(AmmunitionDump);
+    registerAllVariables();
+
+    for (int i = 0; i < numberOfAmmos_; i++)
+    {
+      stock_[i] = 0;
+      capacity_[i] = 0;
+    }
+  }
+
+
+  AmmunitionDump::~AmmunitionDump()
+  {
+    if (stock_)
+      delete stock_;
+    if (capacity_)
+      delete capacity_;
+  }
+
+  void AmmunitionDump::setDumpSize(const std::string &name, int size)
+  {
+    if (size < 0)
+      return;
+    int id = Orxonox::getSingleton()->getBulletMgr()->getAmmunitionID(name);
+    if (id == -1)
+      return;
+    capacity_[id] = size;
+  }
+
+
+  int AmmunitionDump::store(const std::string &name, int quantity)
+  {
+    int id = Orxonox::getSingleton()->getBulletMgr()->getAmmunitionID(name);
+    if (id == -1)
+      return quantity;
+    stock_[id] += quantity;
+    if (stock_[id] > capacity_[id])
+    {
+      quantity = capacity_[id] - stock_[id];
+      stock_[id] = capacity_[id];
+      return quantity;
+    }
+    else
+      return 0;
+  }
+
+
+  int AmmunitionDump::getAmmunition(const std::string &name, int quantity)
+  {
+    int id = Orxonox::getSingleton()->getBulletMgr()->getAmmunitionID(name);
+    if (id == -1)
+      return 0;
+    if (stock_[id] >= quantity)
+      stock_[id] -= quantity;
+    else
+    {
+      quantity = stock_[id];
+      stock_[id] = 0;
+    }
+    return quantity;
+  }
+
+
+  int AmmunitionDump::getStockSize(const std::string &name)
+  {
+    int id = Orxonox::getSingleton()->getBulletMgr()->getAmmunitionID(name);
+    // FIXME changed = to ==, check if correct
+    if (id == -1)
+      return -1;
+    return stock_[id];
+  }
+
+  void AmmunitionDump::registerAllVariables(){
+    registerVar( &numberOfAmmos_, sizeof(int), network::DATA);
+
+    for (int i = 0; i < numberOfAmmos_; i++)
+    {
+      registerVar(&stock_[i], sizeof(int), network::DATA);
+      registerVar(&capacity_[i], sizeof(int), network::DATA);
+    }
+  }
+}
Index: code/branches/hud/src/asylum/orxonox/objects/weapon/AmmunitionDump.h
===================================================================
--- code/branches/hud/src/asylum/orxonox/objects/weapon/AmmunitionDump.h	(revision 1620)
+++ code/branches/hud/src/asylum/orxonox/objects/weapon/AmmunitionDump.h	(revision 1620)
@@ -0,0 +1,69 @@
+/*
+ *   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 3 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, see <http://www.gnu.org/licenses/>.
+ *
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+
+#ifndef _AmmunitionDump_H__
+#define _AmmunitionDump_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <string>
+
+#include <OgrePrerequisites.h>
+
+#include "network/Synchronisable.h"
+#include "core/BaseObject.h"
+
+
+namespace orxonox {
+  class _OrxonoxExport AmmunitionDump : public BaseObject, public network::Synchronisable
+  {
+  public:
+    AmmunitionDump();
+	  ~AmmunitionDump();
+
+    void setDumpSize(const std::string &name, int size);
+
+    int store(const std::string &name, int quantiy);
+
+    int getAmmunition(const std::string &name, int quantity);
+
+    int getStockSize(const std::string &name);
+
+
+  protected:
+    inline bool create() { return Synchronisable::create(); }
+    void registerAllVariables();
+
+    int numberOfAmmos_;
+    int *stock_;
+    int *capacity_;
+  };
+}
+
+#endif /* _AmmunitionDump_H__ */
Index: code/branches/hud/src/asylum/orxonox/objects/weapon/BarrelGun.cc
===================================================================
--- code/branches/hud/src/asylum/orxonox/objects/weapon/BarrelGun.cc	(revision 1620)
+++ code/branches/hud/src/asylum/orxonox/objects/weapon/BarrelGun.cc	(revision 1620)
@@ -0,0 +1,147 @@
+/*
+ *   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:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "BarrelGun.h"
+
+#include <OgreStringConverter.h>
+#include <OgreSceneNode.h>
+#include <OgreEntity.h>
+#include <OgreSceneManager.h>
+
+#include "util/Math.h"
+#include "Bullet.h"
+#include "BulletManager.h"
+#include "AmmunitionDump.h"
+#include "BaseWeapon.h"
+#include "core/CoreIncludes.h"
+
+
+namespace orxonox {
+  CreateFactory(BarrelGun);
+
+  BarrelGun::BarrelGun()
+  {
+    RegisterObject(BarrelGun);
+
+    primaryFirePower_ = 100;
+    secondaryFirePower_ = 500;
+    primaryFiringRate_ = 1.0/7.0;
+    secondaryFiringRate_ = 1.0/2.0;
+    primaryBulletSpeed_ = 800;
+    secondaryBulletSpeed_ = 500;
+    magazineSize_ = 25;
+  }
+
+
+  BarrelGun::~BarrelGun()
+  {
+  }
+
+
+  void BarrelGun::primaryFire()
+  {
+    if (leftAmmo_ < 1)
+    {
+      currentState_ = IDLE;
+      return;
+    }
+
+    Ogre::SceneNode *temp = sceneMgr_->getRootSceneNode()->createChildSceneNode(
+          getNode()->getWorldPosition(),
+          getNode()->getWorldOrientation());
+
+    Ogre::Entity* bulletEntity = sceneMgr_->createEntity("BulletEntity"
+      + Ogre::StringConverter::toString(bulletCounter_++), "Barrel.mesh");
+
+    Vector3 speed = (temp->getOrientation() * Vector3(1, 0, 0))
+          .normalisedCopy() * primaryBulletSpeed_;
+    speed += getVelocity();
+
+	  temp->setScale(Vector3(1, 1, 1) * 1.5);
+    temp->roll(Degree(90));
+
+    Bullet* bullet = new Bullet();
+    bullet->setNode(temp);
+    bullet->attachObject(bulletEntity);
+    bullet->setVelocity(speed);
+	  bulletManager_->addBullet(bullet);
+
+    --leftAmmo_;
+  }
+
+
+  void BarrelGun::primaryFiring(float time)
+  {
+    if (time > primaryFiringRate_)
+    {
+      currentState_ = IDLE;
+    }
+  }
+
+
+  void BarrelGun::secondaryFire()
+  {
+    if (leftAmmo_ < 5)
+    {
+      currentState_ = IDLE;
+      return;
+    }
+
+    Ogre::SceneNode *temp = sceneMgr_->getRootSceneNode()->createChildSceneNode(
+          getNode()->getWorldPosition(),
+          getNode()->getWorldOrientation());
+
+    Ogre::Entity* bulletEntity = sceneMgr_->createEntity("BulletEntity"
+      + Ogre::StringConverter::toString(bulletCounter_++), "Barrel.mesh");
+
+    Vector3 speed = (temp->getOrientation() * Vector3(1, 0, 0))
+          .normalisedCopy() * secondaryBulletSpeed_*0.5;
+    speed += getVelocity();
+
+	  temp->setScale(Vector3(1, 1, 1) * 3);
+	  temp->roll(Degree(90));
+
+    Bullet* bullet = new Bullet();
+    bullet->setNode(temp);
+    bullet->attachObject(bulletEntity);
+    bullet->setVelocity(speed);
+	  bulletManager_->addBullet(bullet);
+
+
+    leftAmmo_ -= 5;
+  }
+
+
+  void BarrelGun::secondaryFiring(float time)
+  {
+    if (time > secondaryFiringRate_)
+      currentState_ = IDLE;
+  }
+
+}
Index: code/branches/hud/src/asylum/orxonox/objects/weapon/BarrelGun.h
===================================================================
--- code/branches/hud/src/asylum/orxonox/objects/weapon/BarrelGun.h	(revision 1620)
+++ code/branches/hud/src/asylum/orxonox/objects/weapon/BarrelGun.h	(revision 1620)
@@ -0,0 +1,65 @@
+/*
+ *   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 3 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, see <http://www.gnu.org/licenses/>.
+ *
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+
+#ifndef _BarrelGun_H__
+#define _BarrelGun_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <OgrePrerequisites.h>
+
+#include "BaseWeapon.h"
+
+
+namespace orxonox {
+  class _OrxonoxExport BarrelGun : public BaseWeapon
+  {
+ public:
+    BarrelGun();
+	  virtual ~BarrelGun();
+
+    //virtual void tick(float dt);
+
+  protected:
+    void primaryFire();
+
+    void primaryFiring(float);
+
+    void secondaryFire();
+
+    void secondaryFiring(float);
+
+  public:
+
+  protected:
+
+  };
+}
+
+#endif /* _BarrelGun_H__ */
Index: code/branches/hud/src/asylum/orxonox/objects/weapon/BaseWeapon.cc
===================================================================
--- code/branches/hud/src/asylum/orxonox/objects/weapon/BaseWeapon.cc	(revision 1620)
+++ code/branches/hud/src/asylum/orxonox/objects/weapon/BaseWeapon.cc	(revision 1620)
@@ -0,0 +1,186 @@
+/*
+ *   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:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "BaseWeapon.h"
+
+#include <OgreStringConverter.h>
+#include <OgreSceneNode.h>
+#include <OgreEntity.h>
+#include <OgreSceneManager.h>
+
+#include "util/Math.h"
+#include "Orxonox.h"
+#include "Bullet.h"
+#include "BulletManager.h"
+#include "AmmunitionDump.h"
+#include "core/CoreIncludes.h"
+
+
+namespace orxonox {
+  float BaseWeapon::nextActionValidityPeriod_s = 0.5;
+
+  BaseWeapon::BaseWeapon()
+    : sceneMgr_(GraphicsEngine::getSingleton().getSceneManager()),
+      bulletCounter_(0),
+      bulletManager_(Orxonox::getSingleton()->getBulletMgr()),
+      ammoDump_(NULL),
+      primaryFireRequest_(false), secondaryFireRequest_(false),
+      totalTime_(0.0f), actionStartTime_(0.0f),
+      currentState_(IDLE), secondaryFired_(false),
+      nextAction_(NOTHING), actionAdded_(false),
+      timeSinceNextActionAdded_(0.0f),
+      leftAmmo_(0)
+  {
+    RegisterObject(BaseWeapon);
+  }
+
+
+  BaseWeapon::~BaseWeapon()
+  {
+  }
+
+
+  bool BaseWeapon::addAction(const Action act)
+  {
+    if (nextAction_ == NOTHING)
+    {
+      nextAction_ = act;
+      actionAdded_ = true;
+      return true;
+    }
+    else
+      return false;
+  }
+
+
+  void BaseWeapon::primaryFireRequest()
+  {
+    primaryFireRequest_ = true;
+  }
+
+
+  void BaseWeapon::secondaryFireRequest()
+  {
+    secondaryFireRequest_ = true;
+  }
+
+
+  void BaseWeapon::tick(float dt)
+  {
+    totalTime_ += dt;
+    // process action adder
+    if (actionAdded_)
+    {
+      timeSinceNextActionAdded_ = totalTime_;
+      actionAdded_ = false;
+    }
+
+    switch (currentState_)
+    {
+    case IDLE:
+      break;
+
+    case PRIMARY_FIRE:
+      primaryFiring(totalTime_ - actionStartTime_);
+      break;
+
+    case SECONDARY_FIRE:
+      secondaryFiring(totalTime_ - actionStartTime_);
+      break;
+
+    case RELOADING:
+      break;
+
+    case CHANGING_AMMO:
+      break;
+    }
+
+    if (currentState_ == IDLE)
+    {
+      // first, process next action
+      if (nextAction_ != NOTHING)
+      {
+        actionStartTime_ = totalTime_;
+        switch (nextAction_)
+        {
+        case RELOAD:
+          leftAmmo_ += ammoDump_->getAmmunition("Barrel", magazineSize_ - leftAmmo_);
+          break;
+
+        case CHANGE_AMMO:
+          break;
+
+        case SPECIAL:
+          break;
+
+        default:
+          break;
+        }
+
+        // pay attention when multithreaded!
+        nextAction_ = NOTHING;
+      }
+      else
+      {
+        // secondly, execute firing
+        if (primaryFireRequest_ && !(secondaryFired_ && secondaryFireRequest_))
+        {
+          actionStartTime_ = totalTime_;
+          currentState_ = PRIMARY_FIRE;
+          secondaryFired_ = false;
+          primaryFire();
+        }
+        else if (secondaryFireRequest_)
+        {
+          actionStartTime_ = totalTime_;
+          currentState_ = SECONDARY_FIRE;
+          secondaryFired_ = true;
+          secondaryFire();
+        }
+      }
+    }
+
+    primaryFireRequest_ = false;
+    secondaryFireRequest_ = false;
+
+    if (totalTime_ - timeSinceNextActionAdded_ > nextActionValidityPeriod_s)
+      nextAction_ = NOTHING;
+  }
+
+
+  int BaseWeapon::getAmmoState()
+  {
+    return leftAmmo_;
+  }
+
+  void BaseWeapon::setAmmoDump(AmmunitionDump* dump)
+  {
+    this->ammoDump_ = dump;
+  }
+}
Index: code/branches/hud/src/asylum/orxonox/objects/weapon/BaseWeapon.h
===================================================================
--- code/branches/hud/src/asylum/orxonox/objects/weapon/BaseWeapon.h	(revision 1620)
+++ code/branches/hud/src/asylum/orxonox/objects/weapon/BaseWeapon.h	(revision 1620)
@@ -0,0 +1,125 @@
+/*
+ *   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:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+
+#ifndef _BaseWeapon_H__
+#define _BaseWeapon_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <OgrePrerequisites.h>
+
+#include "../Model.h"
+
+
+namespace orxonox {
+  class _OrxonoxExport BaseWeapon : public Model
+  {
+  public:
+    enum Action {
+      NOTHING  = 0,
+      RELOAD   = 1,
+      CHANGE_AMMO  = 2,
+      SPECIAL  = 3
+    };
+
+  protected:
+    enum State {
+      IDLE = 0,
+      PRIMARY_FIRE = 1,
+      SECONDARY_FIRE = 2,
+      RELOADING = 3,
+      CHANGING_AMMO = 4,
+    };
+
+  public:
+    BaseWeapon();
+	  virtual ~BaseWeapon();
+
+    bool addAction(const Action);
+
+    void primaryFireRequest();
+
+    void secondaryFireRequest();
+
+    int getAmmoState();
+
+    void setAmmoDump(AmmunitionDump*);
+
+    virtual void tick(float dt);
+
+  protected:
+    virtual void primaryFire() = 0;
+
+    virtual void primaryFiring(float) = 0;
+
+    virtual void secondaryFire() = 0;
+
+    virtual void secondaryFiring(float) = 0;
+
+    virtual void registerAllVariables() { };
+
+  public:
+
+  protected:
+    Ogre::SceneManager *sceneMgr_;
+
+    int bulletCounter_;
+    BulletManager *bulletManager_;
+
+    AmmunitionDump *ammoDump_;
+
+    bool primaryFireRequest_;
+    bool secondaryFireRequest_;
+
+    float totalTime_;
+    float actionStartTime_;
+
+    State currentState_;
+    bool secondaryFired_;
+
+    Action nextAction_;
+    bool actionAdded_;
+    float timeSinceNextActionAdded_;
+    static float nextActionValidityPeriod_s;
+
+    // weapon properties
+    int leftAmmo_;
+    float primaryFirePower_;
+    float secondaryFirePower_;
+    float primaryFiringRate_;
+    float secondaryFiringRate_;
+    Real primaryBulletSpeed_;
+    Real secondaryBulletSpeed_;
+
+    int magazineSize_;
+
+  };
+}
+
+#endif /* _BaseWeapon_H__ */
Index: code/branches/hud/src/asylum/orxonox/objects/weapon/Bullet.cc
===================================================================
--- code/branches/hud/src/asylum/orxonox/objects/weapon/Bullet.cc	(revision 1620)
+++ code/branches/hud/src/asylum/orxonox/objects/weapon/Bullet.cc	(revision 1620)
@@ -0,0 +1,46 @@
+/*
+ *   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:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "Bullet.h"
+
+#include "core/CoreIncludes.h"
+
+
+namespace orxonox {
+  CreateFactory(Bullet);
+
+  Bullet::Bullet()
+  {
+    RegisterObject(Bullet);
+  }
+
+  Bullet::~Bullet()
+  {
+  }
+}
Index: code/branches/hud/src/asylum/orxonox/objects/weapon/Bullet.h
===================================================================
--- code/branches/hud/src/asylum/orxonox/objects/weapon/Bullet.h	(revision 1620)
+++ code/branches/hud/src/asylum/orxonox/objects/weapon/Bullet.h	(revision 1620)
@@ -0,0 +1,50 @@
+/*
+ *   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 3 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, see <http://www.gnu.org/licenses/>.
+ *
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+
+#ifndef _Bullet_H__
+#define _Bullet_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <OgrePrerequisites.h>
+
+#include "../Model.h"
+
+namespace orxonox {
+  class _OrxonoxExport Bullet : public Model
+  {
+  public:
+	  Bullet();
+	  ~Bullet();
+
+    virtual void tick(float dt) { }
+ };
+}
+
+#endif /* _Bullet_H__ */
Index: code/branches/hud/src/asylum/orxonox/objects/weapon/BulletManager.cc
===================================================================
--- code/branches/hud/src/asylum/orxonox/objects/weapon/BulletManager.cc	(revision 1620)
+++ code/branches/hud/src/asylum/orxonox/objects/weapon/BulletManager.cc	(revision 1620)
@@ -0,0 +1,114 @@
+/*
+ *   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:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "BulletManager.h"
+
+#include "Bullet.h"
+#include "core/CoreIncludes.h"
+
+
+namespace orxonox {
+  CreateFactory(BulletManager);
+
+  BulletManager::BulletManager() : bulletsSize_(8), bulletsIndex_(0)
+  {
+    RegisterObject(BulletManager);
+    registerAllVariables();
+    bullets_ = new Bullet*[bulletsSize_];
+  }
+
+
+  BulletManager::~BulletManager()
+  {
+    // clean up the bullet list
+    if (bullets_)
+    {
+      for (int i = 0; i < bulletsIndex_; i++)
+        delete bullets_[i];
+      delete bullets_;
+    }
+  }
+
+
+  void BulletManager::addBullet(Bullet *bullet)
+  {
+    // resize array if neccessary (double the size then)
+    if (bulletsIndex_ >= bulletsSize_)
+    {
+      // redimension the array
+      Bullet **tempArray = new Bullet*[2*bulletsSize_];
+      for (int i = 0; i < bulletsSize_; i++)
+        tempArray[i] = bullets_[i];
+      bulletsSize_ *= 2;
+      delete bullets_;
+      bullets_ = tempArray;
+    }
+
+    // add the bullet to the list
+    bullets_[bulletsIndex_++] = bullet;
+  }
+
+
+  void BulletManager::tick(float dt)
+  {
+    // update the bullet positions
+    for (int i = 0; i < bulletsIndex_; i++)
+    {
+      bullets_[i]->getNode()->translate(bullets_[i]->getVelocity()*dt);
+      //bullets_[i]->getNode()->yaw(Degree(dt*100));
+      //bullets_[i]->getNode()->roll(Degree(dt*300));
+    }
+  }
+
+  int BulletManager::getAmmunitionID(const std::string &ammoName)
+  {
+    std::string ammoTypes[] = { "Energy Cell", "Barrel", "Lead Shot" };
+    int ammoTypesLength = 3;
+
+    for (int i = 0; i < ammoTypesLength; i++)
+    {
+      if (ammoTypes[i] == ammoName)
+        return i;
+    }
+    return -1;
+  }
+
+  int BulletManager::getNumberOfAmmos()
+  {
+    return 3;
+  }
+
+  void BulletManager::registerAllVariables(){
+    registerVar(&bulletsSize_, sizeof(int), network::DATA);
+    registerVar(&bulletsIndex_, sizeof(int), network::DATA);
+    // TODO we got a problem here:
+    // there is no possibility (so far) to synchronise pointers to objects
+  }
+
+}
Index: code/branches/hud/src/asylum/orxonox/objects/weapon/BulletManager.h
===================================================================
--- code/branches/hud/src/asylum/orxonox/objects/weapon/BulletManager.h	(revision 1620)
+++ code/branches/hud/src/asylum/orxonox/objects/weapon/BulletManager.h	(revision 1620)
@@ -0,0 +1,70 @@
+/*
+ *   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 3 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, see <http://www.gnu.org/licenses/>.
+ *
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+
+#ifndef _BulletManager_H__
+#define _BulletManager_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <string>
+
+#include <OgrePrerequisites.h>
+
+#include "network/Synchronisable.h"
+#include "tinyxml/tinyxml.h"
+#include "core/BaseObject.h"
+#include "core/Tickable.h"
+
+namespace orxonox {
+  class _OrxonoxExport BulletManager : public BaseObject, public network::Synchronisable, public Tickable
+  {
+  public:
+    BulletManager();
+	  virtual ~BulletManager();
+
+    void addBullet(Bullet*);
+
+    int getAmmunitionID(const std::string&);
+
+    int getNumberOfAmmos();
+
+    virtual void tick(float dt);
+
+  protected:
+    inline bool create() { return Synchronisable::create(); }
+    void registerAllVariables();
+
+    // Bullet array
+	  Bullet **bullets_;
+	  int bulletsSize_;
+	  int bulletsIndex_;
+  };
+}
+
+#endif /* _BulletManager_H__ */
Index: code/branches/hud/src/asylum/orxonox/objects/weapon/WeaponStation.cc
===================================================================
--- code/branches/hud/src/asylum/orxonox/objects/weapon/WeaponStation.cc	(revision 1620)
+++ code/branches/hud/src/asylum/orxonox/objects/weapon/WeaponStation.cc	(revision 1620)
@@ -0,0 +1,71 @@
+/*
+ *   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:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "WeaponStation.h"
+
+#include "BaseWeapon.h"
+
+
+namespace orxonox {
+  WeaponStation::WeaponStation(int stationSize)
+        : slots_(new BaseWeapon*[stationSize]),
+          lastActiveSlotIndex_(-1), stationSize_(stationSize)
+  {
+  	//slots_ = new BaseWeapon*[stationSize];
+  }
+
+
+  WeaponStation::~WeaponStation()
+  {
+    if (slots_)
+      delete slots_;
+    // when factory available: delete weapons too
+  }
+
+
+  bool WeaponStation::addWeapon(BaseWeapon *weapon)
+  {
+    if (lastActiveSlotIndex_ == stationSize_ - 1)
+      return false;
+
+    // this is ugly, but for the time being, it has to fit.
+    slots_[++lastActiveSlotIndex_] = weapon;
+    selectedSlot_ = slots_ + lastActiveSlotIndex_;
+    return true;
+  }
+
+
+  BaseWeapon* WeaponStation::selectWeapon(int slotNumber)
+  {
+    if (slotNumber < lastActiveSlotIndex_)
+      return NULL;
+    return slots_[slotNumber];
+  }
+
+}
Index: code/branches/hud/src/asylum/orxonox/objects/weapon/WeaponStation.h
===================================================================
--- code/branches/hud/src/asylum/orxonox/objects/weapon/WeaponStation.h	(revision 1620)
+++ code/branches/hud/src/asylum/orxonox/objects/weapon/WeaponStation.h	(revision 1620)
@@ -0,0 +1,66 @@
+/*
+ *   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 3 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, see <http://www.gnu.org/licenses/>.
+ *
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+
+#ifndef _WeaponStation_H__
+#define _WeaponStation_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <OgrePrerequisites.h>
+
+
+namespace orxonox {
+  class _OrxonoxExport WeaponStation
+  {
+  public:
+    WeaponStation(int slotSize);
+	  ~WeaponStation();
+
+    bool addWeapon(BaseWeapon*);
+
+    //bool removeCurrentWeapon();
+
+    // TODO: access every weapon by name
+    BaseWeapon* selectWeapon(int slotNumber);
+
+  protected:
+
+  public:
+
+  protected:
+    // slot management
+    BaseWeapon **slots_;
+    BaseWeapon **selectedSlot_;
+    int lastActiveSlotIndex_;
+    int stationSize_;
+
+  };
+}
+
+#endif /* _WeaponStation_H__ */
