[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 | |
---|
[2105] | 29 | #include "OrxonoxStableHeaders.h" |
---|
| 30 | #include "AddQuestHint.h" |
---|
| 31 | |
---|
[1992] | 32 | #include "core/CoreIncludes.h" |
---|
[2068] | 33 | #include "util/Exception.h" |
---|
[2021] | 34 | |
---|
| 35 | #include "QuestManager.h" |
---|
[2081] | 36 | #include "QuestItem.h" |
---|
[2095] | 37 | #include "QuestHint.h" |
---|
[1992] | 38 | |
---|
| 39 | namespace orxonox { |
---|
| 40 | |
---|
| 41 | CreateFactory(AddQuestHint); |
---|
| 42 | |
---|
[2092] | 43 | AddQuestHint::AddQuestHint(BaseObject* creator) : QuestEffect(creator) |
---|
[2021] | 44 | { |
---|
[2092] | 45 | RegisterObject(AddQuestHint); |
---|
[2021] | 46 | } |
---|
[2092] | 47 | |
---|
[1992] | 48 | /** |
---|
| 49 | @brief |
---|
| 50 | Destructor. |
---|
| 51 | */ |
---|
| 52 | AddQuestHint::~AddQuestHint() |
---|
| 53 | { |
---|
| 54 | } |
---|
[2092] | 55 | |
---|
[2076] | 56 | void AddQuestHint::XMLPort(Element& xmlelement, XMLPort::Mode mode) |
---|
| 57 | { |
---|
| 58 | SUPER(AddQuestHint, XMLPort, xmlelement, mode); |
---|
[2092] | 59 | |
---|
[2076] | 60 | XMLPortParam(AddQuestHint, "hintId", setHintId, getHintId, xmlelement, mode); |
---|
[2092] | 61 | |
---|
[2076] | 62 | } |
---|
[1992] | 63 | |
---|
[2081] | 64 | inline void AddQuestHint::setHintId(const std::string & id) |
---|
| 65 | { |
---|
| 66 | if(!QuestItem::isId(id)) |
---|
| 67 | { |
---|
| 68 | COUT(2) << "Invalid id. QuestItem id {" << id << "} could not be set." << std::endl; |
---|
| 69 | return; |
---|
| 70 | } |
---|
| 71 | this->hintId_ = id; |
---|
| 72 | } |
---|
| 73 | |
---|
[1992] | 74 | /** |
---|
| 75 | @brief |
---|
| 76 | Invokes the effect. |
---|
| 77 | @param player |
---|
| 78 | The player. |
---|
[2068] | 79 | @return |
---|
| 80 | Returns true if the effect was successfully invoked. |
---|
[1992] | 81 | */ |
---|
[2068] | 82 | bool AddQuestHint::invoke(Player* player) |
---|
[1992] | 83 | { |
---|
[2068] | 84 | if(player == NULL) |
---|
| 85 | { |
---|
| 86 | COUT(2) << "The input player is NULL." << std::endl; |
---|
| 87 | return false; |
---|
| 88 | } |
---|
| 89 | |
---|
| 90 | try |
---|
| 91 | { |
---|
| 92 | QuestHint* hint = QuestManager::findHint(this->hintId_); |
---|
[2093] | 93 | if(!hint->activate(player)) |
---|
| 94 | { |
---|
| 95 | return false; |
---|
| 96 | } |
---|
| 97 | } |
---|
| 98 | catch(const Exception& e) |
---|
| 99 | { |
---|
| 100 | COUT(2) << e.getFullDescription() << std::endl; |
---|
| 101 | return false; |
---|
| 102 | } |
---|
[2092] | 103 | |
---|
[2093] | 104 | return true; |
---|
[2092] | 105 | |
---|
[1992] | 106 | } |
---|
| 107 | } |
---|