orxonox::QuestEffectBeacon Class Reference

A QuestEffectBeacon is a physical entity in the game which can (under some condition(s)) invoke a number QuestEffects on players meeting the condition(s). The conditions under which the QuestEffects are invoked on the player are defined by Triggers. A QuestEffectBeacon can be executed a defined number of times. A QuestEffectBeacon can be inactive or active. More...

#include <src/orxonox/objects/quest/QuestEffectBeacon.h>

Inheritance diagram for orxonox::QuestEffectBeacon:

orxonox::StaticEntity orxonox::WorldEntity orxonox::BaseObject orxonox::Synchronisable orxonox::OrxonoxClass orxonox::OrxonoxClass

List of all members.

Public Member Functions

bool execute (bool b, PlayerTrigger *trigger)
 Executes the QuestEffects of the QuestEffectBeacon.
bool isActive (void)
 Tests whether the QuestEffectBeacon is active.
virtual void processEvent (Event &event)
 Processes an event for this QuestEffectBeacon.
 QuestEffectBeacon (BaseObject *creator)
 Constructor. Registers the object and initializes defaults.
bool setActive (bool activate)
 Set the status of the QuestEffectBeacon.
virtual void XMLPort (Element &xmlelement, XMLPort::Mode mode)
 Method for creating a QuestEffectBeacon object through XML.
virtual ~QuestEffectBeacon ()

Protected Member Functions

bool decrementTimes (void)
 Decrement the number of times the QuestEffectBeacon can still be executed.
const int & getTimes (void) const
 Returns the number of times the QUestEffectBeacon can still be executed.

Private Member Functions

bool addEffect (QuestEffect *effect)
 Add a QuestEffect to the QuestEffectBeacon.
const QuestEffectgetEffect (unsigned int index) const
 Get the QuestEffect at a given index.
bool setTimes (const int &n)
 Set the number of times the QuestEffectBeacon can be executed.

Private Attributes

std::list< QuestEffect * > effects_
 The list of QuestEffects to be invoked on the executing player.
QuestEffectBeaconStatus::Value status_
 The status of the QUestEffectBeacon, Can be eighter active or inactive.
int times_
 Number of times the beacon can be exectued.

Static Private Attributes

static const int INFINITE_TIME = -1
 Constant to avoid using magic numbers.


Detailed Description

A QuestEffectBeacon is a physical entity in the game which can (under some condition(s)) invoke a number QuestEffects on players meeting the condition(s). The conditions under which the QuestEffects are invoked on the player are defined by Triggers. A QuestEffectBeacon can be executed a defined number of times. A QuestEffectBeacon can be inactive or active.

Creating a QuestEffectBeacon through XML goes as follows:

<QuestEffectBeacon times="n>"> //Where 'n' is eighter a number >= 0, which means the QuestEffectBeacon can be executed n times. Or n = -1, which means the QuestEffectBeacon can be executed an infinite number of times. <effects> <QuestEffect> //A list of QuestEffects, invoked when the QuestEffectBeacon is executed, see QuestEffect for the full XML representation. ... <QuestEffect> </effects> <events> <execute> <EventListener event="eventIdString"> </execute> </events> <attached> <PlayerTrigger name="eventIdString"> //A PlayerTrigger triggering the execution of the QuestEffectBeacon. </attached> </QuestEffectBeacon>

Author:
Damian 'Mozork' Frick

Constructor & Destructor Documentation

orxonox::QuestEffectBeacon::QuestEffectBeacon ( BaseObject creator  ) 

Constructor. Registers the object and initializes defaults.

References orxonox::QuestEffectBeaconStatus::Active, INFINITE_TIME, RegisterObject, status_, and times_.

orxonox::QuestEffectBeacon::~QuestEffectBeacon (  )  [virtual]

Destructor.


Member Function Documentation

bool orxonox::QuestEffectBeacon::addEffect ( QuestEffect effect  )  [private]

Add a QuestEffect to the QuestEffectBeacon.

Adds a QuestEffect to the QuestEffectBeacon.

Parameters:
effect A pointer to the QuestEffect to be added.
Returns:
Returns true if successful.

< NULL-pointers are not well liked here...

References COUT, and effects_.

Referenced by XMLPort().

bool orxonox::QuestEffectBeacon::decrementTimes ( void   )  [protected]

Decrement the number of times the QuestEffectBeacon can still be executed.

Decrement the number of times the QuestEffectBeacon can be executed.

Returns:
Returns true if successful.

< The QuestEffectBeacon mus be active to decrement the number of times it can be executed.

< If times is infinity the QuestEffectBeacon can be executed an infinite number fo times.

< Decrement number of times the QuestEffectBeacon can be executed.

< Set the QuestEffectBeacon to inactive when the number of times it can be executed is reduced to 0.

References getTimes(), orxonox::QuestEffectBeaconStatus::Inactive, INFINITE_TIME, isActive(), status_, and times_.

Referenced by execute().

bool orxonox::QuestEffectBeacon::execute ( bool  b,
PlayerTrigger trigger 
)

Executes the QuestEffects of the QuestEffectBeacon.

Executes the QuestEffectBeacon. This means extracting the ControllableEntity from the PlayerTrigger, provided by the Event causing the execution, and the extracting the PlayerInfo from the received ControllableEntity and invoking the QuestEffectbeacon's QuestEffects on the received PlayerInfo.

Parameters:
trigger Apointer to the PlayerTrigger that threw the Event.
Returns:
Returns true if successfully executed, false if not.

< If the QuestEffectBeacon is inactive it cannot be executed.

< The PlayerTrigger is not exclusively for ControllableEntities which means we cannot extract one.

Extracting the ControllableEntity form the PlayerTrigger.

Extract the PlayerInfo from the ControllableEntity.

< Invoke the QuestEffects on the PlayerInfo.

< Decrement the number of times the beacon can be used.

References COUT, decrementTimes(), effects_, orxonox::ControllableEntity::getPlayer(), orxonox::PlayerTrigger::getTriggeringPlayer(), orxonox::QuestEffect::invokeEffects(), isActive(), and orxonox::PlayerTrigger::isForPlayer().

Referenced by processEvent().

const QuestEffect * orxonox::QuestEffectBeacon::getEffect ( unsigned int  index  )  const [private]

Get the QuestEffect at a given index.

Returns the QuestEffect at the given index.

Parameters:
index The index.
Returns:
Returns a pointer to the QuestEffect at the given index.

References effects_.

Referenced by XMLPort().

const int& orxonox::QuestEffectBeacon::getTimes ( void   )  const [inline, protected]

Returns the number of times the QUestEffectBeacon can still be executed.

Returns:
Returns the number of times the QUestEffectBeacon can still be executed.

Referenced by decrementTimes(), setActive(), and XMLPort().

bool orxonox::QuestEffectBeacon::isActive ( void   )  [inline]

Tests whether the QuestEffectBeacon is active.

Returns:
Returns true if the QuestEffectBeacon is active, fals if not.

Reimplemented from orxonox::BaseObject.

References orxonox::QuestEffectBeaconStatus::Active.

Referenced by decrementTimes(), and execute().

void orxonox::QuestEffectBeacon::processEvent ( Event event  )  [virtual]

Processes an event for this QuestEffectBeacon.

Reimplemented from orxonox::BaseObject.

References execute(), ORXONOX_SET_SUBCLASS_EVENT, and SUPER.

bool orxonox::QuestEffectBeacon::setActive ( bool  activate  ) 

Set the status of the QuestEffectBeacon.

Parameters:
activate If true the QuestEffectBeacon is activated, if false it is deactivated.
Returns:
Returns whether the activation/deactivation was successful.

< A QuestEffectBeacon that can be executed only 0 times is always inactive.

Reimplemented from orxonox::BaseObject.

References orxonox::QuestEffectBeaconStatus::Active, getTimes(), orxonox::QuestEffectBeaconStatus::Inactive, and status_.

bool orxonox::QuestEffectBeacon::setTimes ( const int &  n  )  [private]

Set the number of times the QuestEffectBeacon can be executed.

Set the number of times the QuestEffectBeacon can be executed. The number must be eighter <= 0, or INFINITY which is '-1'.

Parameters:
n The number of times the QuestEffectBeacon can be executed. The number must be eighter <= 0, or INFINITY which is '-1'.
Returns:
Returns true if successful.

References INFINITE_TIME, and times_.

Referenced by XMLPort().

void orxonox::QuestEffectBeacon::XMLPort ( Element &  xmlelement,
XMLPort::Mode  mode 
) [virtual]

Method for creating a QuestEffectBeacon object through XML.

Reimplemented from orxonox::WorldEntity.

References addEffect(), COUT, getEffect(), getTimes(), setTimes(), SUPER, XMLPortObject, and XMLPortParam.


Member Data Documentation

The list of QuestEffects to be invoked on the executing player.

Referenced by addEffect(), execute(), and getEffect().

const int orxonox::QuestEffectBeacon::INFINITE_TIME = -1 [static, private]

Constant to avoid using magic numbers.

Referenced by decrementTimes(), QuestEffectBeacon(), and setTimes().

The status of the QUestEffectBeacon, Can be eighter active or inactive.

Referenced by decrementTimes(), QuestEffectBeacon(), and setActive().

Number of times the beacon can be exectued.

Referenced by decrementTimes(), QuestEffectBeacon(), and setTimes().


The documentation for this class was generated from the following files:

Generated on Tue Jul 28 16:22:58 2009 for Orxonox by  doxygen 1.5.6