Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8036 in orxonox.OLD


Ignore:
Timestamp:
May 31, 2006, 4:33:31 PM (18 years ago)
Author:
patrick
Message:

cr: network spawning points implemented and new group introduced

Location:
branches/network/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/network/src/story_entities/multi_player_world.cc

    r7954 r8036  
    8686
    8787/**
     88 * kicks the CDEngine to detect the collisions between the object groups in the world
     89 */
     90void MultiPlayerWorld::collide()
     91{
     92  CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_PLAYERS),
     93    this->dataTank->objectManager->getObjectList(OM_PLAYERS));
     94  CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_PLAYERS),
     95    this->dataTank->objectManager->getObjectList(OM_PLAYERS_PROJ));
     96
     97  CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_GROUP_00),
     98    this->dataTank->objectManager->getObjectList(OM_GROUP_01_PROJ));
     99  CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_GROUP_01),
     100    this->dataTank->objectManager->getObjectList(OM_GROUP_00_PROJ));
     101  CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_GROUP_00),
     102    this->dataTank->objectManager->getObjectList(OM_GROUP_01));
     103
     104  CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_GROUP_00),
     105    this->dataTank->objectManager->getObjectList(OM_COMMON));
     106  CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_GROUP_01),
     107    this->dataTank->objectManager->getObjectList(OM_COMMON));
     108
     109}
     110
     111
     112/**
    88113 * some debug ouptut - shell command
    89114 */
  • branches/network/src/story_entities/multi_player_world.h

    r6512 r8036  
    3131  protected:
    3232    virtual void synchronize();
     33    virtual void collide();
    3334};
    3435
  • branches/network/src/util/object_manager.h

    r7836 r8036  
    2020  OM_BACKGROUND,
    2121  OM_COMMON,
     22
     23  OM_PLAYERS,
     24  OM_PLAYERS_PROJ,
    2225
    2326  OM_GROUP_00,
  • branches/network/src/world_entities/spawning_point.cc

    r7357 r8036  
    2020#include "util/loading/factory.h"
    2121
     22#include "world_entity.h"
     23
    2224#include "compiler.h"
     25
     26#include <map>
    2327
    2428
     
    2630 *  constructor
    2731 */
    28 SpawningPoint::SpawningPoint (ClassID classID, const Vector& position)
     32SpawningPoint::SpawningPoint (ClassID classid, const Vector& position)
    2933{
    3034  this->setAbsCoor(position);
    31   this->classID = classID;
     35  this->classid = classid;
    3236  this->mode = SPT_ALL_AT_ONCE;
    3337  this->delay = 0;
     
    4044 *  standard constructor
    4145 */
    42 SpawningPoint::SpawningPoint (const Vector& position, ClassID classID, SpawningPointMode mode, float delay)
     46SpawningPoint::SpawningPoint (const Vector& position, ClassID classid, SpawningPointMode mode, float delay)
    4347{
    4448  this->setAbsCoor(position);
    45   this->classID = classID;
     49  this->classid = classid;
    4650  this->mode = mode;
    4751  this->delay = delay;
     
    9094
    9195
     96
     97/**
     98 * pushes a world entity to the spawning queue
     99 *  @param entity WorldEntity to be added
     100 */
     101void SpawningPoint::pushEntity(WorldEntity* entity, float delay)
     102{
     103  this->queue[entity] = this->localTimer + delay;
     104}
     105
     106
    92107/**
    93108 *  spawn the entity
    94109 */
    95 void SpawningPoint::spawn()
     110void SpawningPoint::spawn(WorldEntity* entity)
    96111{
    97   PRINTF(5)("Spangingpoint creates a new Entity (id: %i, delay: %f, mode: %f)\n", this->classID,
    98             this->delay, this->mode);
     112  PRINTF(1)("Spawningpoint spawns new Entity (%s)\n", entity->getClassName());
     113
    99114
    100115  //BaseObject* spawningEntity = Factory::fabricate(this->classID);
    101 
    102 //   if( likely(this->world != NULL))
    103 //     this->world->spawn(dynamic_cast<WorldEntity*>(spawningEntity));
     116  //   if( likely(this->world != NULL))
     117  //     this->world->spawn(dynamic_cast<WorldEntity*>(spawningEntity));
    104118}
    105119
     
    114128{
    115129  this->localTimer += dt;
    116   if( this->localTimer > this->delay)
     130
     131  std::map<WorldEntity*, float>::iterator it = this->queue.begin();
     132  for( ; it != this->queue.end(); it++)
    117133  {
    118     this->spawn();
    119     this->localTimer = 0.0f;
     134    //
     135    if( it->second <= this->localTimer)
     136    {
     137      //spawn the player
     138      this->spawn(it->first);
     139    }
    120140  }
     141
    121142}
    122143
  • branches/network/src/world_entities/spawning_point.h

    r7370 r8036  
    99
    1010#include "world_entity.h"
     11
     12#include <map>
    1113
    1214class World;
     
    4345
    4446    /**  sets the entity that is going to be spawned by this point @param classID: the id from the class_id.h file */
    45     void SpawningPoint::setSpawningEntity(ClassID classID) { this->classID = classID; }
     47    void SpawningPoint::setSpawningEntity(ClassID classid) { this->classid = classid; }
    4648    /** sets the frequency with which the point is going to spawn entities (1/sec) @param frequency: the frequency */
    4749    void SpawningPoint::setSpawningDelay(float delay) { this->delay = delay; }
     
    4951    void SpawningPoint::setSpawningMode(int mode) { this->mode = (SpawningPointMode)mode; }
    5052
     53    void pushEntity(WorldEntity* entity, float delay = 0);
    5154
    5255    /** activates the spawning point */
    53     void activate() { this->bSpawning = true; }
     56    inline void activate() { this->bSpawning = true; }
    5457    /** deactivates the spawning point */
    55     void deactivate() { this->bSpawning = false; }
     58    inline void deactivate() { this->bSpawning = false; }
     59    inline bool isActive() const { return this->bSpawning; }
    5660
    5761
     
    6165
    6266  private:
    63     void spawn();
     67    void spawn(WorldEntity* entity);
    6468
    6569
    6670  private:
    67     float                     delay;                          //!< the timer that counts down until the next spawn
    68     float                     localTimer;                     //!< the local timer
    69     float                     seed;                           //!< the random seed of the position
    70     ClassID                   classID;                        //!< the classid of the entity to spawn
    71     SpawningPointMode         mode;                           //!< the mode of the spawning point
    72     ObjectManager::EntityList   queue;                          //!< queue of waiting WorldEntities to be spawned
    73     bool                      bSpawning;                      //!< flag to indicate if this spawning point is active or not
     71    float                           delay;                          //!< the timer that counts down until the next spawn
     72    float                           localTimer;                     //!< the local timer
     73    float                           seed;                           //!< the random seed of the position
     74    ClassID                         classid;                        //!< the classid of the entity to spawn
     75    SpawningPointMode               mode;                           //!< the mode of the spawning point
     76    std::map<WorldEntity*, float>   queue;                          //!< queue of waiting WorldEntities to be spawned
     77    bool                            bSpawning;                      //!< flag to indicate if this spawning point is active or not
    7478};
    7579
Note: See TracChangeset for help on using the changeset viewer.