Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/formationupdate/src/modules/pickup/CollectiblePickup.cc @ 9786

Last change on this file since 9786 was 9348, checked in by landauf, 12 years ago

merged branch presentation2012merge back to trunk

  • Property svn:eol-style set to native
File size: 2.8 KB
Line 
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 *      Damian 'Mozork' Frick
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29/**
30    @file CollectiblePickup.cc
31    @brief Implementation of the CollectiblePickup class.
32*/
33
34#include "CollectiblePickup.h"
35
36#include "core/CoreIncludes.h"
37
38#include "PickupCollection.h"
39
40namespace orxonox {
41
42    /**
43    @brief
44        Constructor.
45        Registers the object and initializes variables.
46    */
47    CollectiblePickup::CollectiblePickup() : collection_(NULL)
48    {
49        RegisterObject(CollectiblePickup);
50    }
51
52    /**
53    @brief
54        Destructor.
55    */
56    CollectiblePickup::~CollectiblePickup()
57    {
58        if (this->isInCollection())
59            this->collection_->removePickupable(this);
60    }
61
62    /**
63    @brief
64        Is called when the pickup has transited from used to unused or the other way around.
65    */
66    void CollectiblePickup::changedUsed(void)
67    {
68        SUPER(CollectiblePickup, changedUsed);
69
70        if(this->isInCollection())
71            this->collection_->pickupChangedUsed(this->isUsed());
72    }
73
74    /**
75    @brief
76        Is called when the pickup has transited from picked up to dropped or the other way around.
77    */
78    void CollectiblePickup::changedPickedUp(void)
79    {
80        SUPER(CollectiblePickup, changedPickedUp);
81
82        if(this->isInCollection())
83            this->collection_->pickupChangedPickedUp(this->isPickedUp());
84    }
85
86    /**
87    @brief
88        Notifies this CollectiblePickup that it was added to a PickupCollection.
89    @param collection
90        A pointer to the PickupCollection to which the CollectiblePickup should be added.
91    */
92    void CollectiblePickup::wasAddedToCollection(PickupCollection* collection)
93    {
94        this->collection_ = collection;
95    }
96
97    /**
98    @brief
99        Notifies this CollectiblePickup that it was removed from its PickupCollection.
100    */
101    void CollectiblePickup::wasRemovedFromCollection(void)
102    {
103        this->collection_ = NULL;
104    }
105}
Note: See TracBrowser for help on using the repository browser.