Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/network/src/orxonox/objects/quest/AddQuestHint.cc @ 2492

Last change on this file since 2492 was 2105, checked in by rgrieder, 16 years ago

updated msvc files and precompiled headers.

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