Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/network/src/world_entities/spawning_point.cc @ 8589

Last change on this file since 8589 was 8068, checked in by patrick, 18 years ago

trunk: merged the network branche back to trunk

File size: 3.2 KB
Line 
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"
18
19#include "util/loading/load_param.h"
20#include "util/loading/factory.h"
21
22#include "world_entity.h"
23
24#include "compiler.h"
25
26#include <map>
27
28
29/**
30 *  constructor
31 */
32SpawningPoint::SpawningPoint (ClassID classid, const Vector& position)
33{
34  this->setAbsCoor(position);
35  this->classid = classid;
36  this->mode = SPT_ALL_AT_ONCE;
37  this->delay = 0;
38
39  this->init();
40}
41
42
43/**
44 *  standard constructor
45 */
46SpawningPoint::SpawningPoint (const Vector& position, ClassID classid, SpawningPointMode mode, float delay)
47{
48  this->setAbsCoor(position);
49  this->classid = classid;
50  this->mode = mode;
51  this->delay = delay;
52
53  this->init();
54}
55
56
57
58void SpawningPoint::init()
59{
60  this->setClassID(CL_SPAWNING_POINT, "SpawningPoint");
61}
62
63
64/**
65 *  deconstructor
66 */
67SpawningPoint::~SpawningPoint ()
68{}
69
70
71/**
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{
77  /* let the world entity its stuff first */
78  WorldEntity::loadParams(root);
79
80  /* now load the frequency */
81  LoadParam(root, "delay", this, SpawningPoint, setSpawningDelay)
82      .describe("sets the delay of the spawning point");
83
84
85  /* now load the seed */
86//   LoadParam(root, "entity", this, SpawningPoint, setSpawningEntity)
87//       .describe("sets the spawning entity");
88
89  /* now load the seed */
90/*  LoadParam(root, "classid", this, SpawningPoint, setSpawningEntity)
91      .describe("sets the class id of the entity to spawn")
92      .defaultValues(CL_WORLD_ENTITY);*/
93}
94
95
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
107/**
108 *  spawn the entity
109 */
110void SpawningPoint::spawn(WorldEntity* entity)
111{
112  PRINTF(1)("Spawningpoint spawns new Entity (%s)\n", entity->getClassName());
113
114
115  //BaseObject* spawningEntity = Factory::fabricate(this->classID);
116  //   if( likely(this->world != NULL))
117  //     this->world->spawn(dynamic_cast<WorldEntity*>(spawningEntity));
118}
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)
128{
129  this->localTimer += dt;
130
131  std::map<WorldEntity*, float>::iterator it = this->queue.begin();
132  for( ; it != this->queue.end(); it++)
133  {
134    //
135    if( it->second <= this->localTimer)
136    {
137      //spawn the player
138      this->spawn(it->first);
139    }
140  }
141
142}
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()
152{}
Note: See TracBrowser for help on using the repository browser.