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
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 "orxonox/objects/worldentities/ControllableEntity.h"
36#include "QuestManager.h"
37#include "QuestItem.h"
38#include "QuestHint.h"
39
40namespace orxonox {
41
42    CreateFactory(AddQuestHint);
43
44    AddQuestHint::AddQuestHint(BaseObject* creator) : QuestEffect(creator)
45    {
46        RegisterObject(AddQuestHint);
47    }
48
49    /**
50    @brief
51        Destructor.
52    */
53    AddQuestHint::~AddQuestHint()
54    {
55    }
56
57    void AddQuestHint::XMLPort(Element& xmlelement, XMLPort::Mode mode)
58    {
59        SUPER(AddQuestHint, XMLPort, xmlelement, mode);
60
61        XMLPortParam(AddQuestHint, "hintId", setHintId, getHintId, xmlelement, mode);
62
63    }
64
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
75    /**
76    @brief
77        Invokes the effect.
78    @param player
79        The player.
80    @return
81        Returns true if the effect was successfully invoked.
82    */
83    bool AddQuestHint::invoke(ControllableEntity* player)
84    {
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_);
94            if(!hint->setActive(player))
95            {
96                return false;
97            }
98        }
99        catch(const Exception& e)
100        {
101           COUT(2) << e.getFullDescription() << std::endl;
102           return false;
103        }
104
105        return true;
106
107    }
108}
Note: See TracBrowser for help on using the repository browser.