Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2707 in orxonox.OLD for orxonox/branches/buerli/src/world.h


Ignore:
Timestamp:
Nov 3, 2004, 12:29:03 AM (21 years ago)
Author:
bensch
Message:

orxonox/branches/buerli: merged back from trunk, with new configure makefile and so forth.

File:
1 edited

Legend:

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

    r2551 r2707  
    88
    99#include "stdincl.h"
     10#include "story_entity.h"
     11
     12
    1013
    1114class Track;
    1215class WorldEntity;
     16class Camera;
    1317
    1418//! The game environment
    15 class World {
     19class World : public StoryEntity {
    1620
    1721 public:
    18   World ();
     22  World (char* name);
     23  World (int worldID);
    1924  ~World ();
    2025
    21         template<typename T>
    22           T* spawn(Location* loc, WorldEntity* owner);  // template to be able to spawn any derivation of WorldEntity
    23         template<typename T>
    24           T* spawn(Placement* plc, WorldEntity* owner);
     26  template<typename T>
     27    T* spawn(Location* loc, WorldEntity* owner);        // template to be able to spawn any derivation of WorldEntity
     28  template<typename T>
     29    T* spawn(Placement* plc, WorldEntity* owner);
     30 
     31  virtual Error init();
     32  virtual Error start();
     33  virtual Error stop();
     34  virtual Error pause();
     35  virtual Error resume();
    2536
    26         void time_slice (Uint32 deltaT);
    27         void collide ();
    28         void draw ();
    29         void update (); // maps Locations to Placements
    30         void calc_camera_pos (Location* loc, Placement* plc);
     37  virtual void load();
     38
     39  void time_slice (Uint32 deltaT);
     40  void collide ();
     41  void draw ();
     42  void update ();       // maps Locations to Placements
     43  void calc_camera_pos (Location* loc, Placement* plc);
    3144       
    32         void unload ();
    33        
    34         void load_debug_level ();
    35        
     45  void unload ();
     46 
     47  void setTrackLen(Uint32 tracklen);
     48  int getTrackLen();
     49  bool system_command (Command* cmd);
     50  Camera* getCamera();
     51  //private:
     52
     53  void spawn(WorldEntity* entity);
     54
     55  List<WorldEntity>* entities;
     56 
     57  // base level data
     58  Track* track;
     59  Uint32 tracklen;   // number of Tracks the World consist of
     60  Vector* pathnodes;
     61  Camera* localCamera; 
     62
    3663 private:
    37  
    38         List<WorldEntity>* entities;
    39        
    40                 // base level data
    41         Track* track;
    42         Uint32 tracklen;   // number of Tracks the World consist of
    43         Vector* pathnodes;
     64  Uint32 lastFrame; //!> last time of frame
     65  bool bQuitOrxonox; //!> quit this application
     66  bool bQuitCurrentGame; //!> quit only the current game and return to menu
     67  bool bPause;
    4468
     69  char* worldName;
     70  int debugWorldNr;
     71
     72  WorldEntity* localPlayer;
     73 
     74  void mainLoop();
     75  void synchronize();
     76  void handle_input();
     77  void time_slice();
     78  void collision();
     79  void display();
     80  void debug();
    4581};
    4682
     
    5894template<typename T> T* World::spawn(Location* loc = NULL, WorldEntity* owner = NULL)
    5995{
    60         Location zeroloc;
    61         T* entity = new T();
    62         entities->add ((WorldEntity*)entity, LIST_ADD_NEXT);
    63         if( loc == NULL)
    64         {
    65                 zeroloc.dist = 0;
    66                 zeroloc.part = 0;
    67                 zeroloc.pos = Vector();
    68                 zeroloc.rot = Quaternion();
    69                 loc = &zeroloc;
    70         }
    71         entity->init (loc, owner);
    72         if (entity->bFree)
    73         {
    74                 track[loc->part].map_coords( loc, entity->get_placement());
    75         }
    76         entity->post_spawn ();
    77         return entity;
     96  Location zeroloc;
     97  T* entity = new T();
     98  entities->add ((WorldEntity*)entity, LIST_ADD_NEXT);
     99  if( loc == NULL)
     100    {
     101      zeroloc.dist = 0;
     102      zeroloc.part = 0;
     103      zeroloc.pos = Vector();
     104      zeroloc.rot = Quaternion();
     105      loc = &zeroloc;
     106    }
     107  entity->init (loc, owner);
     108  if (entity->bFree)
     109    {
     110      track[loc->part].map_coords( loc, entity->get_placement());
     111    }
     112  entity->post_spawn ();
     113  return entity;
    78114}
    79115
     
    92128template<typename T> T* World::spawn(Placement* plc, WorldEntity* owner = NULL)
    93129{
    94         T* entity = new T();
    95         entities->add ((WorldEntity*)entity, LIST_ADD_NEXT);
    96         entity->init (plc, owner);
    97         if (!entity->bFree)
    98         {
    99                 printf("Can't spawn unfree entity with placement\n");
    100                 entities->remove( (WorldEntity*)entity, LIST_FIND_FW);
    101                 return NULL;
    102         }
    103         entity->post_spawn ();
    104         return entity;
     130  T* entity = new T();
     131  entities->add ((WorldEntity*)entity, LIST_ADD_NEXT);
     132  entity->init (plc, owner);
     133  if (!entity->bFree)
     134    {
     135      printf("Can't spawn unfree entity with placement\n");
     136      entities->remove( (WorldEntity*)entity, LIST_FIND_FW);
     137      return NULL;
     138    }
     139  entity->post_spawn ();
     140  return entity;
    105141}
    106142
Note: See TracChangeset for help on using the changeset viewer.