#include <src/orxonox/objects/quest/QuestListener.h>
Public Member Functions | |
bool | execute (void) |
Executes the QuestListener, resp. fires an Event. | |
std::string | getMode (void) |
Get the mode of the QuestListener. | |
const std::string & | getQuestId (void) |
Get the questId of the Quest the QuestListener reacts to. | |
QuestListener (BaseObject *creator) | |
Constructor. Registers the object and initializes variables. | |
bool | setMode (const std::string &mode) |
Sets the mode of the QuestListener. | |
bool | setQuestId (const std::string &id) |
Sets the questId of the Quest the QuestListener reacts to. | |
virtual void | XMLPort (Element &xmlelement, XMLPort::Mode mode) |
Method for creating a QuestListener object through XML. | |
virtual | ~QuestListener () |
Destructor. | |
Static Public Member Functions | |
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. | |
Private Attributes | |
QuestListenerMode::Value | mode_ |
The mode of the QuestListener. | |
Quest * | quest_ |
A pointer to the Quest the QuestListener is reacting to. |
The XML representation goes as follows: 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.
<BaseObject> // The object that should react to the status change of a Quest. <events> <function> // Where function is the method of the object that schould be executed. Normally this would be visibility or activity. <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). </function> </events> </BaseObject>
orxonox::QuestListener::QuestListener | ( | BaseObject * | creator | ) |
Constructor. Registers the object and initializes variables.
References orxonox::QuestListenerMode::All, mode_, quest_, and RegisterObject.
orxonox::QuestListener::~QuestListener | ( | ) | [virtual] |
Destructor.
void orxonox::QuestListener::advertiseStatusChange | ( | std::list< QuestListener * > & | listeners, | |
const std::string & | status | |||
) | [static] |
Makes all QuestListener in the list aware that a certain status change has occured.
Makes all QuestListener in the list aware that a certain status change has occured and executes them if the status change affects them.
listeners | The list of QuestListeners that have to be made aware of the status change. | |
status | The status that has changed. Can be 'start' (if the Quest was started), 'complete' (if the Quest was completed) or 'fail' (if the Quest was failed). |
< Iterate through all QuestListeners
< Check whether the status change affects the give QuestListener.
References execute(), and getMode().
Referenced by orxonox::Quest::complete(), orxonox::Quest::fail(), and orxonox::Quest::start().
bool orxonox::QuestListener::execute | ( | void | ) |
Executes the QuestListener, resp. fires an Event.
References orxonox::BaseObject::fireEvent().
Referenced by advertiseStatusChange().
std::string orxonox::QuestListener::getMode | ( | void | ) |
Get the mode of the QuestListener.
References orxonox::QuestListenerMode::All, orxonox::QuestListenerMode::Complete, COUT, orxonox::QuestListenerMode::Fail, mode_, and orxonox::QuestListenerMode::Start.
Referenced by advertiseStatusChange(), and XMLPort().
const std::string & orxonox::QuestListener::getQuestId | ( | void | ) |
Get the questId of the Quest the QuestListener reacts to.
References orxonox::QuestItem::getId(), and quest_.
Referenced by XMLPort().
bool orxonox::QuestListener::setMode | ( | const std::string & | mode | ) |
Sets the mode of the QuestListener.
mode | The mode to be set. Can be eighter 'all', 'start', 'fail' or 'complete'. |
References orxonox::QuestListenerMode::All, orxonox::QuestListenerMode::Complete, COUT, orxonox::QuestListenerMode::Fail, mode_, and orxonox::QuestListenerMode::Start.
Referenced by XMLPort().
bool orxonox::QuestListener::setQuestId | ( | const std::string & | id | ) |
Sets the questId of the Quest the QuestListener reacts to.
id | The questId of the Quest the QUestListener reacts to. |
< Find the Quest corresponding to the given questId.
< If there is no such Quest.
References orxonox::QuestManager::findQuest(), orxonox::QuestManager::getInstance(), quest_, and ThrowException.
Referenced by XMLPort().
void orxonox::QuestListener::XMLPort | ( | Element & | xmlelement, | |
XMLPort::Mode | mode | |||
) | [virtual] |
Method for creating a QuestListener object through XML.
Method for creating a Quest object through XML.
< Adds the QuestListener to the Quests list of listeners.
Reimplemented from orxonox::BaseObject.
References orxonox::Quest::addListener(), COUT, orxonox::QuestItem::getId(), getMode(), getQuestId(), quest_, setMode(), setQuestId(), SUPER, and XMLPortParam.
Quest* orxonox::QuestListener::quest_ [private] |
A pointer to the Quest the QuestListener is reacting to.
Referenced by getQuestId(), QuestListener(), setQuestId(), and XMLPort().