Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 27, 2006, 2:46:40 PM (19 years ago)
Author:
rennerc
Message:

SpawningPoint works now

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/multi_player_map/src/world_entities/spawning_point.cc

    r8820 r8827  
    2222#include "world_entity.h"
    2323
     24#include "class_list.h"
     25
    2426#include "compiler.h"
    2527
     
    3436 *  constructor
    3537 */
    36 SpawningPoint::SpawningPoint (ClassID classid, const Vector& position)
    37 {
    38   this->setAbsCoor(position);
    39 
    40   this->init();
    41 }
    42 
    43 
    44 /**
    45  *  standard constructor
    46  */
    47 SpawningPoint::SpawningPoint (const Vector& position, ClassID classid, SpawningPointMode mode, float delay)
    48 {
    49   this->setAbsCoor(position);
    50 
    51   this->init();
    52 }
    53 
    54 
    5538SpawningPoint::SpawningPoint( const TiXmlElement * root )
    5639{
     
    6952 
    7053  this->teamId = -1;
     54  this->localTimer = 0.0f;
     55 
     56  this->toList( OM_DEAD_TICK );
    7157 
    7258  MessageManager::getInstance()->registerMessageHandler( MSGID_RESPAWN, respawnMessageHandler, NULL );
     
    10187 *  @param entity WorldEntity to be added
    10288 */
    103 void SpawningPoint::pushEntity(WorldEntity* entity, float delay)
     89void SpawningPoint::pushEntity(Playable* entity, float delay)
    10490{
    10591  QueueEntry qe;
     
    114100 *  spawn the entity
    115101 */
    116 void SpawningPoint::spawn(WorldEntity* entity)
    117 {
    118   PRINTF(1)("Spawningpoint spawns new Entity (%s)\n", entity->getClassName());
     102void SpawningPoint::spawn(Playable* entity)
     103{
     104  PRINTF(0)("Spawningpoint spawns Entity (%s)\n", entity->getClassName());
    119105
    120106
     
    128114    (State::getGameRules())->registerSpawn( entity );
    129115  }
     116 
     117  entity->respawn();
    130118}
    131119
     
    140128{
    141129  this->localTimer += dt;
    142 
    143130  std::list<QueueEntry>::iterator it = this->queue.begin();
    144131  for( ; it != this->queue.end(); )
    145132  {
    146    
     133    //PRINTF(0)("%f <= %f\n", it->respawnTime, this->localTimer);
    147134    if( it->respawnTime <= this->localTimer)
    148135    {
     
    207194  assert( Converter::byteArrayToInt( data+INTSIZE, &uniqueId ) == INTSIZE );
    208195 
    209   //TODO find Playable and SpawningPoint and spawn Playable
     196  SpawningPoint * sp = NULL;
     197  Playable      * playable = NULL;
     198 
     199  const std::list<BaseObject*> * list = ClassList::getList( CL_SPAWNING_POINT );
     200 
     201  if ( list )
     202  {
     203    for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ )
     204    {
     205      if ( dynamic_cast<SpawningPoint*>(*it)->getUniqueID() == uniqueId )
     206      {
     207        sp = dynamic_cast<SpawningPoint*>(*it);
     208        break;
     209      }
     210    }
     211  }
     212 
     213  if ( !sp )
     214  {
     215    PRINTF(2)("could not find spawning point\n");
     216    return false;
     217  }
     218 
     219  list = ClassList::getList( CL_PLAYABLE );
     220 
     221  if ( list )
     222  {
     223    for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ )
     224    {
     225      if ( dynamic_cast<Playable*>(*it)->getUniqueID() == uniqueId )
     226      {
     227        playable = dynamic_cast<Playable*>(*it);
     228        break;
     229      }
     230    }
     231  }
     232 
     233  if ( !playable )
     234  {
     235    PRINTF(2)("could not find playable\n");
     236    return false;
     237  }
     238 
     239  sp->spawn( playable );
    210240 
    211241  return true;
Note: See TracChangeset for help on using the changeset viewer.