Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/presentation/src/orxonox/objects/quest/QuestListener.h @ 2385

Last change on this file since 2385 was 2385, checked in by dafrick, 15 years ago

Merged questsystem3.

File size: 3.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/**
30    @file QuestListener.h
31    @brief Definition of the QuestListener class.
32*/
33
34#ifndef _QuestListener_H__
35#define _QuestListener_H__
36
37#include "OrxonoxPrereqs.h"
38
39#include <string>
40#include <list>
41
42#include "core/BaseObject.h"
43
44#include "Quest.h"
45
46namespace questListenerMode
47{
48
49    //! The mode of the QuestListener.
50    enum Enum
51    {
52        all,
53        start,
54        fail,
55        complete
56    };
57
58}
59
60namespace orxonox {
61
62    /**
63    @brief
64        Provides a way to react to the starting, completing and failing of Quests.
65       
66        The XML representation goes as follows:
67        You can use the QuestListener as if it were a Trigger or EventListener, that fires an Event when the status (depending on the set mode) of the given Quest changes.
68       
69        <BaseObject> // The object that should react to the status change of a Quest.
70            <events>
71                <function> // Where function is the method of the object that schould be executed. Normally this would be visibility or activity.
72                    <QuestListener questId="someQuestId" mode="someMode" /> // Where someQuestId is the identifier for the Quest the QuestListener is reacting to, and someMode is the kind of status change the QUestListener reacts to (all, start, complete or fail).
73                </function>
74            </events>
75        </BaseObject>
76    @author
77        Damian 'Mozork' Frick
78    */
79    class _OrxonoxExport QuestListener : public BaseObject
80    {
81        public:
82            QuestListener(BaseObject* creator);
83            virtual ~QuestListener();
84           
85            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a QuestListener object through XML.
86           
87            static void advertiseStatusChange(std::list<QuestListener*> & listeners, const std::string & status); //!< Makes all QuestListener in the list aware that a certain status change has occured.
88           
89            bool setQuestId(const std::string & id); //!< Sets the questId of the Quest the QuestListener reacts to.
90            bool setMode(const std::string & mode); //!< Sets the mode of the QuestListener.
91           
92            const std::string getMode(void); //!< Get the mode of the QuestListener.
93           
94            /**
95            @brief Get the questId of the Quest the QuestListener reacts to.
96            @return Returns the questId of the Quest the QuestListener reacts to.
97            */
98            inline const std::string & getQuestId(void)
99                { return this->quest_->getId(); }
100           
101            bool execute(void); //!< Executes the QuestListener, resp. fires an Event.
102           
103        private:
104            questListenerMode::Enum mode_; //!< The mode of the QuestListener.
105            Quest* quest_; //!< A pointer to the Quest the QuestListener is reacting to.
106   
107    };
108
109}
110
111#endif /* _QuestListener_H__ */
Note: See TracBrowser for help on using the repository browser.