[2329] | 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 | |
---|
[2352] | 29 | /** |
---|
[3196] | 30 | @file |
---|
[2352] | 31 | @brief Definition of the QuestListener class. |
---|
| 32 | */ |
---|
| 33 | |
---|
[2329] | 34 | #ifndef _QuestListener_H__ |
---|
| 35 | #define _QuestListener_H__ |
---|
| 36 | |
---|
[5722] | 37 | #include "questsystem/QuestsystemPrereqs.h" |
---|
[2329] | 38 | |
---|
| 39 | #include <string> |
---|
| 40 | #include <list> |
---|
| 41 | #include "core/BaseObject.h" |
---|
[2352] | 42 | |
---|
[2435] | 43 | namespace orxonox |
---|
[2329] | 44 | { |
---|
[3280] | 45 | namespace QuestListenerMode |
---|
[2329] | 46 | { |
---|
[2435] | 47 | //! The mode of the QuestListener. |
---|
[3280] | 48 | enum Value |
---|
[2435] | 49 | { |
---|
[3280] | 50 | All, |
---|
| 51 | Start, |
---|
| 52 | Fail, |
---|
| 53 | Complete |
---|
[2435] | 54 | }; |
---|
| 55 | } |
---|
[2329] | 56 | |
---|
| 57 | /** |
---|
| 58 | @brief |
---|
[2352] | 59 | Provides a way to react to the starting, completing and failing of Quests. |
---|
[5693] | 60 | |
---|
[2352] | 61 | The XML representation goes as follows: |
---|
| 62 | 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. |
---|
[5693] | 63 | |
---|
[2352] | 64 | <BaseObject> // The object that should react to the status change of a Quest. |
---|
| 65 | <events> |
---|
[5693] | 66 | <function> // Where function is the method of the object that should be executed. Normally this would be visibility or activity. |
---|
[2352] | 67 | <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). |
---|
| 68 | </function> |
---|
| 69 | </events> |
---|
| 70 | </BaseObject> |
---|
[2329] | 71 | @author |
---|
[2435] | 72 | Damian 'Mozork' Frick |
---|
[2329] | 73 | */ |
---|
[5722] | 74 | class _QuestsystemExport QuestListener : public BaseObject |
---|
[2329] | 75 | { |
---|
[2435] | 76 | public: |
---|
| 77 | QuestListener(BaseObject* creator); |
---|
| 78 | virtual ~QuestListener(); |
---|
[5693] | 79 | |
---|
[2435] | 80 | virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a QuestListener object through XML. |
---|
[5693] | 81 | |
---|
[2435] | 82 | 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. |
---|
[5693] | 83 | |
---|
[2435] | 84 | bool setQuestId(const std::string & id); //!< Sets the questId of the Quest the QuestListener reacts to. |
---|
| 85 | bool setMode(const std::string & mode); //!< Sets the mode of the QuestListener. |
---|
[5693] | 86 | |
---|
[3196] | 87 | std::string getMode(void); //!< Get the mode of the QuestListener. |
---|
[5693] | 88 | |
---|
| 89 | const std::string & getQuestId(void); |
---|
[2435] | 90 | bool execute(void); //!< Executes the QuestListener, resp. fires an Event. |
---|
[5693] | 91 | |
---|
[2435] | 92 | private: |
---|
[3280] | 93 | QuestListenerMode::Value mode_; //!< The mode of the QuestListener. |
---|
[2435] | 94 | Quest* quest_; //!< A pointer to the Quest the QuestListener is reacting to. |
---|
[5693] | 95 | |
---|
[2329] | 96 | }; |
---|
| 97 | |
---|
| 98 | } |
---|
| 99 | |
---|
| 100 | #endif /* _QuestListener_H__ */ |
---|