Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8068 in orxonox.OLD for trunk/src/world_entities/spawning_point.cc


Ignore:
Timestamp:
Jun 1, 2006, 2:28:16 PM (18 years ago)
Author:
patrick
Message:

trunk: merged the network branche back to trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/spawning_point.cc

    r7357 r8068  
    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
Note: See TracChangeset for help on using the changeset viewer.