#include <src/orxonox/objects/pickup/PickupSpawner.h>
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. |
orxonox::PickupSpawner::PickupSpawner | ( | BaseObject * | creator | ) |
Constructor. Registers the PickupSpawner.
creator | Pointer to the object which created this item. |
References itemTemplate_, RegisterObject, respawnTime_, tickSum_, and triggerDistance_.
orxonox::PickupSpawner::~PickupSpawner | ( | ) | [virtual] |
Deconstructor.
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.
const std::string& orxonox::PickupSpawner::getItemTemplateName | ( | ) | const [inline] |
Get the template name for the item to spawn.
Referenced by XMLPort().
float orxonox::PickupSpawner::getRespawnTime | ( | ) | const [inline] |
Get the time to respawn.
Referenced by XMLPort().
float orxonox::PickupSpawner::getTriggerDistance | ( | ) | const [inline] |
Get the distance in which to trigger.
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.
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.
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.
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.
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.
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.
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.
const float orxonox::PickupSpawner::bounceDistance_s = 4.0f [static, private] |
const float orxonox::PickupSpawner::bounceSpeed_s = 6.0f [static, private] |
Template* orxonox::PickupSpawner::itemTemplate_ [private] |
Template of the item to spawn.
Referenced by PickupSpawner(), setItemTemplateName(), trigger(), and XMLPort().
float orxonox::PickupSpawner::respawnTime_ [private] |
const float orxonox::PickupSpawner::rotationSpeed_s = 1.0f [static, private] |
float orxonox::PickupSpawner::tickSum_ [private] |
float orxonox::PickupSpawner::triggerDistance_ [private] |