Orxonox: orxonox::BaseItem Class Reference

# orxonox::BaseItem Class Reference

Base class for all items/pickups. More...

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

Inheritance diagram for orxonox::BaseItem:

List of all members.

## 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..

## Detailed Description

Base class for all items/pickups.

Provides common methods to be used in derived classes.

Author:
  Daniel 'Huty' Haggenmueller

## Constructor & Destructor Documentation

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

Constructor. Registers the BaseItem.

Parameters:

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

References orxonox::BaseObject::getName(), RegisterObject, setGUIImage(), setGUIText(), setOwner(), and setPickupIdentifier().

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

Destructor.

## Member Function Documentation

bool orxonox::BaseItem::addTo | ( | Pawn * | pawn | ) |

Add the item to a pawn.

Method to add the item to a pawn.

Parameters:

  | pawn | Pawn to which the item should get added.

Returns:
  Returns whether the pawn's PickupCollection accepted the item.

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().

Parameters:

  | pawn | Pawn which dropped the item.

Returns:
  Returns whether the item was able to get dropped by the pawn.

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]`

References guiText_.

Referenced by orxonox::PickupInventory::setWindowProperties(), and XMLPort().

virtual int orxonox::BaseItem::getMaxCarryAmount | ( |  | ) | const`[inline, virtual]`

Checks how many instances of this item can be carried at a time.

Returns:
  How many of this item can be carried.

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.

Returns:
  Returns the current owner.

const std::string& orxonox::BaseItem::getPickupIdentifier | ( |  | ) | const`[inline]`

Gets the pickupIdentifier of the item.

Returns:
  Returns the pickupIdentifier of the item.

See also:
  pickupIdentifier_

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().

Parameters:

  | pawn | Pawn who picks up the item.

Returns:
  Returns whether the pawn was able to pick 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.

Parameters:

  | pawn | Pawn from which to remove the item.

Returns:
  Returns whether the pawn's PickupCollection was able to locate and 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.

Parameters:

  | 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.

Parameters:

  | identifier | New pickupIdentifier for the item.

See also:
  pickupIdentifier_

Referenced by BaseItem(), and orxonox::PickupSpawner::trigger().

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

XMLPort.

XMLPort for BaseItem.

Parameters:

  | 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.

## Member Data Documentation

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.

std::string orxonox::BaseItem::pickupIdentifier_`[private]`

The pickupIdentifier of the item..

Usually set to the template name used by a PickupSpawner, used to index items in the PickupCollection.

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

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