Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/questsystem2/src/orxonox/objects/quest/AddQuestHint.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.7 KB
RevLine 
[1992]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
[2105]29#include "OrxonoxStableHeaders.h"
30#include "AddQuestHint.h"
31
[1992]32#include "core/CoreIncludes.h"
[2068]33#include "util/Exception.h"
[2021]34
[2146]35#include "orxonox/objects/worldentities/ControllableEntity.h"
[2021]36#include "QuestManager.h"
[2081]37#include "QuestItem.h"
[2095]38#include "QuestHint.h"
[1992]39
40namespace orxonox {
41
42    CreateFactory(AddQuestHint);
43
[2092]44    AddQuestHint::AddQuestHint(BaseObject* creator) : QuestEffect(creator)
[2021]45    {
[2092]46        RegisterObject(AddQuestHint);
[2021]47    }
[2092]48
[1992]49    /**
50    @brief
51        Destructor.
52    */
53    AddQuestHint::~AddQuestHint()
54    {
55    }
[2092]56
[2076]57    void AddQuestHint::XMLPort(Element& xmlelement, XMLPort::Mode mode)
58    {
59        SUPER(AddQuestHint, XMLPort, xmlelement, mode);
[2092]60
[2076]61        XMLPortParam(AddQuestHint, "hintId", setHintId, getHintId, xmlelement, mode);
[2092]62
[2076]63    }
[1992]64
[2081]65    inline void AddQuestHint::setHintId(const std::string & id)
66    {
67        if(!QuestItem::isId(id))
68        {
69            COUT(2) << "Invalid id. QuestItem id {" << id << "} could not be set." << std::endl;
70            return;
71        }
72        this->hintId_ = id;
73    }
74
[1992]75    /**
76    @brief
77        Invokes the effect.
78    @param player
79        The player.
[2068]80    @return
81        Returns true if the effect was successfully invoked.
[1992]82    */
[2146]83    bool AddQuestHint::invoke(ControllableEntity* player)
[1992]84    {
[2068]85        if(player == NULL)
86        {
87            COUT(2) << "The input player is NULL." << std::endl;
88            return false;
89        }
90
91        try
92        {
93            QuestHint* hint = QuestManager::findHint(this->hintId_);
[2146]94            if(!hint->setActive(player))
[2093]95            {
96                return false;
97            }
98        }
99        catch(const Exception& e)
100        {
101           COUT(2) << e.getFullDescription() << std::endl;
102           return false;
103        }
[2092]104
[2093]105        return true;
[2092]106
[1992]107    }
108}
Note: See TracBrowser for help on using the repository browser.