Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/pch/src/orxonox/objects/worldentities/SpawnPoint.cc @ 3165

Last change on this file since 3165 was 3110, checked in by rgrieder, 16 years ago

Removed old msvc specific support for precompiled header files.

  • Property svn:eol-style set to native
File size: 2.8 KB
Line 
1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Fabian 'x3n' Landau
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29#include "SpawnPoint.h"
30
31#include "core/CoreIncludes.h"
32#include "core/XMLPort.h"
33#include "objects/gametypes/Gametype.h"
34
35namespace orxonox
36{
37    CreateFactory(SpawnPoint);
38
39    SpawnPoint::SpawnPoint(BaseObject* creator) : StaticEntity(creator)
40    {
41        RegisterObject(SpawnPoint);
42
43        this->template_ = 0;
44
45        if (this->getGametype())
46            this->getGametype()->registerSpawnPoint(this);
47        else
48            COUT(1) << "Error: SpawnPoint has no Gametype" << std::endl;
49
50        this->setObjectMode(0x0);
51    }
52
53    void SpawnPoint::XMLPort(Element& xmlelement, XMLPort::Mode mode)
54    {
55        SUPER(SpawnPoint, XMLPort, xmlelement, mode);
56
57        XMLPortParam(SpawnPoint, "spawnclass", setSpawnClassName, getSpawnClassName, xmlelement, mode);
58        XMLPortParam(SpawnPoint, "pawndesign", setTemplateName, getTemplateName, xmlelement, mode);
59    }
60
61    void SpawnPoint::setSpawnClassName(const std::string& name)
62    {
63        this->spawnclassname_ = name;
64        this->spawnclass_ = ClassByString(name);
65    }
66
67    void SpawnPoint::setTemplateName(const std::string& name)
68    {
69        this->templatename_ = name;
70        this->template_ = Template::getTemplate(name);
71    }
72
73    Pawn* SpawnPoint::spawn()
74    {
75        Pawn* entity = this->spawnclass_.fabricate(this);
76        if (entity)
77        {
78            this->getGametype()->pawnPreSpawn(entity);
79
80            this->spawn(entity);
81
82            if (this->template_)
83                entity->addTemplate(this->template_);
84
85            entity->postSpawn();
86
87            this->getGametype()->pawnPostSpawn(entity);
88
89            this->fireEvent();
90        }
91        return entity;
92    }
93
94    void SpawnPoint::spawn(ControllableEntity* entity)
95    {
96        entity->setPosition(this->getWorldPosition());
97        entity->setOrientation(this->getWorldOrientation());
98    }
99}
Note: See TracBrowser for help on using the repository browser.