Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 3137 was 3110, checked in by rgrieder, 16 years ago

Removed old msvc specific support for precompiled header files.

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