Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/questsystem2/src/orxonox/objects/quest/AddQuest.cc @ 2146

Last change on this file since 2146 was 2146, checked in by dafrick, 16 years ago

Started implementation of QuestEffectBeacon.
Done some documentation of QuestItem and subclasses.

File size: 2.3 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 "OrxonoxStableHeaders.h"
30#include "AddQuest.h"
31
32#include <string>
33
34#include "core/CoreIncludes.h"
35#include "util/Exception.h"
36
37#include "orxonox/objects/worldentities/ControllableEntity.h"
38#include "QuestManager.h"
39#include "Quest.h"
40
41namespace orxonox {
42
43    CreateFactory(AddQuest);
44
45
46    AddQuest::AddQuest(BaseObject* creator) : ChangeQuestStatus(creator)
47    {
48        RegisterObject(AddQuest);
49    }
50
51    /**
52    @brief
53        Destructor.
54    */
55    AddQuest::~AddQuest()
56    {
57    }
58
59    void AddQuest::XMLPort(Element& xmlelement, XMLPort::Mode mode)
60    {
61        SUPER(AddQuest, XMLPort, xmlelement, mode);
62
63    }
64
65    /**
66    @brief
67        Invokes the effect.
68    @param player
69        The player the effect is invoked on.
70    @return
71        Returns true if the effect was successfully invoked.
72    */
73    bool AddQuest::invoke(ControllableEntity* player)
74    {
75        if(player == NULL)
76        {
77            COUT(2) << "Input player is NULL." << std::endl;
78            return false;
79        }
80
81        try
82        {
83            Quest* quest = QuestManager::findQuest(this->getQuestId());
84            if(!quest->start(player))
85            {
86               return false;
87            }
88        }
89        catch(const orxonox::Exception& ex)
90        {
91            COUT(2) << ex.getFullDescription() << std::endl;
92            return false;
93        }
94
95        return true;
96    }
97
98
99}
Note: See TracBrowser for help on using the repository browser.