Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 8798 was 8798, checked in by rennerc, 18 years ago

network changes

File size: 3.4 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  this->teamId = -1;
63}
64
65
66/**
67 *  deconstructor
68 */
69SpawningPoint::~SpawningPoint ()
70{}
71
72
73/**
74 * loads the WorldEntity Specific Parameters.
75 * @param root: the XML-Element to load the Data From
76 */
77void SpawningPoint::loadParams(const TiXmlElement* root)
78{
79  /* let the world entity its stuff first */
80  WorldEntity::loadParams(root);
81
82  /* now load the frequency */
83  LoadParam(root, "delay", this, SpawningPoint, setSpawningDelay)
84      .describe("sets the delay of the spawning point");
85     
86  /* load teamId */
87  LoadParam(root, "teamId", this, SpawningPoint, setTeamId)
88      .describe("sets teamId");
89
90
91  /* now load the seed */
92//   LoadParam(root, "entity", this, SpawningPoint, setSpawningEntity)
93//       .describe("sets the spawning entity");
94
95  /* now load the seed */
96/*  LoadParam(root, "classid", this, SpawningPoint, setSpawningEntity)
97      .describe("sets the class id of the entity to spawn")
98      .defaultValues(CL_WORLD_ENTITY);*/
99}
100
101
102
103/**
104 * pushes a world entity to the spawning queue
105 *  @param entity WorldEntity to be added
106 */
107void SpawningPoint::pushEntity(WorldEntity* entity, float delay)
108{
109  this->queue[entity] = this->localTimer + delay;
110}
111
112
113/**
114 *  spawn the entity
115 */
116void SpawningPoint::spawn(WorldEntity* entity)
117{
118  PRINTF(1)("Spawningpoint spawns new Entity (%s)\n", entity->getClassName());
119
120
121  //BaseObject* spawningEntity = Factory::fabricate(this->classID);
122  //   if( likely(this->world != NULL))
123  //     this->world->spawn(dynamic_cast<WorldEntity*>(spawningEntity));
124}
125
126
127/**
128 *  this method is called every frame
129 * @param time: the time in seconds that has passed since the last tick
130 *
131 * Handle all stuff that should update with time inside this method (movement, animation, etc.)
132 */
133void SpawningPoint::tick(float dt)
134{
135  this->localTimer += dt;
136
137  std::map<WorldEntity*, float>::iterator it = this->queue.begin();
138  for( ; it != this->queue.end(); it++)
139  {
140    //
141    if( it->second <= this->localTimer)
142    {
143      //spawn the player
144      this->spawn(it->first);
145    }
146  }
147
148}
149
150
151/**
152 *  the entity is drawn onto the screen with this function
153 *
154 * This is a central function of an entity: call it to let the entity painted to the screen.
155 * Just override this function with whatever you want to be drawn.
156 */
157void SpawningPoint::draw()
158{}
Note: See TracBrowser for help on using the repository browser.