Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5155 in orxonox.OLD for trunk/src/util/loading


Ignore:
Timestamp:
Aug 27, 2005, 3:39:26 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: now one should be able to create entities on the Fly

Location:
trunk/src/util/loading
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/util/loading/factory.cc

    r4836 r5155  
    1616
    1717#include "factory.h"
     18
     19#include "shell_command.h"
    1820#include "game_loader.h"
    19 
    2021using namespace std;
    2122
     
    6869
    6970  if( Factory::first == NULL)
     71  {
    7072    Factory::first = factory;
     73    ShellCommand<Factory>::registerCommand("create", CL_FACTORY, &Factory::fabricate);
     74  }
    7175  else
    7276  {
     
    7983  }
    8084}
     85
     86void Factory::fabricate(const char* className, const char* entityName)
     87{
     88  if (className == NULL)
     89    return;
     90  Factory* fac = Factory::first;
     91
     92  while (fac != NULL)
     93  {
     94    if (!strcmp(className, fac->getName()))
     95    {
     96      PRINTF(3)("Create a new Object of type %s\n", fac->getName());
     97      BaseObject* object = fac->fabricate(NULL);
     98      if (object != NULL)
     99      {
     100        object->setName(entityName);
     101      }
     102      break;
     103    }
     104    fac = fac->next;
     105  }
     106}
  • trunk/src/util/loading/factory.h

    r4932 r5155  
    2626
    2727#include "tinyxml.h"
    28 #include "load_param.h"
    2928#include "base_object.h"
    3029#include "debug.h"
     
    4443  ~Factory ();
    4544
    46 
     45  void fabricate(const char* className, const char* entityName);
    4746  virtual BaseObject* fabricate(const TiXmlElement* root) = NULL;
    4847
Note: See TracChangeset for help on using the changeset viewer.