Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/questsystem2/src/orxonox/objects/quest/QuestHint.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: 4.2 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 */
[2146]28 
29/**
30    @file QuestHint.cc
31    @brief
32        Implementation of the QuestHint class.
33*/
[1992]34
[2105]35#include "OrxonoxStableHeaders.h"
36#include "QuestHint.h"
37
[1992]38#include "core/CoreIncludes.h"
[2068]39#include "util/Exception.h"
[2021]40
[2146]41#include "orxonox/objects/worldentities/ControllableEntity.h"
[2021]42#include "Quest.h"
[1992]43
44namespace orxonox {
45
46    CreateFactory(QuestHint);
47
[2068]48    /**
49    @brief
[2146]50        Constructor. Initializes the object.
[2068]51    */
[2092]52    QuestHint::QuestHint(BaseObject* creator) : QuestItem(creator)
[2021]53    {
[2068]54        this->initialize();
[2021]55    }
[2146]56   
57    /**
58    @brief
59        Initialize the object.
60    */
61    void QuestHint::initialize(void)
62    {
63        RegisterObject(QuestHint);
64    }
[2092]65
[1992]66    /**
67    @brief
68        Destructor.
69    */
70    QuestHint::~QuestHint()
71    {
[2092]72
[1992]73    }
[2092]74
[2146]75    /**
76    @brief
77        Method for creating a QuestHint object through XML.
78    */
[2068]79    void QuestHint::XMLPort(Element& xmlelement, XMLPort::Mode mode)
80    {
[2093]81        SUPER(QuestHint, XMLPort, xmlelement, mode);
[2092]82
[2093]83        COUT(3) << "New QuestHint {" << this->getId() << "} created." << std::endl;
[2068]84    }
85
[2092]86
[1996]87    /**
88    @brief
89        Checks whether the hint is active for a specific player.
90    @param player
91        The player.
[2068]92    @throws
93        Throws an Argument Exception if the input Player-pointer is NULL.
[1996]94    @return
[2068]95        Returns true if the hint is active for the specified player.
[1996]96    */
[2146]97    bool QuestHint::isActive(ControllableEntity* player)
[1992]98    {
[2146]99        if(player == NULL) //!< NULL-Pointers are ugly!
[2068]100        {
[2146]101            ThrowException(Argument, "The input ControllableEntity* is NULL.");
[2068]102            return false;
103        }
[2092]104
[2146]105        //! Find the player.
106        std::map<ControllableEntity*, questHintStatus::Enum>::iterator it = this->playerStatus_.find(player);
107        if (it != this->playerStatus_.end()) //!< If the player is in the map.
[2093]108        {
109            return it->second;
110        }
[2146]111       
[2093]112        return questStatus::inactive;
[1992]113    }
[2092]114
[2021]115    /**
116    @brief
[2068]117        Activates a QuestHint for a given player.
[2021]118    @param player
[2068]119        The player.
[2021]120    @return
[2068]121        Returns true if the activation was successful, false if there were problems.
[2021]122    */
[2146]123    bool QuestHint::setActive(ControllableEntity* player)
[1992]124    {
[2146]125        if(this->quest_->isActive(player)) //!< For a hint to get activated the quest must be active.
[1992]126        {
[2146]127            if(!(this->isActive(player)))  //!< If the hint is already active, activation is pointless.
[2093]128            {
129                this->playerStatus_[player] = questHintStatus::active;
130                return true;
131            }
132            else
133            {
[2068]134                COUT(2) << "An already active questHint was trying to get activated." << std::endl;
135                return false;
[2093]136            }
[1992]137        }
[2146]138       
[2093]139        COUT(2) << "A hint of a non-active quest was trying to get activated." << std::endl;
140        return false;
[1992]141    }
142
[2021]143    /**
144    @brief
[2068]145        Sets the quest the QuestHitn belongs to.
[2021]146    @param quest
[2146]147        The quest to be set as quest the hint is attached to.
[2021]148    @return
[2146]149        Returns true if successful.
[2021]150    */
[2068]151    bool QuestHint::setQuest(Quest* quest)
[1992]152    {
[2146]153        if(quest == NULL) //!< NULL-Pointer. Again..?
[2068]154        {
155            COUT(2) << "The input Quest* is NULL." << std::endl;
156            return false;
157        }
[2092]158
[1992]159        this->quest_ = quest;
[2068]160        return true;
[1992]161    }
162
163}
Note: See TracBrowser for help on using the repository browser.