Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/questsystem2/src/orxonox/objects/quest/AddQuestHint.cc @ 2263

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

Some cleanup…

File size: 3.5 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
[2159]29/**
30    @file AddQuestHint.cc
31    @brief
[2251]32    Implementation of the AddQuestHint class.
[2159]33*/
34
[2105]35#include "OrxonoxStableHeaders.h"
36#include "AddQuestHint.h"
37
[1992]38#include "core/CoreIncludes.h"
[2068]39#include "util/Exception.h"
[2021]40
[2205]41#include "orxonox/objects/infos/PlayerInfo.h"
[2021]42#include "QuestManager.h"
[2081]43#include "QuestItem.h"
[2095]44#include "QuestHint.h"
[1992]45
46namespace orxonox {
47
48    CreateFactory(AddQuestHint);
49
[2159]50    /**
51    @brief
52        Constructor. Registers the object.
53    */
[2092]54    AddQuestHint::AddQuestHint(BaseObject* creator) : QuestEffect(creator)
[2021]55    {
[2092]56        RegisterObject(AddQuestHint);
[2021]57    }
[2092]58
[1992]59    /**
60    @brief
61        Destructor.
62    */
63    AddQuestHint::~AddQuestHint()
64    {
65    }
[2092]66
[2159]67    /**
68    @brief
69        Method for creating a AddQuestHint object through XML.
70    */
[2076]71    void AddQuestHint::XMLPort(Element& xmlelement, XMLPort::Mode mode)
72    {
73        SUPER(AddQuestHint, XMLPort, xmlelement, mode);
[2092]74
[2076]75        XMLPortParam(AddQuestHint, "hintId", setHintId, getHintId, xmlelement, mode);
[2226]76       
77        COUT(3) << "New AddQuestHint, with target QuestHint {" << this->getHintId() << "}, created." << std::endl;
[2076]78    }
[1992]79
[2159]80    /**
81    @brief
[2191]82        Sets the id of the QuestHint to be added to the player the QuestEffect is invoked on.
[2159]83    @param id
84        The QuestHint id.
85    @param
86        Returns true if successful.
87    */
[2191]88    bool AddQuestHint::setHintId(const std::string & id)
[2081]89    {
90        if(!QuestItem::isId(id))
91        {
92            COUT(2) << "Invalid id. QuestItem id {" << id << "} could not be set." << std::endl;
[2159]93            return false;
[2081]94        }
[2159]95       
[2081]96        this->hintId_ = id;
[2159]97        return true;
[2081]98    }
99
[1992]100    /**
101    @brief
[2191]102        Invokes the QuestEffect.
[1992]103    @param player
104        The player.
[2068]105    @return
[2191]106        Returns true if the QuestEffect was successfully invoked.
[1992]107    */
[2205]108    bool AddQuestHint::invoke(PlayerInfo* player)
[1992]109    {
[2159]110        if(player == NULL) //!< NULL-pointers are evil!
[2068]111        {
112            COUT(2) << "The input player is NULL." << std::endl;
113            return false;
114        }
115
[2226]116        COUT(3) << "AddQuestHint on player: " << player << " ." << std::endl;
117
[2068]118        try
119        {
120            QuestHint* hint = QuestManager::findHint(this->hintId_);
[2226]121            if(hint == NULL || !hint->setActive(player))
[2093]122            {
123                return false;
124            }
125        }
126        catch(const Exception& e)
127        {
128           COUT(2) << e.getFullDescription() << std::endl;
129           return false;
130        }
[2092]131
[2226]132        COUT(3) << "QuestHint {" << this->getHintId() << "} successfully added to player." << std::endl;
[2093]133        return true;
[2092]134
[1992]135    }
136}
Note: See TracBrowser for help on using the repository browser.