#include <src/orxonox/objects/pickup/BaseItem.h>
Public Member Functions | |
bool | addTo (Pawn *pawn) |
Add the item to a pawn. | |
BaseItem (BaseObject *creator) | |
Constructor. Registers the BaseItem. | |
virtual bool | dropped (Pawn *pawn) |
Method invoked when the item is dropped from a player. | |
virtual const std::string & | getGUIImage () const |
virtual const std::string & | getGUIText () const |
virtual int | getMaxCarryAmount () const |
Checks how many instances of this item can be carried at a time. | |
Pawn * | getOwner () const |
Gets the current owner of the pickup. | |
const std::string & | getPickupIdentifier () const |
Gets the pickupIdentifier of the item. | |
virtual bool | pickedUp (Pawn *pawn) |
Method invoked when the item gets picked up. | |
bool | removeFrom (Pawn *pawn) |
Removes the item from a pawn. | |
void | setGUIImage (const std::string &image) |
void | setGUIText (const std::string &text) |
void | setOwner (Pawn *owner) |
Sets the owner of the pickup. | |
void | setPickupIdentifier (const std::string &identifier) |
Sets the pickupIdentifier for the item. | |
virtual void | XMLPort (Element &xmlelement, XMLPort::Mode mode) |
XMLPort. | |
virtual | ~BaseItem () |
Destructor. | |
Private Attributes | |
std::string | guiImage_ |
std::string | guiText_ |
Pawn * | owner_ |
The current owner of the item. | |
std::string | pickupIdentifier_ |
The pickupIdentifier of the item.. |
Provides common methods to be used in derived classes.
orxonox::BaseItem::BaseItem | ( | BaseObject * | creator | ) |
Constructor. Registers the BaseItem.
creator | Pointer to the object which created this item. |
References orxonox::BaseObject::getName(), RegisterObject, setGUIImage(), setGUIText(), setOwner(), and setPickupIdentifier().
orxonox::BaseItem::~BaseItem | ( | ) | [virtual] |
Destructor.
bool orxonox::BaseItem::addTo | ( | Pawn * | pawn | ) |
Add the item to a pawn.
Method to add the item to a pawn.
pawn | Pawn to which the item should get added. |
References orxonox::PickupCollection::add(), COUT, getPickupIdentifier(), orxonox::Pawn::getPickups(), and setOwner().
Referenced by orxonox::ModifierPickup::pickedUp(), orxonox::Jump::pickedUp(), and orxonox::HealthUsable::pickedUp().
virtual bool orxonox::BaseItem::dropped | ( | Pawn * | pawn | ) | [inline, virtual] |
Method invoked when the item is dropped from a player.
Should be overridden by derived classes, should also contain a call to removeFrom().
pawn | Pawn which dropped the item. |
Reimplemented in orxonox::HealthUsable, orxonox::Jump, and orxonox::ModifierPickup.
virtual const std::string& orxonox::BaseItem::getGUIImage | ( | ) | const [inline, virtual] |
Referenced by orxonox::PickupInventory::getImageForItem(), and XMLPort().
const std::string & orxonox::BaseItem::getGUIText | ( | ) | const [virtual] |
virtual int orxonox::BaseItem::getMaxCarryAmount | ( | ) | const [inline, virtual] |
Checks how many instances of this item can be carried at a time.
Reimplemented in orxonox::HealthUsable, and orxonox::Jump.
Referenced by orxonox::PickupCollection::checkSlot().
Pawn* orxonox::BaseItem::getOwner | ( | ) | const [inline] |
Gets the current owner of the pickup.
const std::string& orxonox::BaseItem::getPickupIdentifier | ( | ) | const [inline] |
Gets the pickupIdentifier of the item.
Referenced by orxonox::PickupCollection::add(), addTo(), orxonox::PickupCollection::checkSlot(), orxonox::PickupCollection::contains(), orxonox::DroppedItem::createDefaultDrop(), orxonox::PickupCollection::remove(), removeFrom(), orxonox::DroppedItem::timerCallback(), and orxonox::DroppedItem::trigger().
virtual bool orxonox::BaseItem::pickedUp | ( | Pawn * | pawn | ) | [inline, virtual] |
Method invoked when the item gets picked up.
Has to be overridden for an item to work, should contain a call to addTo().
pawn | Pawn who picks up the item. |
Reimplemented in orxonox::HealthImmediate, orxonox::HealthUsable, orxonox::Jump, and orxonox::ModifierPickup.
Referenced by orxonox::PickupSpawner::trigger(), and orxonox::DroppedItem::trigger().
bool orxonox::BaseItem::removeFrom | ( | Pawn * | pawn | ) |
Removes the item from a pawn.
pawn | Pawn from which to remove the item. |
References COUT, getPickupIdentifier(), orxonox::Pawn::getPickups(), orxonox::PickupCollection::remove(), and setOwner().
Referenced by orxonox::ModifierPickup::dropped(), orxonox::Jump::dropped(), orxonox::HealthUsable::dropped(), orxonox::Jump::used(), and orxonox::HealthUsable::used().
void orxonox::BaseItem::setGUIImage | ( | const std::string & | image | ) | [inline] |
Referenced by BaseItem(), and XMLPort().
void orxonox::BaseItem::setGUIText | ( | const std::string & | text | ) | [inline] |
Referenced by BaseItem(), and XMLPort().
void orxonox::BaseItem::setOwner | ( | Pawn * | owner | ) | [inline] |
Sets the owner of the pickup.
owner | New owner for the pickup. |
Referenced by addTo(), BaseItem(), and removeFrom().
void orxonox::BaseItem::setPickupIdentifier | ( | const std::string & | identifier | ) | [inline] |
Sets the pickupIdentifier for the item.
identifier | New pickupIdentifier for the item. |
Referenced by BaseItem(), and orxonox::PickupSpawner::trigger().
void orxonox::BaseItem::XMLPort | ( | Element & | xmlelement, | |
XMLPort::Mode | mode | |||
) | [virtual] |
xmlelement | Element of the XML-file. | |
mode | XMLPort mode to use. |
Reimplemented from orxonox::BaseObject.
Reimplemented in orxonox::HealthImmediate, orxonox::HealthUsable, orxonox::Jump, and orxonox::ModifierPickup.
References getGUIImage(), getGUIText(), setGUIImage(), setGUIText(), SUPER, and XMLPortParam.
std::string orxonox::BaseItem::guiImage_ [private] |
std::string orxonox::BaseItem::guiText_ [private] |
Referenced by getGUIText().
Pawn* orxonox::BaseItem::owner_ [private] |
The current owner of the item.
The pickupIdentifier of the item..
Usually set to the template name used by a PickupSpawner, used to index items in the PickupCollection.