Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/orxonox/objects/quest/AddQuestHint.cc @ 2095

Last change on this file since 2095 was 2095, checked in by landauf, 16 years ago
  • added forward declarations of all quest classes to OrxonoxPrereqs.h
  • moved some includes from .h to .cc
  • Property svn:eol-style set to native
File size: 2.6 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 "core/CoreIncludes.h"
30#include "util/Exception.h"
31
32#include "AddQuestHint.h"
33#include "QuestManager.h"
34#include "QuestItem.h"
35#include "QuestHint.h"
36
37namespace orxonox {
38
39    CreateFactory(AddQuestHint);
40
41    AddQuestHint::AddQuestHint(BaseObject* creator) : QuestEffect(creator)
42    {
43        RegisterObject(AddQuestHint);
44    }
45
46    /**
47    @brief
48        Destructor.
49    */
50    AddQuestHint::~AddQuestHint()
51    {
52    }
53
54    void AddQuestHint::XMLPort(Element& xmlelement, XMLPort::Mode mode)
55    {
56        SUPER(AddQuestHint, XMLPort, xmlelement, mode);
57
58        XMLPortParam(AddQuestHint, "hintId", setHintId, getHintId, xmlelement, mode);
59
60    }
61
62    inline void AddQuestHint::setHintId(const std::string & id)
63    {
64        if(!QuestItem::isId(id))
65        {
66            COUT(2) << "Invalid id. QuestItem id {" << id << "} could not be set." << std::endl;
67            return;
68        }
69        this->hintId_ = id;
70    }
71
72    /**
73    @brief
74        Invokes the effect.
75    @param player
76        The player.
77    @return
78        Returns true if the effect was successfully invoked.
79    */
80    bool AddQuestHint::invoke(Player* player)
81    {
82        if(player == NULL)
83        {
84            COUT(2) << "The input player is NULL." << std::endl;
85            return false;
86        }
87
88        try
89        {
90            QuestHint* hint = QuestManager::findHint(this->hintId_);
91            if(!hint->activate(player))
92            {
93                return false;
94            }
95        }
96        catch(const Exception& e)
97        {
98           COUT(2) << e.getFullDescription() << std::endl;
99           return false;
100        }
101
102        return true;
103
104    }
105}
Note: See TracBrowser for help on using the repository browser.