Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/core7/src/modules/pickup/CollectiblePickup.cc @ 11012

Last change on this file since 11012 was 10362, checked in by landauf, 10 years ago

use static identifier initializer to store the inheritance definition of abstract classes. this prevents that identifiers are used (via Class(Name)) before they are properly initialized.

  • 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    RegisterAbstractClass(CollectiblePickup).inheritsFrom<Pickupable>();
43
44    /**
45    @brief
46        Constructor.
47        Registers the object and initializes variables.
48    */
49    CollectiblePickup::CollectiblePickup() : collection_(NULL)
50    {
51        RegisterObject(CollectiblePickup);
52    }
53
54    /**
55    @brief
56        Destructor.
57    */
58    CollectiblePickup::~CollectiblePickup()
59    {
60        if (this->isInCollection())
61            this->collection_->removePickupable(this);
62    }
63
64    /**
65    @brief
66        Is called when the pickup has transited from used to unused or the other way around.
67    */
68    void CollectiblePickup::changedUsed(void)
69    {
70        SUPER(CollectiblePickup, changedUsed);
71
72        if(this->isInCollection())
73            this->collection_->pickupChangedUsed(this->isUsed());
74    }
75
76    /**
77    @brief
78        Is called when the pickup has transited from picked up to dropped or the other way around.
79    */
80    void CollectiblePickup::changedPickedUp(void)
81    {
82        SUPER(CollectiblePickup, changedPickedUp);
83
84        if(this->isInCollection())
85            this->collection_->pickupChangedPickedUp(this->isPickedUp());
86    }
87
88    /**
89    @brief
90        Notifies this CollectiblePickup that it was added to a PickupCollection.
91    @param collection
92        A pointer to the PickupCollection to which the CollectiblePickup should be added.
93    */
94    void CollectiblePickup::wasAddedToCollection(PickupCollection* collection)
95    {
96        this->collection_ = collection;
97    }
98
99    /**
100    @brief
101        Notifies this CollectiblePickup that it was removed from its PickupCollection.
102    */
103    void CollectiblePickup::wasRemovedFromCollection(void)
104    {
105        this->collection_ = NULL;
106    }
107}
Note: See TracBrowser for help on using the repository browser.