Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/world_entities/spawning_point.cc @ 8649

Last change on this file since 8649 was 8068, checked in by patrick, 19 years ago

trunk: merged the network branche back to trunk

File size: 3.2 KB
RevLine 
[6080]1
2/*
3   orxonox - the future of 3D-vertical-scrollers
4
5   Copyright (C) 2004 orx
6
7   This program is free software; you can redistribute it and/or modify
8   it under the terms of the GNU General Public License as published by
9   the Free Software Foundation; either version 2, or (at your option)
10   any later version.
11
12### File Specific:
13   main-programmer: Patrick Boenzli
14   co-programmer:
15*/
16
17#include "spawning_point.h"
[6424]18
[7193]19#include "util/loading/load_param.h"
20#include "util/loading/factory.h"
[6424]21
[8068]22#include "world_entity.h"
23
[6093]24#include "compiler.h"
[6080]25
[8068]26#include <map>
[6424]27
[8068]28
[6080]29/**
[7357]30 *  constructor
[6080]31 */
[8068]32SpawningPoint::SpawningPoint (ClassID classid, const Vector& position)
[6084]33{
[7357]34  this->setAbsCoor(position);
[8068]35  this->classid = classid;
[7357]36  this->mode = SPT_ALL_AT_ONCE;
37  this->delay = 0;
[6088]38
39  this->init();
[6084]40}
[6080]41
42
43/**
[7357]44 *  standard constructor
[6081]45 */
[8068]46SpawningPoint::SpawningPoint (const Vector& position, ClassID classid, SpawningPointMode mode, float delay)
[6081]47{
[7357]48  this->setAbsCoor(position);
[8068]49  this->classid = classid;
[7357]50  this->mode = mode;
51  this->delay = delay;
[6088]52
53  this->init();
54}
55
56
[7357]57
[6088]58void SpawningPoint::init()
59{
[7357]60  this->setClassID(CL_SPAWNING_POINT, "SpawningPoint");
[6081]61}
62
63
64/**
[6080]65 *  deconstructor
66 */
67SpawningPoint::~SpawningPoint ()
68{}
69
70
[6081]71/**
[6086]72 * loads the WorldEntity Specific Parameters.
73 * @param root: the XML-Element to load the Data From
74 */
75void SpawningPoint::loadParams(const TiXmlElement* root)
76{
[6087]77  /* let the world entity its stuff first */
[6512]78  WorldEntity::loadParams(root);
[6086]79
[6087]80  /* now load the frequency */
[7357]81  LoadParam(root, "delay", this, SpawningPoint, setSpawningDelay)
82      .describe("sets the delay of the spawning point");
[6086]83
[6087]84
85  /* now load the seed */
[7357]86//   LoadParam(root, "entity", this, SpawningPoint, setSpawningEntity)
87//       .describe("sets the spawning entity");
[6087]88
89  /* now load the seed */
[6093]90/*  LoadParam(root, "classid", this, SpawningPoint, setSpawningEntity)
[6088]91      .describe("sets the class id of the entity to spawn")
[7198]92      .defaultValues(CL_WORLD_ENTITY);*/
[6086]93}
94
95
[8068]96
[6086]97/**
[8068]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
107/**
[6081]108 *  spawn the entity
109 */
[8068]110void SpawningPoint::spawn(WorldEntity* entity)
[6083]111{
[8068]112  PRINTF(1)("Spawningpoint spawns new Entity (%s)\n", entity->getClassName());
[6424]113
[8068]114
[7357]115  //BaseObject* spawningEntity = Factory::fabricate(this->classID);
[8068]116  //   if( likely(this->world != NULL))
117  //     this->world->spawn(dynamic_cast<WorldEntity*>(spawningEntity));
[6083]118}
[6080]119
120
121/**
122 *  this method is called every frame
123 * @param time: the time in seconds that has passed since the last tick
124 *
125 * Handle all stuff that should update with time inside this method (movement, animation, etc.)
126 */
127void SpawningPoint::tick(float dt)
[6084]128{
[7357]129  this->localTimer += dt;
[8068]130
131  std::map<WorldEntity*, float>::iterator it = this->queue.begin();
132  for( ; it != this->queue.end(); it++)
[6084]133  {
[8068]134    //
135    if( it->second <= this->localTimer)
136    {
137      //spawn the player
138      this->spawn(it->first);
139    }
[6084]140  }
[8068]141
[6084]142}
[6080]143
144
145/**
146 *  the entity is drawn onto the screen with this function
147 *
148 * This is a central function of an entity: call it to let the entity painted to the screen.
149 * Just override this function with whatever you want to be drawn.
150 */
151void SpawningPoint::draw()
[6087]152{}
Note: See TracBrowser for help on using the repository browser.