Index: /branches/world_entities/src/lib/graphics/light.cc
===================================================================
--- /branches/world_entities/src/lib/graphics/light.cc	(revision 5621)
+++ /branches/world_entities/src/lib/graphics/light.cc	(revision 5622)
@@ -29,5 +29,5 @@
 using namespace std;
 
-CREATE_FACTORY(Light);
+CREATE_FACTORY(Light, CL_LIGHT);
 
 //! Definition of the Lights and their Names
Index: /branches/world_entities/src/lib/gui/gl_gui/glmenu/glmenu_imagescreen.cc
===================================================================
--- /branches/world_entities/src/lib/gui/gl_gui/glmenu/glmenu_imagescreen.cc	(revision 5621)
+++ /branches/world_entities/src/lib/gui/gl_gui/glmenu/glmenu_imagescreen.cc	(revision 5622)
@@ -25,5 +25,5 @@
 #include "load_param.h"
 
-CREATE_FACTORY(GLMenuImageScreen);
+CREATE_FACTORY(GLMenuImageScreen, CL_GLMENU_IMAGE_SCREEN);
 
 using namespace std;
Index: /branches/world_entities/src/lib/particles/particle_emitter.cc
===================================================================
--- /branches/world_entities/src/lib/particles/particle_emitter.cc	(revision 5621)
+++ /branches/world_entities/src/lib/particles/particle_emitter.cc	(revision 5622)
@@ -28,5 +28,5 @@
 
 
-CREATE_FACTORY(ParticleEmitter);
+CREATE_FACTORY(ParticleEmitter, CL_PARTICLE_EMITTER);
 
 /**
Index: /branches/world_entities/src/lib/particles/particle_system.cc
===================================================================
--- /branches/world_entities/src/lib/particles/particle_system.cc	(revision 5621)
+++ /branches/world_entities/src/lib/particles/particle_system.cc	(revision 5622)
@@ -32,5 +32,5 @@
 #include "tinyxml.h"
 
-CREATE_FACTORY(ParticleSystem);
+CREATE_FACTORY(ParticleSystem, CL_PARTICLE_SYSTEM);
 SHELL_COMMAND(texture, ParticleSystem, setMaterialTexture)
     ->defaultValues(1, "maps/evil-flower.png");
Index: /branches/world_entities/src/lib/physics/fields/gravity.cc
===================================================================
--- /branches/world_entities/src/lib/physics/fields/gravity.cc	(revision 5621)
+++ /branches/world_entities/src/lib/physics/fields/gravity.cc	(revision 5622)
@@ -23,5 +23,5 @@
 using namespace std;
 
-CREATE_FACTORY(Gravity);
+CREATE_FACTORY(Gravity, CL_FIELD_GRAVITY);
 
 Gravity::Gravity(const TiXmlElement* root)
Index: /branches/world_entities/src/lib/physics/physics_connection.cc
===================================================================
--- /branches/world_entities/src/lib/physics/physics_connection.cc	(revision 5621)
+++ /branches/world_entities/src/lib/physics/physics_connection.cc	(revision 5622)
@@ -29,5 +29,5 @@
 using namespace std;
 
-CREATE_FACTORY(PhysicsConnection);
+CREATE_FACTORY(PhysicsConnection, CL_PHYSICS_CONNECTION);
 
 /**
Index: /branches/world_entities/src/story_entities/world.cc
===================================================================
--- /branches/world_entities/src/story_entities/world.cc	(revision 5621)
+++ /branches/world_entities/src/story_entities/world.cc	(revision 5622)
@@ -81,5 +81,5 @@
 
 //! This creates a Factory to fabricate a World
-CREATE_FACTORY(World);
+CREATE_FACTORY(World, CL_WORLD);
 
 World::World(const TiXmlElement* root)
Index: /branches/world_entities/src/subprojects/collision_detection/collision_test_entity.cc
===================================================================
--- /branches/world_entities/src/subprojects/collision_detection/collision_test_entity.cc	(revision 5621)
+++ /branches/world_entities/src/subprojects/collision_detection/collision_test_entity.cc	(revision 5622)
@@ -26,5 +26,5 @@
 
 using namespace std;
-CREATE_FACTORY(CollisionTestEntity);
+CREATE_FACTORY(CollisionTestEntity, CL_ENVIRONMENT);
 
 /**
Index: /branches/world_entities/src/util/loading/factory.cc
===================================================================
--- /branches/world_entities/src/util/loading/factory.cc	(revision 5621)
+++ /branches/world_entities/src/util/loading/factory.cc	(revision 5622)
@@ -34,5 +34,5 @@
    set everything to zero and define factoryName
 */
-Factory::Factory (const char* factoryName)
+Factory::Factory (const char* factoryName, ClassID classID)
 {
   this->setClassID(CL_FACTORY, "Factory");
@@ -40,4 +40,5 @@
 
   this->next = NULL;
+  this->classID = classID;
 
   Factory::registerFactory(this);
Index: /branches/world_entities/src/util/loading/factory.h
===================================================================
--- /branches/world_entities/src/util/loading/factory.h	(revision 5621)
+++ /branches/world_entities/src/util/loading/factory.h	(revision 5622)
@@ -33,6 +33,6 @@
  * this should be used at the beginning of all the Classes that should be loadable (in the cc-file)
 */
-#define CREATE_FACTORY(CLASS_NAME) \
-    tFactory<CLASS_NAME>* global_##CLASS_NAME##_Factory = new tFactory<CLASS_NAME>(#CLASS_NAME)
+#define CREATE_FACTORY(CLASS_NAME, CLASS_ID) \
+    tFactory<CLASS_NAME>* global_##CLASS_NAME##_Factory = new tFactory<CLASS_NAME>(#CLASS_NAME, CLASS_ID)
 
 //! The Factory is a loadable object handler
@@ -40,8 +40,9 @@
 
  public:
-  Factory (const char* factoryName = NULL);
+  Factory (const char* factoryName = NULL, ClassID classID = CL_NULL);
   virtual ~Factory ();
 
   void fabricate(const char* className, const char* entityName);
+  virtual BaseObject* fabricate(ClassID classID) = NULL;
   virtual BaseObject* fabricate(const TiXmlElement* root) = NULL;
   virtual BaseObject* fabricateDirect() = NULL;
@@ -57,4 +58,8 @@
     Factory* getNext() const { return this->next; };
 
+
+  protected:
+    ClassID           classID;              //!< The CLass-Identifyer of the Factory.
+
   private:
     Factory*          next;                 //!< pointer to the next factory.
@@ -64,15 +69,16 @@
 /**
  *  a factory that is able to load any kind of Object
-   (this is a Functor)
-*/
+ * (this is a Functor)
+ */
 template<class T> class tFactory : public Factory
 {
- public:
-  tFactory(const char* factoryName);
-  virtual ~tFactory();
+  public:
+    tFactory(const char* factoryName, ClassID classID);
+    virtual ~tFactory();
 
   private:
-  virtual BaseObject* fabricate(const TiXmlElement* root);
-  virtual BaseObject* fabricateDirect();
+    virtual BaseObject* fabricate(ClassID classID);
+    virtual BaseObject* fabricate(const TiXmlElement* root);
+    virtual BaseObject* fabricateDirect();
 };
 
@@ -82,16 +88,23 @@
 */
 template<class T>
-tFactory<T>::tFactory(const char* factoryName) : Factory(factoryName)
+    tFactory<T>::tFactory(const char* factoryName, ClassID classID) : Factory(factoryName, classID)
 {
   PRINTF(4)("Class: %s loadable\n", this->getName());
 }
 
-
+/**
+ * destructs the type-Factory
+ */
 template<class T>
-tFactory<T>::~tFactory()
+    tFactory<T>::~tFactory()
 {}
 
+/**
+ * fabricates an Object of type T, with the constructor T::T(const TiXmlElemnt*)
+ * @param root the TiXmlElement T should load parameters from.
+ * @return the newly fabricated T, NULL otherwise.
+ */
 template<class T>
-BaseObject* tFactory<T>::fabricate(const TiXmlElement* root)
+    BaseObject* tFactory<T>::fabricate(const TiXmlElement* root)
 {
   if (root == NULL)
@@ -106,4 +119,24 @@
 }
 
+
+/**
+ * fabricates an Object of type T, with the constructor T::T(const TiXmlElemnt*)
+ * @param classID the ClassID of T that should be created.
+ * @return the newly fabricated T if fabricated NULL otherwise.
+ */
+template<class T>
+    BaseObject* tFactory<T>::fabricate(ClassID classID)
+{
+  if(classID == this->classID)
+    return this->fabricateDirect();
+  else if( getNext() != NULL)
+    return getNext()->fabricate( classID);
+  else
+    return NULL;
+}
+
+/**
+ * directly fabricate an Entity of this factory.
+ */
 template<class T>
     BaseObject* tFactory<T>::fabricateDirect()
Index: /branches/world_entities/src/world_entities/environment.cc
===================================================================
--- /branches/world_entities/src/world_entities/environment.cc	(revision 5621)
+++ /branches/world_entities/src/world_entities/environment.cc	(revision 5622)
@@ -28,5 +28,5 @@
 
 using namespace std;
-CREATE_FACTORY(Environment);
+CREATE_FACTORY(Environment, CL_ENVIRONMENT);
 
 /**
Index: /branches/world_entities/src/world_entities/player.cc
===================================================================
--- /branches/world_entities/src/world_entities/player.cc	(revision 5621)
+++ /branches/world_entities/src/world_entities/player.cc	(revision 5622)
@@ -37,5 +37,5 @@
 using namespace std;
 
-CREATE_FACTORY(Player);
+CREATE_FACTORY(Player, CL_PLAYER);
 
 /**
@@ -83,5 +83,6 @@
   Weapon* wpLeft = new TestGun(this->weaponMan, 1);
   wpLeft->setName("testGun Left");
-  Weapon* cannon = new Cannon(this->weaponMan);
+  Weapon* cannon = dynamic_cast<Weapon*>(Factory::getFirst()->fabricate(CL_CANNON));
+  cannon->setWeaponManager(this->weaponMan);
   cannon->setName("BFG");
 
Index: /branches/world_entities/src/world_entities/power_ups/laser_power_up.cc
===================================================================
--- /branches/world_entities/src/world_entities/power_ups/laser_power_up.cc	(revision 5621)
+++ /branches/world_entities/src/world_entities/power_ups/laser_power_up.cc	(revision 5622)
@@ -25,5 +25,5 @@
 using namespace std;
 
-CREATE_FACTORY(LaserPowerUp);
+CREATE_FACTORY(LaserPowerUp, CL_LASER_POWER_UP);
 
 LaserPowerUp::LaserPowerUp ()
Index: /branches/world_entities/src/world_entities/power_ups/turret_power_up.cc
===================================================================
--- /branches/world_entities/src/world_entities/power_ups/turret_power_up.cc	(revision 5621)
+++ /branches/world_entities/src/world_entities/power_ups/turret_power_up.cc	(revision 5622)
@@ -25,5 +25,5 @@
 using namespace std;
 
-CREATE_FACTORY(TurretPowerUp);
+CREATE_FACTORY(TurretPowerUp, CL_TURRET_POWER_UP);
 
 TurretPowerUp::TurretPowerUp ()
Index: /branches/world_entities/src/world_entities/skybox.cc
===================================================================
--- /branches/world_entities/src/world_entities/skybox.cc	(revision 5621)
+++ /branches/world_entities/src/world_entities/skybox.cc	(revision 5622)
@@ -25,5 +25,5 @@
 using namespace std;
 
-CREATE_FACTORY(SkyBox);
+CREATE_FACTORY(SkyBox, CL_SKYBOX);
 
 /**
Index: /branches/world_entities/src/world_entities/terrain.cc
===================================================================
--- /branches/world_entities/src/world_entities/terrain.cc	(revision 5621)
+++ /branches/world_entities/src/world_entities/terrain.cc	(revision 5622)
@@ -29,5 +29,5 @@
 using namespace std;
 
-CREATE_FACTORY(Terrain);
+CREATE_FACTORY(Terrain, CL_TERRAIN);
 
 /**
Index: /branches/world_entities/src/world_entities/weapons/aiming_turret.cc
===================================================================
--- /branches/world_entities/src/world_entities/weapons/aiming_turret.cc	(revision 5621)
+++ /branches/world_entities/src/world_entities/weapons/aiming_turret.cc	(revision 5622)
@@ -30,5 +30,5 @@
 #include "factory.h"
 
-CREATE_FACTORY(AimingTurret);
+CREATE_FACTORY(AimingTurret, CL_AIMING_TURRET);
 
 using namespace std;
Index: /branches/world_entities/src/world_entities/weapons/cannon.cc
===================================================================
--- /branches/world_entities/src/world_entities/weapons/cannon.cc	(revision 5621)
+++ /branches/world_entities/src/world_entities/weapons/cannon.cc	(revision 5622)
@@ -41,5 +41,5 @@
 using namespace std;
 
-CREATE_FACTORY(Cannon);
+CREATE_FACTORY(Cannon, CL_CANNON);
 
 /**
Index: /branches/world_entities/src/world_entities/weapons/test_gun.cc
===================================================================
--- /branches/world_entities/src/world_entities/weapons/test_gun.cc	(revision 5621)
+++ /branches/world_entities/src/world_entities/weapons/test_gun.cc	(revision 5622)
@@ -41,5 +41,5 @@
 using namespace std;
 
-CREATE_FACTORY(TestGun);
+CREATE_FACTORY(TestGun, CL_TEST_GUN);
 
 /**
Index: /branches/world_entities/src/world_entities/weapons/turret.cc
===================================================================
--- /branches/world_entities/src/world_entities/weapons/turret.cc	(revision 5621)
+++ /branches/world_entities/src/world_entities/weapons/turret.cc	(revision 5622)
@@ -30,5 +30,5 @@
 #include "factory.h"
 
-CREATE_FACTORY(Turret);
+CREATE_FACTORY(Turret, CL_TURRET);
 
 using namespace std;
