[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 | |
---|
| 29 | #include "core/CoreIncludes.h" |
---|
| 30 | #include "QuestManager.h" |
---|
| 31 | |
---|
| 32 | namespace orxonox { |
---|
| 33 | |
---|
| 34 | QuestManager::QuestManager() : OrxonoxClass() |
---|
| 35 | { |
---|
| 36 | RegisterRootObject(QuestManager); |
---|
| 37 | } |
---|
| 38 | |
---|
| 39 | |
---|
| 40 | QuestManager::~QuestManager() |
---|
| 41 | { |
---|
| 42 | |
---|
| 43 | } |
---|
| 44 | |
---|
| 45 | /** |
---|
| 46 | @brief |
---|
| 47 | Registers a quest with the QuestManager to make it globally accessable. |
---|
| 48 | @param |
---|
| 49 | The quest that is to be registered. |
---|
| 50 | */ |
---|
| 51 | static void QuestManager::registerQuest(Quest & quest) |
---|
| 52 | { |
---|
| 53 | this->questMap_.insert ( pair<std::string,Quest>(quest.getId(),quest) ); |
---|
| 54 | } |
---|
| 55 | |
---|
| 56 | /** |
---|
| 57 | @brief |
---|
| 58 | Registers a QuestHint with the QuestManager to make it globally accessable. |
---|
| 59 | @param |
---|
| 60 | The QuestHint to be registered. |
---|
| 61 | */ |
---|
| 62 | static void QuestManager::registerHint(QuestHint & hint) |
---|
| 63 | { |
---|
| 64 | this->hintMap_.insert ( pair<std::string,Hint>(hint.getId(),hint) ); |
---|
| 65 | } |
---|
| 66 | |
---|
| 67 | /** |
---|
| 68 | @brief |
---|
| 69 | Finds a quest with the given id. |
---|
| 70 | @param questId |
---|
| 71 | The id of the quest sought for. |
---|
| 72 | @return |
---|
| 73 | Returns a reference to the quest with the input id. |
---|
| 74 | */ |
---|
| 75 | static Quest & QuestManager::findQuest(const std::string & questId) const |
---|
| 76 | { |
---|
| 77 | Quest* quest; |
---|
| 78 | std::map<std::string, Quest>::iterator it = this->questMap_.find(questId); |
---|
| 79 | if (it != this->questMap_.end()) |
---|
| 80 | { |
---|
| 81 | quest = &(it->second); |
---|
| 82 | } |
---|
| 83 | else |
---|
| 84 | { |
---|
| 85 | //TDO: Exception??? |
---|
| 86 | quest = NULL; |
---|
| 87 | COUT(2) << "The quest with id {" << questId << "} is nowhere to be found." << std::endl; |
---|
| 88 | } |
---|
| 89 | |
---|
| 90 | return *quest; |
---|
| 91 | |
---|
| 92 | } |
---|
| 93 | |
---|
| 94 | /** |
---|
| 95 | @brief |
---|
| 96 | Finds a hint with the given id. |
---|
| 97 | @param hintId |
---|
| 98 | The id of the hint sought for. |
---|
| 99 | @return |
---|
| 100 | Returns a reference to the hint with the input id. |
---|
| 101 | */ |
---|
| 102 | static QuestHint & QuestManager::findHint(const std::string & hintId) const |
---|
| 103 | { |
---|
| 104 | QuestHint* hint; |
---|
| 105 | std::map<std::string, QuestHint>::iterator it = this->hintMap_.find(hintId); |
---|
| 106 | if (it != this->hintMap_.end()) |
---|
| 107 | { |
---|
| 108 | hint = &(it->second); |
---|
| 109 | } |
---|
| 110 | else |
---|
| 111 | { |
---|
| 112 | //TDO: Exception??? |
---|
| 113 | hint = NULL; |
---|
| 114 | COUT(2) << "The hint with id {" << hintId << "} is nowhere to be found." << std::endl; |
---|
| 115 | } |
---|
| 116 | |
---|
| 117 | return hint; |
---|
| 118 | |
---|
| 119 | } |
---|
| 120 | |
---|
| 121 | |
---|
| 122 | } |
---|