Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/pickups2/src/orxonox/objects/pickup/BaseItem.cc @ 2961

Last change on this file since 2961 was 2917, checked in by landauf, 16 years ago

merged pickup into pickup2

  • Property svn:eol-style set to native
File size: 2.4 KB
RevLine 
[2917]1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Daniel 'Huty' Haggenmueller
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29/**
30    @file
31    @brief Implementation of BaseItem (base-class for items/pickups).
32*/
33
34#include "BaseItem.h"
35
36#include "PickupCollection.h"
37#include "objects/worldentities/pawns/Pawn.h"
38
39namespace orxonox
40{
41    /**
42        @brief Constructor. Registers the BaseItem.
43        @param creator Pointer to the object which created this item.
44    */
45    BaseItem::BaseItem(BaseObject* creator) : BaseObject(creator)
46    {
47        RegisterObject(BaseItem);
48
49        this->setOwner(0);
50        this->setPickupIdentifier(this->getName());
51    }
52    //! Deconstructor.
53    BaseItem::~BaseItem()
54    {
55    }
56    /**
57        @brief Method to add the item to a pawn.
58        @param pawn Pawn to which the item should get added.
59        @return Returns whether the pawn's PickupCollection accepted the item.
60    */
61    bool BaseItem::addTo(Pawn* pawn)
62    {
63        this->setOwner(pawn);
64
65        if (pawn->getPickups().add(this))
66        {
67            COUT(3) << "Added '" << this->getPickupIdentifier() << "' item." << std::endl;
68            return true;
69        }
70        return false;
71    }
72    /**
73        @brief Removes the item from a pawn.
74        @param pawn Pawn from which to remove the item.
75        @return Returns whether the pawn's PickupCollection was able to locate and remove the item.
76    */
77    bool BaseItem::removeFrom(Pawn* pawn)
78    {
79        this->setOwner(0);
80
81        COUT(3) << "Removing '" << this->getPickupIdentifier() << "' item." << std::endl;
82
83        pawn->getPickups().remove(this, false);
84
85        return true;
86    }
87}
Note: See TracBrowser for help on using the repository browser.