Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2101 in orxonox.OLD for orxonox/branches/chris/src/world.h


Ignore:
Timestamp:
Jul 10, 2004, 2:00:04 PM (21 years ago)
Author:
chris
Message:

orxonox/branches/chris: Finished the "GETITTOCOMPILE" project… compiling should work now, but linking is a different story

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/chris/src/world.h

    r2100 r2101  
    33#define WORLD_H
    44
     5#include "stdincl.h"
     6
    57class Track;
     8class WorldEntity;
    69
    710class World {
     
    1114  ~World ();
    1215
    13         template<class T>
    14           T* spawn<T>(Location* loc, WorldEntity* owner);       // template to be able to spawn any derivation of WorldEntity
    15         template<class T>
    16           T* spawn<T>(Placement* plc, WorldEntity* owner);
     16        template<typename T>
     17          T* spawn(Location* loc, WorldEntity* owner);  // template to be able to spawn any derivation of WorldEntity
     18        template<typename T>
     19          T* spawn(Placement* plc, WorldEntity* owner);
    1720
    1821        void time_slice (Uint32 deltaT);
     
    3740};
    3841
     42template<typename T> T* World::spawn(Location* loc = NULL, WorldEntity* owner = NULL)
     43{
     44        Location zeroloc;
     45        T* entity = new T();
     46        entities->add ((WorldEntity*)entity, LIST_ADD_NEXT);
     47        if( loc == NULL)
     48        {
     49                zeroloc.dist = 0;
     50                zeroloc.part = 0;
     51                zeroloc.pos = Vector();
     52                zeroloc.rot = Rotation();
     53                loc = &zeroloc;
     54        }
     55        entity->init (loc, owner);
     56        if (entity->bFree)
     57        {
     58                track[loc->part].map_coords( loc, entity->get_placement());
     59        }
     60        entity->post_spawn ();
     61        return entity;
     62}
     63
     64template<typename T> T* World::spawn(Placement* plc, WorldEntity* owner = NULL)
     65{
     66        T* entity = new T();
     67        entities->add ((WorldEntity*)entity, LIST_ADD_NEXT);
     68        entity->init (plc, owner);
     69        if (!entity->bFree)
     70        {
     71                printf("Can't spawn unfree entity with placement\n");
     72                entities->remove( (WorldEntity*)entity, LIST_FIND_FW);
     73                return NULL;
     74        }
     75        entity->post_spawn ();
     76        return entity;
     77}
     78
    3979#endif
Note: See TracChangeset for help on using the changeset viewer.