Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/pickup3/src/modules/pickup/PickupRepresentation.cc @ 6474

Last change on this file since 6474 was 6474, checked in by dafrick, 14 years ago

Some documenting done. Added files, that I had forgotten to add. Cleaned the old pickups out.

File size: 3.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 *      Damian 'Mozork' Frick
24 *   Co-authors:
25 *      ...
26 *
27*/
28
29#include "PickupRepresentation.h"
30
31#include "core/CoreIncludes.h"
32#include "PickupManager.h"
33#include "graphics/Billboard.h"
34
35namespace orxonox
36{
37   
38    CreateFactory(PickupRepresentation);
39   
40    PickupRepresentation::PickupRepresentation() : BaseObject(this)
41    {
42        RegisterObject(PickupRepresentation);
43       
44        this->initialize();
45    }
46   
47    PickupRepresentation::PickupRepresentation(BaseObject* creator) : BaseObject(creator)
48    {
49        RegisterObject(PickupRepresentation);
50       
51        this->initialize();
52    }
53   
54    PickupRepresentation::~PickupRepresentation()
55    {
56       
57    }
58   
59    void PickupRepresentation::initialize(void)
60    {
61        this->description_ = "This is a pickup.";
62        this->name_ = "Pickup";
63        this->spawnerTemplate_ = "";
64        this->spawnerRepresentation_ = NULL;
65        this->pickup_ = NULL;
66    }
67   
68    void PickupRepresentation::XMLPort(Element& xmlelement, XMLPort::Mode mode)
69    {
70        SUPER(PickupRepresentation, XMLPort, xmlelement, mode);
71       
72        XMLPortParam(PickupRepresentation, "name", setName, getName, xmlelement, mode);
73        XMLPortParam(PickupRepresentation, "description", setDescription, getDescription, xmlelement, mode);
74        XMLPortParam(PickupRepresentation, "spawnerTemplate", setSpawnerTemplate, getSpawnerTemplate, xmlelement, mode);
75        XMLPortObject(PickupRepresentation, Pickupable, "pickup", setPickup, getPickup, xmlelement, mode);
76        XMLPortObject(PickupRepresentation, StaticEntity, "spawner-representation", setSpawnerRepresentation, getSpawnerRepresentationIndex, xmlelement, mode);
77       
78        PickupManager::getInstance().registerRepresentation(*this->pickup_->getPickupIdentifier(), this);
79    }
80   
81    StaticEntity* PickupRepresentation::getSpawnerRepresentation(PickupSpawner* spawner)
82    {
83        if(this->spawnerRepresentation_ == NULL)
84        {
85            COUT(4) << "PickupRepresentation: No spawner representation found." << std::endl;
86            if(this->spawnerTemplate_ == "")
87            {
88                COUT(4) << "PickupRepresentation: Spawner template is empty." << std::endl;
89                return this->getDefaultSpawnerRepresentation(spawner);
90            }
91            this->addTemplate(this->spawnerTemplate_);
92        }
93        StaticEntity* representation = this->spawnerRepresentation_;
94       
95        this->addTemplate(this->spawnerTemplate_);
96       
97        return representation;
98    }
99   
100    StaticEntity* PickupRepresentation::getDefaultSpawnerRepresentation(PickupSpawner* spawner)
101    {
102        StaticEntity* representation = new StaticEntity(spawner);
103        //TODO: Nicer...
104        Billboard* billboard = new Billboard(spawner);
105        billboard->setColour(ColourValue(1.0, 0.0, 0.0));
106        billboard->setMaterial("Examples/Flare");
107        representation->attach(billboard);
108        return representation;
109    }
110   
111}
Note: See TracBrowser for help on using the repository browser.