Orxonox: orxonox::PickupSpawner Class Reference

# orxonox::PickupSpawner Class Reference

PickupSpawner. More...

`#include <src/orxonox/objects/pickup/PickupSpawner.h>`

Inheritance diagram for orxonox::PickupSpawner:

List of all members.

## Public Member Functions

virtual void | changedActivity ()
| Invoked when activity has changed (set visibilty).
Template * | getItemTemplate () const
| Get the template for the item to spawn.
const std::string & | getItemTemplateName () const
| Get the template name for the item to spawn.
float | getRespawnTime () const
| Get the time to respawn.
float | getTriggerDistance () const
| Get the distance in which to trigger.
| PickupSpawner (BaseObject *creator)
| Constructor. Registers the PickupSpawner.
void | respawnTimerCallback ()
| Method called when the timer runs out.
void | setItemTemplateName (const std::string &name)
| Set the template name of the item to spawn.
void | setRespawnTime (float time)
| Set the time to respawn.
void | setTriggerDistance (float value)
| Set the distance in which to trigger.
virtual void | tick (float dt)
| Tick, checks if any Pawn is close enough to trigger.
void | trigger (Pawn *pawn)
| Method called when a Pawn is close enough.
virtual void | XMLPort (Element &xmlelement, XMLPort::Mode mode)
| Method for creating a PickupSpawner through XML.
virtual | ~PickupSpawner ()
| Deconstructor.

## Private Attributes

Template * | itemTemplate_
| Template of the item to spawn.
std::string | itemTemplateName_
| Template name of the item to spawn.
float | respawnTime_
| Time after which this gets re-actived.
Timer< PickupSpawner > | respawnTimer_
| Timer used for re-activating.
float | tickSum_
| Adds up tick to use in sine movement.
float | triggerDistance_
| Distance in which this gets triggered.

## Static Private Attributes

static const float | bounceDistance_s = 4.0f
| Distance the pickup bounces up and down.
static const float | bounceSpeed_s = 6.0f
| Speed of pickup to bounce up and down.
static const float | rotationSpeed_s = 1.0f
| Rotation speed of pickup.

## Detailed Description

PickupSpawner.

Author:
  Daniel 'Huty' Haggenmueller

## Constructor & Destructor Documentation

orxonox::PickupSpawner::PickupSpawner | ( | BaseObject * | creator | ) |

Constructor. Registers the PickupSpawner.

Parameters:

  | creator | Pointer to the object which created this item.

References itemTemplate_, RegisterObject, respawnTime_, tickSum_, and triggerDistance_.

orxonox::PickupSpawner::~PickupSpawner | ( |  | ) | `[virtual]`

Deconstructor.

## Member Function Documentation

void orxonox::PickupSpawner::changedActivity | ( |  | ) | `[virtual]`

Invoked when activity has changed (set visibilty).

Invoked when the activity has changed. Sets visibility of attached objects.

Reimplemented from orxonox::BaseObject.

References orxonox::WorldEntity::getAttachedObjects(), and SUPER.

Template* orxonox::PickupSpawner::getItemTemplate | ( |  | ) | const`[inline]`

Get the template for the item to spawn.

Returns:
  Returns the template of the item to spawn.

const std::string& orxonox::PickupSpawner::getItemTemplateName | ( |  | ) | const`[inline]`

Get the template name for the item to spawn.

Returns:
  Returns the name of the template of the item to spawn.

Referenced by XMLPort().

float orxonox::PickupSpawner::getRespawnTime | ( |  | ) | const`[inline]`

Get the time to respawn.

Returns:
  Returns the time after which this gets re-actived.

Referenced by XMLPort().

float orxonox::PickupSpawner::getTriggerDistance | ( |  | ) | const`[inline]`

Get the distance in which to trigger.

Returns:
  Returns the distance in which this gets triggered.

Referenced by XMLPort().

void orxonox::PickupSpawner::respawnTimerCallback | ( |  | ) |

Method called when the timer runs out.

Invoked by the timer, re-activates the PickupSpawner.

References COUT, and orxonox::BaseObject::setActive().

Referenced by trigger().

void orxonox::PickupSpawner::setItemTemplateName | ( | const std::string & | name | ) |

Set the template name of the item to spawn.

Set the template name of the item to spawn, also loads the template.

Parameters:

  | name | Name of the new template.

References orxonox::Template::getTemplate(), itemTemplate_, and itemTemplateName_.

Referenced by XMLPort().

void orxonox::PickupSpawner::setRespawnTime | ( | float | time | ) | `[inline]`

Set the time to respawn.

Parameters:

  | time | New time after which this gets re-actived.

Referenced by XMLPort().

void orxonox::PickupSpawner::setTriggerDistance | ( | float | value | ) | `[inline]`

Set the distance in which to trigger.

Parameters:

  | value | The new distance in which to trigger.

Referenced by XMLPort().

void orxonox::PickupSpawner::tick | ( | float | dt | ) | `[virtual]`

Tick, checks if any Pawn is close enough to trigger.

Parameters:

  | dt | Time since last tick.

Implements orxonox::Tickable.

References bounceDistance_s, bounceSpeed_s, orxonox::WorldEntity::getWorldPosition(), orxonox::BaseObject::isActive(), orxonox::MT_Type::Radian, rotationSpeed_s, tickSum_, orxonox::WorldEntity::translate(), trigger(), triggerDistance_, orxonox::MT_Type::Vector3, and orxonox::WorldEntity::yaw().

void orxonox::PickupSpawner::trigger | ( | Pawn * | pawn | ) |

Method called when a Pawn is close enough.

Trigger the PickupSpawner.

Adds the pickup to the Pawn that triggered, sets the timer to re-activate and deactives the PickupSpawner.

Parameters:

  | pawn | Pawn which triggered the PickupSpawner.

References orxonox::BaseObject::addTemplate(), COUT, orxonox::createExecutor(), orxonox::Identifier::fabricate(), orxonox::BaseObject::fireEvent(), orxonox::Template::getBaseclassIdentifier(), orxonox::BaseObject::isActive(), itemTemplate_, itemTemplateName_, orxonox::BaseItem::pickedUp(), respawnTime_, respawnTimer_, respawnTimerCallback(), orxonox::BaseObject::setActive(), and orxonox::BaseItem::setPickupIdentifier().

Referenced by tick().

void orxonox::PickupSpawner::XMLPort | ( | Element & | xmlelement,
|  | XMLPort::Mode | mode |
| ) |  |  | `[virtual]`

Method for creating a PickupSpawner through XML.

Parameters:

  | xmlelement | XML element which contains the PickupSpawner.
  | mode | XMLPort mode.

Reimplemented from orxonox::WorldEntity.

References orxonox::BaseObject::addTemplate(), orxonox::GUIManager::executeCode(), orxonox::Identifier::fabricate(), orxonox::Template::getBaseclassIdentifier(), orxonox::PickupInventory::getImageForItem(), orxonox::GUIManager::getInstance(), getItemTemplateName(), getRespawnTime(), orxonox::PickupInventory::getSingleton(), getTriggerDistance(), itemTemplate_, setItemTemplateName(), setRespawnTime(), setTriggerDistance(), orxonox::GUIManager::showGUI(), SUPER, and XMLPortParam.

## Member Data Documentation

const float orxonox::PickupSpawner::bounceDistance_s = 4.0f`[static, private]`

Distance the pickup bounces up and down.

Referenced by tick().

const float orxonox::PickupSpawner::bounceSpeed_s = 6.0f`[static, private]`

Speed of pickup to bounce up and down.

Referenced by tick().

Template* orxonox::PickupSpawner::itemTemplate_`[private]`

Template of the item to spawn.

Referenced by PickupSpawner(), setItemTemplateName(), trigger(), and XMLPort().

std::string orxonox::PickupSpawner::itemTemplateName_`[private]`

Template name of the item to spawn.

Referenced by setItemTemplateName(), and trigger().

float orxonox::PickupSpawner::respawnTime_`[private]`

Time after which this gets re-actived.

Referenced by PickupSpawner(), and trigger().

Timer<PickupSpawner> orxonox::PickupSpawner::respawnTimer_`[private]`

Timer used for re-activating.

Referenced by trigger().

const float orxonox::PickupSpawner::rotationSpeed_s = 1.0f`[static, private]`

Rotation speed of pickup.

Referenced by tick().

float orxonox::PickupSpawner::tickSum_`[private]`

Adds up tick to use in sine movement.

Referenced by PickupSpawner(), and tick().

float orxonox::PickupSpawner::triggerDistance_`[private]`

Distance in which this gets triggered.

Referenced by PickupSpawner(), and tick().

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

- src/orxonox/objects/pickup/PickupSpawner.h
- src/orxonox/objects/pickup/PickupSpawner.cc